diff options
author | Jon Miranda <jonmiranda@google.com> | 2017-03-08 12:22:34 -0800 |
---|---|---|
committer | Jon Miranda <jonmiranda@google.com> | 2017-03-08 12:22:34 -0800 |
commit | 5f3f4d428021ce1a21a9fba4c681ec9ec2ccdf37 (patch) | |
tree | dce740f4900f5648ab4f2b4aabca028ad196331d /src/com/android/launcher3/folder/FolderAnimationManager.java | |
parent | 88c07e5b8157fc806ac80fb984559813cba1e4bf (diff) | |
download | android_packages_apps_Trebuchet-5f3f4d428021ce1a21a9fba4c681ec9ec2ccdf37.tar.gz android_packages_apps_Trebuchet-5f3f4d428021ce1a21a9fba4c681ec9ec2ccdf37.tar.bz2 android_packages_apps_Trebuchet-5f3f4d428021ce1a21a9fba4c681ec9ec2ccdf37.zip |
Added new interpolators for preview items in large folders.
With larger folders, we want the preview items to reach their final positions faster
(when opening) and later (when closing) so that they appear aligned with the rest of
the folder items when they are both visible.
Bug: 35064148
Change-Id: I170ac2db36a3a20ebe5505711ea59e625050bc1b
Diffstat (limited to 'src/com/android/launcher3/folder/FolderAnimationManager.java')
-rw-r--r-- | src/com/android/launcher3/folder/FolderAnimationManager.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index 9ce1c57c7..6ce572d94 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -65,6 +65,8 @@ public class FolderAnimationManager { private Animator mRevealAnimator; private final TimeInterpolator mOpeningInterpolator; private final TimeInterpolator mClosingInterpolator; + private final TimeInterpolator mPreviewItemOpeningInterpolator; + private final TimeInterpolator mPreviewItemClosingInterpolator; private final FolderIcon.PreviewItemDrawingParams mTmpParams = new FolderIcon.PreviewItemDrawingParams(0, 0, 0, 0); @@ -115,6 +117,10 @@ public class FolderAnimationManager { R.interpolator.folder_opening_interpolator); mClosingInterpolator = AnimationUtils.loadInterpolator(mContext, R.interpolator.folder_closing_interpolator); + mPreviewItemOpeningInterpolator = AnimationUtils.loadInterpolator(mContext, + R.interpolator.folder_preview_item_opening_interpolator); + mPreviewItemClosingInterpolator = AnimationUtils.loadInterpolator(mContext, + R.interpolator.folder_preview_item_closing_interpolator); } public AnimatorSet getOpeningAnimator() { @@ -122,7 +128,6 @@ public class FolderAnimationManager { mFolder.setPivotY(0); AnimatorSet a = getAnimatorSet(true /* isOpening */); - a.setInterpolator(mOpeningInterpolator); a.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { @@ -134,7 +139,6 @@ public class FolderAnimationManager { public AnimatorSet getClosingAnimator() { AnimatorSet a = getAnimatorSet(false /* isOpening */); - a.setInterpolator(mClosingInterpolator); return a; } @@ -242,6 +246,12 @@ public class FolderAnimationManager { } }); + // We set the interpolator on all current child animators here, because the preview item + // animators may use a different interpolator. + for (Animator animator : a.getChildAnimations()) { + animator.setInterpolator(isOpening ? mOpeningInterpolator : mClosingInterpolator); + } + addPreviewItemAnimatorsToSet(a, isOpening, folderScale, nudgeOffsetX); return a; } @@ -269,6 +279,8 @@ public class FolderAnimationManager { final List<BubbleTextView> itemsInPreview = mFolderIcon.getItemsToDisplay(); final int numItemsInPreview = itemsInPreview.size(); + TimeInterpolator previewItemInterpolator = getPreviewItemInterpolator(isOpening); + ShortcutAndWidgetContainer cwc = mContent.getPageAt(0).getShortcutsAndWidgets(); for (int i = 0; i < numItemsInPreview; ++i) { final BubbleTextView btv = itemsInPreview.get(i); @@ -305,16 +317,19 @@ public class FolderAnimationManager { ObjectAnimator translationX = isOpening ? ObjectAnimator.ofFloat(btv, View.TRANSLATION_X, xDistance, 0) : ObjectAnimator.ofFloat(btv, View.TRANSLATION_X, 0, xDistance); + translationX.setInterpolator(previewItemInterpolator); animatorSet.play(translationX); ObjectAnimator translationY = isOpening ? ObjectAnimator.ofFloat(btv, View.TRANSLATION_Y, yDistance, 0) : ObjectAnimator.ofFloat(btv, View.TRANSLATION_Y, 0, yDistance); + translationY.setInterpolator(previewItemInterpolator); animatorSet.play(translationY); ObjectAnimator scaleAnimator = isOpening ? ObjectAnimator.ofFloat(btv, SCALE_PROPERTY, initialScale, finalScale) : ObjectAnimator.ofFloat(btv, SCALE_PROPERTY, finalScale, initialScale); + scaleAnimator.setInterpolator(previewItemInterpolator); animatorSet.play(scaleAnimator); animatorSet.addListener(new AnimatorListenerAdapter() { @@ -329,4 +344,14 @@ public class FolderAnimationManager { }); } } + + private TimeInterpolator getPreviewItemInterpolator(boolean isOpening) { + if (mFolder.getItemCount() > FolderIcon.NUM_ITEMS_IN_PREVIEW) { + // With larger folders, we want the preview items to reach their final positions faster + // (when opening) and later (when closing) so that they appear aligned with the rest of + // the folder items when they are both visible. + return isOpening ? mPreviewItemOpeningInterpolator : mPreviewItemClosingInterpolator; + } + return isOpening ? mOpeningInterpolator : mClosingInterpolator; + } } |