Accessibility shortcut secondary action - handle all preferred shortcut type key

- save and restore all preferredShortcutType: SOFTWARE, HARDWARE, TRIPLETAP

Bug: 142530063
Test: manual
Change-Id: I7dd714d1516f49e89c42822241f9cb2b41ae2d2e
This commit is contained in:
jasonwshsu
2020-01-07 15:24:40 +08:00
parent 7ad9008ce9
commit fb576356aa
6 changed files with 189 additions and 91 deletions

View File

@@ -245,6 +245,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
updateUserShortcutType(/* saveChanges= */ true);
mShortcutPreference.setSummary(
getShortcutTypeSummary(getPrefContext()));
if (mShortcutPreference.getChecked()) {
AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
getComponentName());
AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
getComponentName());
}
}
@Override
@@ -303,15 +309,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
@Override
public void onCheckboxClicked(ShortcutPreference preference) {
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
if (preference.getChecked()) {
// TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
// preferred key.
AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
getComponentName());
} else {
// TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
// preferred key.
AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
getComponentName());
}
}
@@ -355,11 +358,9 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
getShortcutPreferenceKey());
if (shortcutPreference != null) {
// TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
// preferred key.
final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
shortcutPreference.setChecked(
AccessibilityUtil.hasValueInSettings(getContext(),
UserShortcutType.SOFTWARE,
AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
getComponentName()));
}