aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-06-20 18:58:58 +0900
committerJean Chalard <jchalard@google.com>2013-06-24 12:31:14 +0900
commite8c4b99e5665c6c19793df6c2490ee4bf281bf63 (patch)
tree52d8c1c6bc57979fa5f39261fd9a192760e225cc /java/src/com/android/inputmethod/latin/LatinIME.java
parent564ad4927c784e541e7f00bb17bea416cb06115e (diff)
downloadlatinime-e8c4b99e5665c6c19793df6c2490ee4bf281bf63.tar.gz
latinime-e8c4b99e5665c6c19793df6c2490ee4bf281bf63.tar.xz
latinime-e8c4b99e5665c6c19793df6c2490ee4bf281bf63.zip
Refactor text range to be able to get spans larger than the word
This changes how the Range class stores its data, but not its functionality. It also improves encapsulation a bit. Bug: 8839763 Bug: 8862327 Change-Id: I5bd583b3fc96a99b93a2632882d8fd587c03ab76
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 52a9b9a6c..57eaa3836 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2495,11 +2495,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (null == range) return; // Happens if we don't have an input connection at all
// If for some strange reason (editor bug or so) we measure the text before the cursor as
// longer than what the entire text is supposed to be, the safe thing to do is bail out.
- if (range.mCharsBefore > mLastSelectionStart) return;
+ final int numberOfCharsInWordBeforeCursor = range.getNumberOfCharsInWordBeforeCursor();
+ if (numberOfCharsInWordBeforeCursor > mLastSelectionStart) return;
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
- final String typedWord = range.mWord.toString();
- if (range.mWord instanceof SpannableString) {
- final SpannableString spannableString = (SpannableString)range.mWord;
+ final CharSequence word = range.mWord;
+ final String typedWord = word.toString();
+ if (word instanceof SpannableString) {
+ final SpannableString spannableString = (SpannableString)word;
int i = 0;
for (Object object : spannableString.getSpans(0, spannableString.length(),
SuggestionSpan.class)) {
@@ -2515,9 +2517,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
mWordComposer.setComposingWord(typedWord, mKeyboardSwitcher.getKeyboard());
- mWordComposer.setCursorPositionWithinWord(range.mCharsBefore);
- mConnection.setComposingRegion(mLastSelectionStart - range.mCharsBefore,
- mLastSelectionEnd + range.mCharsAfter);
+ mWordComposer.setCursorPositionWithinWord(numberOfCharsInWordBeforeCursor);
+ mConnection.setComposingRegion(
+ mLastSelectionStart - numberOfCharsInWordBeforeCursor,
+ mLastSelectionEnd + range.getNumberOfCharsInWordAfterCursor());
final SuggestedWords suggestedWords;
if (suggestions.isEmpty()) {
// We come here if there weren't any suggestion spans on this word. We will try to