aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkai.cao <kai.cao@ck-telecom.com>2015-04-16 10:55:34 +0800
committerJorge Ruesga <jorge@ruesga.com>2015-04-21 03:09:36 +0200
commit226460f8724fdc3f74e59e92862dd88087385b70 (patch)
treea7acc9906011e82d0fbe0d20f20b3b69b3a82c45
parent9fe55d253a619da925cfaedd34aeb0aff5eb641c (diff)
downloadandroid_packages_apps_CMFileManager-226460f8724fdc3f74e59e92862dd88087385b70.tar.gz
android_packages_apps_CMFileManager-226460f8724fdc3f74e59e92862dd88087385b70.tar.bz2
android_packages_apps_CMFileManager-226460f8724fdc3f74e59e92862dd88087385b70.zip
[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
-rwxr-xr-x[-rw-r--r--]src/com/cyanogenmod/filemanager/ui/policy/CopyMoveActionPolicy.java35
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(