From 43fd2f426a0c9f562a7b3809718563086a0f79ff Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Mon, 8 Jun 2015 14:03:34 -0700 Subject: [PATCH] Text selection: update touch delta when moving towards handles When the text selection drag handles jump to the end / start of a word, the delta between the current touch position and where the handle jumps to is tracked. Previously this value was not updated if the handle jumped and then the finger moved towards the handle. This CL adjusts the logic to update the delta in this situation. Bug: 21131483 Change-Id: I331f53191103e1a3fc08e34b5df5cd6cbc177af6 --- core/java/android/widget/Editor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index e17594996d1e3..d08f6e9825572 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -4131,6 +4131,11 @@ public class Editor { offset = adjustedOffset; } positionCursor = true; + } else if (adjustedOffset < mPreviousOffset) { + // Handle has jumped to the start of the word, and the user is moving + // their finger towards the handle, the delta should be updated. + mTouchWordDelta = mTextView.convertToLocalHorizontalCoordinate(x) + - layout.getPrimaryHorizontal(mPreviousOffset); } } @@ -4258,6 +4263,11 @@ public class Editor { offset = adjustedOffset; } positionCursor = true; + } else if (adjustedOffset > mPreviousOffset) { + // Handle has jumped to the end of the word, and the user is moving + // their finger towards the handle, the delta should be updated. + mTouchWordDelta = layout.getPrimaryHorizontal(mPreviousOffset) + - mTextView.convertToLocalHorizontalCoordinate(x); } }