From fe4789b42d2eb4f601ed53bec4f755c63047b504 Mon Sep 17 00:00:00 2001 From: "kai.cao" Date: Thu, 16 Apr 2015 10:55:34 +0800 Subject: [CMFileManager] Fix the filemanager can copy parent folder to child folder Procedures 1.Go into filemanager and select a directory(such as Music). 2.enter the Music and copy the folder. The filemanager stay in "copying" interface. Change-Id: I9a765d1d89c4736b26d57bdf99237f04a810f254 (cherry picked from commit 226460f8724fdc3f74e59e92862dd88087385b70) --- .../ui/policy/CopyMoveActionPolicy.java | 35 ++++++++++++---------- 1 file changed, 19 insertions(+), 16 deletions(-) mode change 100644 => 100755 src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java diff --git a/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java b/src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java old mode 100644 new mode 100755 index c8f61397..6713f1d5 --- 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.
+ * Method that check the consistency of copy or move operations.
*
* The method checks the following rules:
* * * @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 files, String currentDirectory) { + private static boolean checkCopyOrMoveConsistency(Context ctx, List 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( -- cgit v1.2.3