diff options
3 files changed, 44 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java b/packages/SystemUI/src/com/android/systemui/statusbar/FlingAnimationUtils.java index 2ed580012679..758fb7a9971e 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 @@ 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; - 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 @@ 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; } 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 50a258d458d1..82a5cc2bf415 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 @@ public class NotificationPanelView extends PanelView implements } @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 c8d0932fbb02..18e394e2836a 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 @@ 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(); |