aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-08-19 01:27:54 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-19 01:27:54 -0700
commitff5a54c5af5bfcf942e02bc015c8f1e55d6ed742 (patch)
tree430288b01b98cd1b258de80a4dd941c6c4c22c5a /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
parent6929b0dd97ca46d237f709c1d70cf422b4175258 (diff)
parent150bad6fd4b401177c480acf5640b4db0f821886 (diff)
downloadlatinime-ff5a54c5af5bfcf942e02bc015c8f1e55d6ed742.tar.gz
latinime-ff5a54c5af5bfcf942e02bc015c8f1e55d6ed742.tar.xz
latinime-ff5a54c5af5bfcf942e02bc015c8f1e55d6ed742.zip
Merge "Have the spell checker use the User dictionary."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 649774d78..ec82f9e80 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -30,7 +30,9 @@ import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.Dictionary.DataType;
import com.android.inputmethod.latin.Dictionary.WordCallback;
+import com.android.inputmethod.latin.DictionaryCollection;
import com.android.inputmethod.latin.DictionaryFactory;
+import com.android.inputmethod.latin.UserDictionary;
import com.android.inputmethod.latin.Utils;
import com.android.inputmethod.latin.WordComposer;
@@ -51,6 +53,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
private final static String[] emptyArray = new String[0];
private Map<String, DictionaryPool> mDictionaryPools =
Collections.synchronizedMap(new TreeMap<String, DictionaryPool>());
+ private Map<String, Dictionary> mUserDictionaries =
+ Collections.synchronizedMap(new TreeMap<String, Dictionary>());
@Override
public Session createSession() {
@@ -109,9 +113,14 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
public boolean onUnbind(final Intent intent) {
final Map<String, DictionaryPool> oldPools = mDictionaryPools;
mDictionaryPools = Collections.synchronizedMap(new TreeMap<String, DictionaryPool>());
+ final Map<String, Dictionary> oldUserDictionaries = mUserDictionaries;
+ mUserDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>());
for (DictionaryPool pool : oldPools.values()) {
pool.close();
}
+ for (Dictionary dict : oldUserDictionaries.values()) {
+ dict.close();
+ }
return false;
}
@@ -129,9 +138,16 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
final ProximityInfo proximityInfo = ProximityInfo.createSpellCheckerProximityInfo();
final Resources resources = getResources();
final int fallbackResourceId = Utils.getMainDictionaryResourceId(resources);
- final Dictionary dictionary =
+ final DictionaryCollection dictionaryCollection =
DictionaryFactory.createDictionaryFromManager(this, locale, fallbackResourceId);
- return new DictAndProximity(dictionary, proximityInfo);
+ final String localeStr = locale.toString();
+ Dictionary userDict = mUserDictionaries.get(localeStr);
+ if (null == userDict) {
+ userDict = new UserDictionary(this, localeStr);
+ mUserDictionaries.put(localeStr, userDict);
+ }
+ dictionaryCollection.addDictionary(userDict);
+ return new DictAndProximity(dictionaryCollection, proximityInfo);
}
private class AndroidSpellCheckerSession extends Session {