summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMady Mellor <madym@google.com>2015-07-09 16:05:36 -0700
committerMady Mellor <madym@google.com>2015-07-09 16:05:36 -0700
commit80679071abb516bcc6470dfcc68ac4d5bc16ff96 (patch)
tree5db608f10b689d3c048986509e3663c3234aaead /core/java
parent607a040dae1b8fde0f9ea9f1723e0721f891f3dd (diff)
downloadframeworks_base-80679071abb516bcc6470dfcc68ac4d5bc16ff96.zip
frameworks_base-80679071abb516bcc6470dfcc68ac4d5bc16ff96.tar.gz
frameworks_base-80679071abb516bcc6470dfcc68ac4d5bc16ff96.tar.bz2
Fix: line slop shouldn't always increase / decrease by one line
Touch slop is from the bottom (or top) of the line + line height / 2. It only makes sense to apply touch slop if the user is within a line from the previous line. Additionally, not doing this can cause some undesirable behavior if the user moves very quickly and the selection catches up with a weird line by line selection increase, potentially even having the selection be stalled until a next move event. This CL alters the logic so that if the user isn't within one line of the previous selection, it'll just use whatever line the user is currently on. Bug: 22385003 Change-Id: I4f37988893868e5e2b7925314fe824c3da9c1b97
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/widget/Editor.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 96e033a..5153f67 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4416,10 +4416,16 @@ public class Editor {
}
private int getCurrentLineAdjustedForSlop(Layout layout, int prevLine, float y) {
+ final int trueLine = mTextView.getLineAtCoordinate(y);
if (layout == null || prevLine > layout.getLineCount()
|| layout.getLineCount() <= 0 || prevLine < 0) {
// Invalid parameters, just return whatever line is at y.
- return mTextView.getLineAtCoordinate(y);
+ return trueLine;
+ }
+
+ if (Math.abs(trueLine - prevLine) >= 2) {
+ // Only stick to lines if we're within a line of the previous selection.
+ return trueLine;
}
final float verticalOffset = mTextView.viewportToContentVerticalOffset();