From: tobiasKaminsky Date: Sat, 31 Oct 2015 07:48:10 +0000 (+0100) Subject: Merge remote-tracking branch 'remotes/upstream/master' into beta X-Git-Tag: beta-20151122~66 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/495fd6e4041c6ed933022e49d1aee0a30a9d6f76?hp=--cc Merge remote-tracking branch 'remotes/upstream/master' into beta --- 495fd6e4041c6ed933022e49d1aee0a30a9d6f76 diff --cc owncloud-android-library index 652cd28b,f02dffb1..59fb6160 --- a/owncloud-android-library +++ b/owncloud-android-library @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 652cd28bb15672eaedfe8c1d9a46cf293c909b89 -Subproject commit f02dffb1d3c46305c70d246f696cde7b8c3b0971 ++Subproject commit 59fb61601de4dd8bfcab1afb619e016e1a7b904d diff --cc res/values/strings.xml index d73dd573,305a5404..b0ff1feb --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -343,8 -341,8 +342,9 @@@ Instant Uploads Security - Upload Video Path + Upload video path + Download of %1$s folder could not be completed + Synchronization of %1$s folder could not be completed shared with you diff --cc src/com/owncloud/android/datamodel/FileDataStorageManager.java index 46a4d854,540e83d1..7d014b03 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -1485,47 -1414,9 +1409,9 @@@ public class FileDataStorageManager } } return preparedOperations; - - /* - if (operations.size() > 0) { - try { - if (getContentResolver() != null) { - getContentResolver().applyBatch(MainApp.getAuthority(), operations); - - } else { - getContentProviderClient().applyBatch(operations); - } - - } catch (OperationApplicationException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); - - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); - } - } - */ - - /* - if (getContentResolver() != null) { - - getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, - where, - whereArgs); - } else { - try { - getContentProviderClient().delete( ProviderTableMeta.CONTENT_URI_SHARE, - where, - whereArgs); - - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception deleting shares in a folder " + e.getMessage()); - } - } - */ - //} } - public void triggerMediaScan(String path) { + public static void triggerMediaScan(String path) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path))); MainApp.getAppContext().sendBroadcast(intent); diff --cc src/com/owncloud/android/datamodel/OCFile.java index 1c2ec265,fcde054a..bc1d7e21 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@@ -72,8 -74,8 +72,10 @@@ public class OCFile implements Parcelab private boolean mIsDownloading; + private boolean mShowGridView; + + private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null + /** * Create new {@link OCFile} with given path. diff --cc src/com/owncloud/android/files/FileOperationsHelper.java index 51d447e1,cf0f50f0..e799e176 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@@ -248,32 -236,13 +248,37 @@@ public class FileOperationsHelper } } + public void sendCachedImage(OCFile file) { + if (file != null) { + Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); + // set MimeType + sendIntent.setType(file.getMimetype()); +// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName())); + sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath())); + sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action + + // Show dialog, without the own app + String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; + DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file); + chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); + } else { + Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); + } + } + + public void syncFiles(ArrayList files) { + for (OCFile file: files) { + syncFile(file); + } + } + + /** + * Request the synchronization of a file or folder with the OC server, including its contents. + * + * @param file The file or folder to synchronize + */ public void syncFile(OCFile file) { - if (!file.isFolder()) { + if (!file.isFolder()){ Intent intent = new Intent(mFileActivity, OperationsService.class); intent.setAction(OperationsService.ACTION_SYNC_FILE); intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); diff --cc src/com/owncloud/android/operations/RefreshFolderOperation.java index dade4d97,61b13fc8..ddd843de --- a/src/com/owncloud/android/operations/RefreshFolderOperation.java +++ b/src/com/owncloud/android/operations/RefreshFolderOperation.java @@@ -201,8 -195,14 +195,14 @@@ public class RefreshFolderOperation ext if (mRemoteFolderChanged) { result = fetchAndSyncRemoteFolder(client); } else { + fetchFavoritesToSyncFromLocalData(); - mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/); + mChildren = mStorageManager.getFolderContent(mLocalFolder, false); } + + if (result.isSuccess()) { + // request for the synchronization of KEPT-IN-SYNC file contents + startContentSynchronizations(mFilesToSyncContents, client); + } } if (!mSyncFullAccount) { @@@ -344,10 -343,11 +343,10 @@@ + " changed - starting update of local data "); List updatedFiles = new Vector(folderAndFiles.size() - 1); - List filesToSyncContents = new Vector(); + mFilesToSyncContents.clear(); // get current data about local contents of the folder to synchronize - // TODO Enable when "On Device" is recovered ? - List localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/); + List localFiles = mStorageManager.getFolderContent(mLocalFolder, false); Map localFilesMap = new HashMap(localFiles.size()); for (OCFile file : localFiles) { localFilesMap.put(file.getRemotePath(), file); @@@ -612,8 -501,20 +500,20 @@@ } - public boolean getRemoteFolderChanged() { - return mRemoteFolderChanged; + private void fetchFavoritesToSyncFromLocalData() { - List children = mStorageManager.getFolderContent(mLocalFolder); ++ List children = mStorageManager.getFolderContent(mLocalFolder, false); + for (OCFile child : children) { + if (!child.isFolder() && child.isFavorite()) { + SynchronizeFileOperation operation = new SynchronizeFileOperation( + child, + child, // cheating with the remote file to get an update to server; to refactor + mAccount, + true, + mContext + ); + mFilesToSyncContents.add(operation); + } + } } } diff --cc src/com/owncloud/android/operations/UploadFileOperation.java index 6be2e0ae,ee9f7c88..e7b5ba3d --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@@ -322,47 -320,48 +321,50 @@@ public class UploadFileOperation extend while (listener.hasNext()) { mUploadOperation.addDatatransferProgressListener(listener.next()); } - if (!mCancellationRequested.get()) { - result = mUploadOperation.execute(client); - - /// move local temporal file or original file to its corresponding - // location in the ownCloud local folder - if (result.isSuccess()) { - if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { - mFile.setStoragePath(null); - } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_REMOVE){ - mFile.setStoragePath(null); - originalFile.delete(); - } else { - mFile.setStoragePath(expectedPath); - File fileToMove = null; - if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY - // ; see where temporalFile was - // set - fileToMove = temporalFile; - } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE - fileToMove = originalFile; - } - if (!expectedFile.equals(fileToMove)) { - File expectedFolder = expectedFile.getParentFile(); - expectedFolder.mkdirs(); - if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) { - mFile.setStoragePath(null); // forget the local file - // by now, treat this as a success; the file was - // uploaded; the user won't like that the local file - // is not linked, but this should be a very rare - // fail; - // the best option could be show a warning message - // (but not a fail) - // result = new - // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); - // return result; - } + if (mCancellationRequested.get()) { + throw new OperationCancelledException(); + } + + result = mUploadOperation.execute(client); + + /// move local temporal file or original file to its corresponding + // location in the ownCloud local folder + if (result.isSuccess()) { + if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { + mFile.setStoragePath(null); + + } else { + mFile.setStoragePath(expectedPath); + File fileToMove = null; + if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY + // ; see where temporalFile was + // set + fileToMove = temporalFile; + } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE + fileToMove = originalFile; + } + if (!expectedFile.equals(fileToMove)) { + File expectedFolder = expectedFile.getParentFile(); + expectedFolder.mkdirs(); + if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) { + mFile.setStoragePath(null); // forget the local file + // by now, treat this as a success; the file was + // uploaded; the user won't like that the local file + // is not linked, but this should be a very rare + // fail; + // the best option could be show a warning message + // (but not a fail) + // result = new + // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); + // return result; } } + FileDataStorageManager.triggerMediaScan(originalFile.getAbsolutePath()); + FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath()); } + + } else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) { + result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); } } catch (Exception e) { diff --cc src/com/owncloud/android/ui/fragment/OCFileListFragment.java index c639525e,23590b5e..804d5074 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@@ -546,122 -334,85 +546,121 @@@ public class OCFileListFragment extend } } - /** - * {@inheritDoc} - */ - @Override - public boolean onFileActionChosen(int menuId, int filePosition) { - mTargetFile = (OCFile) mAdapter.getItem(filePosition); - switch (menuId) { - case R.id.action_share_file: { - mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile); - return true; - } - case R.id.action_open_file_with: { - mContainerActivity.getFileOperationsHelper().openFile(mTargetFile); - return true; - } - case R.id.action_unshare_file: { - mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile); - return true; - } - case R.id.action_rename_file: { - RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile); - dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE); - return true; - } - case R.id.action_remove_file: { - RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile); - dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION); - return true; - } - case R.id.action_download_file: - case R.id.action_sync_file: { - mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile); - return true; - } - case R.id.action_cancel_sync: { - ((FileDisplayActivity)mContainerActivity).cancelTransference(mTargetFile); - return true; - } - case R.id.action_see_details: { - mContainerActivity.showDetails(mTargetFile); - return true; - } - case R.id.action_send_file: { - // Obtain the file - if (!mTargetFile.isDown()) { // Download the file - Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded"); - ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile); + public boolean onFileActionChosen(int menuId) { + if (mAdapter.getCheckedItems().size() == 1){ + OCFile mTargetFile = mAdapter.getCheckedItems().get(0); - } else { - mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile); + switch (menuId) { + case R.id.action_share_file: { + mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile); + return true; } - return true; - } - case R.id.action_move: { - Intent action = new Intent(getActivity(), FolderPickerActivity.class); + case R.id.action_open_file_with: { + mContainerActivity.getFileOperationsHelper().openFile(mTargetFile); + return true; + } + case R.id.action_unshare_file: { + mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile); + return true; + } + case R.id.action_rename_file: { + RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile); + dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE); + return true; + } + case R.id.action_remove_file: { + RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile); + dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION); + return true; + } + case R.id.action_download_file: + case R.id.action_sync_file: { + mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile); + return true; + } - case R.id.action_cancel_download: - case R.id.action_cancel_upload: { ++ case R.id.action_cancel_sync: { + ((FileDisplayActivity) mContainerActivity).cancelTransference(mTargetFile); + return true; + } + case R.id.action_see_details: { + mContainerActivity.showDetails(mTargetFile); + return true; + } + case R.id.action_send_file: { + // Obtain the file + if (!mTargetFile.isDown()) { // Download the file + Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded"); + ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile); - // Pass mTargetFile that contains info of selected file/folder - action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile); - getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES); - return true; - } - case R.id.action_favorite_file: { - mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true); - return true; - } - case R.id.action_unfavorite_file: { - mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false); - return true; + } else { + mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile); + } + return true; + } + case R.id.action_move: { + Intent action = new Intent(getActivity(), FolderPickerActivity.class); + ArrayList files = new ArrayList(); + files.add(mTargetFile); + action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, files); + getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES); + return true; + } + case R.id.action_favorite_file: { + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true); + return true; + } + case R.id.action_unfavorite_file: { + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false); + return true; + } + case R.id.action_copy: + Intent action = new Intent(getActivity(), FolderPickerActivity.class); + + // Pass mTargetFile that contains info of selected file/folder + action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile); + getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES); + return true; + default: + return false; } - case R.id.action_copy: - Intent action = new Intent(getActivity(), FolderPickerActivity.class); + } else { + ArrayList mTargetFiles = mAdapter.getCheckedItems(); - // Pass mTargetFile that contains info of selected file/folder - action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile); - getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES); - return true; - default: - return false; + switch (menuId) { + case R.id.action_remove_file: { + RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(mTargetFiles); + dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION); + return true; + } + case R.id.action_download_file: + case R.id.action_sync_file: { + mContainerActivity.getFileOperationsHelper().syncFiles(mTargetFiles); + return true; + } + case R.id.action_move: { + Intent action = new Intent(getActivity(), FolderPickerActivity.class); + action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles); + getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES); + return true; + } + case R.id.action_favorite_file: { + mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, true); + return true; + } + case R.id.action_unfavorite_file: { + mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, false); + return true; + } + case R.id.action_copy: + Intent action = new Intent(getActivity(), FolderPickerActivity.class); + action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles); + getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES); + return true; + default: + return false; + } } + } /**