Do not reset IME Subtype in InputMethodConfig fragment
Bug: 3415292 Change-Id: Ic9a27982402c6bfd747960d32cce13f3856545da
This commit is contained in:
@@ -159,7 +159,7 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
HashSet<String> disabledSystemIMEs = getDisabledSystemIMEs(resolver);
|
HashSet<String> disabledSystemIMEs = getDisabledSystemIMEs(resolver);
|
||||||
|
|
||||||
final boolean onlyOneIME = inputMethodInfos.size() == 1;
|
final boolean onlyOneIME = inputMethodInfos.size() == 1;
|
||||||
boolean existsSelectedSubtype = false;
|
boolean needsToResetSelectedSubtype = false;
|
||||||
for (InputMethodInfo imi : inputMethodInfos) {
|
for (InputMethodInfo imi : inputMethodInfos) {
|
||||||
final String imiId = imi.getId();
|
final String imiId = imi.getId();
|
||||||
Preference pref = context.findPreference(imiId);
|
Preference pref = context.findPreference(imiId);
|
||||||
@@ -178,7 +178,7 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
}
|
}
|
||||||
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
|
HashSet<String> subtypesSet = enabledIMEAndSubtypesMap.get(imiId);
|
||||||
|
|
||||||
boolean subtypeCleared = false;
|
boolean subtypePrefFound = false;
|
||||||
final int subtypeCount = imi.getSubtypeCount();
|
final int subtypeCount = imi.getSubtypeCount();
|
||||||
for (int i = 0; i < subtypeCount; ++i) {
|
for (int i = 0; i < subtypeCount; ++i) {
|
||||||
InputMethodSubtype subtype = imi.getSubtypeAt(i);
|
InputMethodSubtype subtype = imi.getSubtypeAt(i);
|
||||||
@@ -187,17 +187,21 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
imiId + subtypeHashCodeStr);
|
imiId + subtypeHashCodeStr);
|
||||||
// In the Configure input method screen which does not have subtype preferences.
|
// In the Configure input method screen which does not have subtype preferences.
|
||||||
if (subtypePref == null) continue;
|
if (subtypePref == null) continue;
|
||||||
// Once subtype checkbox is found, subtypeSet needs to be cleared.
|
if (!subtypePrefFound) {
|
||||||
// Because of system change, hashCode value could have been changed.
|
// Once subtype checkbox is found, subtypeSet needs to be cleared.
|
||||||
if (!subtypeCleared) {
|
// Because of system change, hashCode value could have been changed.
|
||||||
subtypesSet.clear();
|
subtypesSet.clear();
|
||||||
subtypeCleared = true;
|
// If selected subtype preference is disabled, needs to reset.
|
||||||
|
needsToResetSelectedSubtype = true;
|
||||||
|
subtypePrefFound = true;
|
||||||
}
|
}
|
||||||
if (subtypePref.isChecked()) {
|
if (subtypePref.isChecked()) {
|
||||||
subtypesSet.add(subtypeHashCodeStr);
|
subtypesSet.add(subtypeHashCodeStr);
|
||||||
if (isCurrentInputMethod) {
|
if (isCurrentInputMethod) {
|
||||||
if (selectedInputMethodSubtype == subtype.hashCode()) {
|
if (selectedInputMethodSubtype == subtype.hashCode()) {
|
||||||
existsSelectedSubtype = true;
|
// Selected subtype is still enabled, there is no need to reset
|
||||||
|
// selected subtype.
|
||||||
|
needsToResetSelectedSubtype = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -241,12 +245,14 @@ public class InputMethodAndSubtypeUtil {
|
|||||||
Log.d(TAG, "--- Save disable system inputmethod settings. :"
|
Log.d(TAG, "--- Save disable system inputmethod settings. :"
|
||||||
+ disabledSysImesBuilder.toString());
|
+ disabledSysImesBuilder.toString());
|
||||||
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
|
Log.d(TAG, "--- Save default inputmethod settings. :" + currentInputMethodId);
|
||||||
|
Log.d(TAG, "--- Needs to reset the selected subtype :" + needsToResetSelectedSubtype);
|
||||||
|
Log.d(TAG, "--- Subtype is selected :" + isInputMethodSubtypeSelected(resolver));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
|
// Redefines SelectedSubtype when all subtypes are unchecked or there is no subtype
|
||||||
// selected. And if the selected subtype of the current input method was disabled,
|
// selected. And if the selected subtype of the current input method was disabled,
|
||||||
// We should reset the selected input method's subtype.
|
// We should reset the selected input method's subtype.
|
||||||
if (!existsSelectedSubtype || !isInputMethodSubtypeSelected(resolver)) {
|
if (needsToResetSelectedSubtype || !isInputMethodSubtypeSelected(resolver)) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "--- Reset inputmethod subtype because it's not defined.");
|
Log.d(TAG, "--- Reset inputmethod subtype because it's not defined.");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user