aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorTom Ouyang <ouyang@google.com>2012-06-05 21:29:14 -0700
committerTom Ouyang <ouyang@google.com>2012-06-07 00:25:41 -0700
commit2e8aa0600293875c620ba7b650010cb30ec023c1 (patch)
treecc2d403abeb888556bbe9f72e848d2a18baa91d2 /java/src/com/android/inputmethod/latin/LatinIME.java
parent6b3b37da97a5198acd4a31387108e0c512cd37e2 (diff)
downloadlatinime-2e8aa0600293875c620ba7b650010cb30ec023c1.tar.gz
latinime-2e8aa0600293875c620ba7b650010cb30ec023c1.tar.xz
latinime-2e8aa0600293875c620ba7b650010cb30ec023c1.zip
Contacts binary dictionary updates with change in keyboard locale.
Bug: 6616436 Change-Id: I8d66a37f295134c5b9875b2a305a9be7442bd75d
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java45
1 files changed, 29 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 7092b4e7e..77acf941d 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -505,9 +505,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
/**
* Resets the contacts dictionary in mSuggest according to the user settings.
*
- * This method takes an optional contacts dictionary to use. Since the contacts dictionary
- * does not depend on the locale, it can be reused across different instances of Suggest.
- * The dictionary will also be opened or closed as necessary depending on the settings.
+ * This method takes an optional contacts dictionary to use when the locale hasn't changed
+ * since the contacts dictionary can be opened or closed as necessary depending on the settings.
*
* @param oldContactsDictionary an optional dictionary to use, or null
*/
@@ -520,21 +519,35 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// so it's safe to call it anyways.
if (null != oldContactsDictionary) oldContactsDictionary.close();
dictionaryToUse = null;
- } else if (null != oldContactsDictionary) {
- // Make sure the old contacts dictionary is opened. If it is already open, this is a
- // no-op, so it's safe to call it anyways.
- if (USE_BINARY_CONTACTS_DICTIONARY) {
- ((ContactsBinaryDictionary)oldContactsDictionary).reopen(this);
- } else {
- ((ContactsDictionary)oldContactsDictionary).reopen(this);
- }
- dictionaryToUse = oldContactsDictionary;
} else {
- if (USE_BINARY_CONTACTS_DICTIONARY) {
- dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS,
- mSubtypeSwitcher.getCurrentSubtypeLocale());
+ final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale();
+ if (null != oldContactsDictionary) {
+ if (USE_BINARY_CONTACTS_DICTIONARY) {
+ ContactsBinaryDictionary oldContactsBinaryDictionary =
+ (ContactsBinaryDictionary)oldContactsDictionary;
+ if (!oldContactsBinaryDictionary.mLocale.equals(locale)) {
+ // If the locale has changed then recreate the contacts dictionary. This
+ // allows locale dependent rules for handling bigram name predictions.
+ oldContactsDictionary.close();
+ dictionaryToUse = new ContactsBinaryDictionary(
+ this, Suggest.DIC_CONTACTS, locale);
+ } else {
+ // Make sure the old contacts dictionary is opened. If it is already open,
+ // this is a no-op, so it's safe to call it anyways.
+ oldContactsBinaryDictionary.reopen(this);
+ dictionaryToUse = oldContactsDictionary;
+ }
+ } else {
+ ((ContactsDictionary)oldContactsDictionary).reopen(this);
+ dictionaryToUse = oldContactsDictionary;
+ }
} else {
- dictionaryToUse = new ContactsDictionary(this, Suggest.DIC_CONTACTS);
+ if (USE_BINARY_CONTACTS_DICTIONARY) {
+ dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS,
+ locale);
+ } else {
+ dictionaryToUse = new ContactsDictionary(this, Suggest.DIC_CONTACTS);
+ }
}
}