summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/SwipeHelper.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/SwipeHelper.java69
1 files changed, 39 insertions, 30 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 02a452182d36..d17ca4041b31 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -69,6 +69,7 @@ public class SwipeHelper implements Gefingerpoken {
private final FlingAnimationUtils mFlingAnimationUtils;
private float mPagingTouchSlop;
+ private final float mSlopMultiplier;
private final Callback mCallback;
private final int mSwipeDirection;
private final VelocityTracker mVelocityTracker;
@@ -84,11 +85,28 @@ public class SwipeHelper implements Gefingerpoken {
private float mTranslation = 0;
private boolean mMenuRowIntercepting;
- private boolean mLongPressSent;
- private Runnable mWatchLongPress;
private final long mLongPressTimeout;
+ private boolean mLongPressSent;
+ private final float[] mDownLocation = new float[2];
+ private final Runnable mPerformLongPress = new Runnable() {
+
+ private final int[] mViewOffset = new int[2];
+
+ @Override
+ public void run() {
+ if (mCurrView != null && !mLongPressSent) {
+ mLongPressSent = true;
+ if (mCurrView instanceof ExpandableNotificationRow) {
+ mCurrView.getLocationOnScreen(mViewOffset);
+ final int x = (int) mDownLocation[0] - mViewOffset[0];
+ final int y = (int) mDownLocation[1] - mViewOffset[1];
+ mCurrView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
+ ((ExpandableNotificationRow) mCurrView).doLongClickCallback(x, y);
+ }
+ }
+ }
+ };
- final private int[] mTmpPos = new int[2];
private final int mFalsingThreshold;
private boolean mTouchAboveFalsingThreshold;
private boolean mDisableHwLayers;
@@ -102,7 +120,9 @@ public class SwipeHelper implements Gefingerpoken {
mHandler = new Handler();
mSwipeDirection = swipeDirection;
mVelocityTracker = VelocityTracker.obtain();
- mPagingTouchSlop = ViewConfiguration.get(context).getScaledPagingTouchSlop();
+ final ViewConfiguration configuration = ViewConfiguration.get(context);
+ mPagingTouchSlop = configuration.getScaledPagingTouchSlop();
+ mSlopMultiplier = configuration.getScaledAmbiguousGestureMultiplier();
// Extra long-press!
mLongPressTimeout = (long) (ViewConfiguration.getLongPressTimeout() * 1.5f);
@@ -255,10 +275,7 @@ public class SwipeHelper implements Gefingerpoken {
}
public void cancelLongPress() {
- if (mWatchLongPress != null) {
- mHandler.removeCallbacks(mWatchLongPress);
- mWatchLongPress = null;
- }
+ mHandler.removeCallbacks(mPerformLongPress);
}
@Override
@@ -287,27 +304,9 @@ public class SwipeHelper implements Gefingerpoken {
mInitialTouchPos = getPos(ev);
mPerpendicularInitialTouchPos = getPerpendicularPos(ev);
mTranslation = getTranslation(mCurrView);
- 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) {
- mCurrView.sendAccessibilityEvent(
- AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
- ExpandableNotificationRow currRow =
- (ExpandableNotificationRow) mCurrView;
- currRow.doLongClickCallback(x, y);
- }
- }
- }
- };
- }
- mHandler.postDelayed(mWatchLongPress, mLongPressTimeout);
+ mDownLocation[0] = ev.getRawX();
+ mDownLocation[1] = ev.getRawY();
+ mHandler.postDelayed(mPerformLongPress, mLongPressTimeout);
}
break;
@@ -318,7 +317,12 @@ public class SwipeHelper implements Gefingerpoken {
float perpendicularPos = getPerpendicularPos(ev);
float delta = pos - mInitialTouchPos;
float deltaPerpendicular = perpendicularPos - mPerpendicularInitialTouchPos;
- if (Math.abs(delta) > mPagingTouchSlop
+ // Adjust the touch slop if another gesture may be being performed.
+ final float pagingTouchSlop =
+ ev.getClassification() == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE
+ ? mPagingTouchSlop * mSlopMultiplier
+ : mPagingTouchSlop;
+ if (Math.abs(delta) > pagingTouchSlop
&& Math.abs(delta) > Math.abs(deltaPerpendicular)) {
if (mCallback.canChildBeDragged(mCurrView)) {
mCallback.onBeginDrag(mCurrView);
@@ -327,6 +331,11 @@ public class SwipeHelper implements Gefingerpoken {
mTranslation = getTranslation(mCurrView);
}
cancelLongPress();
+ } else if (ev.getClassification() == MotionEvent.CLASSIFICATION_DEEP_PRESS
+ && mHandler.hasCallbacks(mPerformLongPress)) {
+ // Accelerate the long press signal.
+ cancelLongPress();
+ mPerformLongPress.run();
}
}
break;