Merge "Fix a bug with the user dictionary locale."

main
Jean Chalard 2012-07-02 02:57:50 -07:00 committed by Android (Google) Code Review
commit d6496c0913
1 changed files with 10 additions and 2 deletions

View File

@ -34,7 +34,10 @@ import java.util.Arrays;
*/ */
public class UserBinaryDictionary extends ExpandableBinaryDictionary { 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"; final static String SHORTCUT = "shortcut";
private static final String[] PROJECTION_QUERY; private static final String[] PROJECTION_QUERY;
static { static {
@ -71,7 +74,12 @@ public class UserBinaryDictionary extends ExpandableBinaryDictionary {
final boolean alsoUseMoreRestrictiveLocales) { final boolean alsoUseMoreRestrictiveLocales) {
super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_USER); super(context, getFilenameWithLocale(NAME, locale), Dictionary.TYPE_USER);
if (null == locale) throw new NullPointerException(); // Catch the error earlier 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; mAlsoUseMoreRestrictiveLocales = alsoUseMoreRestrictiveLocales;
// Perform a managed query. The Activity will handle closing and re-querying the cursor // Perform a managed query. The Activity will handle closing and re-querying the cursor
// when needed. // when needed.