diff options
author | 2011-10-24 03:52:05 -0700 | |
---|---|---|
committer | 2011-10-24 03:52:05 -0700 | |
commit | eaa6e3d7a17308a93357774be415986867d626e0 (patch) | |
tree | 6c696e254dd6b80a27e3dd9ba592b9d958698750 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | |
parent | 34da5b8cd98de24927959a64de70eae6f855003e (diff) | |
parent | ee89b40a92cc5dd73ad192bfdb1ee27766ec3000 (diff) | |
download | latinime-eaa6e3d7a17308a93357774be415986867d626e0.tar.gz latinime-eaa6e3d7a17308a93357774be415986867d626e0.tar.xz latinime-eaa6e3d7a17308a93357774be415986867d626e0.zip |
am ee89b40a: Merge "Use the contacts dictionary in the spell checker."
* commit 'ee89b40a92cc5dd73ad192bfdb1ee27766ec3000':
Use the contacts dictionary in the spell checker.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index f9e6a5e68..8f478f385 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -35,6 +35,7 @@ import com.android.inputmethod.latin.DictionaryFactory; import com.android.inputmethod.latin.Flag; import com.android.inputmethod.latin.LocaleUtils; import com.android.inputmethod.latin.R; +import com.android.inputmethod.latin.SynchronouslyLoadedContactsDictionary; import com.android.inputmethod.latin.SynchronouslyLoadedUserDictionary; import com.android.inputmethod.latin.Utils; import com.android.inputmethod.latin.WhitelistDictionary; @@ -82,6 +83,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService { Collections.synchronizedMap(new TreeMap<String, Dictionary>()); private Map<String, Dictionary> mWhitelistDictionaries = Collections.synchronizedMap(new TreeMap<String, Dictionary>()); + private SynchronouslyLoadedContactsDictionary mContactsDictionary; // The threshold for a candidate to be offered as a suggestion. private double mSuggestionThreshold; @@ -267,6 +269,14 @@ public class AndroidSpellCheckerService extends SpellCheckerService { for (Dictionary dict : oldWhitelistDictionaries.values()) { dict.close(); } + if (null != mContactsDictionary) { + // The synchronously loaded contacts dictionary should have been in one + // or several pools, but it is shielded against multiple closing and it's + // safe to call it several times. + final SynchronouslyLoadedContactsDictionary dictToClose = mContactsDictionary; + mContactsDictionary = null; + dictToClose.close(); + } return false; } @@ -300,6 +310,11 @@ public class AndroidSpellCheckerService extends SpellCheckerService { mWhitelistDictionaries.put(localeStr, whitelistDictionary); } dictionaryCollection.addDictionary(whitelistDictionary); + if (null == mContactsDictionary) { + mContactsDictionary = new SynchronouslyLoadedContactsDictionary(this); + } + // TODO: add a setting to use or not contacts when checking spelling + dictionaryCollection.addDictionary(mContactsDictionary); return new DictAndProximity(dictionaryCollection, proximityInfo); } |