aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-10-06 15:57:43 +0900
committerJean Chalard <jchalard@google.com>2011-10-07 19:25:36 +0900
commitfee149abe0358ff0efcebff3d0b60d8be83af437 (patch)
treebf0bea9a96ababac0c2720c51d2de58cf5fa3f58 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
parent266ae6964d5bcab82e10f6ba7fe36f38da0c086d (diff)
downloadlatinime-fee149abe0358ff0efcebff3d0b60d8be83af437.tar.gz
latinime-fee149abe0358ff0efcebff3d0b60d8be83af437.tar.xz
latinime-fee149abe0358ff0efcebff3d0b60d8be83af437.zip
Use the whitelist as a dictionary in the spell checker.
Bug: 5402436 Change-Id: If89b8bbdebf6751697c4788270d01d4639cff665
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java24
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);
}