summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-04-14 15:06:40 -0700
committerMady Mellor <madym@google.com>2015-04-14 15:06:40 -0700
commite5561984951366b67b7405a85486c62320cbcaab (patch)
tree6ffe78b758f11b465961c201a31b9eea66b953f8 /core/java
parent7f9be1cbfaafe9f92f3c073a7b48bbfaa12230ba (diff)
downloadframeworks_base-e5561984951366b67b7405a85486c62320cbcaab.zip
frameworks_base-e5561984951366b67b7405a85486c62320cbcaab.tar.gz
frameworks_base-e5561984951366b67b7405a85486c62320cbcaab.tar.bz2
Recognize stylus touch + press button as a longpress in AbsListView
The gesture is: stylus touching screen + button pressed, the event is recognized when the button is pressed, not when it's released. It can be pressed during DOWN or MOVE. Bug: 19620479 Change-Id: I4ce2cea4eb058e308ba88ef3dd3bed278bdca555
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/AbsListView.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index e7b6238..c9d9a8c 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -3116,6 +3116,25 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
}
+ private boolean performStylusButtonPressAction(MotionEvent ev) {
+ if (ev.getToolType(0) == MotionEvent.TOOL_TYPE_STYLUS
+ && ev.isButtonPressed(MotionEvent.BUTTON_SECONDARY)
+ && mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode == null) {
+ final View child = getChildAt(mMotionPosition - mFirstPosition);
+ if (child != null) {
+ final int longPressPosition = mMotionPosition;
+ final long longPressId = mAdapter.getItemId(mMotionPosition);
+ if (performLongPress(child, longPressPosition, longPressId)) {
+ mTouchMode = TOUCH_MODE_REST;
+ setPressed(false);
+ child.setPressed(false);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
boolean performLongPress(final View child,
final int longPressPosition, final long longPressId) {
// CHOICE_MODE_MULTIPLE_MODAL takes over long press.
@@ -3757,8 +3776,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
if (mTouchMode == TOUCH_MODE_DOWN && mMotionPosition != INVALID_POSITION
- && performButtonActionOnTouchDown(ev)) {
- removeCallbacks(mPendingCheckForTap);
+ && (performButtonActionOnTouchDown(ev) || performStylusButtonPressAction(ev))) {
+ removeCallbacks(mPendingCheckForTap);
}
}
@@ -3800,6 +3819,11 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mTouchMode = TOUCH_MODE_DONE_WAITING;
updateSelectorState();
} else if (motionView != null) {
+ if (performStylusButtonPressAction(ev)) {
+ removeCallbacks(mPendingCheckForTap);
+ removeCallbacks(mPendingCheckForLongPress);
+ }
+
// Still within bounds, update the hotspot.
final float[] point = mTmpPoint;
point[0] = x;