Show empty options in shortcut chooser dialog if shortPreference is unchecked.

* Fix the magnification can not auto restore shortcut options.
* The shortcut chooser dialog behavior will be:
1. If user's toggle switch is turned off, and they open the shortcut chooser dialog, none of the options are selected. In this state, if user chooses some of the shortcuts and saves, these choices will be honored.
2. If user's toggle switch is turned off, and they turn on the switch without opening the shortcut chooser dialog, their previously-saved shortcut option is brought back (e.g. if I previously used a11y button, I turn toggle switch off and then on again, I still have a11y button).
3. If user's toggle switch is turned on, and they open the shortcut chooser dialog, their previously-saved shortcut options will be shown.

Bug: 152539702
Bug: 153042341
Test: manual test
Change-Id: Ic109b3363eaf00ba77ce0ed05f4ec11517b1367e
This commit is contained in:
jasonwshsu
2020-03-29 17:19:45 +08:00
parent 93162ce9f4
commit bfc3201e84
2 changed files with 19 additions and 11 deletions

View File

@@ -71,8 +71,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private int mUserShortcutType = UserShortcutType.EMPTY;
// Used to restore the edit dialog status.
private int mUserShortcutTypeCache = UserShortcutType.EMPTY;
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
private CheckBox mTripleTapTypeCheckBox;
@@ -283,9 +281,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
private void updateAlertDialogCheckState() {
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
updateCheckStatus(mTripleTapTypeCheckBox, UserShortcutType.TRIPLETAP);
if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
updateCheckStatus(mTripleTapTypeCheckBox, UserShortcutType.TRIPLETAP);
}
}
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
@@ -457,7 +457,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onSettingsClicked(ShortcutPreference preference) {
mUserShortcutTypeCache = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
// Do not restore shortcut in shortcut chooser dialog when shortcutPreference is turned off.
mUserShortcutTypeCache = mShortcutPreference.isChecked()
? getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE)
: UserShortcutType.EMPTY;
showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
}