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
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java b/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java
index 2ed5800..758fb7a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java
@@ -40,6 +40,7 @@
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 @@
* 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;
- mLinearOutSlowInX2 = NotificationUtils.interpolate(LINEAR_OUT_SLOW_IN_X2,
- LINEAR_OUT_SLOW_IN_X2_MAX,
- mSpeedUpFactor);
+ 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 @@
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 @@
float speedup = mSpeedUpFactor * (1.0f - velocityFactor);
mInterpolator = new PathInterpolator(speedup,
speedup * startGradient,
- mLinearOutSlowInX2, 1);
+ mLinearOutSlowInX2, mY2);
mCachedStartGradient = startGradient;
mCachedVelocityFactor = velocityFactor;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 50a258d..82a5cc2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -2007,6 +2007,12 @@
}
@Override
+ protected boolean shouldUseDismissingAnimation() {
+ return mStatusBarState != StatusBarState.SHADE
+ && !mStatusBar.isKeyguardCurrentlySecure();
+ }
+
+ @Override
protected boolean fullyExpandedClearAllVisible() {
return mNotificationStackScroller.isDismissViewNotGone()
&& mNotificationStackScroller.isScrolledToBottom() && !mQsExpandImmediate;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index c8d0932..18e394e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -94,6 +94,7 @@
private VelocityTrackerInterface mVelocityTracker;
private FlingAnimationUtils mFlingAnimationUtils;
private FlingAnimationUtils mFlingAnimationUtilsClosing;
+ private FlingAnimationUtils mFlingAnimationUtilsDismissing;
private FalsingManager mFalsingManager;
/**
@@ -184,6 +185,9 @@
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 @@
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 @@
animator.start();
}
+ protected abstract boolean shouldUseDismissingAnimation();
+
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();