summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2015-05-07 17:34:21 +0900
committerMady Mellor <madym@google.com>2015-05-07 19:30:30 -0700
commit50a927cdd14db7a99a7444ffb7c85f1882c9f43a (patch)
treee71a5ab249ee600d878d26625498a1142173c979 /core
parentc1125dedfcb52644aabc175d749c89b3008e4337 (diff)
downloadframeworks_base-50a927cdd14db7a99a7444ffb7c85f1882c9f43a.zip
frameworks_base-50a927cdd14db7a99a7444ffb7c85f1882c9f43a.tar.gz
frameworks_base-50a927cdd14db7a99a7444ffb7c85f1882c9f43a.tar.bz2
Fix: Hard to modify multi-line selection.
mTouchWordOffset was not appropriately updated when a selection is modified across multiple lines. Bug: 20650838 Change-Id: I46f5393970dc8d806719467bac489feac0fbe1a5
Diffstat (limited to 'core')
-rw-r--r--core/java/android/widget/Editor.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 86a100f..78c418b 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -3974,16 +3974,16 @@ public class Editor {
}
}
mTouchWordOffset = Math.max(trueOffset - offset, 0);
- mInWord = !getWordIteratorWithText().isBoundary(offset);
positionCursor = true;
- } else if (offset - mTouchWordOffset > mPreviousOffset) {
+ } else if (offset - mTouchWordOffset > mPreviousOffset || currLine > mPrevLine) {
// User is shrinking the selection.
if (currLine > mPrevLine) {
// We're on a different line, so we'll snap to word boundaries.
- offset = end;
+ offset = start;
+ mTouchWordOffset = Math.max(trueOffset - offset, 0);
+ } else {
+ offset -= mTouchWordOffset;
}
- offset -= mTouchWordOffset;
- mInWord = !getWordIteratorWithText().isBoundary(offset);
positionCursor = true;
}
@@ -3999,7 +3999,9 @@ public class Editor {
} else {
offset = alteredOffset;
}
+ mTouchWordOffset = 0;
}
+ mInWord = !getWordIteratorWithText().isBoundary(offset);
positionAtCursorOffset(offset, false);
}
}
@@ -4072,17 +4074,17 @@ public class Editor {
}
}
mTouchWordOffset = Math.max(offset - trueOffset, 0);
- mInWord = !getWordIteratorWithText().isBoundary(offset);
positionCursor = true;
- } else if (offset + mTouchWordOffset < mPreviousOffset) {
+ } else if (offset + mTouchWordOffset < mPreviousOffset || currLine < mPrevLine) {
// User is shrinking the selection.
if (currLine < mPrevLine) {
// We're on a different line, so we'll snap to word boundaries.
- offset = start;
+ offset = end;
+ mTouchWordOffset = Math.max(offset - trueOffset, 0);
+ } else {
+ offset += mTouchWordOffset;
}
- offset += mTouchWordOffset;
positionCursor = true;
- mInWord = !getWordIteratorWithText().isBoundary(offset);
}
if (positionCursor) {
@@ -4097,7 +4099,9 @@ public class Editor {
} else {
offset = Math.min(alteredOffset, length);
}
+ mTouchWordOffset = 0;
}
+ mInWord = !getWordIteratorWithText().isBoundary(offset);
positionAtCursorOffset(offset, false);
}
}