diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-10-21 21:06:50 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-10-21 21:06:50 +0000 |
commit | 6f0f35806f860b9e4a4513ac219e2c5cd1ee56cd (patch) | |
tree | d2de00e1fd7434e473b7e7680e2c6e71190c7439 | |
parent | b644780148abf5c3f24509a75b9028237c5fe607 (diff) | |
parent | 935fca185741e51ab634e5df63c6369d2d55dba5 (diff) | |
download | android_packages_apps_Trebuchet-6f0f35806f860b9e4a4513ac219e2c5cd1ee56cd.tar.gz android_packages_apps_Trebuchet-6f0f35806f860b9e4a4513ac219e2c5cd1ee56cd.tar.bz2 android_packages_apps_Trebuchet-6f0f35806f860b9e4a4513ac219e2c5cd1ee56cd.zip |
Do not animate folder when it is closed while changing activity state
am: 935fca1857
* commit '935fca185741e51ab634e5df63c6369d2d55dba5':
Do not animate folder when it is closed while changing activity state
-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 da32e7e0f..310b6369b 100644 --- a/src/com/android/launcher3/Folder.java +++ b/src/com/android/launcher3/Folder.java @@ -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() { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 3897d9e85..a1dd2fb37 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -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; } } - 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 f5db6c0b6..03731d175 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); |