diff options
-rwxr-xr-x[-rw-r--r--] | src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java index c8f61397..6713f1d5 100644..100755 --- a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java +++ b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java @@ -250,8 +250,9 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { } } // 3.- Check the operation consistency - if (operation.compareTo(COPY_MOVE_OPERATION.MOVE) == 0) { - if (!checkMoveConsistency(ctx, files, currentDirectory)) { + if (operation.equals(COPY_MOVE_OPERATION.MOVE) + || operation.equals(COPY_MOVE_OPERATION.COPY)) { + if (!checkCopyOrMoveConsistency(ctx, files, currentDirectory, operation)) { return; } } @@ -270,8 +271,8 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { @Override public int getDialogTitle() { - return this.mOperation.compareTo(COPY_MOVE_OPERATION.MOVE) == 0 || - this.mOperation.compareTo(COPY_MOVE_OPERATION.RENAME) == 0 ? + return this.mOperation.equals(COPY_MOVE_OPERATION.MOVE) + || this.mOperation.equals(COPY_MOVE_OPERATION.RENAME) ? R.string.waiting_dialog_moving_title : R.string.waiting_dialog_copying_title; } @@ -293,10 +294,10 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { String progress = this.mCtx.getResources(). getString( - this.mOperation.compareTo(COPY_MOVE_OPERATION.MOVE) == 0 || - this.mOperation.compareTo(COPY_MOVE_OPERATION.RENAME) == 0 ? - R.string.waiting_dialog_moving_msg : - R.string.waiting_dialog_copying_msg, + this.mOperation.equals(COPY_MOVE_OPERATION.MOVE) + || this.mOperation.equals(COPY_MOVE_OPERATION.RENAME) ? + R.string.waiting_dialog_moving_msg : + R.string.waiting_dialog_copying_msg, src.getAbsolutePath(), dst.getAbsolutePath()); return Html.fromHtml(progress); @@ -400,8 +401,8 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { mDstConsole = CommandHelper.ensureConsoleForFile(ctx, null, dest); // Copy or move? - if (operation.compareTo(COPY_MOVE_OPERATION.MOVE) == 0 || - operation.compareTo(COPY_MOVE_OPERATION.RENAME) == 0) { + if (operation.equals(COPY_MOVE_OPERATION.MOVE) + || operation.equals(COPY_MOVE_OPERATION.RENAME)) { CommandHelper.move( ctx, source, @@ -534,23 +535,24 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { /** - * Method that check the consistency of move operations.<br/> + * Method that check the consistency of copy or move operations.<br/> * <br/> * The method checks the following rules:<br/> * <ul> - * <li>Any of the files of the move operation can not include the + * <li>Any of the files of the copy or move operation can not include the * current directory.</li> - * <li>Any of the files of the move operation can not include the + * <li>Any of the files of the copy or move operation can not include the * current directory.</li> * </ul> * * @param ctx The current context * @param files The list of source/destination files * @param currentDirectory The current directory + * @param operation the operation is copy or move * @return boolean If the consistency is validate successfully */ - private static boolean checkMoveConsistency( - Context ctx, List<LinkedResource> files, String currentDirectory) { + private static boolean checkCopyOrMoveConsistency(Context ctx, List<LinkedResource> files, + String currentDirectory, final COPY_MOVE_OPERATION operation) { int cc = files.size(); for (int i = 0; i < cc; i++) { LinkedResource linkRes = files.get(i); @@ -558,7 +560,8 @@ public final class CopyMoveActionPolicy extends ActionsPolicy { String dst = linkRes.mDst.getAbsolutePath(); // 1.- Current directory can't be moved - if (currentDirectory != null && currentDirectory.startsWith(src)) { + if (operation.equals(COPY_MOVE_OPERATION.MOVE) && + currentDirectory != null && currentDirectory.startsWith(src)) { // Operation not allowed AlertDialog dialog = DialogHelper.createErrorDialog( |