diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-10-13 10:19:01 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2015-10-21 13:42:36 -0700 |
commit | 935fca185741e51ab634e5df63c6369d2d55dba5 (patch) | |
tree | b804b58a1c804ec37df1108a8d1a04b834a1e82f | |
parent | 56070d4b67490b371fa0839997aaddac46e1758a (diff) | |
download | android_packages_apps_Trebuchet-935fca185741e51ab634e5df63c6369d2d55dba5.tar.gz android_packages_apps_Trebuchet-935fca185741e51ab634e5df63c6369d2d55dba5.tar.bz2 android_packages_apps_Trebuchet-935fca185741e51ab634e5df63c6369d2d55dba5.zip |
Do not animate folder when it is closed while changing activity state
Bug: 21733536
Change-Id: I36aa3041b9300c917e320b511e00a1721e44f854
-rw-r--r-- | src/com/android/launcher3/Folder.java | 55 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 31 | ||||
-rw-r--r-- | src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java | 2 |
3 files changed, 50 insertions, 38 deletions
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java index fb9d95a20..9377bad6d 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -414,7 +414,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. */ @@ -639,9 +639,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) { @@ -655,6 +654,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 = (ItemInfo) d.dragInfo; final int itemType = item.itemType; @@ -1087,30 +1112,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() { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index caa3b8b86..7ba9cc8ca 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1906,7 +1906,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, @@ -1988,7 +1988,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) { @@ -2782,7 +2782,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(); @@ -3122,7 +3122,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; PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); @@ -3148,6 +3148,9 @@ public class Launcher extends Activity } }); oa.start(); + if (!animate) { + oa.end(); + } } /** @@ -3191,30 +3194,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; } } - folder.animateClosed(); + 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); } diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index 2233ebb7a..2306b776e 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -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); |