diff --git a/app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt b/app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt index 024e07a894..2d97de7634 100644 --- a/app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt +++ b/app/src/main/java/com/nextcloud/ui/fileactions/FileAction.kt @@ -39,8 +39,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe // File moving RENAME_FILE(R.id.action_rename_file, R.string.common_rename, R.drawable.ic_rename), - MOVE(R.id.action_move, R.string.actionbar_move, R.drawable.ic_move), - COPY(R.id.action_copy, R.string.actionbar_copy, R.drawable.ic_content_copy), + MOVE_OR_COPY(R.id.action_move_or_copy, R.string.actionbar_move_or_copy, R.drawable.ic_move), // favorites FAVORITE(R.id.action_favorite, R.string.favorite, R.drawable.ic_star), @@ -83,8 +82,7 @@ enum class FileAction(@IdRes val id: Int, @StringRes val title: Int, @DrawableRe SEE_DETAILS, LOCK_FILE, RENAME_FILE, - MOVE, - COPY, + MOVE_OR_COPY, DOWNLOAD_FILE, EXPORT_FILE, STREAM_MEDIA, diff --git a/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java b/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java index f4092a9860..ecf266cc04 100644 --- a/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java +++ b/app/src/main/java/com/owncloud/android/files/FileMenuFilter.java @@ -161,8 +161,7 @@ public class FileMenuFilter { filterDownload(toHide, synchronizing); filterExport(toHide); filterRename(toHide, synchronizing); - filterCopy(toHide, synchronizing); - filterMove(toHide, synchronizing); + filterMoveOrCopy(toHide, synchronizing); filterRemove(toHide, synchronizing); filterSelectAll(toHide, inSingleFileFragment); filterDeselectAll(toHide, inSingleFileFragment); @@ -346,19 +345,12 @@ public class FileMenuFilter { } } - private void filterMove(List toHide, boolean synchronizing) { + private void filterMoveOrCopy(List toHide, boolean synchronizing) { if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) { - toHide.add(R.id.action_move); + toHide.add(R.id.action_move_or_copy); } } - private void filterCopy(List toHide, boolean synchronizing) { - if (files.isEmpty() || synchronizing || containsEncryptedFile() || containsEncryptedFolder()) { - toHide.add(R.id.action_copy); - } - } - - private void filterRename(Collection toHide, boolean synchronizing) { if (!isSingleSelection() || synchronizing || containsEncryptedFile() || containsEncryptedFolder() || containsLockedFile()) { toHide.add(R.id.action_rename_file); diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 5c55a80904..e87cfce616 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -204,8 +204,7 @@ public class FileDisplayActivity extends FileActivity public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1; public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2; - public static final int REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 3; - public static final int REQUEST_CODE__COPY_FILES = REQUEST_CODE__LAST_SHARED + 4; + public static final int REQUEST_CODE__MOVE_OR_COPY_FILES = REQUEST_CODE__LAST_SHARED + 3; public static final int REQUEST_CODE__UPLOAD_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 5; public static final int REQUEST_CODE__UPLOAD_SCAN_DOC_FROM_CAMERA = REQUEST_CODE__LAST_SHARED + 6; @@ -887,31 +886,10 @@ public class FileDisplayActivity extends FileActivity } } }, new String[]{FileOperationsHelper.createImageFile(getActivity()).getAbsolutePath()}).execute(); - } else if (requestCode == REQUEST_CODE__MOVE_FILES && resultCode == RESULT_OK) { + } else if (requestCode == REQUEST_CODE__MOVE_OR_COPY_FILES && resultCode == RESULT_OK) { exitSelectionMode(); final Intent fData = data; - getHandler().postDelayed( - new Runnable() { - @Override - public void run() { - requestMoveOperation(fData); - } - }, - DELAY_TO_REQUEST_OPERATIONS_LATER - ); - - } else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) { - exitSelectionMode(); - final Intent fData = data; - getHandler().postDelayed( - new Runnable() { - @Override - public void run() { - requestCopyOperation(fData); - } - }, - DELAY_TO_REQUEST_OPERATIONS_LATER - ); + getHandler().postDelayed(() -> requestMoveOrCopyOperation(fData), DELAY_TO_REQUEST_OPERATIONS_LATER); } else if (requestCode == PermissionUtil.REQUEST_CODE_MANAGE_ALL_FILES) { syncAndUpdateFolder(true); } else { @@ -1018,26 +996,11 @@ public class FileDisplayActivity extends FileActivity } - /** - * Request the operation for moving the file/folder from one path to another - * - * @param data Intent received - */ - private void requestMoveOperation(Intent data) { - final OCFile folderToMoveAt = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); + private void requestMoveOrCopyOperation(Intent data) { + final OCFile file = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); final List filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS); - getFileOperationsHelper().moveFiles(filePaths, folderToMoveAt); - } - - /** - * Request the operation for copying the file/folder from one path to another - * - * @param data Intent received - */ - private void requestCopyOperation(Intent data) { - final OCFile targetFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); - final List filePaths = data.getStringArrayListExtra(FolderPickerActivity.EXTRA_FILE_PATHS); - getFileOperationsHelper().copyFiles(filePaths, targetFolder); + assert filePaths != null; + getFileOperationsHelper().moveOrCopyFiles(filePaths, file); } private boolean isSearchOpen() { diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt index 32a8873074..b2154644c4 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt @@ -347,7 +347,7 @@ open class FolderPickerActivity : // for copy and move, disable selecting parent folder of target files private fun checkFolderSelectable(): Boolean { return when { - mAction != COPY && mAction != MOVE -> true + mAction != MOVE_OR_COPY -> true mTargetFilePaths.isNullOrEmpty() -> true file?.isFolder != true -> true // all of the target files are already in the selected directory @@ -588,8 +588,7 @@ open class FolderPickerActivity : @JvmField val EXTRA_ACTION = FolderPickerActivity::class.java.canonicalName?.plus(".EXTRA_ACTION") - const val MOVE = "MOVE" - const val COPY = "COPY" + const val MOVE_OR_COPY = "MOVE_OR_COPY" const val CHOOSE_LOCATION = "CHOOSE_LOCATION" private val TAG = FolderPickerActivity::class.java.simpleName protected const val TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS" diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java index 76b5393ecf..b82c10ae24 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -278,8 +278,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener, R.id.action_favorite, R.id.action_unset_favorite, R.id.action_see_details, - R.id.action_move, - R.id.action_copy, + R.id.action_move_or_copy, R.id.action_stream_media, R.id.action_send_share_file, R.id.action_pin_to_homescreen diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java index e7745f3ba3..35859ddf32 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -1235,11 +1235,8 @@ public class OCFileListFragment extends ExtendedListFragment implements } else if (itemId == R.id.action_unset_favorite) { mContainerActivity.getFileOperationsHelper().toggleFavoriteFiles(checkedFiles, false); return true; - } else if (itemId == R.id.action_move) { - pickFolderForMoveOrCopy(FolderPickerActivity.MOVE, checkedFiles); - return true; - } else if (itemId == R.id.action_copy) { - pickFolderForMoveOrCopy(FolderPickerActivity.COPY, checkedFiles); + } else if (itemId == R.id.action_move_or_copy) { + pickFolderForMoveOrCopy(FolderPickerActivity.MOVE_OR_COPY, checkedFiles); return true; } else if (itemId == R.id.action_select_all_action_menu) { selectAllFiles(true); @@ -1259,15 +1256,10 @@ public class OCFileListFragment extends ExtendedListFragment implements private void pickFolderForMoveOrCopy(final String extraAction, final Set checkedFiles) { int requestCode; - switch (extraAction) { - case FolderPickerActivity.MOVE: - requestCode = FileDisplayActivity.REQUEST_CODE__MOVE_FILES; - break; - case FolderPickerActivity.COPY: - requestCode = FileDisplayActivity.REQUEST_CODE__COPY_FILES; - break; - default: - throw new IllegalArgumentException("Unknown extra action: " + extraAction); + if (extraAction.equals(FolderPickerActivity.MOVE_OR_COPY)) { + requestCode = FileDisplayActivity.REQUEST_CODE__MOVE_OR_COPY_FILES; + } else { + throw new IllegalArgumentException("Unknown extra action: " + extraAction); } final Intent action = new Intent(getActivity(), FolderPickerActivity.class); diff --git a/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java b/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java index 2a382c2a78..afb8acf794 100755 --- a/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java +++ b/app/src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java @@ -1007,30 +1007,10 @@ public class FileOperationsHelper { } } - /** - * Start operations to move one or several files - * - * @param filePaths Remote paths of files to move - * @param targetFolder Folder where the files while be moved into - */ - public void moveFiles(final List filePaths, final OCFile targetFolder) { - copyOrMoveFiles(OperationsService.ACTION_MOVE_FILE, filePaths, targetFolder); - } - - /** - * Start operations to copy one or several files - * - * @param filePaths Remote paths of files to move - * @param targetFolder Folder where the files while be copied into - */ - public void copyFiles(final List filePaths, final OCFile targetFolder) { - copyOrMoveFiles(OperationsService.ACTION_COPY_FILE, filePaths, targetFolder); - } - - private void copyOrMoveFiles(final String action, final List filePaths, final OCFile targetFolder) { + public void moveOrCopyFiles(final List filePaths, final OCFile targetFolder) { for (String path : filePaths) { Intent service = new Intent(fileActivity, OperationsService.class); - service.setAction(action); + //service.setAction(OperationsService.ACTION_MOVE_OR_COPY_FILE); service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, targetFolder.getRemotePath()); service.putExtra(OperationsService.EXTRA_REMOTE_PATH, path); service.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount()); diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java index 09e03ab9b6..b0ec4ee1b4 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -375,8 +375,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable { Arrays.asList( R.id.action_rename_file, R.id.action_sync_file, - R.id.action_move, - R.id.action_copy, + R.id.action_move_or_copy, R.id.action_favorite, R.id.action_unset_favorite, R.id.action_pin_to_homescreen diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 18ee93690f..20d82add5a 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -424,8 +424,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene Arrays.asList( R.id.action_rename_file, R.id.action_sync_file, - R.id.action_move, - R.id.action_copy, + R.id.action_move_or_copy, R.id.action_favorite, R.id.action_unset_favorite, R.id.action_pin_to_homescreen diff --git a/app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java b/app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java index e34031a51a..16648c631c 100644 --- a/app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/preview/PreviewTextFileFragment.java @@ -300,8 +300,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment { Arrays.asList( R.id.action_rename_file, R.id.action_sync_file, - R.id.action_move, - R.id.action_copy, + R.id.action_move_or_copy, R.id.action_favorite, R.id.action_unset_favorite, R.id.action_pin_to_homescreen diff --git a/app/src/main/res/values/ids.xml b/app/src/main/res/values/ids.xml index 60e85c4e8b..113e681bbd 100644 --- a/app/src/main/res/values/ids.xml +++ b/app/src/main/res/values/ids.xml @@ -30,8 +30,7 @@ - - + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 54fc5482f7..c21c467f4f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -428,6 +428,7 @@ No app for sending logs found. Please install an email client. %1$s Android app logs + Move or Copy Move Copy Nothing in here. You can add a folder.