am 38ec825e: [ML16] Remove DictionaryFacilitator.getLocale()

* commit '38ec825ef896db5f90025d86caded938df606194':
  [ML16] Remove DictionaryFacilitator.getLocale()
main
Jean Chalard 2014-10-07 09:17:43 +00:00 committed by Android Git Automerger
commit d46950c056
4 changed files with 19 additions and 19 deletions

View File

@ -219,11 +219,6 @@ public class DictionaryFacilitator {
mPersonalizationHelper.setIsMonolingualUser(isMonolingualUser);
}
// TODO: remove this, replace with version returning multiple locales
public Locale getLocale() {
return mDictionaryGroups[0].mLocale;
}
public boolean isActive() {
return null != mDictionaryGroups[0].mLocale;
}
@ -240,6 +235,15 @@ public class DictionaryFacilitator {
return getDictionaryGroupForMostProbableLanguage().mLocale;
}
public Locale[] getLocales() {
final DictionaryGroup[] dictionaryGroups = mDictionaryGroups;
final Locale[] locales = new Locale[dictionaryGroups.length];
for (int i = 0; i < dictionaryGroups.length; ++i) {
locales[i] = dictionaryGroups[i].mLocale;
}
return locales;
}
private DictionaryGroup getDictionaryGroupForMostProbableLanguage() {
// TODO: implement this
return mDictionaryGroups[0];
@ -266,11 +270,11 @@ public class DictionaryFacilitator {
}
}
public void resetDictionaries(final Context context, final Locale newLocale,
public void resetDictionaries(final Context context, final Locale[] newLocales,
final boolean useContactsDict, final boolean usePersonalizedDicts,
final boolean forceReloadMainDictionary,
final DictionaryInitializationListener listener) {
resetDictionariesWithDictNamePrefix(context, newLocale, useContactsDict,
resetDictionariesWithDictNamePrefix(context, newLocales, useContactsDict,
usePersonalizedDicts, forceReloadMainDictionary, listener, "" /* dictNamePrefix */);
}
@ -285,14 +289,12 @@ public class DictionaryFacilitator {
}
public void resetDictionariesWithDictNamePrefix(final Context context,
final Locale newLocaleToUse,
final Locale[] newLocales,
final boolean useContactsDict, final boolean usePersonalizedDicts,
final boolean forceReloadMainDictionary,
final DictionaryInitializationListener listener,
final String dictNamePrefix) {
final HashMap<Locale, ArrayList<String>> existingDictsToCleanup = new HashMap<>();
// TODO: use several locales
final Locale[] newLocales = new Locale[] { newLocaleToUse };
// TODO: Make subDictTypesToUse configurable by resource or a static final list.
final HashSet<String> subDictTypesToUse = new HashSet<>();
subDictTypesToUse.add(Dictionary.TYPE_USER);

View File

@ -101,7 +101,7 @@ public class DictionaryFacilitatorLruCache {
private void resetDictionariesForLocaleLocked(final DictionaryFacilitator dictionaryFacilitator,
final Locale locale) {
dictionaryFacilitator.resetDictionariesWithDictNamePrefix(mContext, locale,
dictionaryFacilitator.resetDictionariesWithDictNamePrefix(mContext, new Locale[] { locale },
mUseContactsDictionary, false /* usePersonalizedDicts */,
false /* forceReloadMainDictionary */, null /* listener */,
mDictionaryNamePrefix);

View File

@ -674,9 +674,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: make sure the current settings always have the right locales, and read from them
private void resetDictionaryFacilitatorForLocale(final Locale[] locales) {
final SettingsValues settingsValues = mSettings.getCurrent();
// TODO: pass the array instead
final Locale locale = locales[0];
mDictionaryFacilitator.resetDictionaries(this /* context */, locale,
mDictionaryFacilitator.resetDictionaries(this /* context */, locales,
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
false /* forceReloadMainDictionary */, this);
if (settingsValues.mAutoCorrectionEnabledPerUserSettings) {
@ -691,7 +689,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
/* package private */ void resetSuggestMainDict() {
final SettingsValues settingsValues = mSettings.getCurrent();
mDictionaryFacilitator.resetDictionaries(this /* context */,
mDictionaryFacilitator.getLocale(), settingsValues.mUseContactsDict,
mDictionaryFacilitator.getLocales(), settingsValues.mUseContactsDict,
settingsValues.mUsePersonalizedDicts, true /* forceReloadMainDictionary */, this);
}
@ -1893,7 +1891,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@UsedForTesting
/* package for test */ void replaceDictionariesForTest(final Locale locale) {
final SettingsValues settingsValues = mSettings.getCurrent();
mDictionaryFacilitator.resetDictionaries(this, locale,
mDictionaryFacilitator.resetDictionaries(this, new Locale[] { locale },
settingsValues.mUseContactsDict, settingsValues.mUsePersonalizedDicts,
false /* forceReloadMainDictionary */, this /* listener */);
}

View File

@ -50,15 +50,15 @@ public class DictionaryFacilitatorLruCacheTests extends AndroidTestCase {
private void testGetFacilitator(final DictionaryFacilitatorLruCache cache) {
final DictionaryFacilitator dictionaryFacilitatorEnUs = cache.get(Locale.US);
assertNotNull(dictionaryFacilitatorEnUs);
assertEquals(Locale.US, dictionaryFacilitatorEnUs.getLocale());
assertTrue(dictionaryFacilitatorEnUs.isForLocales(new Locale[] { Locale.US }));
final DictionaryFacilitator dictionaryFacilitatorFr = cache.get(Locale.FRENCH);
assertNotNull(dictionaryFacilitatorEnUs);
assertEquals(Locale.FRENCH, dictionaryFacilitatorFr.getLocale());
assertTrue(dictionaryFacilitatorFr.isForLocales(new Locale[] { Locale.FRENCH }));
final DictionaryFacilitator dictionaryFacilitatorDe = cache.get(Locale.GERMANY);
assertNotNull(dictionaryFacilitatorDe);
assertEquals(Locale.GERMANY, dictionaryFacilitatorDe.getLocale());
assertTrue(dictionaryFacilitatorDe.isForLocales(new Locale[] { Locale.GERMANY }));
}
public void testSetUseContactsDictionary() {