diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 5b4365902..5e1795a26 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1830,19 +1830,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // length == 1). if (builder.size() > 1 || typedWord.length() == 1 || !builder.allowsToBeAutoCorrected() || mSuggestionsView.isShowingAddToDictionaryHint()) { - boolean autoCorrectionAvailable = builder.hasAutoCorrection(); - if (mCorrectionMode == Suggest.CORRECTION_FULL - || mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) { - autoCorrectionAvailable |= !builder.allowsToBeAutoCorrected(); - } - // Don't auto-correct words with multiple capital letter - autoCorrectionAvailable &= !mWordComposer.isMostlyCaps(); - builder.setTypedWordValid(!builder.allowsToBeAutoCorrected()).setHasMinimalSuggestion( - autoCorrectionAvailable); - if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest, - mSettingsValues.mAutoCorrectionThreshold)) { - builder.setShouldBlockAutoCorrectionBySafetyNet(); - } showSuggestions(builder.build(), typedWord); } else { SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions(); diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index f3ba1e5a7..6230b4224 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -411,6 +411,7 @@ public class Suggest implements Dictionary.WordCallback { mSuggestions.add(0, typedWord); StringUtils.removeDupes(mSuggestions); + final SuggestedWords.Builder builder; if (DBG) { final CharSequence autoCorrectionSuggestion = mSuggestions.get(0); final int autoCorrectionSuggestionScore = mScores[0]; @@ -435,13 +436,28 @@ public class Suggest implements Dictionary.WordCallback { for (int i = mScores.length; i < mSuggestions.size(); ++i) { scoreInfoList.add(new SuggestedWords.SuggestedWordInfo("--", false)); } - return new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList) + builder = new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList) + .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected) + .setHasAutoCorrection(hasAutoCorrection); + } else { + builder = new SuggestedWords.Builder().addWords(mSuggestions, null) .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected) .setHasAutoCorrection(hasAutoCorrection); } - return new SuggestedWords.Builder().addWords(mSuggestions, null) - .setAllowsToBeAutoCorrected(allowsToBeAutoCorrected) - .setHasAutoCorrection(hasAutoCorrection); + + boolean autoCorrectionAvailable = hasAutoCorrection; + if (correctionMode == Suggest.CORRECTION_FULL + || correctionMode == Suggest.CORRECTION_FULL_BIGRAM) { + autoCorrectionAvailable |= !allowsToBeAutoCorrected; + } + // Don't auto-correct words with multiple capital letter + autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); + builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion( + autoCorrectionAvailable); + if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, this, mAutoCorrectionThreshold)) { + builder.setShouldBlockAutoCorrectionBySafetyNet(); + } + return builder; } @Override