Loading java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,9 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { /** The number of contacts in the most recent dictionary rebuild. */ static private int sContactCountAtLastRebuild = 0; /** The locale for this contacts dictionary. Controls name bigram predictions. */ public final Locale mLocale; private ContentObserver mObserver; /** Loading @@ -61,6 +64,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { public ContactsBinaryDictionary(final Context context, final int dicTypeId, Locale locale) { super(context, getFilenameWithLocale(NAME, locale.toString()), dicTypeId); mLocale = locale; mUseFirstLastBigrams = useFirstLastBigramsForLocale(locale); registerObserver(context); Loading java/src/com/android/inputmethod/latin/LatinIME.java +29 −16 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -520,23 +519,37 @@ 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. } else { final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale(); if (null != oldContactsDictionary) { if (USE_BINARY_CONTACTS_DICTIONARY) { ((ContactsBinaryDictionary)oldContactsDictionary).reopen(this); 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 { ((ContactsDictionary)oldContactsDictionary).reopen(this); // 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 { if (USE_BINARY_CONTACTS_DICTIONARY) { dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS, mSubtypeSwitcher.getCurrentSubtypeLocale()); locale); } else { dictionaryToUse = new ContactsDictionary(this, Suggest.DIC_CONTACTS); } } } if (null != mSuggest) { mSuggest.setContactsDictionary(dictionaryToUse); Loading Loading
java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +4 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,9 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { /** The number of contacts in the most recent dictionary rebuild. */ static private int sContactCountAtLastRebuild = 0; /** The locale for this contacts dictionary. Controls name bigram predictions. */ public final Locale mLocale; private ContentObserver mObserver; /** Loading @@ -61,6 +64,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { public ContactsBinaryDictionary(final Context context, final int dicTypeId, Locale locale) { super(context, getFilenameWithLocale(NAME, locale.toString()), dicTypeId); mLocale = locale; mUseFirstLastBigrams = useFirstLastBigramsForLocale(locale); registerObserver(context); Loading
java/src/com/android/inputmethod/latin/LatinIME.java +29 −16 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -520,23 +519,37 @@ 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. } else { final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale(); if (null != oldContactsDictionary) { if (USE_BINARY_CONTACTS_DICTIONARY) { ((ContactsBinaryDictionary)oldContactsDictionary).reopen(this); 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 { ((ContactsDictionary)oldContactsDictionary).reopen(this); // 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 { if (USE_BINARY_CONTACTS_DICTIONARY) { dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS, mSubtypeSwitcher.getCurrentSubtypeLocale()); locale); } else { dictionaryToUse = new ContactsDictionary(this, Suggest.DIC_CONTACTS); } } } if (null != mSuggest) { mSuggest.setContactsDictionary(dictionaryToUse); Loading