diff options
| author | Tony Mak <tonymak@google.com> | 2020-10-23 21:22:01 +0100 |
|---|---|---|
| committer | Tony Mak <tonymak@google.com> | 2020-11-03 10:00:16 +0000 |
| commit | 039bad3a231eb1f98ffcf45d09689323c6a802fe (patch) | |
| tree | 83a9859df9048217476cf1f50d690e2643515ab2 /core/java/android/widget/SmartSelectSprite.java | |
| parent | 5377c1e0b1f7ed43f11e653c0b7e2868e26e1c2c (diff) | |
Tweak smart selection animation
Result(with ag/12911059 as well):
https://recall.googleplex.com/projects/ea8c4705-96bd-46f0-9f37-786708050727
1. Removed the corner animators.
Before 3552167, we supported two modes - fit and overshoot.
In fit mode, the highlight is expanded to a rounded rectangle.
Then corner animator then fills the corner so that the highlight
becomes a rectangle.
In overshoot mode, the expansion animation ends up in a rectangular
highlight, so the corner animator is just like doing no-op for 50ms.
With ag/3552167, we deleted the fit mode and ended up using the overshoot
mode. So, the corner animator is no longer necessary. Deleting it
saves 50ms. I confirmed that it is a no-op by increasing the duration of
it to be 5s.
2. Before this CL, the whole animation takes 350ms.
As per the material design spec
(https://material.io/design/motion/speed.html#duration)
small animation(e.g. toggle) takes 100ms
medium animation(bottom sheet) takes 250ms
large animation(page transition) takes 300 ms.
That means, our animation takes even longer than the large animation!
I think smart selection animation is somewhere between small
and medium, so adjusted the animation duration to be 200ms.
Bug: 169043706
Test: Manual. Select the text and observe the animation.
Change-Id: Ib32bb47851c1cfe95d6951998d6dc5c09a37e17b
Diffstat (limited to 'core/java/android/widget/SmartSelectSprite.java')
| -rw-r--r-- | core/java/android/widget/SmartSelectSprite.java | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/core/java/android/widget/SmartSelectSprite.java b/core/java/android/widget/SmartSelectSprite.java index dc472e1bbd82..baf92e5dc3e8 100644 --- a/core/java/android/widget/SmartSelectSprite.java +++ b/core/java/android/widget/SmartSelectSprite.java @@ -50,11 +50,9 @@ import java.util.Objects; */ final class SmartSelectSprite { - private static final int EXPAND_DURATION = 300; - private static final int CORNER_DURATION = 50; + private static final int EXPAND_DURATION = 200; private final Interpolator mExpandInterpolator; - private final Interpolator mCornerInterpolator; private Animator mActiveAnimator = null; private final Runnable mInvalidator; @@ -337,9 +335,6 @@ final class SmartSelectSprite { mExpandInterpolator = AnimationUtils.loadInterpolator( context, android.R.interpolator.fast_out_slow_in); - mCornerInterpolator = AnimationUtils.loadInterpolator( - context, - android.R.interpolator.fast_out_linear_in); mFillColor = highlightColor; mInvalidator = Objects.requireNonNull(invalidator); } @@ -372,7 +367,6 @@ final class SmartSelectSprite { final int rectangleCount = destinationRectangles.size(); final List<RoundedRectangleShape> shapes = new ArrayList<>(rectangleCount); - final List<Animator> cornerAnimators = new ArrayList<>(rectangleCount); RectangleWithTextSelectionLayout centerRectangle = null; @@ -405,7 +399,6 @@ final class SmartSelectSprite { expansionDirections[index], rectangleWithTextSelectionLayout.getTextSelectionLayout() == Layout.TEXT_SELECTION_LAYOUT_RIGHT_TO_LEFT); - cornerAnimators.add(createCornerAnimator(shape, updateListener)); shapes.add(shape); } @@ -420,7 +413,7 @@ final class SmartSelectSprite { mExistingDrawable = shapeDrawable; mActiveAnimator = createAnimator(rectangleList, startingOffset, startingOffset, - cornerAnimators, updateListener, onAnimationEnd); + updateListener, onAnimationEnd); mActiveAnimator.start(); } @@ -433,7 +426,6 @@ final class SmartSelectSprite { final RectangleList rectangleList, final float startingOffsetLeft, final float startingOffsetRight, - final List<Animator> cornerAnimators, final ValueAnimator.AnimatorUpdateListener updateListener, final Runnable onAnimationEnd) { final ObjectAnimator rightBoundaryAnimator = ObjectAnimator.ofFloat( @@ -457,18 +449,12 @@ final class SmartSelectSprite { rightBoundaryAnimator.setInterpolator(mExpandInterpolator); leftBoundaryAnimator.setInterpolator(mExpandInterpolator); - final AnimatorSet cornerAnimator = new AnimatorSet(); - cornerAnimator.playTogether(cornerAnimators); - final AnimatorSet boundaryAnimator = new AnimatorSet(); boundaryAnimator.playTogether(leftBoundaryAnimator, rightBoundaryAnimator); - final AnimatorSet animatorSet = new AnimatorSet(); - animatorSet.playSequentially(boundaryAnimator, cornerAnimator); - - setUpAnimatorListener(animatorSet, onAnimationEnd); + setUpAnimatorListener(boundaryAnimator, onAnimationEnd); - return animatorSet; + return boundaryAnimator; } private void setUpAnimatorListener(final Animator animator, final Runnable onAnimationEnd) { @@ -495,19 +481,6 @@ final class SmartSelectSprite { }); } - private ObjectAnimator createCornerAnimator( - final RoundedRectangleShape shape, - final ValueAnimator.AnimatorUpdateListener listener) { - final ObjectAnimator animator = ObjectAnimator.ofFloat( - shape, - RoundedRectangleShape.PROPERTY_ROUND_RATIO, - shape.getRoundRatio(), 0.0F); - animator.setDuration(CORNER_DURATION); - animator.addUpdateListener(listener); - animator.setInterpolator(mCornerInterpolator); - return animator; - } - private static @RoundedRectangleShape.ExpansionDirection int[] generateDirections( final RectangleWithTextSelectionLayout centerRectangle, final List<RectangleWithTextSelectionLayout> rectangles) { |
