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
This commit is contained in:
@@ -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(boundaryAnimator, onAnimationEnd);
|
||||
|
||||
setUpAnimatorListener(animatorSet, 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) {
|
||||
|
||||
Reference in New Issue
Block a user