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:
@@ -83,6 +83,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
protected CharSequence mPackageName;
|
protected CharSequence mPackageName;
|
||||||
protected Uri mImageUri;
|
protected Uri mImageUri;
|
||||||
protected CharSequence mHtmlDescription;
|
protected CharSequence mHtmlDescription;
|
||||||
|
// Used to restore the edit dialog status.
|
||||||
|
protected int mUserShortcutTypeCache = UserShortcutType.EMPTY;
|
||||||
private static final String DRAWABLE_FOLDER = "drawable";
|
private static final String DRAWABLE_FOLDER = "drawable";
|
||||||
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
|
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
|
||||||
protected static final String KEY_GENERAL_CATEGORY = "general_categories";
|
protected static final String KEY_GENERAL_CATEGORY = "general_categories";
|
||||||
@@ -91,8 +93,6 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||||
private int mUserShortcutType = UserShortcutType.EMPTY;
|
private int mUserShortcutType = UserShortcutType.EMPTY;
|
||||||
// Used to restore the edit dialog status.
|
|
||||||
private int mUserShortcutTypeCache = UserShortcutType.EMPTY;
|
|
||||||
private CheckBox mSoftwareTypeCheckBox;
|
private CheckBox mSoftwareTypeCheckBox;
|
||||||
private CheckBox mHardwareTypeCheckBox;
|
private CheckBox mHardwareTypeCheckBox;
|
||||||
|
|
||||||
@@ -473,8 +473,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlertDialogCheckState() {
|
private void updateAlertDialogCheckState() {
|
||||||
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
|
if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
|
||||||
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
|
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
|
||||||
|
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
|
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
|
||||||
@@ -658,7 +660,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsClicked(ShortcutPreference preference) {
|
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) {
|
private void createFooterPreference(CharSequence title) {
|
||||||
|
@@ -71,8 +71,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
|
||||||
private int mUserShortcutType = UserShortcutType.EMPTY;
|
private int mUserShortcutType = UserShortcutType.EMPTY;
|
||||||
// Used to restore the edit dialog status.
|
|
||||||
private int mUserShortcutTypeCache = UserShortcutType.EMPTY;
|
|
||||||
private CheckBox mSoftwareTypeCheckBox;
|
private CheckBox mSoftwareTypeCheckBox;
|
||||||
private CheckBox mHardwareTypeCheckBox;
|
private CheckBox mHardwareTypeCheckBox;
|
||||||
private CheckBox mTripleTapTypeCheckBox;
|
private CheckBox mTripleTapTypeCheckBox;
|
||||||
@@ -283,9 +281,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlertDialogCheckState() {
|
private void updateAlertDialogCheckState() {
|
||||||
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
|
if (mUserShortcutTypeCache != UserShortcutType.EMPTY) {
|
||||||
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
|
updateCheckStatus(mSoftwareTypeCheckBox, UserShortcutType.SOFTWARE);
|
||||||
updateCheckStatus(mTripleTapTypeCheckBox, UserShortcutType.TRIPLETAP);
|
updateCheckStatus(mHardwareTypeCheckBox, UserShortcutType.HARDWARE);
|
||||||
|
updateCheckStatus(mTripleTapTypeCheckBox, UserShortcutType.TRIPLETAP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
|
private void updateCheckStatus(CheckBox checkBox, @UserShortcutType int type) {
|
||||||
@@ -457,7 +457,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSettingsClicked(ShortcutPreference preference) {
|
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);
|
showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user