diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 0f9b983a3..f92949681 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1847,7 +1847,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar autoCorrection = null; } mWordComposer.setAutoCorrection(autoCorrection); - final boolean isAutoCorrection = Utils.willAutoCorrect(suggestedWords); + final boolean isAutoCorrection = suggestedWords.willAutoCorrect(); setSuggestions(suggestedWords, isAutoCorrection); setAutoCorrectionIndicator(isAutoCorrection); setSuggestionStripShown(isSuggestionsStripVisible()); diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 78922978a..ff8945f71 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -77,6 +77,11 @@ public class SuggestedWords { return mShouldBlockAutoCorrectionBySafetyNet; } + public boolean willAutoCorrect() { + return !mTypedWordValid && mHasAutoCorrectionCandidate + && !shouldBlockAutoCorrectionBySafetyNet(); + } + public static class Builder { private List mWords = new ArrayList(); private boolean mTypedWordValid; diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index f46352d0e..f6bc85431 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -778,11 +778,6 @@ public class Utils { return s.toUpperCase(locale).charAt(0) + s.substring(1); } - public static boolean willAutoCorrect(SuggestedWords suggestions) { - return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate - && !suggestions.shouldBlockAutoCorrectionBySafetyNet(); - } - public static class Stats { public static void onNonSeparator(final char code, final int x, final int y) { diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index 9ab8c01e6..e5638ef21 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -62,7 +62,6 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.StaticInnerHandlerWrapper; import com.android.inputmethod.latin.SuggestedWords; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; -import com.android.inputmethod.latin.Utils; import java.util.ArrayList; import java.util.List; @@ -261,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 && Utils.willAutoCorrect(suggestions); + final boolean isAutoCorrect = pos == 1 && suggestions.willAutoCorrect(); final boolean isTypedWordValid = pos == 0 && suggestions.mTypedWordValid; if (!isAutoCorrect && !isTypedWordValid) return word; @@ -282,7 +281,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, 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 = Utils.willAutoCorrect(suggestions) ? 1 : 0; + final int centerPos = suggestions.willAutoCorrect() ? 1 : 0; if (index == mCenterSuggestionIndex) { return centerPos; } else if (index == centerPos) { @@ -297,7 +296,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener, final boolean isSuggested = (pos != 0); final int color; - if (index == mCenterSuggestionIndex && Utils.willAutoCorrect(suggestions)) { + if (index == mCenterSuggestionIndex && suggestions.willAutoCorrect()) { color = mColorAutoCorrect; } else if (index == mCenterSuggestionIndex && suggestions.mTypedWordValid) { color = mColorValidTypedWord;