diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 4d569b808..f9e6a5e68 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -37,6 +37,7 @@ import com.android.inputmethod.latin.LocaleUtils; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SynchronouslyLoadedUserDictionary; import com.android.inputmethod.latin.Utils; +import com.android.inputmethod.latin.WhitelistDictionary; import com.android.inputmethod.latin.WordComposer; import java.util.ArrayList; @@ -79,6 +80,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService { Collections.synchronizedMap(new TreeMap<String, DictionaryPool>()); private Map<String, Dictionary> mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>()); + private Map<String, Dictionary> mWhitelistDictionaries = + Collections.synchronizedMap(new TreeMap<String, Dictionary>()); // The threshold for a candidate to be offered as a suggestion. private double mSuggestionThreshold; @@ -253,12 +256,17 @@ public class AndroidSpellCheckerService extends SpellCheckerService { mDictionaryPools = Collections.synchronizedMap(new TreeMap<String, DictionaryPool>()); final Map<String, Dictionary> oldUserDictionaries = mUserDictionaries; mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>()); + final Map<String, Dictionary> oldWhitelistDictionaries = mWhitelistDictionaries; + mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>()); for (DictionaryPool pool : oldPools.values()) { pool.close(); } for (Dictionary dict : oldUserDictionaries.values()) { dict.close(); } + for (Dictionary dict : oldWhitelistDictionaries.values()) { + dict.close(); + } return false; } @@ -280,12 +288,18 @@ public class AndroidSpellCheckerService extends SpellCheckerService { DictionaryFactory.createDictionaryFromManager(this, locale, fallbackResourceId, USE_FULL_EDIT_DISTANCE_FLAG_ARRAY); final String localeStr = locale.toString(); - Dictionary userDict = mUserDictionaries.get(localeStr); - if (null == userDict) { - userDict = new SynchronouslyLoadedUserDictionary(this, localeStr, true); - mUserDictionaries.put(localeStr, userDict); + Dictionary userDictionary = mUserDictionaries.get(localeStr); + if (null == userDictionary) { + userDictionary = new SynchronouslyLoadedUserDictionary(this, localeStr, true); + mUserDictionaries.put(localeStr, userDictionary); + } + dictionaryCollection.addDictionary(userDictionary); + Dictionary whitelistDictionary = mWhitelistDictionaries.get(localeStr); + if (null == whitelistDictionary) { + whitelistDictionary = new WhitelistDictionary(this, locale); + mWhitelistDictionaries.put(localeStr, whitelistDictionary); } - dictionaryCollection.addDictionary(userDict); + dictionaryCollection.addDictionary(whitelistDictionary); return new DictAndProximity(dictionaryCollection, proximityInfo); } |