From 6452b84763f864139a3744bd3406f72a0014301a Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 31 Mar 2016 22:58:33 -0700 Subject: [PATCH] Fix jank when dismissing InputMethodAndSubtypeEnabler. InputMethodAndSubtypeUtil#saveInputMethodSubtypeList() has a bug that it saves implicitly enabled subtypes when "Use system languages" is checked. Implicitly enabled subtypes are transient data and the system should have only a null data (0) in the persistent strage. The root cause of this bug is that the method in question has not checked whether the preference item is in enabled (not grayed-out). If it is grayed-out, its checked state does not mean that the user manually checked that subtype but it is just an indicator for the user. The strange UI jank when dismissing InputMethodAndSubtypeEnabler is one of the victim of the above bug because we have worked around it by actually changing checked state before calling the method in question. With this CL we no longer need to update preference items in InputMethodAndSubtypeEnabler#onPause(). Bug: 27867966 Change-Id: Ifc291d77ea41a988438765b9ba16bc5d18a15e1b --- .../settings/inputmethod/InputMethodAndSubtypeEnabler.java | 2 -- .../settings/inputmethod/InputMethodAndSubtypeUtil.java | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java index b6663184791..03e97ff5095 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeEnabler.java @@ -121,8 +121,6 @@ public class InputMethodAndSubtypeEnabler extends SettingsPreferenceFragment @Override public void onPause() { super.onPause(); - // Clear all subtypes of all IMEs to make sure - updateImplicitlyEnabledSubtypes(null /* targetImiId */, false /* check */); InputMethodAndSubtypeUtil.saveInputMethodSubtypeList(this, getContentResolver(), mInputMethodInfoList, mHaveHardKeyboard); } diff --git a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java index dfa16340e1e..b79f44d7f2e 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java +++ b/src/com/android/settings/inputmethod/InputMethodAndSubtypeUtil.java @@ -209,7 +209,12 @@ class InputMethodAndSubtypeUtil { needsToResetSelectedSubtype = true; subtypePrefFound = true; } - if (subtypePref.isChecked()) { + // Checking subtypePref.isEnabled() is insufficient to determine + // whether the user manually enabled this subtype or not. Implicitly-enabled + // subtypes are also checked just as an indicator to users. We also need to + // check subtypePref.isEnabled() so that only manually enabled + // subtypes can be saved here. + if (subtypePref.isEnabled() && subtypePref.isChecked()) { subtypesSet.add(subtypeHashCodeStr); if (isCurrentInputMethod) { if (selectedInputMethodSubtype == subtype.hashCode()) {