mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Check all enabled IME's subtypes to enable personalization.
Bug: 13067743 Change-Id: I6fc68b5151430a5ab51777f4c381e20f5a657924
This commit is contained in:
parent
bb17354041
commit
6b23749dec
@ -541,7 +541,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||||||
shouldKeepUserHistoryDictionaries = true;
|
shouldKeepUserHistoryDictionaries = true;
|
||||||
// TODO: Eliminate this restriction
|
// TODO: Eliminate this restriction
|
||||||
shouldKeepPersonalizationDictionaries =
|
shouldKeepPersonalizationDictionaries =
|
||||||
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypes();
|
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes();
|
||||||
} else {
|
} else {
|
||||||
shouldKeepUserHistoryDictionaries = false;
|
shouldKeepUserHistoryDictionaries = false;
|
||||||
shouldKeepPersonalizationDictionaries = false;
|
shouldKeepPersonalizationDictionaries = false;
|
||||||
|
@ -37,9 +37,11 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
|||||||
import com.android.inputmethod.latin.utils.LocaleUtils;
|
import com.android.inputmethod.latin.utils.LocaleUtils;
|
||||||
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public final class SubtypeSwitcher {
|
public final class SubtypeSwitcher {
|
||||||
private static boolean DBG = LatinImeLogger.sDBG;
|
private static boolean DBG = LatinImeLogger.sDBG;
|
||||||
@ -273,12 +275,26 @@ public final class SubtypeSwitcher {
|
|||||||
return mNeedsToDisplayLanguage.getValue();
|
return mNeedsToDisplayLanguage.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypes() {
|
public boolean isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes() {
|
||||||
final Locale systemLocale = mResources.getConfiguration().locale;
|
final Locale systemLocale = mResources.getConfiguration().locale;
|
||||||
final List<InputMethodSubtype> enabledSubtypesOfThisIme =
|
final Set<InputMethodSubtype> enabledSubtypesOfEnabledImes =
|
||||||
mRichImm.getMyEnabledInputMethodSubtypeList(true);
|
new HashSet<InputMethodSubtype>();
|
||||||
for (final InputMethodSubtype subtype : enabledSubtypesOfThisIme) {
|
final InputMethodManager inputMethodManager = mRichImm.getInputMethodManager();
|
||||||
if (!systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
|
final List<InputMethodInfo> enabledInputMethodInfoList =
|
||||||
|
inputMethodManager.getEnabledInputMethodList();
|
||||||
|
for (final InputMethodInfo info : enabledInputMethodInfoList) {
|
||||||
|
final List<InputMethodSubtype> enabledSubtypes =
|
||||||
|
inputMethodManager.getEnabledInputMethodSubtypeList(
|
||||||
|
info, true /* allowsImplicitlySelectedSubtypes */);
|
||||||
|
if (enabledSubtypes.isEmpty()) {
|
||||||
|
// An IME with no subtypes is found.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
enabledSubtypesOfEnabledImes.addAll(enabledSubtypes);
|
||||||
|
}
|
||||||
|
for (final InputMethodSubtype subtype : enabledSubtypesOfEnabledImes) {
|
||||||
|
if (!subtype.isAuxiliary() && !subtype.getLocale().isEmpty()
|
||||||
|
&& !systemLocale.equals(SubtypeLocaleUtils.getSubtypeLocale(subtype))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user