Merge "Refactoring Accessibility settings to use ShortcutConstants.UserShortcutType" into main
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 8441c2a..d746434 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -16,6 +16,8 @@
package com.android.settings.accessibility;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.accessibilityservice.AccessibilityShortcutInfo;
import android.app.settings.SettingsEnums;
@@ -283,7 +285,7 @@
info.getResolveInfo().serviceInfo.packageName,
info.getResolveInfo().serviceInfo.name);
final boolean shortcutEnabled = AccessibilityUtil.getUserShortcutTypesFromSettings(
- context, componentName) != AccessibilityUtil.UserShortcutType.EMPTY;
+ context, componentName) != DEFAULT;
serviceState = shortcutEnabled
? context.getText(R.string.accessibility_summary_shortcut_enabled)
: context.getText(R.string.generic_accessibility_feature_shortcut_off);
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 92259ac..0f55a11 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -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.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 @@
}
/**
- * 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 @@
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 @@
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 @@
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
- if (type == AccessibilityUtil.UserShortcutType.EMPTY) {
+ if (type == DEFAULT) {
return;
}
@@ -456,16 +461,16 @@
// 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 @@
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 @@
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 @@
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);
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
index e286c63..8d908ac 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutsTutorial.java
@@ -19,7 +19,11 @@
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
-import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -171,7 +175,7 @@
AlertDialog dialog, List<TutorialPage> pages, int selectedPageIndex) {
final Button button = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
final int pageType = pages.get(selectedPageIndex).getType();
- final int buttonVisibility = pageType == UserShortcutType.SOFTWARE ? VISIBLE : GONE;
+ final int buttonVisibility = (pageType == SOFTWARE) ? VISIBLE : GONE;
button.setVisibility(buttonVisibility);
if (buttonVisibility == VISIBLE) {
final int textResId = AccessibilityUtil.isFloatingMenuEnabled(dialog.getContext())
@@ -393,7 +397,7 @@
}
private static TutorialPage createSoftwareTutorialPage(@NonNull Context context) {
- final int type = UserShortcutType.SOFTWARE;
+ final int type = SOFTWARE;
final CharSequence title = getSoftwareTitle(context);
final View image = createSoftwareImage(context);
final CharSequence instruction = getSoftwareInstruction(context);
@@ -405,7 +409,7 @@
}
private static TutorialPage createHardwareTutorialPage(@NonNull Context context) {
- final int type = UserShortcutType.HARDWARE;
+ final int type = HARDWARE;
final CharSequence title =
context.getText(R.string.accessibility_tutorial_dialog_title_volume);
final View image =
@@ -420,7 +424,7 @@
}
private static TutorialPage createTripleTapTutorialPage(@NonNull Context context) {
- final int type = UserShortcutType.TRIPLETAP;
+ final int type = TRIPLETAP;
final CharSequence title =
context.getText(R.string.accessibility_tutorial_dialog_title_triple);
final View image =
@@ -436,7 +440,7 @@
}
private static TutorialPage createTwoFingerTripleTapTutorialPage(@NonNull Context context) {
- final int type = UserShortcutType.TWOFINGER_DOUBLETAP;
+ final int type = TWOFINGER_DOUBLETAP;
final int numFingers = 2;
final CharSequence title = context.getString(
R.string.accessibility_tutorial_dialog_title_two_finger_double, numFingers);
@@ -454,7 +458,7 @@
private static TutorialPage createQuickSettingsTutorialPage(
@NonNull Context context, @NonNull CharSequence featureName, boolean inSetupWizard) {
- final int type = UserShortcutType.QUICK_SETTINGS;
+ final int type = QUICK_SETTINGS;
final CharSequence title =
context.getText(R.string.accessibility_tutorial_dialog_title_quick_setting);
final View image =
@@ -494,28 +498,28 @@
// LINT.IfChange(shortcut_type_ui_order)
final List<TutorialPage> tutorialPages = new ArrayList<>();
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if ((shortcutTypes & UserShortcutType.QUICK_SETTINGS)
- == UserShortcutType.QUICK_SETTINGS) {
+ if ((shortcutTypes & QUICK_SETTINGS)
+ == QUICK_SETTINGS) {
tutorialPages.add(
createQuickSettingsTutorialPage(context, featureName, inSetupWizard));
}
}
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
tutorialPages.add(createSoftwareTutorialPage(context));
}
- if ((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE) {
+ if ((shortcutTypes & HARDWARE) == HARDWARE) {
tutorialPages.add(createHardwareTutorialPage(context));
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if ((shortcutTypes & UserShortcutType.TWOFINGER_DOUBLETAP)
- == UserShortcutType.TWOFINGER_DOUBLETAP) {
+ if ((shortcutTypes & TWOFINGER_DOUBLETAP)
+ == TWOFINGER_DOUBLETAP) {
tutorialPages.add(createTwoFingerTripleTapTutorialPage(context));
}
}
- if ((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP) {
+ if ((shortcutTypes & TRIPLETAP) == TRIPLETAP) {
tutorialPages.add(createTripleTapTutorialPage(context));
}
// LINT.ThenChange(/res/xml/accessibility_edit_shortcuts.xml:shortcut_type_ui_order)
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index afc7b84..5bf2a3e 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -21,6 +21,12 @@
import static android.view.WindowInsets.Type.systemBars;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
+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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.ComponentName;
import android.content.Context;
@@ -41,6 +47,7 @@
import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import java.lang.annotation.Retention;
@@ -82,41 +89,6 @@
new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
/**
- * Annotation for different user shortcut type UI type.
- *
- * {@code EMPTY} for displaying default value.
- * {@code SOFTWARE} for displaying specifying the accessibility services or features which
- * choose accessibility button in the navigation bar as preferred shortcut.
- * {@code HARDWARE} for displaying specifying the accessibility services or features which
- * choose accessibility shortcut as preferred shortcut.
- * {@code TRIPLETAP} for displaying specifying magnification to be toggled via quickly
- * tapping screen 3 times as preferred shortcut.
- * {@code TWOFINGER_DOUBLETAP} for displaying specifying magnification to be toggled via
- * quickly tapping screen 2 times with two fingers as preferred shortcut.
- * {@code QUICK_SETTINGS} for displaying specifying the accessibility services or features which
- * choose Quick Settings as preferred shortcut.
- */
- @Retention(RetentionPolicy.SOURCE)
- @IntDef({
- UserShortcutType.EMPTY,
- UserShortcutType.SOFTWARE,
- UserShortcutType.HARDWARE,
- UserShortcutType.TRIPLETAP,
- UserShortcutType.TWOFINGER_DOUBLETAP,
- UserShortcutType.QUICK_SETTINGS,
- })
-
- /** Denotes the user shortcut type. */
- public @interface UserShortcutType {
- int EMPTY = 0;
- int SOFTWARE = 1;
- int HARDWARE = 1 << 1;
- int TRIPLETAP = 1 << 2;
- int TWOFINGER_DOUBLETAP = 1 << 3;
- int QUICK_SETTINGS = 1 << 4;
- }
-
- /**
* Denotes the quick setting tooltip type.
*
* {@code GUIDE_TO_EDIT} for QS tiles that need to be added by editing.
@@ -230,11 +202,11 @@
return;
}
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- optInValueToSettings(context, UserShortcutType.SOFTWARE, componentName);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ optInValueToSettings(context, SOFTWARE, componentName);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- optInValueToSettings(context, UserShortcutType.HARDWARE, componentName);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ optInValueToSettings(context, HARDWARE, componentName);
}
}
@@ -301,11 +273,11 @@
return;
}
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- optOutValueFromSettings(context, UserShortcutType.SOFTWARE, componentName);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ optOutValueFromSettings(context, SOFTWARE, componentName);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- optOutValueFromSettings(context, UserShortcutType.HARDWARE, componentName);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ optOutValueFromSettings(context, HARDWARE, componentName);
}
}
@@ -364,16 +336,16 @@
static boolean hasValuesInSettings(Context context, int shortcutTypes,
@NonNull ComponentName componentName) {
boolean exist = false;
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentName);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ exist = hasValueInSettings(context, SOFTWARE, componentName);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentName);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ exist |= hasValueInSettings(context, HARDWARE, componentName);
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if ((shortcutTypes & UserShortcutType.QUICK_SETTINGS)
- == UserShortcutType.QUICK_SETTINGS) {
- exist |= hasValueInSettings(context, UserShortcutType.QUICK_SETTINGS,
+ if ((shortcutTypes & QUICK_SETTINGS)
+ == QUICK_SETTINGS) {
+ exist |= hasValueInSettings(context, QUICK_SETTINGS,
componentName);
}
}
@@ -427,16 +399,16 @@
*/
static int getUserShortcutTypesFromSettings(Context context,
@NonNull ComponentName componentName) {
- int shortcutTypes = UserShortcutType.EMPTY;
- if (hasValuesInSettings(context, UserShortcutType.SOFTWARE, componentName)) {
- shortcutTypes |= UserShortcutType.SOFTWARE;
+ int shortcutTypes = DEFAULT;
+ if (hasValuesInSettings(context, SOFTWARE, componentName)) {
+ shortcutTypes |= SOFTWARE;
}
- if (hasValuesInSettings(context, UserShortcutType.HARDWARE, componentName)) {
- shortcutTypes |= UserShortcutType.HARDWARE;
+ if (hasValuesInSettings(context, HARDWARE, componentName)) {
+ shortcutTypes |= HARDWARE;
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if (hasValuesInSettings(context, UserShortcutType.QUICK_SETTINGS, componentName)) {
- shortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ if (hasValuesInSettings(context, QUICK_SETTINGS, componentName)) {
+ shortcutTypes |= QUICK_SETTINGS;
}
}
@@ -455,11 +427,11 @@
}
switch (shortcutType) {
- case UserShortcutType.SOFTWARE:
+ case SOFTWARE:
return Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS;
- case UserShortcutType.HARDWARE:
+ case HARDWARE:
return Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
- case UserShortcutType.TRIPLETAP:
+ case TRIPLETAP:
return Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED;
default:
throw new IllegalArgumentException(
diff --git a/src/com/android/settings/accessibility/PreferredShortcut.java b/src/com/android/settings/accessibility/PreferredShortcut.java
index 1654992..c26960e 100644
--- a/src/com/android/settings/accessibility/PreferredShortcut.java
+++ b/src/com/android/settings/accessibility/PreferredShortcut.java
@@ -19,7 +19,7 @@
import android.content.ComponentName;
import android.text.TextUtils;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.google.common.base.Objects;
diff --git a/src/com/android/settings/accessibility/PreferredShortcuts.java b/src/com/android/settings/accessibility/PreferredShortcuts.java
index 895430a..c3e64ab 100644
--- a/src/com/android/settings/accessibility/PreferredShortcuts.java
+++ b/src/com/android/settings/accessibility/PreferredShortcuts.java
@@ -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.QUICK_SETTINGS;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
+
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
@@ -27,8 +31,8 @@
import androidx.annotation.VisibleForTesting;
import com.android.internal.accessibility.common.ShortcutConstants;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import java.util.HashSet;
import java.util.Map;
@@ -43,18 +47,18 @@
/**
* Retrieves the user preferred shortcut types for the given {@code componentName} from
* SharedPreferences. If the user doesn't have a preferred shortcut,
- * {@link ShortcutConstants.UserShortcutType.SOFTWARE} is returned.
+ * {@link SOFTWARE} is returned.
*
* @param context {@link Context} to access the {@link SharedPreferences}
* @param componentName Name of the service or activity, should be the format of {@link
* ComponentName#flattenToString()}.
- * @return {@link ShortcutConstants.UserShortcutType}
+ * @return {@link UserShortcutType}
*/
- @ShortcutConstants.UserShortcutType
+ @UserShortcutType
public static int retrieveUserShortcutType(
@NonNull Context context, @NonNull String componentName) {
return retrieveUserShortcutType(
- context, componentName, ShortcutConstants.UserShortcutType.SOFTWARE);
+ context, componentName, SOFTWARE);
}
/**
@@ -66,13 +70,13 @@
* ComponentName#flattenToString()}.
* @param defaultTypes The default shortcut types to use if the user doesn't have a
* preferred shortcut.
- * @return {@link ShortcutConstants.UserShortcutType}
+ * @return {@link UserShortcutType}
*/
- @ShortcutConstants.UserShortcutType
+ @UserShortcutType
public static int retrieveUserShortcutType(
@NonNull Context context,
@NonNull String componentName,
- @ShortcutConstants.UserShortcutType int defaultTypes) {
+ @UserShortcutType int defaultTypes) {
// Create a mutable set to modify
final Set<String> info = new HashSet<>(getFromSharedPreferences(context));
@@ -121,7 +125,7 @@
final Map<Integer, Set<String>> shortcutTypeToTargets = new ArrayMap<>();
for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
if (!Flags.a11yQsShortcut()
- && shortcutType == ShortcutConstants.UserShortcutType.QUICK_SETTINGS) {
+ && shortcutType == QUICK_SETTINGS) {
// Skip saving quick setting as preferred shortcut option when flag is not enabled
continue;
}
@@ -132,14 +136,14 @@
}
for (String target : components) {
- int shortcutTypes = ShortcutConstants.UserShortcutType.DEFAULT;
+ int shortcutTypes = DEFAULT;
for (Map.Entry<Integer, Set<String>> entry : shortcutTypeToTargets.entrySet()) {
if (entry.getValue().contains(target)) {
shortcutTypes |= entry.getKey();
}
}
- if (shortcutTypes != ShortcutConstants.UserShortcutType.DEFAULT) {
+ if (shortcutTypes != DEFAULT) {
final PreferredShortcut shortcut = new PreferredShortcut(
target, shortcutTypes);
PreferredShortcuts.saveUserShortcutType(context, shortcut);
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index e4d7925..8bbc7a8 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -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 android.app.Activity;
@@ -55,11 +59,11 @@
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.SettingsActivity;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.flags.Flags;
@@ -677,13 +681,13 @@
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
- : UserShortcutType.EMPTY;
+ : DEFAULT;
}
mSoftwareTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.SOFTWARE));
+ hasShortcutType(value, SOFTWARE));
mHardwareTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.HARDWARE));
+ hasShortcutType(value, HARDWARE));
}
private int restoreOnConfigChangedValue() {
@@ -705,12 +709,12 @@
return NOT_SET;
}
- int value = UserShortcutType.EMPTY;
+ int value = DEFAULT;
if (mSoftwareTypeCheckBox.isChecked()) {
- value |= UserShortcutType.SOFTWARE;
+ value |= SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
- value |= UserShortcutType.HARDWARE;
+ value |= HARDWARE;
}
return value;
}
@@ -730,16 +734,16 @@
final List<CharSequence> list = new ArrayList<>();
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if (hasShortcutType(shortcutTypes, 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, UserShortcutType.SOFTWARE)) {
+ if (hasShortcutType(shortcutTypes, SOFTWARE)) {
list.add(getSoftwareShortcutTypeSummary(context));
}
- if (hasShortcutType(shortcutTypes, UserShortcutType.HARDWARE)) {
+ if (hasShortcutType(shortcutTypes, HARDWARE)) {
final CharSequence hardwareTitle = context.getText(
R.string.accessibility_shortcut_hardware_keyword);
list.add(hardwareTitle);
@@ -793,7 +797,7 @@
saveNonEmptyUserShortcutType(value);
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, mComponentName);
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, mComponentName);
- final boolean shortcutAssigned = value != UserShortcutType.EMPTY;
+ final boolean shortcutAssigned = value != DEFAULT;
mShortcutPreference.setChecked(shortcutAssigned);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
@@ -814,7 +818,7 @@
final int shortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(
getPrefContext(), mComponentName);
- if (shortcutTypes != UserShortcutType.EMPTY) {
+ if (shortcutTypes != DEFAULT) {
final PreferredShortcut shortcut = new PreferredShortcut(
mComponentName.flattenToString(), shortcutTypes);
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
@@ -909,7 +913,7 @@
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
- if (type == UserShortcutType.EMPTY) {
+ if (type == DEFAULT) {
return;
}
@@ -996,7 +1000,7 @@
*/
@ShortcutConstants.UserShortcutType
protected int getDefaultShortcutTypes() {
- return ShortcutConstants.UserShortcutType.SOFTWARE;
+ return SOFTWARE;
}
/**
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index b1ad7f7..34ed5cb 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -18,6 +18,12 @@
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
+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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import static com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
@@ -51,13 +57,13 @@
import androidx.preference.SwitchPreferenceCompat;
import androidx.preference.TwoStatePreference;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.accessibility.Flags;
import com.android.settings.DialogCreatable;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.utils.LocaleUtils;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -365,19 +371,19 @@
return NOT_SET;
}
- int value = UserShortcutType.EMPTY;
+ int value = DEFAULT;
if (mSoftwareTypeCheckBox.isChecked()) {
- value |= UserShortcutType.SOFTWARE;
+ value |= SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
- value |= UserShortcutType.HARDWARE;
+ value |= HARDWARE;
}
if (mTripleTapTypeCheckBox.isChecked()) {
- value |= UserShortcutType.TRIPLETAP;
+ value |= TRIPLETAP;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (mTwoFingerTripleTapTypeCheckBox.isChecked()) {
- value |= UserShortcutType.TWOFINGER_DOUBLETAP;
+ value |= TWOFINGER_DOUBLETAP;
}
}
return value;
@@ -427,18 +433,18 @@
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
- : UserShortcutType.EMPTY;
+ : DEFAULT;
}
mSoftwareTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.SOFTWARE));
+ hasShortcutType(value, SOFTWARE));
mHardwareTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.HARDWARE));
+ hasShortcutType(value, HARDWARE));
mTripleTapTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.TRIPLETAP));
+ hasShortcutType(value, TRIPLETAP));
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
mTwoFingerTripleTapTypeCheckBox.setChecked(
- hasShortcutType(value, UserShortcutType.TWOFINGER_DOUBLETAP));
+ hasShortcutType(value, TWOFINGER_DOUBLETAP));
}
}
@@ -529,28 +535,28 @@
// LINT.IfChange(shortcut_type_ui_order)
final List<CharSequence> list = new ArrayList<>();
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if (hasShortcutType(shortcutTypes, 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, UserShortcutType.SOFTWARE)) {
+ if (hasShortcutType(shortcutTypes, SOFTWARE)) {
list.add(getSoftwareShortcutTypeSummary(context));
}
- if (hasShortcutType(shortcutTypes, UserShortcutType.HARDWARE)) {
+ if (hasShortcutType(shortcutTypes, HARDWARE)) {
final CharSequence hardwareTitle = context.getText(
R.string.accessibility_shortcut_hardware_keyword);
list.add(hardwareTitle);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (hasShortcutType(shortcutTypes, UserShortcutType.TWOFINGER_DOUBLETAP)) {
+ if (hasShortcutType(shortcutTypes, TWOFINGER_DOUBLETAP)) {
final CharSequence twoFingerDoubleTapTitle = context.getString(
R.string.accessibility_shortcut_two_finger_double_tap_keyword, 2);
list.add(twoFingerDoubleTapTitle);
}
}
- if (hasShortcutType(shortcutTypes, UserShortcutType.TRIPLETAP)) {
+ if (hasShortcutType(shortcutTypes, TRIPLETAP)) {
final CharSequence tripleTapTitle = context.getText(
R.string.accessibility_shortcut_triple_tap_keyword);
list.add(tripleTapTitle);
@@ -573,7 +579,7 @@
saveNonEmptyUserShortcutType(value);
optInAllMagnificationValuesToSettings(getPrefContext(), value);
optOutAllMagnificationValuesFromSettings(getPrefContext(), ~value);
- mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
+ mShortcutPreference.setChecked(value != DEFAULT);
mShortcutPreference.setSummary(
getShortcutTypeSummary(getPrefContext()));
@@ -673,7 +679,7 @@
@Override
protected void updateShortcutPreferenceData() {
final int shortcutTypes = getUserShortcutTypeFromSettings(getPrefContext());
- if (shortcutTypes != UserShortcutType.EMPTY) {
+ if (shortcutTypes != DEFAULT) {
final PreferredShortcut shortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME, shortcutTypes);
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
@@ -708,7 +714,7 @@
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
- if (type == UserShortcutType.EMPTY) {
+ if (type == DEFAULT) {
return;
}
@@ -719,25 +725,25 @@
@VisibleForTesting
static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- optInMagnificationValueToSettings(context, UserShortcutType.SOFTWARE);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ optInMagnificationValueToSettings(context, SOFTWARE);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- optInMagnificationValueToSettings(context, UserShortcutType.HARDWARE);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ optInMagnificationValueToSettings(context, HARDWARE);
}
- if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
- optInMagnificationValueToSettings(context, UserShortcutType.TRIPLETAP);
+ if (((shortcutTypes & TRIPLETAP) == TRIPLETAP)) {
+ optInMagnificationValueToSettings(context, TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (((shortcutTypes & UserShortcutType.TWOFINGER_DOUBLETAP)
- == UserShortcutType.TWOFINGER_DOUBLETAP)) {
- optInMagnificationValueToSettings(context, UserShortcutType.TWOFINGER_DOUBLETAP);
+ if (((shortcutTypes & TWOFINGER_DOUBLETAP)
+ == TWOFINGER_DOUBLETAP)) {
+ optInMagnificationValueToSettings(context, TWOFINGER_DOUBLETAP);
}
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if (((shortcutTypes & UserShortcutType.QUICK_SETTINGS)
- == UserShortcutType.QUICK_SETTINGS)) {
- optInMagnificationValueToSettings(context, UserShortcutType.QUICK_SETTINGS);
+ if (((shortcutTypes & QUICK_SETTINGS)
+ == QUICK_SETTINGS)) {
+ optInMagnificationValueToSettings(context, QUICK_SETTINGS);
}
}
}
@@ -757,14 +763,14 @@
return;
}
- if (shortcutType == UserShortcutType.TRIPLETAP) {
+ if (shortcutType == TRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, ON);
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (shortcutType == UserShortcutType.TWOFINGER_DOUBLETAP) {
+ if (shortcutType == TWOFINGER_DOUBLETAP) {
Settings.Secure.putInt(
context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
@@ -790,7 +796,7 @@
Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
// The size setting defaults to unknown. If the user has ever manually changed the size
// before, we do not automatically change it.
- if (shortcutType == UserShortcutType.SOFTWARE
+ if (shortcutType == SOFTWARE
&& Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
FloatingMenuSizePreferenceController.Size.UNKNOWN)
@@ -804,25 +810,25 @@
@VisibleForTesting
static void optOutAllMagnificationValuesFromSettings(Context context,
int shortcutTypes) {
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- optOutMagnificationValueFromSettings(context, UserShortcutType.SOFTWARE);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ optOutMagnificationValueFromSettings(context, SOFTWARE);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- optOutMagnificationValueFromSettings(context, UserShortcutType.HARDWARE);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ optOutMagnificationValueFromSettings(context, HARDWARE);
}
- if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
- optOutMagnificationValueFromSettings(context, UserShortcutType.TRIPLETAP);
+ if (((shortcutTypes & TRIPLETAP) == TRIPLETAP)) {
+ optOutMagnificationValueFromSettings(context, TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (((shortcutTypes & UserShortcutType.TWOFINGER_DOUBLETAP)
- == UserShortcutType.TWOFINGER_DOUBLETAP)) {
- optOutMagnificationValueFromSettings(context, UserShortcutType.TWOFINGER_DOUBLETAP);
+ if (((shortcutTypes & TWOFINGER_DOUBLETAP)
+ == TWOFINGER_DOUBLETAP)) {
+ optOutMagnificationValueFromSettings(context, TWOFINGER_DOUBLETAP);
}
}
if (android.view.accessibility.Flags.a11yQsShortcut()) {
- if (((shortcutTypes & UserShortcutType.QUICK_SETTINGS)
- == UserShortcutType.QUICK_SETTINGS)) {
- optOutMagnificationValueFromSettings(context, UserShortcutType.QUICK_SETTINGS);
+ if (((shortcutTypes & QUICK_SETTINGS)
+ == QUICK_SETTINGS)) {
+ optOutMagnificationValueFromSettings(context, QUICK_SETTINGS);
}
}
}
@@ -842,14 +848,14 @@
return;
}
- if (shortcutType == UserShortcutType.TRIPLETAP) {
+ if (shortcutType == TRIPLETAP) {
Settings.Secure.putInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF);
return;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (shortcutType == UserShortcutType.TWOFINGER_DOUBLETAP) {
+ if (shortcutType == TWOFINGER_DOUBLETAP) {
Settings.Secure.putInt(
context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
@@ -884,20 +890,20 @@
static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) {
boolean exist = false;
- if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
- exist = hasMagnificationValueInSettings(context, UserShortcutType.SOFTWARE);
+ if ((shortcutTypes & SOFTWARE) == SOFTWARE) {
+ exist = hasMagnificationValueInSettings(context, SOFTWARE);
}
- if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
- exist |= hasMagnificationValueInSettings(context, UserShortcutType.HARDWARE);
+ if (((shortcutTypes & HARDWARE) == HARDWARE)) {
+ exist |= hasMagnificationValueInSettings(context, HARDWARE);
}
- if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
- exist |= hasMagnificationValueInSettings(context, UserShortcutType.TRIPLETAP);
+ if (((shortcutTypes & TRIPLETAP) == TRIPLETAP)) {
+ exist |= hasMagnificationValueInSettings(context, TRIPLETAP);
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (((shortcutTypes & UserShortcutType.TWOFINGER_DOUBLETAP)
- == UserShortcutType.TWOFINGER_DOUBLETAP)) {
+ if (((shortcutTypes & TWOFINGER_DOUBLETAP)
+ == TWOFINGER_DOUBLETAP)) {
exist |= hasMagnificationValueInSettings(context,
- UserShortcutType.TWOFINGER_DOUBLETAP);
+ TWOFINGER_DOUBLETAP);
}
}
return exist;
@@ -905,13 +911,13 @@
private static boolean hasMagnificationValueInSettings(Context context,
@UserShortcutType int shortcutType) {
- if (shortcutType == UserShortcutType.TRIPLETAP) {
+ if (shortcutType == TRIPLETAP) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF) == ON;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (shortcutType == UserShortcutType.TWOFINGER_DOUBLETAP) {
+ if (shortcutType == TWOFINGER_DOUBLETAP) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
OFF) == ON;
@@ -937,19 +943,19 @@
}
private static int getUserShortcutTypeFromSettings(Context context) {
- int shortcutTypes = UserShortcutType.EMPTY;
- if (hasMagnificationValuesInSettings(context, UserShortcutType.SOFTWARE)) {
- shortcutTypes |= UserShortcutType.SOFTWARE;
+ int shortcutTypes = DEFAULT;
+ if (hasMagnificationValuesInSettings(context, SOFTWARE)) {
+ shortcutTypes |= SOFTWARE;
}
- if (hasMagnificationValuesInSettings(context, UserShortcutType.HARDWARE)) {
- shortcutTypes |= UserShortcutType.HARDWARE;
+ if (hasMagnificationValuesInSettings(context, HARDWARE)) {
+ shortcutTypes |= HARDWARE;
}
- if (hasMagnificationValuesInSettings(context, UserShortcutType.TRIPLETAP)) {
- shortcutTypes |= UserShortcutType.TRIPLETAP;
+ if (hasMagnificationValuesInSettings(context, TRIPLETAP)) {
+ shortcutTypes |= TRIPLETAP;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
- if (hasMagnificationValuesInSettings(context, UserShortcutType.TWOFINGER_DOUBLETAP)) {
- shortcutTypes |= UserShortcutType.TWOFINGER_DOUBLETAP;
+ if (hasMagnificationValuesInSettings(context, TWOFINGER_DOUBLETAP)) {
+ shortcutTypes |= TWOFINGER_DOUBLETAP;
}
}
return shortcutTypes;
@@ -964,7 +970,7 @@
// Get the user shortcut type from settings provider.
final int userShortcutType = getUserShortcutTypeFromSettings(context);
final CharSequence featureState =
- (userShortcutType != AccessibilityUtil.UserShortcutType.EMPTY)
+ (userShortcutType != DEFAULT)
? context.getText(R.string.accessibility_summary_shortcut_enabled)
: context.getText(R.string.generic_accessibility_feature_shortcut_off);
final CharSequence featureSummary = context.getText(R.string.magnification_feature_summary);
diff --git a/src/com/android/settings/accessibility/VolumeShortcutToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/VolumeShortcutToggleAccessibilityServicePreferenceFragment.java
index eccfbce..11aa565 100644
--- a/src/com/android/settings/accessibility/VolumeShortcutToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/VolumeShortcutToggleAccessibilityServicePreferenceFragment.java
@@ -16,12 +16,14 @@
package com.android.settings.accessibility;
-import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.os.Bundle;
import android.view.View;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.settings.R;
/**
@@ -44,7 +46,7 @@
mShortcutPreference.setSummary(hardwareTitle);
mShortcutPreference.setSettingsEditable(false);
- setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
+ setAllowedPreferredShortcutType(HARDWARE);
}
@Override
@@ -56,9 +58,9 @@
final boolean hasRequestAccessibilityButtonFlag =
(info.flags & AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON) != 0;
if (hasRequestAccessibilityButtonFlag && isServiceOn) {
- shortcutTypes |= UserShortcutType.SOFTWARE;
+ shortcutTypes |= SOFTWARE;
} else {
- shortcutTypes &= (~UserShortcutType.SOFTWARE);
+ shortcutTypes &= (~SOFTWARE);
}
return shortcutTypes;
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
index f108b8e..b74f38e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragmentTest.java
@@ -16,10 +16,13 @@
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.AccessibilityShortcutPreferenceFragment.KEY_SAVED_QS_TOOLTIP_RESHOW;
import static com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
import static com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
-import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import static com.google.common.truth.Truth.assertThat;
@@ -128,7 +131,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.getComponentName().flattenToString());
// Compare to default UserShortcutType
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE);
}
@Test
@@ -140,20 +143,20 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.getComponentName().flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
}
@Test
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
- PLACEHOLDER_COMPONENT_NAME.flattenToString(), UserShortcutType.HARDWARE);
+ PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
putUserShortcutTypeIntoSharedPreference(mContext, hardwareShortcut);
mFragment.updateShortcutPreferenceData();
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.getComponentName().flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(HARDWARE);
}
@Test
@@ -171,7 +174,7 @@
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
+ assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -184,7 +187,7 @@
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
null);
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
- PLACEHOLDER_COMPONENT_NAME.flattenToString(), UserShortcutType.HARDWARE);
+ PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
mFragment.mShortcutPreference = shortcutPreference;
PreferredShortcuts.saveUserShortcutType(mContext, hardwareShortcut);
@@ -192,7 +195,7 @@
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.HARDWARE);
+ assertThat(checkboxValue).isEqualTo(HARDWARE);
}
@Test
@@ -209,7 +212,7 @@
mFragment.mShortcutPreference = shortcutPreference;
savedInstanceState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE,
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ SOFTWARE | HARDWARE);
mFragment.onAttach(mContext);
mFragment.onCreate(savedInstanceState);
mFragment.setupEditShortcutDialog(dialog);
@@ -218,7 +221,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.getComponentName().flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
}
@Test
@@ -290,7 +293,7 @@
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
PLACEHOLDER_COMPONENT_NAME.flattenToString(),
- UserShortcutType.HARDWARE | UserShortcutType.QUICK_SETTINGS);
+ HARDWARE | QUICK_SETTINGS);
putUserShortcutTypeIntoSharedPreference(mContext, userPreferredShortcut);
final ShortcutPreference shortcutPreference =
new ShortcutPreference(mContext, /* attrs= */ null);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java
index a5aceed..d5c1fd1 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutsTutorialTest.java
@@ -16,11 +16,15 @@
package com.android.settings.accessibility;
+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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import static com.android.settings.accessibility.AccessibilityShortcutsTutorial.createAccessibilityTutorialDialog;
import static com.android.settings.accessibility.AccessibilityShortcutsTutorial.createAccessibilityTutorialDialogForSetupWizard;
import static com.android.settings.accessibility.AccessibilityShortcutsTutorial.createShortcutTutorialPages;
import static com.android.settings.accessibility.AccessibilityShortcutsTutorial.showGestureNavigationTutorialDialog;
-import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import static com.google.common.truth.Truth.assertThat;
@@ -99,7 +103,7 @@
@Test
public void createTutorialPages_turnOnTripleTapShortcut_hasOnePage() {
- mShortcutTypes |= UserShortcutType.TRIPLETAP;
+ mShortcutTypes |= TRIPLETAP;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -114,7 +118,7 @@
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void createTutorialPages_turnOnTwoFingerTripleTapShortcut_hasOnePage() {
- mShortcutTypes |= UserShortcutType.TWOFINGER_DOUBLETAP;
+ mShortcutTypes |= TWOFINGER_DOUBLETAP;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -129,7 +133,7 @@
@Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createTutorialPages_turnOnQuickSettingShortcut_hasOnePage() {
- mShortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ mShortcutTypes |= QUICK_SETTINGS;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -143,7 +147,7 @@
@Test
public void createTutorialPages_turnOnSoftwareShortcut_hasOnePage() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -157,8 +161,8 @@
@Test
public void createTutorialPages_turnOnSoftwareAndHardwareShortcuts_hasTwoPages() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
- mShortcutTypes |= UserShortcutType.HARDWARE;
+ mShortcutTypes |= SOFTWARE;
+ mShortcutTypes |= HARDWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -172,7 +176,7 @@
@Test
public void createTutorialPages_turnOnA11yGestureShortcut_linkButtonShownWithText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
@@ -191,7 +195,7 @@
@Test
public void createTutorialPages_turnOnA11yNavButtonShortcut_linkButtonShownWithText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ false);
@@ -210,7 +214,7 @@
@Test
public void createTutorialPages_turnOnFloatingButtonShortcut_linkButtonShownWithText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ true);
@@ -228,7 +232,7 @@
@Test
public void createTutorialPages_turnOnHardwareShortcut_linkButtonGone() {
- mShortcutTypes |= UserShortcutType.HARDWARE;
+ mShortcutTypes |= HARDWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -241,7 +245,7 @@
@Test
public void createTutorialPages_turnOnSoftwareShortcut_showFromSuW_linkButtonGone() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialogForSetupWizard(
@@ -256,7 +260,7 @@
@Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOn_verifyText() {
- mShortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(true);
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_quick_setting);
@@ -288,7 +292,7 @@
@Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOn_verifyText() {
- mShortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(true);
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_quick_setting);
@@ -314,7 +318,7 @@
@Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_inSuwTalkbackOff_verifyText() {
- mShortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(false);
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_quick_setting);
@@ -345,7 +349,7 @@
@Test
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void createAccessibilityTutorialDialog_qsShortcut_notInSuwTalkbackOff_verifyText() {
- mShortcutTypes |= UserShortcutType.QUICK_SETTINGS;
+ mShortcutTypes |= QUICK_SETTINGS;
setTouchExplorationEnabled(false);
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_quick_setting);
@@ -370,7 +374,7 @@
@Test
public void createAccessibilityTutorialDialog_volumeKeysShortcut_verifyText() {
- mShortcutTypes |= UserShortcutType.HARDWARE;
+ mShortcutTypes |= HARDWARE;
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_volume);
final CharSequence expectedInstruction = mContext.getString(
@@ -390,7 +394,7 @@
@Test
public void createAccessibilityTutorialDialog_tripleTapShortcut_verifyText() {
- mShortcutTypes |= UserShortcutType.TRIPLETAP;
+ mShortcutTypes |= TRIPLETAP;
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_triple);
final CharSequence expectedInstruction = mContext.getString(
@@ -411,7 +415,7 @@
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void createAccessibilityTutorialDialog_twoFingerDoubleTapShortcut_verifyText() {
- mShortcutTypes |= UserShortcutType.TWOFINGER_DOUBLETAP;
+ mShortcutTypes |= TWOFINGER_DOUBLETAP;
final int numFingers = 2;
final String expectedTitle = mContext.getString(
R.string.accessibility_tutorial_dialog_title_two_finger_double, numFingers);
@@ -432,7 +436,7 @@
@Test
public void createAccessibilityTutorialDialog_floatingButtonShortcut_verifyText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ true);
final String expectedTitle = mContext.getString(
@@ -454,7 +458,7 @@
@Test
public void createAccessibilityTutorialDialog_navA11yButtonShortcut_verifyText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ false);
final String expectedTitle = mContext.getString(
@@ -476,7 +480,7 @@
@Test
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOn_verifyText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
setTouchExplorationEnabled(true);
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
@@ -501,7 +505,7 @@
@Test
public void createAccessibilityTutorialDialog_gestureShortcut_talkbackOff_verifyText() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
setTouchExplorationEnabled(false);
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
@@ -526,7 +530,7 @@
@Test
public void performClickOnPositiveButton_turnOnSoftwareShortcut_dismiss() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
alertDialog.show();
@@ -540,7 +544,7 @@
@Test
public void performClickOnPositiveButton_turnOnSoftwareShortcut_callOnClickListener() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(
mContext, mShortcutTypes, mOnClickListener, FAKE_FEATURE_NAME);
@@ -555,7 +559,7 @@
@Test
public void performClickOnNegativeButton_turnOnSoftwareShortcut_directToSettingsPage() {
- mShortcutTypes |= UserShortcutType.SOFTWARE;
+ mShortcutTypes |= SOFTWARE;
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(activity, mShortcutTypes, FAKE_FEATURE_NAME);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
index 2d5deeb..c036432 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityUtilTest.java
@@ -16,6 +16,12 @@
package com.android.settings.accessibility;
+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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
+
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.spy;
@@ -39,9 +45,9 @@
import androidx.test.core.app.ApplicationProvider;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.settings.R;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.testutils.AccessibilityTestUtils;
import org.junit.Before;
@@ -159,52 +165,52 @@
@Test
public void hasValueInSettings_putValue_hasValue() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- assertThat(AccessibilityUtil.hasValueInSettings(mContext, UserShortcutType.SOFTWARE,
+ assertThat(AccessibilityUtil.hasValueInSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME)).isTrue();
}
@Test
public void getUserShortcutTypeFromSettings_putOneValue_hasValue() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
final int shortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(mContext,
MOCK_COMPONENT_NAME);
assertThat(shortcutTypes).isEqualTo(
- UserShortcutType.SOFTWARE
+ SOFTWARE
);
}
@Test
public void getUserShortcutTypeFromSettings_putTwoValues_hasValue() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- setShortcut(UserShortcutType.HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
final int shortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(mContext,
MOCK_COMPONENT_NAME);
assertThat(shortcutTypes).isEqualTo(
- UserShortcutType.SOFTWARE
- | UserShortcutType.HARDWARE
+ SOFTWARE
+ | HARDWARE
);
}
@Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void getUserShortcutTypeFromSettings_threeShortcutTypesChosen() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- setShortcut(UserShortcutType.HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
- setShortcut(UserShortcutType.QUICK_SETTINGS, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(QUICK_SETTINGS, MOCK_COMPONENT_NAME.flattenToString());
final int shortcutTypes = AccessibilityUtil.getUserShortcutTypesFromSettings(mContext,
MOCK_COMPONENT_NAME);
assertThat(shortcutTypes).isEqualTo(
- UserShortcutType.SOFTWARE
- | UserShortcutType.HARDWARE
- | UserShortcutType.QUICK_SETTINGS
+ SOFTWARE
+ | HARDWARE
+ | QUICK_SETTINGS
);
}
@@ -212,7 +218,7 @@
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInAllValuesToSettings_optInValue_haveMatchString() {
clearShortcuts();
- int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE;
+ int shortcutTypes = SOFTWARE | HARDWARE;
AccessibilityUtil.optInAllValuesToSettings(mContext, shortcutTypes, MOCK_COMPONENT_NAME);
@@ -229,8 +235,8 @@
AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
Set<String> shortcutTargets = Set.of(MOCK_COMPONENT_NAME.flattenToString());
- int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE
- | UserShortcutType.QUICK_SETTINGS;
+ int shortcutTypes = SOFTWARE | HARDWARE
+ | QUICK_SETTINGS;
AccessibilityUtil.optInAllValuesToSettings(mContext, shortcutTypes, MOCK_COMPONENT_NAME);
@@ -243,9 +249,9 @@
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInValueToSettings_optInValue_haveMatchString() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- AccessibilityUtil.optInValueToSettings(mContext, UserShortcutType.SOFTWARE,
+ AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME2);
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
@@ -261,10 +267,10 @@
Set<String> shortcutTargets = Set.of(MOCK_COMPONENT_NAME2.flattenToString());
AccessibilityUtil.optInValueToSettings(
- mContext, UserShortcutType.HARDWARE, MOCK_COMPONENT_NAME2);
+ mContext, HARDWARE, MOCK_COMPONENT_NAME2);
verify(a11yManager).enableShortcutsForTargets(
- /* enable= */ true, UserShortcutType.HARDWARE,
+ /* enable= */ true, HARDWARE,
shortcutTargets, UserHandle.myUserId());
verifyNoMoreInteractions(a11yManager);
}
@@ -272,11 +278,11 @@
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInValueToSettings_optInTwoValues_haveMatchString() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- AccessibilityUtil.optInValueToSettings(mContext, UserShortcutType.SOFTWARE,
+ AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME2);
- AccessibilityUtil.optInValueToSettings(mContext, UserShortcutType.SOFTWARE,
+ AccessibilityUtil.optInValueToSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME2);
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
@@ -287,10 +293,10 @@
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optOutAllValuesToSettings_optOutValue_emptyString() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- setShortcut(UserShortcutType.HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(HARDWARE, MOCK_COMPONENT_NAME.flattenToString());
int shortcutTypes =
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP;
+ SOFTWARE | HARDWARE | TRIPLETAP;
AccessibilityUtil.optOutAllValuesFromSettings(mContext, shortcutTypes,
MOCK_COMPONENT_NAME);
@@ -305,8 +311,8 @@
AccessibilityManager a11yManager =
AccessibilityTestUtils.setupMockAccessibilityManager(mContext);
int shortcutTypes =
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE
- | UserShortcutType.QUICK_SETTINGS;
+ SOFTWARE | HARDWARE
+ | QUICK_SETTINGS;
Set<String> shortcutTargets = Set.of(MOCK_COMPONENT_NAME.flattenToString());
AccessibilityUtil.optOutAllValuesFromSettings(mContext, shortcutTypes,
@@ -322,9 +328,9 @@
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optOutValueFromSettings_optOutValue_emptyString() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString());
- AccessibilityUtil.optOutValueFromSettings(mContext, UserShortcutType.SOFTWARE,
+ AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME);
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEmpty();
@@ -333,10 +339,10 @@
@Test
@DisableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void optOutValueFromSettings_optOutValue_haveMatchString() {
- setShortcut(UserShortcutType.SOFTWARE, MOCK_COMPONENT_NAME.flattenToString(),
+ setShortcut(SOFTWARE, MOCK_COMPONENT_NAME.flattenToString(),
MOCK_COMPONENT_NAME2.flattenToString());
- AccessibilityUtil.optOutValueFromSettings(mContext, UserShortcutType.SOFTWARE,
+ AccessibilityUtil.optOutValueFromSettings(mContext, SOFTWARE,
MOCK_COMPONENT_NAME2);
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
@@ -351,36 +357,36 @@
Set<String> shortcutTargets = Set.of(MOCK_COMPONENT_NAME.flattenToString());
AccessibilityUtil.optOutValueFromSettings(
- mContext, UserShortcutType.QUICK_SETTINGS, MOCK_COMPONENT_NAME);
+ mContext, QUICK_SETTINGS, MOCK_COMPONENT_NAME);
verify(a11yManager).enableShortcutsForTargets(
- /* enable= */ false, UserShortcutType.QUICK_SETTINGS,
+ /* enable= */ false, QUICK_SETTINGS,
shortcutTargets, UserHandle.myUserId());
verifyNoMoreInteractions(a11yManager);
}
@Test
public void convertKeyFromSettings_shortcutTypeSoftware() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(UserShortcutType.SOFTWARE))
+ assertThat(AccessibilityUtil.convertKeyFromSettings(SOFTWARE))
.isEqualTo(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
}
@Test
public void convertKeyFromSettings_shortcutTypeHardware() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(UserShortcutType.HARDWARE))
+ assertThat(AccessibilityUtil.convertKeyFromSettings(HARDWARE))
.isEqualTo(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
}
@Test
public void convertKeyFromSettings_shortcutTypeTripleTap() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(UserShortcutType.TRIPLETAP))
+ assertThat(AccessibilityUtil.convertKeyFromSettings(TRIPLETAP))
.isEqualTo(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
}
@Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void convertKeyFromSettings_shortcutTypeMultiFingersMultiTap() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(UserShortcutType.TWOFINGER_DOUBLETAP))
+ assertThat(AccessibilityUtil.convertKeyFromSettings(TWOFINGER_DOUBLETAP))
.isEqualTo(
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED);
}
@@ -388,7 +394,7 @@
@Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void convertKeyFromSettings_shortcutTypeQuickSettings() {
- assertThat(AccessibilityUtil.convertKeyFromSettings(UserShortcutType.QUICK_SETTINGS))
+ assertThat(AccessibilityUtil.convertKeyFromSettings(QUICK_SETTINGS))
.isEqualTo(Settings.Secure.ACCESSIBILITY_QS_TARGETS);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
index af94723..04ff4fe 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java
@@ -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.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
import static com.google.common.truth.Truth.assertThat;
@@ -57,7 +61,6 @@
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
-import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.flags.Flags;
import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settingslib.widget.TopIntroPreference;
@@ -204,7 +207,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.mComponentName.flattenToString());
// Compare to default UserShortcutType
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE);
}
@Test
@@ -219,21 +222,21 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.mComponentName.flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
}
@Test
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
- PLACEHOLDER_COMPONENT_NAME.flattenToString(), UserShortcutType.HARDWARE);
+ PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
putUserShortcutTypeIntoSharedPreference(mContext, hardwareShortcut);
mFragment.updateShortcutPreferenceData();
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.mComponentName.flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(HARDWARE);
}
@Test
@@ -272,7 +275,7 @@
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
+ assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -283,7 +286,7 @@
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
null);
final PreferredShortcut hardwareShortcut = new PreferredShortcut(
- PLACEHOLDER_COMPONENT_NAME.flattenToString(), UserShortcutType.HARDWARE);
+ PLACEHOLDER_COMPONENT_NAME.flattenToString(), HARDWARE);
mFragment.mComponentName = PLACEHOLDER_COMPONENT_NAME;
mFragment.mShortcutPreference = shortcutPreference;
@@ -292,7 +295,7 @@
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.HARDWARE);
+ assertThat(checkboxValue).isEqualTo(HARDWARE);
}
@Test
@@ -308,7 +311,7 @@
mFragment.mShortcutPreference = shortcutPreference;
savedInstanceState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE,
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ SOFTWARE | HARDWARE);
mFragment.onCreate(savedInstanceState);
mFragment.setupEditShortcutDialog(dialog);
final int value = mFragment.getShortcutTypeCheckBoxValue();
@@ -316,7 +319,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
mFragment.mComponentName.flattenToString());
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE | HARDWARE);
}
@Test
@@ -470,7 +473,7 @@
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
PLACEHOLDER_COMPONENT_NAME.flattenToString(),
- UserShortcutType.HARDWARE | UserShortcutType.QUICK_SETTINGS);
+ HARDWARE | QUICK_SETTINGS);
putUserShortcutTypeIntoSharedPreference(mContext, userPreferredShortcut);
final ShortcutPreference shortcutPreference =
new ShortcutPreference(mContext, /* attrs= */ null);
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index b801521..6f9981a 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -16,9 +16,14 @@
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.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
-import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import static com.android.settings.accessibility.MagnificationCapabilities.MagnificationMode;
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_USER_SHORTCUT_TYPE;
@@ -433,7 +438,7 @@
setMagnificationTripleTapEnabled(/* enabled= */ true);
assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, UserShortcutType.TRIPLETAP)).isTrue();
+ mContext, TRIPLETAP)).isTrue();
}
@Test
@@ -443,7 +448,7 @@
mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, UserShortcutType.TWOFINGER_DOUBLETAP)).isTrue();
+ mContext, TWOFINGER_DOUBLETAP)).isTrue();
}
@Test
@@ -453,13 +458,13 @@
mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF);
assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
- mContext, UserShortcutType.TWOFINGER_DOUBLETAP)).isFalse();
+ mContext, TWOFINGER_DOUBLETAP)).isFalse();
}
@Test
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInAllValuesToSettings_optInValue_haveMatchString() {
- int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
+ int shortcutTypes = SOFTWARE | TRIPLETAP;
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
shortcutTypes);
@@ -473,24 +478,24 @@
@EnableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInAllValuesToSettings_optInValue_callA11yManager() {
int shortcutTypes =
- UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP | UserShortcutType.HARDWARE
- | UserShortcutType.QUICK_SETTINGS;
+ SOFTWARE | TRIPLETAP | HARDWARE
+ | QUICK_SETTINGS;
Set<String> shortcutTargets = Set.of(MAGNIFICATION_CONTROLLER_NAME);
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
shortcutTypes);
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, UserShortcutType.SOFTWARE,
+ /* enable= */ true, SOFTWARE,
shortcutTargets, UserHandle.myUserId());
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, UserShortcutType.HARDWARE,
+ /* enable= */ true, HARDWARE,
shortcutTargets, UserHandle.myUserId());
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, UserShortcutType.QUICK_SETTINGS,
+ /* enable= */ true, QUICK_SETTINGS,
shortcutTargets, UserHandle.myUserId());
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ true, UserShortcutType.TRIPLETAP,
+ /* enable= */ true, TRIPLETAP,
shortcutTargets, UserHandle.myUserId());
verifyNoMoreInteractions(mAccessibilityManager);
}
@@ -499,7 +504,7 @@
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
@DisableFlags(android.view.accessibility.Flags.FLAG_A11Y_QS_SHORTCUT)
public void optInAllValuesToSettings_twoFingerTripleTap_haveMatchString() {
- int shortcutTypes = UserShortcutType.TWOFINGER_DOUBLETAP;
+ int shortcutTypes = TWOFINGER_DOUBLETAP;
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
shortcutTypes);
@@ -514,7 +519,7 @@
putStringIntoSettings(SOFTWARE_SHORTCUT_KEY, PLACEHOLDER_COMPONENT_NAME.flattenToString());
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
- UserShortcutType.SOFTWARE);
+ SOFTWARE);
assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
@@ -526,7 +531,7 @@
ShadowSettings.ShadowSecure.reset();
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
- UserShortcutType.SOFTWARE);
+ SOFTWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
@@ -543,7 +548,7 @@
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
- UserShortcutType.SOFTWARE);
+ SOFTWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
@@ -562,7 +567,7 @@
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
- UserShortcutType.HARDWARE);
+ HARDWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
@@ -580,7 +585,7 @@
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
- UserShortcutType.TRIPLETAP);
+ TRIPLETAP);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
@@ -595,7 +600,7 @@
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
setMagnificationTripleTapEnabled(/* enabled= */ true);
int shortcutTypes =
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP;
+ SOFTWARE | HARDWARE | TRIPLETAP;
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
mContext, shortcutTypes);
@@ -613,19 +618,19 @@
putStringIntoSettings(HARDWARE_SHORTCUT_KEY, MAGNIFICATION_CONTROLLER_NAME);
setMagnificationTripleTapEnabled(/* enabled= */ true);
int shortcutTypes =
- UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP;
+ SOFTWARE | HARDWARE | TRIPLETAP;
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
mContext, shortcutTypes);
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, UserShortcutType.SOFTWARE,
+ /* enable= */ false, SOFTWARE,
shortcutTargets, UserHandle.myUserId());
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, UserShortcutType.HARDWARE,
+ /* enable= */ false, HARDWARE,
shortcutTargets, UserHandle.myUserId());
verify(mAccessibilityManager).enableShortcutsForTargets(
- /* enable= */ false, UserShortcutType.TRIPLETAP,
+ /* enable= */ false, TRIPLETAP,
shortcutTargets, UserHandle.myUserId());
verifyNoMoreInteractions(mAccessibilityManager);
}
@@ -638,7 +643,7 @@
TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
- mContext, UserShortcutType.TWOFINGER_DOUBLETAP);
+ mContext, TWOFINGER_DOUBLETAP);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON)).isEqualTo(OFF);
@@ -651,7 +656,7 @@
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
putStringIntoSettings(HARDWARE_SHORTCUT_KEY,
PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
- int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.HARDWARE;
+ int shortcutTypes = SOFTWARE | HARDWARE;
ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
mContext, shortcutTypes);
@@ -671,7 +676,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
// Compare to default UserShortcutType
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE);
+ assertThat(expectedType).isEqualTo(SOFTWARE);
}
@Test
@@ -684,13 +689,13 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
- assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP);
+ assertThat(expectedType).isEqualTo(SOFTWARE | TRIPLETAP);
}
@Test
public void updateShortcutPreferenceData_hasValueInSharedPreference_assignToVariable() {
final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
- MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TRIPLETAP);
+ MAGNIFICATION_CONTROLLER_NAME, TRIPLETAP);
putUserShortcutTypeIntoSharedPreference(mContext, tripleTapShortcut);
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
@@ -698,7 +703,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
- assertThat(expectedType).isEqualTo(UserShortcutType.TRIPLETAP);
+ assertThat(expectedType).isEqualTo(TRIPLETAP);
}
@Test
@@ -712,14 +717,14 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
- assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
+ assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void updateShortcutPreferenceData_hasTwoFingerTripleTapInSharedPref_assignToVariable() {
final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
- MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TWOFINGER_DOUBLETAP);
+ MAGNIFICATION_CONTROLLER_NAME, TWOFINGER_DOUBLETAP);
putUserShortcutTypeIntoSharedPreference(mContext, tripleTapShortcut);
mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
@@ -727,7 +732,7 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
- assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
+ assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
}
@Test
@@ -742,7 +747,7 @@
createEditShortcutDialog(fragment.getActivity()));
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
+ assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -753,7 +758,7 @@
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
null);
final PreferredShortcut tripletapShortcut = new PreferredShortcut(
- MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TRIPLETAP);
+ MAGNIFICATION_CONTROLLER_NAME, TRIPLETAP);
fragment.mShortcutPreference = shortcutPreference;
PreferredShortcuts.saveUserShortcutType(mContext, tripletapShortcut);
@@ -762,7 +767,7 @@
createEditShortcutDialog(fragment.getActivity()));
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.TRIPLETAP);
+ assertThat(checkboxValue).isEqualTo(TRIPLETAP);
}
@Test
@@ -774,7 +779,7 @@
final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
null);
final PreferredShortcut twoFingerTripleTapShortcut = new PreferredShortcut(
- MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TWOFINGER_DOUBLETAP);
+ MAGNIFICATION_CONTROLLER_NAME, TWOFINGER_DOUBLETAP);
fragment.mShortcutPreference = shortcutPreference;
PreferredShortcuts.saveUserShortcutType(mContext, twoFingerTripleTapShortcut);
@@ -783,13 +788,13 @@
createEditShortcutDialog(fragment.getActivity()));
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
- assertThat(checkboxValue).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
+ assertThat(checkboxValue).isEqualTo(TWOFINGER_DOUBLETAP);
}
@Test
public void restoreValueFromSavedInstanceState_assignToVariable() {
final Bundle fragmentState = createFragmentSavedInstanceState(
- UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
+ HARDWARE | TRIPLETAP);
ToggleScreenMagnificationPreferenceFragment fragment = mFragController.get();
// Had to use reflection to pass the savedInstanceState when launching the fragment
ReflectionHelpers.setField(fragment, "mSavedFragmentState", fragmentState);
@@ -804,14 +809,14 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
assertThat(value).isEqualTo(6);
- assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
+ assertThat(expectedType).isEqualTo(HARDWARE | TRIPLETAP);
}
@Test
@EnableFlags(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
public void restoreValueFromSavedInstanceState_twoFingerTripleTap_assignToVariable() {
final Bundle fragmentState =
- createFragmentSavedInstanceState(UserShortcutType.TWOFINGER_DOUBLETAP);
+ createFragmentSavedInstanceState(TWOFINGER_DOUBLETAP);
ToggleScreenMagnificationPreferenceFragment fragment = mFragController.get();
// Had to use reflection to pass the savedInstanceState when launching the fragment
ReflectionHelpers.setField(fragment, "mSavedFragmentState", fragmentState);
@@ -825,8 +830,8 @@
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
- assertThat(value).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
- assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
+ assertThat(value).isEqualTo(TWOFINGER_DOUBLETAP);
+ assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
}
@Test
@@ -1069,7 +1074,7 @@
public void getShortcutTypeSummary_shortcutSummaryIsCorrectlySet() {
final PreferredShortcut userPreferredShortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME,
- UserShortcutType.HARDWARE | UserShortcutType.QUICK_SETTINGS);
+ HARDWARE | QUICK_SETTINGS);
putUserShortcutTypeIntoSharedPreference(mContext, userPreferredShortcut);
final ShortcutPreference shortcutPreference =
new ShortcutPreference(mContext, /* attrs= */ null);