Refactoring Accessibility settings to use ShortcutConstants.UserShortcutType
This removes AccessibilityUtil.UserShortcutType, replacing all mention of it with ShortcutConstants.UserShortcutType NO_IFTTT=UI order not changed Test: atest com.android.settings.accessibility Bug: 322014084 Flag: EXEMPT internal refactoring Change-Id: I18695d040c4bd08a455143594e770adda2b1a8de
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
import static com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_GENERAL_CATEGORY;
|
||||
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_TYPE;
|
||||
@@ -43,6 +47,7 @@ import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.accessibility.common.ShortcutConstants;
|
||||
import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
|
||||
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
|
||||
@@ -310,7 +315,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns accumulated {@link AccessibilityUtil.UserShortcutType} checkbox value or
|
||||
* Returns accumulated {@link UserShortcutType} checkbox value or
|
||||
* {@code NOT_SET} if checkboxes did not exist.
|
||||
*/
|
||||
protected int getShortcutTypeCheckBoxValue() {
|
||||
@@ -318,12 +323,12 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
return NOT_SET;
|
||||
}
|
||||
|
||||
int value = AccessibilityUtil.UserShortcutType.EMPTY;
|
||||
int value = DEFAULT;
|
||||
if (mSoftwareTypeCheckBox.isChecked()) {
|
||||
value |= AccessibilityUtil.UserShortcutType.SOFTWARE;
|
||||
value |= SOFTWARE;
|
||||
}
|
||||
if (mHardwareTypeCheckBox.isChecked()) {
|
||||
value |= AccessibilityUtil.UserShortcutType.HARDWARE;
|
||||
value |= HARDWARE;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -374,7 +379,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
saveNonEmptyUserShortcutType(value);
|
||||
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, getComponentName());
|
||||
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, getComponentName());
|
||||
final boolean shortcutAssigned = value != AccessibilityUtil.UserShortcutType.EMPTY;
|
||||
final boolean shortcutAssigned = value != DEFAULT;
|
||||
mShortcutPreference.setChecked(shortcutAssigned);
|
||||
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
|
||||
|
||||
@@ -406,7 +411,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
|
||||
@VisibleForTesting
|
||||
void saveNonEmptyUserShortcutType(int type) {
|
||||
if (type == AccessibilityUtil.UserShortcutType.EMPTY) {
|
||||
if (type == DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -456,16 +461,16 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
// LINT.IfChange(shortcut_type_ui_order)
|
||||
final List<CharSequence> list = new ArrayList<>();
|
||||
if (android.view.accessibility.Flags.a11yQsShortcut()) {
|
||||
if (hasShortcutType(shortcutTypes, AccessibilityUtil.UserShortcutType.QUICK_SETTINGS)) {
|
||||
if (hasShortcutType(shortcutTypes, QUICK_SETTINGS)) {
|
||||
final CharSequence qsTitle = context.getText(
|
||||
R.string.accessibility_feature_shortcut_setting_summary_quick_settings);
|
||||
list.add(qsTitle);
|
||||
}
|
||||
}
|
||||
if (hasShortcutType(shortcutTypes, AccessibilityUtil.UserShortcutType.SOFTWARE)) {
|
||||
if (hasShortcutType(shortcutTypes, SOFTWARE)) {
|
||||
list.add(getSoftwareShortcutTypeSummary(context));
|
||||
}
|
||||
if (hasShortcutType(shortcutTypes, AccessibilityUtil.UserShortcutType.HARDWARE)) {
|
||||
if (hasShortcutType(shortcutTypes, HARDWARE)) {
|
||||
final CharSequence hardwareTitle = context.getText(
|
||||
R.string.accessibility_shortcut_hardware_keyword);
|
||||
list.add(hardwareTitle);
|
||||
@@ -488,13 +493,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
if (value == NOT_SET) {
|
||||
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
|
||||
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
|
||||
: AccessibilityUtil.UserShortcutType.EMPTY;
|
||||
: DEFAULT;
|
||||
}
|
||||
|
||||
mSoftwareTypeCheckBox.setChecked(
|
||||
hasShortcutType(value, AccessibilityUtil.UserShortcutType.SOFTWARE));
|
||||
hasShortcutType(value, SOFTWARE));
|
||||
mHardwareTypeCheckBox.setChecked(
|
||||
hasShortcutType(value, AccessibilityUtil.UserShortcutType.HARDWARE));
|
||||
hasShortcutType(value, HARDWARE));
|
||||
}
|
||||
|
||||
private int restoreOnConfigChangedValue() {
|
||||
@@ -503,7 +508,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
return savedValue;
|
||||
}
|
||||
|
||||
private boolean hasShortcutType(int value, @AccessibilityUtil.UserShortcutType int type) {
|
||||
private boolean hasShortcutType(int value, @UserShortcutType int type) {
|
||||
return (value & type) == type;
|
||||
}
|
||||
|
||||
@@ -514,7 +519,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
|
||||
|
||||
final int shortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(
|
||||
getPrefContext(), getComponentName());
|
||||
if (shortcutTypes != AccessibilityUtil.UserShortcutType.EMPTY) {
|
||||
if (shortcutTypes != DEFAULT) {
|
||||
final PreferredShortcut shortcut = new PreferredShortcut(
|
||||
getComponentName().flattenToString(), shortcutTypes);
|
||||
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
|
||||
|
||||
Reference in New Issue
Block a user