From d113fd0be47f89b796990f1e71a756f5ceedcfad Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 2 Jul 2012 17:12:56 +0900 Subject: [PATCH] Fix a bug with the user dictionary locale. We internally use the string "zz" to mean no locale, but the user dictionary service does not understand that and words added with this locale pitifully end being added to a "zz" user dictionary, which makes no sense to the user. This change fixes things so that words added when the keyboard is in a "no locale" layout, the words are added to the global, all-locales user dictionary. Bug: 6645306 Change-Id: Iec3cdd1fe3d5bc43427a43ef9ae9bf89e12be1f2 --- .../inputmethod/latin/UserBinaryDictionary.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java index 8cef6fa20..60e6fa127 100644 --- a/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserBinaryDictionary.java @@ -34,7 +34,10 @@ import java.util.Arrays; */ public class UserBinaryDictionary extends ExpandableBinaryDictionary { - // TODO: use Words.SHORTCUT when it's public in the SDK + // The user dictionary provider uses an empty string to mean "all languages". + private static final String USER_DICTIONARY_ALL_LANGUAGES = ""; + + // TODO: use Words.SHORTCUT when we target JellyBean or above final static String SHORTCUT = "shortcut"; private static final String[] PROJECTION_QUERY; static { @@ -71,7 +74,12 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary { final boolean alsoUseMoreRestrictiveLocales) { super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_USER); if (null == locale) throw new NullPointerException(); // Catch the error earlier - mLocale = locale; + if (SubtypeLocale.NO_LANGUAGE.equals(locale)) { + // If we don't have a locale, insert into the "all locales" user dictionary. + mLocale = USER_DICTIONARY_ALL_LANGUAGES; + } else { + mLocale = locale; + } mAlsoUseMoreRestrictiveLocales = alsoUseMoreRestrictiveLocales; // Perform a managed query. The Activity will handle closing and re-querying the cursor // when needed.