From 0c05902e331b03426754a1cfffe28d185dd8338c Mon Sep 17 00:00:00 2001 From: Amith Yamasani <yamasani@google.com> Date: Wed, 24 Mar 2010 16:44:31 -0700 Subject: [PATCH] Don't auto-add when in suggest-only mode. Bug: 2521344 Also don't highlight quickfixes when in suggest-only mode In general, reduce the situations where words are auto-added. It was too eagerly adding even words that were in the dictionary. --- .../src/com/android/inputmethod/latin/LatinIME.java | 13 ++++++++++--- java/src/com/android/inputmethod/latin/Suggest.java | 9 ++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 86992db2de..b7de26b416 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1438,7 +1438,7 @@ public class LatinIME extends InputMethodService ((LatinKeyboard) mInputView.getKeyboard()).setPreferredLetters(nextLettersFrequencies); - boolean correctionAvailable = mSuggest.hasMinimalCorrection(); + boolean correctionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasMinimalCorrection(); //|| mCorrectionMode == mSuggest.CORRECTION_FULL; CharSequence typedWord = mWord.getTypedWord(); // If we're in basic correct @@ -1519,7 +1519,9 @@ public class LatinIME extends InputMethodService mJustAccepted = true; pickSuggestion(suggestion); // Add the word to the auto dictionary if it's not a known word - checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED); + if (index == 0) { + checkAddToDictionary(suggestion, AutoDictionary.FREQUENCY_FOR_PICKED); + } TextEntryState.acceptedSuggestion(mComposing.toString(), suggestion); // Follow it with a space if (mAutoSpace) { @@ -1565,8 +1567,13 @@ public class LatinIME extends InputMethodService } private void checkAddToDictionary(CharSequence suggestion, int frequencyDelta) { + // Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be + // adding words in situations where the user or application really didn't + // want corrections enabled or learned. + if (!(mCorrectionMode == Suggest.CORRECTION_FULL)) return; if (mAutoDictionary.isValidWord(suggestion) - || !mSuggest.isValidWord(suggestion.toString().toLowerCase())) { + || (!mSuggest.isValidWord(suggestion.toString()) + && !mSuggest.isValidWord(suggestion.toString().toLowerCase()))) { mAutoDictionary.addWord(suggestion.toString(), frequencyDelta); } } diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index b44717d0aa..14899e84ea 100755 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -346,11 +346,10 @@ public class Suggest implements Dictionary.WordCallback { if (word == null || word.length() == 0) { return false; } - return (mCorrectionMode == CORRECTION_FULL && mMainDict.isValidWord(word)) - || (mCorrectionMode > CORRECTION_NONE && - ((mUserDictionary != null && mUserDictionary.isValidWord(word))) - || (mAutoDictionary != null && mAutoDictionary.isValidWord(word)) - || (mContactsDictionary != null && mContactsDictionary.isValidWord(word))); + return mMainDict.isValidWord(word) + || (mUserDictionary != null && mUserDictionary.isValidWord(word)) + || (mAutoDictionary != null && mAutoDictionary.isValidWord(word)) + || (mContactsDictionary != null && mContactsDictionary.isValidWord(word)); } private void collectGarbage() { -- GitLab