summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-04-16 16:54:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-16 16:54:41 +0000
commit241e119679ebe32f29ad37003a311c7fb56bcf14 (patch)
tree277df646abaa1d31110061bbfef22941769938fc /core/java
parentf8f80c8034b3f2dab3f8edbf78196efc51aa8a1a (diff)
parente5561984951366b67b7405a85486c62320cbcaab (diff)
downloadframeworks_base-241e119679ebe32f29ad37003a311c7fb56bcf14.zip
frameworks_base-241e119679ebe32f29ad37003a311c7fb56bcf14.tar.gz
frameworks_base-241e119679ebe32f29ad37003a311c7fb56bcf14.tar.bz2
Merge "Recognize stylus touch + press button as a longpress in AbsListView"
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;