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

Commit 2411f764 authored by Selim Cinek's avatar Selim Cinek
Browse files

Using a different interpolator when unlocking to an app

On the lockscreen when unlocking to an app without security
/ when trusted, we use a different interpolator not to break
the animation in between.

Change-Id: Iedf3172ff281e82e02f0859101198cb2f7ffe265
Fixes: 33652632
Fixes: 33652041
Test: unlock without security
parent 593ee208
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ public class FlingAnimationUtils {

    private static final float LINEAR_OUT_SLOW_IN_START_GRADIENT = 0.75f;
    private final float mSpeedUpFactor;
    private final float mY2;

    private float mMinVelocityPxPerSecond;
    private float mMaxLengthSeconds;
@@ -62,11 +63,30 @@ public class FlingAnimationUtils {
     *                      acceleration will take place.
     */
    public FlingAnimationUtils(Context ctx, float maxLengthSeconds, float speedUpFactor) {
        this(ctx, maxLengthSeconds, speedUpFactor, -1.0f, 1.0f);
    }

    /**
     * @param maxLengthSeconds the longest duration an animation can become in seconds
     * @param speedUpFactor a factor from 0 to 1 how much the slow down should be shifted towards
     *                      the end of the animation. 0 means it's at the beginning and no
     *                      acceleration will take place.
     * @param x2 the x value to take for the second point of the bezier spline. If a value below 0
     *           is provided, the value is automatically calculated.
     * @param y2 the y value to take for the second point of the bezier spline
     */
    public FlingAnimationUtils(Context ctx, float maxLengthSeconds, float speedUpFactor, float x2,
            float y2) {
        mMaxLengthSeconds = maxLengthSeconds;
        mSpeedUpFactor = speedUpFactor;
        if (x2 < 0) {
            mLinearOutSlowInX2 = NotificationUtils.interpolate(LINEAR_OUT_SLOW_IN_X2,
                    LINEAR_OUT_SLOW_IN_X2_MAX,
                    mSpeedUpFactor);
        } else {
            mLinearOutSlowInX2 = x2;
        }
        mY2 = y2;

        mMinVelocityPxPerSecond
                = MIN_VELOCITY_DP_PER_SECOND * ctx.getResources().getDisplayMetrics().density;
@@ -148,7 +168,7 @@ public class FlingAnimationUtils {
        float velocityFactor = mSpeedUpFactor == 0.0f
                ? 1.0f : Math.min(velAbs / HIGH_VELOCITY_DP_PER_SECOND, 1.0f);
        float startGradient = NotificationUtils.interpolate(LINEAR_OUT_SLOW_IN_START_GRADIENT,
                1.0f / mLinearOutSlowInX2, velocityFactor);
                mY2 / mLinearOutSlowInX2, velocityFactor);
        float durationSeconds = startGradient * diff / velAbs;
        Interpolator slowInInterpolator = getInterpolator(startGradient, velocityFactor);
        if (durationSeconds <= maxLengthSeconds) {
@@ -178,7 +198,7 @@ public class FlingAnimationUtils {
            float speedup = mSpeedUpFactor * (1.0f - velocityFactor);
            mInterpolator = new PathInterpolator(speedup,
                    speedup * startGradient,
                    mLinearOutSlowInX2, 1);
                    mLinearOutSlowInX2, mY2);
            mCachedStartGradient = startGradient;
            mCachedVelocityFactor = velocityFactor;
        }
+6 −0
Original line number Diff line number Diff line
@@ -2006,6 +2006,12 @@ public class NotificationPanelView extends PanelView implements
        }
    }

    @Override
    protected boolean shouldUseDismissingAnimation() {
        return mStatusBarState != StatusBarState.SHADE
                && !mStatusBar.isKeyguardCurrentlySecure();
    }

    @Override
    protected boolean fullyExpandedClearAllVisible() {
        return mNotificationStackScroller.isDismissViewNotGone()
+13 −1
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ public abstract class PanelView extends FrameLayout {
    private VelocityTrackerInterface mVelocityTracker;
    private FlingAnimationUtils mFlingAnimationUtils;
    private FlingAnimationUtils mFlingAnimationUtilsClosing;
    private FlingAnimationUtils mFlingAnimationUtilsDismissing;
    private FalsingManager mFalsingManager;

    /**
@@ -184,6 +185,9 @@ public abstract class PanelView extends FrameLayout {
                0.6f /* speedUpFactor */);
        mFlingAnimationUtilsClosing = new FlingAnimationUtils(context, 0.5f /* maxLengthSeconds */,
                0.6f /* speedUpFactor */);
        mFlingAnimationUtilsDismissing = new FlingAnimationUtils(context,
                0.5f /* maxLengthSeconds */, 0.2f /* speedUpFactor */, 0.6f /* x2 */,
                0.84f /* y2 */);
        mBounceInterpolator = new BounceInterpolator();
        mFalsingManager = FalsingManager.getInstance(context);
    }
@@ -702,7 +706,13 @@ public abstract class PanelView extends FrameLayout {
                animator.setDuration(350);
            }
        } else {
            mFlingAnimationUtilsClosing.apply(animator, mExpandedHeight, target, vel, getHeight());
            if (shouldUseDismissingAnimation()) {
                mFlingAnimationUtilsDismissing.apply(animator, mExpandedHeight, target, vel,
                        getHeight());
            } else {
                mFlingAnimationUtilsClosing
                        .apply(animator, mExpandedHeight, target, vel, getHeight());
            }

            // Make it shorter if we run a canned animation
            if (vel == 0) {
@@ -733,6 +743,8 @@ public abstract class PanelView extends FrameLayout {
        animator.start();
    }

    protected abstract boolean shouldUseDismissingAnimation();

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();