Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dad2fde8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Tweak smart selection animation"

parents c24b331b 039bad3a
Loading
Loading
Loading
Loading
+4 −31
Original line number Diff line number Diff line
@@ -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) {