diff options
author | 2013-04-10 16:38:37 +0900 | |
---|---|---|
committer | 2013-04-12 20:49:03 +0900 | |
commit | 6a114fa700d3ca73c608e1291b74bbbdd5a1a7b7 (patch) | |
tree | 5e6ab1f85370bf2a426145e40fcc2cce243772c3 /java/src/com/android/inputmethod/latin/RichInputConnection.java | |
parent | d24f93971292451c7a16456fecb8eff5deaa2c37 (diff) | |
download | latinime-6a114fa700d3ca73c608e1291b74bbbdd5a1a7b7.tar.gz latinime-6a114fa700d3ca73c608e1291b74bbbdd5a1a7b7.tar.xz latinime-6a114fa700d3ca73c608e1291b74bbbdd5a1a7b7.zip |
Restart suggestions when the cursor moves.
This uses the old suggestions. It does not try to recompute
new suggestions if there are no old suggestions yet: this is
coming in a later change.
If there are no suggestions, this shows the word itself
as a suggestion.
Bug: 8084810
Change-Id: I4c2e25df0ff3673be1825f57a0c19a9d23d47a48
Diffstat (limited to 'java/src/com/android/inputmethod/latin/RichInputConnection.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index 16744d1f0..4699d4c0c 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -17,7 +17,9 @@ package com.android.inputmethod.latin; import android.inputmethodservice.InputMethodService; +import android.text.SpannableString; import android.text.TextUtils; +import android.text.style.SuggestionSpan; import android.util.Log; import android.view.KeyEvent; import android.view.inputmethod.CompletionInfo; @@ -442,9 +444,9 @@ public final class RichInputConnection { public final int mCharsAfter; /** The actual characters that make up a word */ - public final String mWord; + public final CharSequence mWord; - public Range(int charsBefore, int charsAfter, String word) { + public Range(int charsBefore, int charsAfter, CharSequence word) { if (charsBefore < 0 || charsAfter < 0) { throw new IndexOutOfBoundsException(); } @@ -498,7 +500,7 @@ public final class RichInputConnection { * separator. For example, if the field contains "he|llo world", where | * represents the cursor, then "hello " will be returned. */ - public String getWordAtCursor(String separators) { + public CharSequence getWordAtCursor(String separators) { // getWordRangeAtCursor returns null if the connection is null Range r = getWordRangeAtCursor(separators, 0); return (r == null) ? null : r.mWord; @@ -517,8 +519,10 @@ public final class RichInputConnection { if (mIC == null || sep == null) { return null; } - final CharSequence before = mIC.getTextBeforeCursor(1000, 0); - final CharSequence after = mIC.getTextAfterCursor(1000, 0); + final CharSequence before = mIC.getTextBeforeCursor(1000, + InputConnection.GET_TEXT_WITH_STYLES); + final CharSequence after = mIC.getTextAfterCursor(1000, + InputConnection.GET_TEXT_WITH_STYLES); if (before == null || after == null) { return null; } @@ -560,8 +564,9 @@ public final class RichInputConnection { } } - final String word = before.toString().substring(startIndexInBefore, before.length()) - + after.toString().substring(0, endIndexInAfter); + final SpannableString word = new SpannableString(TextUtils.concat( + before.subSequence(startIndexInBefore, before.length()), + after.subSequence(0, endIndexInAfter))); return new Range(before.length() - startIndexInBefore, endIndexInAfter, word); } |