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

Commit 6f0f3580 authored by Sunny Goyal's avatar Sunny Goyal Committed by android-build-merger
Browse files

Do not animate folder when it is closed while changing activity state

am: 935fca18

* commit '935fca18':
  Do not animate folder when it is closed while changing activity state
parents b6447801 935fca18
Loading
Loading
Loading
Loading
+28 −27
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
    /**
     * Creates a new UserFolder, inflated from R.layout.user_folder.
     *
     * @param context The application's context.
     * @param launcher The main activity.
     *
     * @return A new UserFolder.
     */
@@ -649,9 +649,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        oa.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                onCloseComplete();
                setLayerType(LAYER_TYPE_NONE, null);
                mState = STATE_SMALL;
                close();
            }
            @Override
            public void onAnimationStart(Animator animation) {
@@ -665,6 +664,32 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        oa.start();
    }

    public void close() {
        // TODO: Clear all active animations.
        DragLayer parent = (DragLayer) getParent();
        if (parent != null) {
            parent.removeView(this);
        }
        mDragController.removeDropTarget(this);
        clearFocus();
        mFolderIcon.requestFocus();

        if (mRearrangeOnClose) {
            rearrangeChildren();
            mRearrangeOnClose = false;
        }
        if (getItemCount() <= 1) {
            if (!mDragInProgress && !mSuppressFolderDeletion) {
                replaceFolderWithFinalItem();
            } else if (mDragInProgress) {
                mDeleteFolderOnDropCompleted = true;
            }
        }
        mSuppressFolderDeletion = false;
        clearDragInfo();
        mState = STATE_SMALL;
    }

    public boolean acceptDrop(DragObject d) {
        final ItemInfo item = d.dragInfo;
        final int itemType = item.itemType;
@@ -1102,30 +1127,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
        return mContent.getItemCount();
    }

    @Thunk void onCloseComplete() {
        DragLayer parent = (DragLayer) getParent();
        if (parent != null) {
            parent.removeView(this);
        }
        mDragController.removeDropTarget((DropTarget) this);
        clearFocus();
        mFolderIcon.requestFocus();

        if (mRearrangeOnClose) {
            rearrangeChildren();
            mRearrangeOnClose = false;
        }
        if (getItemCount() <= 1) {
            if (!mDragInProgress && !mSuppressFolderDeletion) {
                replaceFolderWithFinalItem();
            } else if (mDragInProgress) {
                mDeleteFolderOnDropCompleted = true;
            }
        }
        mSuppressFolderDeletion = false;
        clearDragInfo();
    }

    @Thunk void replaceFolderWithFinalItem() {
        // Add the last remaining child to the workspace in place of the folder
        Runnable onCompleteRunnable = new Runnable() {
+21 −10
Original line number Diff line number Diff line
@@ -1878,7 +1878,7 @@ public class Launcher extends Activity
            // In all these cases, only animate if we're already on home
            mWorkspace.exitWidgetResizeMode();

            closeFolder();
            closeFolder(alreadyOnHome);
            exitSpringLoadedDragMode();

            // If we are already on home, then just animate back to the workspace,
@@ -1960,7 +1960,7 @@ public class Launcher extends Activity
        outState.putInt(RUNTIME_STATE, mState.ordinal());
        // We close any open folder since it will not be re-opened, and we need to make sure
        // this state is reflected.
        closeFolder();
        closeFolder(false);

        if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 &&
                mWaitingForResult) {
@@ -2750,7 +2750,7 @@ public class Launcher extends Activity
            if (openFolder != null) {
                folderScreen = mWorkspace.getPageForView(openFolder);
                // .. and close it
                closeFolder(openFolder);
                closeFolder(openFolder, true);
                if (folderScreen != mWorkspace.getCurrentPage()) {
                    // Close any folder open on the current screen
                    closeFolder();
@@ -3086,7 +3086,7 @@ public class Launcher extends Activity
        oa.start();
    }

    private void shrinkAndFadeInFolderIcon(final FolderIcon fi) {
    private void shrinkAndFadeInFolderIcon(final FolderIcon fi, boolean animate) {
        if (fi == null) return;
        final CellLayout cl = (CellLayout) fi.getParent().getParent();

@@ -3107,6 +3107,9 @@ public class Launcher extends Activity
            }
        });
        oa.start();
        if (!animate) {
            oa.end();
        }
    }

    /**
@@ -3150,30 +3153,38 @@ public class Launcher extends Activity
    }

    public void closeFolder() {
        closeFolder(true);
    }

    public void closeFolder(boolean animate) {
        Folder folder = mWorkspace != null ? mWorkspace.getOpenFolder() : null;
        if (folder != null) {
            if (folder.isEditingName()) {
                folder.dismissEditingName();
            }
            closeFolder(folder);
            closeFolder(folder, animate);
        }
    }

    public void closeFolder(Folder folder) {
    public void closeFolder(Folder folder, boolean animate) {
        folder.getInfo().opened = false;

        ViewGroup parent = (ViewGroup) folder.getParent().getParent();
        if (parent != null) {
            FolderIcon fi = (FolderIcon) mWorkspace.getViewForTag(folder.mInfo);
            shrinkAndFadeInFolderIcon(fi);
            shrinkAndFadeInFolderIcon(fi, animate);
            if (fi != null) {
                ((CellLayout.LayoutParams) fi.getLayoutParams()).canReorder = true;
            }
        }
        if (animate) {
            folder.animateClosed();
        } else {
            folder.close();
        }

        // Notify the accessibility manager that this folder "window" has disappeard and no
        // longer occludeds the workspace items
        // Notify the accessibility manager that this folder "window" has disappeared and no
        // longer occludes the workspace items
        getDragLayer().sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
    }

+1 −1
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme
            return true;
        } else if (action == MOVE_TO_WORKSPACE) {
            Folder folder = mLauncher.getWorkspace().getOpenFolder();
            mLauncher.closeFolder(folder);
            mLauncher.closeFolder(folder, true);
            ShortcutInfo info = (ShortcutInfo) item;
            folder.getInfo().remove(info);