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

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

Merge "Use decelerating interpolator for IME PB" into main

parents a808c906 904c3686
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

package android.view;

import static android.view.InsetsController.ANIMATION_DURATION_SYNC_IME_MS;
import static android.view.InsetsController.ANIMATION_DURATION_UNSYNC_IME_MS;
import static android.view.InsetsController.ANIMATION_TYPE_USER;
import static android.view.InsetsController.FAST_OUT_LINEAR_IN_INTERPOLATOR;
import static android.view.InsetsController.SYNC_IME_INTERPOLATOR;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
@@ -56,8 +60,6 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
    private static final Interpolator BACK_GESTURE = new BackGestureInterpolator();
    private static final Interpolator EMPHASIZED_DECELERATE = new PathInterpolator(
            0.05f, 0.7f, 0.1f, 1f);
    private static final Interpolator STANDARD_ACCELERATE = new PathInterpolator(0.3f, 0f, 1f, 1f);

    private final InsetsController mInsetsController;
    private final ViewRootImpl mViewRoot;
    private WindowInsetsAnimationController mWindowInsetsAnimationController = null;
@@ -183,8 +185,21 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
        float targetProgress = triggerBack ? 1f : 0f;
        mPostCommitAnimator = ValueAnimator.ofFloat(
                BACK_GESTURE.getInterpolation(mLastProgress) * PEEK_FRACTION, targetProgress);
        mPostCommitAnimator.setInterpolator(
                triggerBack ? STANDARD_ACCELERATE : EMPHASIZED_DECELERATE);
        Interpolator interpolator;
        long duration;
        if (triggerBack && mViewRoot.mView.hasWindowInsetsAnimationCallback()
                && mWindowInsetsAnimationController.getShownStateInsets().bottom != 0) {
            interpolator = SYNC_IME_INTERPOLATOR;
            duration = ANIMATION_DURATION_SYNC_IME_MS;
        } else if (triggerBack) {
            interpolator = FAST_OUT_LINEAR_IN_INTERPOLATOR;
            duration = ANIMATION_DURATION_UNSYNC_IME_MS;
        } else {
            interpolator = EMPHASIZED_DECELERATE;
            duration = POST_COMMIT_CANCEL_DURATION_MS;
        }
        mPostCommitAnimator.setInterpolator(interpolator);
        mPostCommitAnimator.setDuration(duration);
        mPostCommitAnimator.addUpdateListener(animation -> {
            if (mWindowInsetsAnimationController != null) {
                setInterpolatedProgress((float) animation.getAnimatedValue());
@@ -207,8 +222,6 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
                reset();
            }
        });
        mPostCommitAnimator.setDuration(
                triggerBack ? POST_COMMIT_DURATION_MS : POST_COMMIT_CANCEL_DURATION_MS);
        mPostCommitAnimator.start();
        if (triggerBack) {
            mInsetsController.setPredictiveBackImeHideAnimInProgress(true);
+4 −4
Original line number Diff line number Diff line
@@ -235,8 +235,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    private static final int ANIMATION_DELAY_DIM_MS = 500;

    private static final int ANIMATION_DURATION_SYNC_IME_MS = 285;
    private static final int ANIMATION_DURATION_UNSYNC_IME_MS = 200;
    static final int ANIMATION_DURATION_SYNC_IME_MS = 285;
    static final int ANIMATION_DURATION_UNSYNC_IME_MS = 200;

    private static final int PENDING_CONTROL_TIMEOUT_MS = 2000;

@@ -256,11 +256,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            return 1f - SYSTEM_BARS_ALPHA_INTERPOLATOR.getInterpolation(innerFraction);
        }
    };
    private static final Interpolator SYNC_IME_INTERPOLATOR =
    static final Interpolator SYNC_IME_INTERPOLATOR =
            new PathInterpolator(0.2f, 0f, 0f, 1f);
    private static final Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR =
            new PathInterpolator(0, 0, 0.2f, 1f);
    private static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR =
    static final Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR =
            new PathInterpolator(0.4f, 0f, 1f, 1f);

    /** Visible for WindowManagerWrapper */