From 287963146c96a4cd2772cfee829ac4a4a03c1ff7 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Tue, 8 Mar 2016 14:12:42 -0800 Subject: [PATCH] Use FlingAnimationUtils for dismissing a notification Addressing comment in ag/877913 PS6 Adds FlingAnimationUtils to SwipeHelper for dismissing notification so that it may better follow a user's finger. This is not used when a dismiss all is called (i.e. useAcceleration is requested). Additionally alters dismiss behavior to accelerate out if velocity was 0. Change-Id: Ia7dc15d64e8427d5cfbdee3f4e48ccd60f5b0b36 --- .../src/com/android/systemui/SwipeHelper.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index f6dcc115401d0..1fe218a885fb1 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -32,6 +32,7 @@ import android.view.ViewConfiguration; import android.view.accessibility.AccessibilityEvent; import com.android.systemui.classifier.FalsingManager; +import com.android.systemui.statusbar.FlingAnimationUtils; public class SwipeHelper implements Gefingerpoken { static final String TAG = "com.android.systemui.SwipeHelper"; @@ -58,6 +59,7 @@ public class SwipeHelper implements Gefingerpoken { private float mMinSwipeProgress = 0f; private float mMaxSwipeProgress = 1f; + private FlingAnimationUtils mFlingAnimationUtils; private float mPagingTouchSlop; private Callback mCallback; private Handler mHandler; @@ -95,6 +97,8 @@ public class SwipeHelper implements Gefingerpoken { mFalsingThreshold = context.getResources().getDimensionPixelSize( R.dimen.swipe_helper_falsing_threshold); mFalsingManager = FalsingManager.getInstance(context); + mFlingAnimationUtils = new FlingAnimationUtils(context, + MAX_ESCAPE_ANIMATION_DURATION / 1000f /* maxLengthSeconds */); } public void setLongPressListener(LongPressListener listener) { @@ -320,7 +324,8 @@ public class SwipeHelper implements Gefingerpoken { * @param velocity The desired pixels/second speed at which the view should move */ public void dismissChild(final View view, float velocity) { - dismissChild(view, velocity, null, 0, false, 0); + dismissChild(view, velocity, null /* endAction */, 0 /* delay */, + velocity == 0 /* useAccelerateInterpolator */, 0 /* fixedDuration */); } /** @@ -377,10 +382,11 @@ public class SwipeHelper implements Gefingerpoken { } if (useAccelerateInterpolator) { anim.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN); + anim.setDuration(duration); } else { - anim.setInterpolator(Interpolators.LINEAR); + mFlingAnimationUtils.applyDismissing(anim, getTranslation(animView), + newPos, velocity, getSize(animView)); } - anim.setDuration(duration); if (delay > 0) { anim.setStartDelay(delay); }