diff options
author | Dan Sandler <dsandler@android.com> | 2014-07-25 19:30:44 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-07-25 19:30:44 +0000 |
commit | 7ae09aebe2b1c2230cc67f8991118a782ff1e202 (patch) | |
tree | 9ec1809ffb56a42e7a204a088f14b8c765478ec8 /packages/SystemUI/src/com/android/systemui/SwipeHelper.java | |
parent | 58385d11cddbdb2f8bb0f81f953549b84fe1caf4 (diff) | |
parent | 99137c5e8d92ba02ee1a06ae867a08ff328920af (diff) | |
download | frameworks_base-7ae09aebe2b1c2230cc67f8991118a782ff1e202.zip frameworks_base-7ae09aebe2b1c2230cc67f8991118a782ff1e202.tar.gz frameworks_base-7ae09aebe2b1c2230cc67f8991118a782ff1e202.tar.bz2 |
am c9d55d0c: Merge "Notification inspector." into lmp-dev
* commit 'c9d55d0cc1aca2840626754c89a30e27c30b1764':
Notification inspector.
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/SwipeHelper.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/SwipeHelper.java | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 6e1ba3c..6c30c89 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -76,10 +76,12 @@ public class SwipeHelper implements Gefingerpoken { private float mDensityScale; private boolean mLongPressSent; - private View.OnLongClickListener mLongPressListener; + private LongPressListener mLongPressListener; private Runnable mWatchLongPress; private long mLongPressTimeout; + final private int[] mTmpPos = new int[2]; + public SwipeHelper(int swipeDirection, Callback callback, Context context) { mCallback = callback; mHandler = new Handler(); @@ -93,7 +95,7 @@ public class SwipeHelper implements Gefingerpoken { android.R.interpolator.fast_out_linear_in); } - public void setLongPressListener(View.OnLongClickListener listener) { + public void setLongPressListener(LongPressListener listener) { mLongPressListener = listener; } @@ -215,7 +217,7 @@ public class SwipeHelper implements Gefingerpoken { } } - public boolean onInterceptTouchEvent(MotionEvent ev) { + public boolean onInterceptTouchEvent(final MotionEvent ev) { final int action = ev.getAction(); switch (action) { @@ -237,8 +239,12 @@ public class SwipeHelper implements Gefingerpoken { public void run() { if (mCurrView != null && !mLongPressSent) { mLongPressSent = true; - mCurrView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); - mLongPressListener.onLongClick(mCurrView); + 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]; + mLongPressListener.onLongPress(mCurrView, x, y); } } }; @@ -267,14 +273,16 @@ public class SwipeHelper implements Gefingerpoken { case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: + final boolean captured = (mDragging || mLongPressSent); mDragging = false; mCurrView = null; mCurrAnimView = null; mLongPressSent = false; removeLongPressCallback(); + if (captured) return true; break; } - return mDragging; + return mDragging || mLongPressSent; } /** @@ -460,4 +468,15 @@ public class SwipeHelper implements Gefingerpoken { */ boolean updateSwipeProgress(View animView, boolean dismissable, float swipeProgress); } + + /** + * 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); + } } |