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

Commit 7e118827 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Use STANDARD_DECELERATE interpolator for predictive back system animations" into main

parents f4ee1623 aaa42d45
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -71,6 +71,13 @@ public class Interpolators {
     */
    public static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
            0.05f, 0.7f, 0.1f, 1f);

    /**
     * The standard decelerating interpolator that should be used on every regular movement of
     * content that is appearing e.g. when coming from off screen.
     */
    public static final Interpolator STANDARD_DECELERATE = new PathInterpolator(0f, 0f, 0f, 1f);

    /**
     * Interpolator to be used when animating a move based on a click. Pair with enough duration.
     */
+3 −3
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.view.IRemoteAnimationFinishedCallback;
import android.view.IRemoteAnimationRunner;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.window.BackEvent;
import android.window.BackMotionEvent;
@@ -51,6 +50,7 @@ import com.android.internal.dynamicanimation.animation.SpringAnimation;
import com.android.internal.dynamicanimation.animation.SpringForce;
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.internal.protolog.common.ProtoLog;
import com.android.wm.shell.animation.Interpolators;
import com.android.wm.shell.common.annotations.ShellMainThread;

import javax.inject.Inject;
@@ -65,7 +65,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation {

    /** Duration of post animation after gesture committed. */
    private static final int POST_ANIMATION_DURATION = 350;
    private static final Interpolator INTERPOLATOR = new DecelerateInterpolator();
    private static final Interpolator INTERPOLATOR = Interpolators.STANDARD_DECELERATE;
    private static final FloatProperty<CrossActivityBackAnimation> ENTER_PROGRESS_PROP =
            new FloatProperty<>("enter-alpha") {
                @Override
@@ -285,7 +285,7 @@ public class CrossActivityBackAnimation extends ShellBackAnimation {

        ValueAnimator valueAnimator =
                ValueAnimator.ofFloat(1f, 0f).setDuration(POST_ANIMATION_DURATION);
        valueAnimator.setInterpolator(new DecelerateInterpolator());
        valueAnimator.setInterpolator(INTERPOLATOR);
        valueAnimator.addUpdateListener(animation -> {
            float progress = animation.getAnimatedFraction();
            updatePostCommitEnteringAnimation(progress);
+3 −2
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ public class CrossTaskBackAnimation extends ShellBackAnimation {

    private final PointF mInitialTouchPos = new PointF();
    private final Interpolator mPostAnimationInterpolator = Interpolators.EMPHASIZED;
    private final Interpolator mProgressInterpolator = new DecelerateInterpolator();
    private final Interpolator mProgressInterpolator = Interpolators.STANDARD_DECELERATE;
    private final Interpolator mVerticalMoveInterpolator = new DecelerateInterpolator();
    private final Matrix mTransformMatrix = new Matrix();

    private final float[] mTmpFloat9 = new float[9];
@@ -169,7 +170,7 @@ public class CrossTaskBackAnimation extends ShellBackAnimation {
        float yDirection = rawYDelta < 0 ? -1 : 1;
        // limit yDelta interpretation to 1/2 of screen height in either direction
        float deltaYRatio = Math.min(height / 2f, Math.abs(rawYDelta)) / (height / 2f);
        float interpolatedYRatio = mProgressInterpolator.getInterpolation(deltaYRatio);
        float interpolatedYRatio = mVerticalMoveInterpolator.getInterpolation(deltaYRatio);
        // limit y-shift so surface never passes 8dp screen margin
        float deltaY = yDirection * interpolatedYRatio * Math.max(0f,
                (height - scaledHeight) / 2f - mVerticalMargin);