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
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index c55c9a2..9bf4cf8 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -83,6 +83,8 @@
protected CharSequence mPackageName;
protected Uri mImageUri;
protected CharSequence mHtmlDescription;
+ // Used to restore the edit dialog status.
+ protected int mUserShortcutTypeCache = UserShortcutType.EMPTY;
private static final String DRAWABLE_FOLDER = "drawable";
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
protected static final String KEY_GENERAL_CATEGORY = "general_categories";
@@ -91,8 +93,6 @@
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
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;
@@ -473,8 +473,10 @@
}
private void updateAlertDialogCheckState() {
- updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
- updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
+ if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
+ updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
+ updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
+ }
}
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
@@ -658,7 +660,10 @@
@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;
}
private void createFooterPreference(CharSequence title) {
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 5573746..a9667bb 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -71,8 +71,6 @@
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 @@
}
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 @@
@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);
}