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
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index e175949..d08f6e9 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4131,6 +4131,11 @@
                         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 @@
                         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);
                 }
             }