Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 226460f8 authored by kai.cao's avatar kai.cao Committed by Jorge Ruesga
Browse files

[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
parent 9fe55d25
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -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,8 +294,8 @@ 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 ?
                              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(),
@@ -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(