From dc6c97df483fb353ff6e18eb9ed59870c1101be8 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Thu, 31 Mar 2016 14:18:35 -0700 Subject: [PATCH] Fix slow dismiss animation An accelerated interpolator is used for dismissing when the the velocity = 0 which can occur with dismiss all or if the noti is swiped far enough but not fast enough. There is no duration specified when the noti is swiped far enough, and the velocity passed in is 0 so the default duration is used without taking into account the velocity. This CL alters the code to pass in the velocity so that a duration is calculated. Bug: 27864379 Change-Id: Ifac04bb8d1b714c040102fef035d55737c844157 --- .../src/com/android/systemui/SwipeHelper.java | 14 +++++++------- .../stack/NotificationStackScrollLayout.java | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 81ba23f27f23d..330a17c275a69 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -322,10 +322,11 @@ public class SwipeHelper implements Gefingerpoken { /** * @param view The view to be dismissed * @param velocity The desired pixels/second speed at which the view should move + * @param useAccelerateInterpolator Should an accelerating Interpolator be used */ - public void dismissChild(final View view, float velocity) { + public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) { dismissChild(view, velocity, null /* endAction */, 0 /* delay */, - velocity == 0 /* useAccelerateInterpolator */, 0 /* fixedDuration */); + useAccelerateInterpolator, 0 /* fixedDuration */); } /** @@ -526,7 +527,8 @@ public class SwipeHelper implements Gefingerpoken { if (!handleUpEvent(ev, mCurrView, velocity, getTranslation(mCurrView))) { if (isDismissGesture(ev)) { // flingadingy - dismissChild(mCurrView, swipedFastEnough() ? velocity : 0f); + dismissChild(mCurrView, velocity, + !swipedFastEnough() /* useAccelerateInterpolator */); } else { // snappity mCallback.onDragCancelled(mCurrView); @@ -570,11 +572,9 @@ public class SwipeHelper implements Gefingerpoken { protected boolean swipedFastEnough() { float velocity = getVelocity(mVelocityTracker); - float perpendicularVelocity = getPerpendicularVelocity(mVelocityTracker); float translation = getTranslation(mCurrView); - boolean ret = (Math.abs(velocity) > getEscapeVelocity()) && - (Math.abs(velocity) > Math.abs(perpendicularVelocity)) && - (velocity > 0) == (translation > 0); + boolean ret = (Math.abs(velocity) > getEscapeVelocity()) + && (velocity > 0) == (translation > 0); return ret; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java index bd5dcc6736de4..4077e7ab54ef8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java @@ -3486,8 +3486,9 @@ public class NotificationStackScrollLayout extends ViewGroup } @Override - public void dismissChild(final View view, float velocity) { - super.dismissChild(view, velocity); + public void dismissChild(final View view, float velocity, + boolean useAccelerateInterpolator) { + super.dismissChild(view, velocity, useAccelerateInterpolator); cancelCheckForDrag(); setSnappedToGear(false); } @@ -3523,7 +3524,8 @@ public class NotificationStackScrollLayout extends ViewGroup snapChild(animView, 0 /* leftTarget */, velocity); } else if (isDismissGesture(ev)) { // Gesture is a dismiss that's not towards the gear - dismissChild(animView, swipedFastEnough() ? velocity : 0f); + dismissChild(animView, velocity, + !swipedFastEnough() /* useAccelerateInterpolator */); } else { // Didn't move enough to dismiss or cover, snap to the gear snapToGear(animView, velocity); @@ -3548,7 +3550,8 @@ public class NotificationStackScrollLayout extends ViewGroup private void dismissOrSnapBack(View animView, float velocity, MotionEvent ev) { if (isDismissGesture(ev)) { - dismissChild(animView, swipedFastEnough() ? velocity : 0f); + dismissChild(animView, velocity, + !swipedFastEnough() /* useAccelerateInterpolator */); } else { snapChild(animView, 0 /* leftTarget */, velocity); }