Loading packages/SystemUI/src/com/android/systemui/SwipeHelper.java +49 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.view.accessibility.AccessibilityEvent; import com.android.systemui.classifier.FalsingManager; import com.android.systemui.statusbar.FlingAnimationUtils; import java.util.HashMap; public class SwipeHelper implements Gefingerpoken { static final String TAG = "com.android.systemui.SwipeHelper"; private static final boolean DEBUG = false; Loading Loading @@ -70,6 +72,7 @@ public class SwipeHelper implements Gefingerpoken { private float mInitialTouchPos; private float mPerpendicularInitialTouchPos; private boolean mDragging; private boolean mSnappingChild; private View mCurrView; private boolean mCanCurrViewBeDimissed; private float mDensityScale; Loading @@ -85,6 +88,8 @@ public class SwipeHelper implements Gefingerpoken { private boolean mTouchAboveFalsingThreshold; private boolean mDisableHwLayers; private HashMap<View, Animator> mDismissPendingMap = new HashMap<>(); public SwipeHelper(int swipeDirection, Callback callback, Context context) { mCallback = callback; mHandler = new Handler(); Loading Loading @@ -252,6 +257,7 @@ public class SwipeHelper implements Gefingerpoken { case MotionEvent.ACTION_DOWN: mTouchAboveFalsingThreshold = false; mDragging = false; mSnappingChild = false; mLongPressSent = false; mVelocityTracker.clear(); mCurrView = mCallback.getChildAtPosition(ev); Loading Loading @@ -391,9 +397,18 @@ public class SwipeHelper implements Gefingerpoken { anim.setStartDelay(delay); } anim.addListener(new AnimatorListenerAdapter() { private boolean mCancelled; public void onAnimationCancel(Animator animation) { mCancelled = true; } public void onAnimationEnd(Animator animation) { updateSwipeProgressFromOffset(animView, canBeDismissed); mDismissPendingMap.remove(animView); if (!mCancelled) { mCallback.onChildDismissed(animView); } if (endAction != null) { endAction.run(); } Loading @@ -402,7 +417,9 @@ public class SwipeHelper implements Gefingerpoken { } } }); prepareDismissAnimation(animView, anim); mDismissPendingMap.put(animView, anim); anim.start(); } Loading @@ -429,11 +446,13 @@ public class SwipeHelper implements Gefingerpoken { anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { mSnappingChild = false; updateSwipeProgressFromOffset(animView, canBeDismissed); mCallback.onChildSnappedBack(animView, targetLeft); } }); prepareSnapBackAnimation(animView, anim); mSnappingChild = true; anim.start(); } Loading Loading @@ -466,6 +485,33 @@ public class SwipeHelper implements Gefingerpoken { updateSwipeProgressFromOffset(animView, canBeDismissed); } private void snapChildInstantly(final View view) { final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view); setTranslation(view, 0); updateSwipeProgressFromOffset(view, canAnimViewBeDismissed); } public void snapChildIfNeeded(final View view, boolean animate) { if ((mDragging && mCurrView == view) || mSnappingChild) { return; } boolean needToSnap = false; Animator dismissPendingAnim = mDismissPendingMap.get(view); if (dismissPendingAnim != null) { needToSnap = true; dismissPendingAnim.cancel(); } else if (getTranslation(view) != 0) { needToSnap = true; } if (needToSnap) { if (animate) { snapChild(view, 0 /* targetLeft */, 0.0f /* velocity */); } else { snapChildInstantly(view); } } } public boolean onTouchEvent(MotionEvent ev) { if (mLongPressSent) { return true; Loading Loading @@ -532,7 +578,9 @@ public class SwipeHelper implements Gefingerpoken { mCallback.onDragCancelled(mCurrView); snapChild(mCurrView, 0 /* leftTarget */, velocity); } mCurrView = null; } mDragging = false; break; } return true; Loading packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +6 −0 Original line number Diff line number Diff line Loading @@ -2236,6 +2236,12 @@ public abstract class BaseStatusBar extends SystemUI implements // swipe-dismissable) bindVetoButtonClickListener(entry.row, notification); if (!notification.isClearable()) { // The user may have performed a dismiss action on the notification, since it's // not clearable we should snap it back. mStackScroller.snapViewIfNeeded(entry.row); } if (DEBUG) { // Is this for you? boolean isForCurrentUser = isNotificationForCurrentProfiles(notification); Loading packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +5 −0 Original line number Diff line number Diff line Loading @@ -957,6 +957,11 @@ public class NotificationStackScrollLayout extends ViewGroup mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration); } public void snapViewIfNeeded(View child) { boolean animate = mIsExpanded || isPinnedHeadsUp(child); mSwipeHelper.snapChildIfNeeded(child, animate); } @Override public boolean onTouchEvent(MotionEvent ev) { boolean isCancelOrUp = ev.getActionMasked() == MotionEvent.ACTION_CANCEL Loading Loading
packages/SystemUI/src/com/android/systemui/SwipeHelper.java +49 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.view.accessibility.AccessibilityEvent; import com.android.systemui.classifier.FalsingManager; import com.android.systemui.statusbar.FlingAnimationUtils; import java.util.HashMap; public class SwipeHelper implements Gefingerpoken { static final String TAG = "com.android.systemui.SwipeHelper"; private static final boolean DEBUG = false; Loading Loading @@ -70,6 +72,7 @@ public class SwipeHelper implements Gefingerpoken { private float mInitialTouchPos; private float mPerpendicularInitialTouchPos; private boolean mDragging; private boolean mSnappingChild; private View mCurrView; private boolean mCanCurrViewBeDimissed; private float mDensityScale; Loading @@ -85,6 +88,8 @@ public class SwipeHelper implements Gefingerpoken { private boolean mTouchAboveFalsingThreshold; private boolean mDisableHwLayers; private HashMap<View, Animator> mDismissPendingMap = new HashMap<>(); public SwipeHelper(int swipeDirection, Callback callback, Context context) { mCallback = callback; mHandler = new Handler(); Loading Loading @@ -252,6 +257,7 @@ public class SwipeHelper implements Gefingerpoken { case MotionEvent.ACTION_DOWN: mTouchAboveFalsingThreshold = false; mDragging = false; mSnappingChild = false; mLongPressSent = false; mVelocityTracker.clear(); mCurrView = mCallback.getChildAtPosition(ev); Loading Loading @@ -391,9 +397,18 @@ public class SwipeHelper implements Gefingerpoken { anim.setStartDelay(delay); } anim.addListener(new AnimatorListenerAdapter() { private boolean mCancelled; public void onAnimationCancel(Animator animation) { mCancelled = true; } public void onAnimationEnd(Animator animation) { updateSwipeProgressFromOffset(animView, canBeDismissed); mDismissPendingMap.remove(animView); if (!mCancelled) { mCallback.onChildDismissed(animView); } if (endAction != null) { endAction.run(); } Loading @@ -402,7 +417,9 @@ public class SwipeHelper implements Gefingerpoken { } } }); prepareDismissAnimation(animView, anim); mDismissPendingMap.put(animView, anim); anim.start(); } Loading @@ -429,11 +446,13 @@ public class SwipeHelper implements Gefingerpoken { anim.setDuration(duration); anim.addListener(new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animator) { mSnappingChild = false; updateSwipeProgressFromOffset(animView, canBeDismissed); mCallback.onChildSnappedBack(animView, targetLeft); } }); prepareSnapBackAnimation(animView, anim); mSnappingChild = true; anim.start(); } Loading Loading @@ -466,6 +485,33 @@ public class SwipeHelper implements Gefingerpoken { updateSwipeProgressFromOffset(animView, canBeDismissed); } private void snapChildInstantly(final View view) { final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view); setTranslation(view, 0); updateSwipeProgressFromOffset(view, canAnimViewBeDismissed); } public void snapChildIfNeeded(final View view, boolean animate) { if ((mDragging && mCurrView == view) || mSnappingChild) { return; } boolean needToSnap = false; Animator dismissPendingAnim = mDismissPendingMap.get(view); if (dismissPendingAnim != null) { needToSnap = true; dismissPendingAnim.cancel(); } else if (getTranslation(view) != 0) { needToSnap = true; } if (needToSnap) { if (animate) { snapChild(view, 0 /* targetLeft */, 0.0f /* velocity */); } else { snapChildInstantly(view); } } } public boolean onTouchEvent(MotionEvent ev) { if (mLongPressSent) { return true; Loading Loading @@ -532,7 +578,9 @@ public class SwipeHelper implements Gefingerpoken { mCallback.onDragCancelled(mCurrView); snapChild(mCurrView, 0 /* leftTarget */, velocity); } mCurrView = null; } mDragging = false; break; } return true; Loading
packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +6 −0 Original line number Diff line number Diff line Loading @@ -2236,6 +2236,12 @@ public abstract class BaseStatusBar extends SystemUI implements // swipe-dismissable) bindVetoButtonClickListener(entry.row, notification); if (!notification.isClearable()) { // The user may have performed a dismiss action on the notification, since it's // not clearable we should snap it back. mStackScroller.snapViewIfNeeded(entry.row); } if (DEBUG) { // Is this for you? boolean isForCurrentUser = isNotificationForCurrentProfiles(notification); Loading
packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java +5 −0 Original line number Diff line number Diff line Loading @@ -957,6 +957,11 @@ public class NotificationStackScrollLayout extends ViewGroup mSwipeHelper.dismissChild(child, 0, endRunnable, delay, true, duration); } public void snapViewIfNeeded(View child) { boolean animate = mIsExpanded || isPinnedHeadsUp(child); mSwipeHelper.snapChildIfNeeded(child, animate); } @Override public boolean onTouchEvent(MotionEvent ev) { boolean isCancelOrUp = ev.getActionMasked() == MotionEvent.ACTION_CANCEL Loading