diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/SwipeHelper.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/SwipeHelper.java | 73 |
1 files changed, 29 insertions, 44 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 4b377153e558..8c1b736d5698 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -83,7 +83,6 @@ public class SwipeHelper implements Gefingerpoken { private boolean mMenuRowIntercepting; private boolean mLongPressSent; - private LongPressListener mLongPressListener; private Runnable mWatchLongPress; private final long mLongPressTimeout; @@ -115,10 +114,6 @@ public class SwipeHelper implements Gefingerpoken { mFlingAnimationUtils = new FlingAnimationUtils(context, getMaxEscapeAnimDuration() / 1000f); } - public void setLongPressListener(LongPressListener listener) { - mLongPressListener = listener; - } - public void setDensityScale(float densityScale) { mDensityScale = densityScale; } @@ -257,7 +252,7 @@ public class SwipeHelper implements Gefingerpoken { } } - public void removeLongPressCallback() { + public void cancelLongPress() { if (mWatchLongPress != null) { mHandler.removeCallbacks(mWatchLongPress); mWatchLongPress = null; @@ -281,6 +276,14 @@ public class SwipeHelper implements Gefingerpoken { mVelocityTracker.clear(); mCurrView = mCallback.getChildAtPosition(ev); + // The SwipeHelper sends its own long-press, don't let the view send a dupe. + // Queue up a cancelLongPress on the view a few ms after we see a down event. + mHandler.post(() -> { + if (mCurrView != null) { + mCurrView.cancelLongPress(); + } + }); + if (mCurrView != null) { onDownUpdate(mCurrView, ev); mCanCurrViewBeDimissed = mCallback.canChildBeDismissed(mCurrView); @@ -288,33 +291,26 @@ public class SwipeHelper implements Gefingerpoken { mInitialTouchPos = getPos(ev); mPerpendicularInitialTouchPos = getPerpendicularPos(ev); mTranslation = getTranslation(mCurrView); - if (mLongPressListener != null) { - if (mWatchLongPress == null) { - mWatchLongPress = new Runnable() { - @Override - public void run() { - if (mCurrView != null && !mLongPressSent) { - mLongPressSent = true; - mCurrView.sendAccessibilityEvent( - AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); - mCurrView.getLocationOnScreen(mTmpPos); - final int x = (int) ev.getRawX() - mTmpPos[0]; - final int y = (int) ev.getRawY() - mTmpPos[1]; - MenuItem menuItem = null; - if (mCurrView instanceof ExpandableNotificationRow) { - menuItem = ((ExpandableNotificationRow) mCurrView) - .getProvider().getLongpressMenuItem(mContext); - } - if (menuItem != null) { - mLongPressListener.onLongPress(mCurrView, x, y, - menuItem); - } + if (mWatchLongPress == null) { + mWatchLongPress = new Runnable() { + @Override + public void run() { + if (mCurrView != null && !mLongPressSent) { + mLongPressSent = true; + mCurrView.getLocationOnScreen(mTmpPos); + final int x = (int) ev.getRawX() - mTmpPos[0]; + final int y = (int) ev.getRawY() - mTmpPos[1]; + if (mCurrView instanceof ExpandableNotificationRow) { + ExpandableNotificationRow currRow = + (ExpandableNotificationRow) mCurrView; + currRow.setLongPressPosition(x, y); + currRow.performLongClick(x, y); } } - }; - } - mHandler.postDelayed(mWatchLongPress, mLongPressTimeout); + } + }; } + mHandler.postDelayed(mWatchLongPress, mLongPressTimeout); } break; @@ -331,7 +327,7 @@ public class SwipeHelper implements Gefingerpoken { mDragging = true; mInitialTouchPos = getPos(ev); mTranslation = getTranslation(mCurrView); - removeLongPressCallback(); + cancelLongPress(); } } break; @@ -343,7 +339,7 @@ public class SwipeHelper implements Gefingerpoken { mCurrView = null; mLongPressSent = false; mMenuRowIntercepting = false; - removeLongPressCallback(); + cancelLongPress(); if (captured) return true; break; } @@ -586,7 +582,7 @@ public class SwipeHelper implements Gefingerpoken { // We are not doing anything, make sure the long press callback // is not still ticking like a bomb waiting to go off. - removeLongPressCallback(); + cancelLongPress(); return false; } } @@ -734,15 +730,4 @@ public class SwipeHelper implements Gefingerpoken { */ float getFalsingThresholdFactor(); } - - /** - * Equivalent to View.OnLongClickListener with coordinates - */ - public interface LongPressListener { - /** - * Equivalent to {@link View.OnLongClickListener#onLongClick(View)} with coordinates - * @return whether the longpress was handled - */ - boolean onLongPress(View v, int x, int y, MenuItem item); - } } |