diff options
| author | Nikita Dubrovsky <dubrovsky@google.com> | 2020-06-23 18:59:38 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-06-23 18:59:38 +0000 |
| commit | 2d4921d1f555764c19de1d816b11ad99fd419795 (patch) | |
| tree | 4d4a752f9d31777bf27c24559bc89db03951e43c /core/java/android | |
| parent | 6fcac665ac5649ce9e5abd1c9628e3d987625624 (diff) | |
| parent | e97b0ecadcd42b3dbe2415cd8529f50d4f314a98 (diff) | |
Merge "Fix double-tap detection in TextView's SelectionModifierCursorController" into rvc-dev
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/widget/Editor.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 51d37a53f21f..07a721f5a9c9 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -6354,6 +6354,8 @@ public class Editor { // The offsets of that last touch down event. Remembered to start selection there. private int mMinTouchOffset, mMaxTouchOffset; + private boolean mGestureStayedInTapRegion; + // Where the user first starts the drag motion. private int mStartOffset = -1; @@ -6460,8 +6462,10 @@ public class Editor { eventX, eventY); // Double tap detection - if (mTouchState.isMultiTapInSameArea() && (isMouse - || mTouchState.isOnHandle() || isPositionOnText(eventX, eventY))) { + if (mGestureStayedInTapRegion + && mTouchState.isMultiTapInSameArea() + && (isMouse || isPositionOnText(eventX, eventY) + || mTouchState.isOnHandle())) { if (TextView.DEBUG_CURSOR) { logCursor("SelectionModifierCursorController: onTouchEvent", "ACTION_DOWN: select and start drag"); @@ -6473,6 +6477,7 @@ public class Editor { } mDiscardNextActionUp = true; } + mGestureStayedInTapRegion = true; mHaventMovedEnoughToStartDrag = true; } break; @@ -6488,6 +6493,14 @@ public class Editor { break; case MotionEvent.ACTION_MOVE: + if (mGestureStayedInTapRegion) { + final ViewConfiguration viewConfig = ViewConfiguration.get( + mTextView.getContext()); + mGestureStayedInTapRegion = EditorTouchState.isDistanceWithin( + mTouchState.getLastDownX(), mTouchState.getLastDownY(), + eventX, eventY, viewConfig.getScaledDoubleTapTouchSlop()); + } + if (mHaventMovedEnoughToStartDrag) { mHaventMovedEnoughToStartDrag = !mTouchState.isMovedEnoughForDrag(); } |
