aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/WhitelistDictionary.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-10-07 16:34:19 +0900
committerJean Chalard <jchalard@google.com>2011-10-07 18:40:23 +0900
commit5f41b705fc95b21c8edd6226bb50c0fa78a39261 (patch)
tree13b6c8f9de9aa43e998ace4dd4944c0bec2a063e /java/src/com/android/inputmethod/latin/WhitelistDictionary.java
parentce9e4f926b69745834df677501e59c6db3744de4 (diff)
downloadlatinime-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/WhitelistDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/WhitelistDictionary.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/WhitelistDictionary.java b/java/src/com/android/inputmethod/latin/WhitelistDictionary.java
index 93474b654..96241a340 100644
--- a/java/src/com/android/inputmethod/latin/WhitelistDictionary.java
+++ b/java/src/com/android/inputmethod/latin/WhitelistDictionary.java
@@ -93,4 +93,20 @@ public class WhitelistDictionary extends Dictionary {
if (TextUtils.isEmpty(word)) return false;
return !TextUtils.isEmpty(getWhiteListedWord(word.toString()));
}
+
+ // See LatinIME#updateSuggestions. This breaks in the (queer) case that the whitelist
+ // lists that word a should autocorrect to word b, and word c would autocorrect to
+ // an upper-cased version of a. In this case, the way this return value is used would
+ // remove the first candidate when the user typed the upper-cased version of A.
+ // Example : abc -> def and xyz -> Abc
+ // A user typing Abc would experience it being autocorrected to something else (not
+ // necessarily def).
+ // There is no such combination in the whitelist at the time and there probably won't
+ // ever be - it doesn't make sense. But still.
+ public boolean shouldForciblyAutoCorrectFrom(CharSequence word) {
+ if (TextUtils.isEmpty(word)) return false;
+ final String correction = getWhiteListedWord(word.toString());
+ if (TextUtils.isEmpty(correction)) return false;
+ return !correction.equals(word);
+ }
}