diff options
author | 2011-10-07 16:34:19 +0900 | |
---|---|---|
committer | 2011-10-07 18:40:23 +0900 | |
commit | 5f41b705fc95b21c8edd6226bb50c0fa78a39261 (patch) | |
tree | 13b6c8f9de9aa43e998ace4dd4944c0bec2a063e /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | ce9e4f926b69745834df677501e59c6db3744de4 (diff) | |
download | latinime-5f41b705fc95b21c8edd6226bb50c0fa78a39261.tar.gz latinime-5f41b705fc95b21c8edd6226bb50c0fa78a39261.tar.xz latinime-5f41b705fc95b21c8edd6226bb50c0fa78a39261.zip |
Fix a bug with the whitelist
This bug would kill the case where the whitelist contains
a word to be autocorrected to an uppercased version of
itself, and the user would enter the uppercase version.
In this case, this bug would cause the typed word to be
killed off the list of candidates, and possibly autocorrected
to the *next* candidate.
When the whitelist checks whether this the typed word is
a candidate for whitelisting, this change has it check whether
the whitelisting results in the typed word before returning.
Hence, it can keep the case-insensitive behavior of the
whitelist.
Coincidentally, this change renames the method used to do
this, because it does not comply with the general contract
of Dictionary. This happens to be in the way of another
upcoming change.
Bug: 5420371
Change-Id: Ifb305271acc5f171adf9b18c762ae7975b14be0a
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 36e97af11..d15aea3ff 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1634,11 +1634,16 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection(); final CharSequence typedWord = wordComposer.getTypedWord(); // Here, we want to promote a whitelisted word if exists. - final boolean typedWordValid = AutoCorrection.isValidWordForAutoCorrection( + // TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid" + // but still autocorrected from - in the case the whitelist only capitalizes the word. + // The whitelist should be case-insensitive, so it's not possible to be consistent with + // a boolean flag. Right now this is handled with a slight hack in + // WhitelistDictionary#shouldForciblyAutoCorrectFrom. + final boolean allowsToBeAutoCorrected = AutoCorrection.allowsToBeAutoCorrected( mSuggest.getUnigramDictionaries(), typedWord, preferCapitalization()); if (mCorrectionMode == Suggest.CORRECTION_FULL || mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) { - autoCorrectionAvailable |= typedWordValid; + autoCorrectionAvailable |= (!allowsToBeAutoCorrected); } // Don't auto-correct words with multiple capital letter autoCorrectionAvailable &= !wordComposer.isMostlyCaps(); @@ -1651,9 +1656,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // need to clear the previous state when the user starts typing a word (i.e. typed word's // length == 1). if (typedWord != null) { - if (builder.size() > 1 || typedWord.length() == 1 || typedWordValid + if (builder.size() > 1 || typedWord.length() == 1 || (!allowsToBeAutoCorrected) || mSuggestionsView.isShowingAddToDictionaryHint()) { - builder.setTypedWordValid(typedWordValid).setHasMinimalSuggestion( + builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion( autoCorrectionAvailable); } else { SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions(); |