diff options
author | 2011-10-10 02:59:39 -0700 | |
---|---|---|
committer | 2011-10-10 02:59:39 -0700 | |
commit | 2ac4000d1f957a717242e5526c3a1eccc8e2e8d3 (patch) | |
tree | 2b24d45555fdf29761e99fd8ef70e5f3b7263cb7 /java/src/com/android/inputmethod/latin | |
parent | 01f7ed359531d2a9461168052bf2b09fa24f253c (diff) | |
parent | 602bcecf6bbe64080c602cd71e33f814551370f4 (diff) | |
download | latinime-2ac4000d1f957a717242e5526c3a1eccc8e2e8d3.tar.gz latinime-2ac4000d1f957a717242e5526c3a1eccc8e2e8d3.tar.xz latinime-2ac4000d1f957a717242e5526c3a1eccc8e2e8d3.zip |
am 602bcecf: Merge "Put SuggestionSpan as the indicater of the auto-correction"
* commit '602bcecf6bbe64080c602cd71e33f814551370f4':
Put SuggestionSpan as the indicater of the auto-correction
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 11 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SuggestionsView.java | 10 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 4 |
3 files changed, 18 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index dfdb97b50..958092bc7 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1608,6 +1608,17 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mKeyboardSwitcher.onAutoCorrectionStateChanged( words.hasWordAboveAutoCorrectionScoreThreshold()); } + + // Put a blue underline to a word in TextView which will be auto-corrected. + final InputConnection ic = getCurrentInputConnection(); + if (ic != null && Utils.willAutoCorrect(words)) { + final CharSequence textWithUnderline = + SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline( + this, mComposingStringBuilder); + if (!TextUtils.isEmpty(textWithUnderline)) { + ic.setComposingText(textWithUnderline, 1); + } + } } public void updateSuggestions() { diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java index fe54f4ae1..3271b8253 100644 --- a/java/src/com/android/inputmethod/latin/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java @@ -260,7 +260,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, private CharSequence getStyledSuggestionWord(SuggestedWords suggestions, int pos) { final CharSequence word = suggestions.getWord(pos); - final boolean isAutoCorrect = pos == 1 && willAutoCorrect(suggestions); + final boolean isAutoCorrect = pos == 1 && Utils.willAutoCorrect(suggestions); final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid; if (!isAutoCorrect && !isTypedWordValid) return word; @@ -278,14 +278,10 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, return spannedWord; } - private static boolean willAutoCorrect(SuggestedWords suggestions) { - return !suggestions.mTypedWordValid && suggestions.mHasMinimalSuggestion; - } - private int getWordPosition(int index, SuggestedWords suggestions) { // TODO: This works for 3 suggestions. Revisit this algorithm when there are 5 or more // suggestions. - final int centerPos = willAutoCorrect(suggestions) ? 1 : 0; + final int centerPos = Utils.willAutoCorrect(suggestions) ? 1 : 0; if (index == mCenterSuggestionIndex) { return centerPos; } else if (index == centerPos) { @@ -300,7 +296,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, final boolean isSuggested = (pos != 0); final int color; - if (index == mCenterSuggestionIndex && willAutoCorrect(suggestions)) { + if (index == mCenterSuggestionIndex && Utils.willAutoCorrect(suggestions)) { color = mColorAutoCorrect; } else if (isSuggested) { color = mColorSuggested; diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 771276567..de2930460 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -790,4 +790,8 @@ public class Utils { } return -1; } + + public static boolean willAutoCorrect(SuggestedWords suggestions) { + return !suggestions.mTypedWordValid && suggestions.mHasMinimalSuggestion; + } } |