mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
[ML16] Remove DictionaryFacilitator.getLocale()
Bug: 11230254 Change-Id: Ife99df42bc145fbd2d5c3128330bc0f88b104de9
This commit is contained in:
parent
ea07734956
commit
38ec825ef8
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 */);
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user