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:
Riley Jones
2024-06-29 02:52:34 +00:00
parent ac7236ec0f
commit 8f313621aa
14 changed files with 339 additions and 319 deletions

View File

@@ -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 @@ public class AccessibilitySettings extends DashboardFragment implements
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);

View File

@@ -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);

View File

@@ -19,7 +19,11 @@ package com.android.settings.accessibility;
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 @@ public final class AccessibilityShortcutsTutorial {
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 @@ public final class AccessibilityShortcutsTutorial {
}
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 @@ public final class AccessibilityShortcutsTutorial {
}
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 @@ public final class AccessibilityShortcutsTutorial {
}
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 @@ public final class AccessibilityShortcutsTutorial {
}
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 @@ public final class AccessibilityShortcutsTutorial {
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 @@ public final class AccessibilityShortcutsTutorial {
// 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)

View File

@@ -21,6 +21,12 @@ import static android.view.WindowInsets.Type.displayCutout;
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.NonNull;
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;
@@ -81,41 +88,6 @@ public final class AccessibilityUtil {
private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
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.
*
@@ -230,11 +202,11 @@ public final class AccessibilityUtil {
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 @@ public final class AccessibilityUtil {
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 @@ public final class AccessibilityUtil {
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 @@ public final class AccessibilityUtil {
*/
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 @@ public final class AccessibilityUtil {
}
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(

View File

@@ -19,7 +19,7 @@ package com.android.settings.accessibility;
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;

View File

@@ -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.NonNull;
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 @@ public final class PreferredShortcuts {
/**
* 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 @@ public final class PreferredShortcuts {
* 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 @@ public final class PreferredShortcuts {
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 @@ public final class PreferredShortcuts {
}
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);

View File

@@ -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.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.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;
@@ -664,13 +668,13 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
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() {
@@ -692,12 +696,12 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
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;
}
@@ -717,16 +721,16 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
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);
@@ -780,7 +784,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
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()));
@@ -801,7 +805,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
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);
@@ -896,7 +900,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
if (type == UserShortcutType.EMPTY) {
if (type == DEFAULT) {
return;
}
@@ -983,7 +987,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
*/
@ShortcutConstants.UserShortcutType
protected int getDefaultShortcutTypes() {
return ShortcutConstants.UserShortcutType.SOFTWARE;
return SOFTWARE;
}
/**

View File

@@ -18,6 +18,12 @@ package com.android.settings.accessibility;
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;
@@ -50,13 +56,13 @@ import androidx.preference.PreferenceCategory;
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;
@@ -360,19 +366,19 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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;
@@ -422,18 +428,18 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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));
}
}
@@ -499,28 +505,28 @@ public class ToggleScreenMagnificationPreferenceFragment extends
// 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);
@@ -543,7 +549,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
saveNonEmptyUserShortcutType(value);
optInAllMagnificationValuesToSettings(getPrefContext(), value);
optOutAllMagnificationValuesFromSettings(getPrefContext(), ~value);
mShortcutPreference.setChecked(value != UserShortcutType.EMPTY);
mShortcutPreference.setChecked(value != DEFAULT);
mShortcutPreference.setSummary(
getShortcutTypeSummary(getPrefContext()));
@@ -643,7 +649,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@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);
@@ -678,7 +684,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
if (type == UserShortcutType.EMPTY) {
if (type == DEFAULT) {
return;
}
@@ -689,25 +695,25 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@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);
}
}
}
@@ -727,14 +733,14 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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,
@@ -760,7 +766,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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)
@@ -774,25 +780,25 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@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);
}
}
}
@@ -812,14 +818,14 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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,
@@ -854,20 +860,20 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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;
@@ -875,13 +881,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
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;
@@ -907,19 +913,19 @@ public class ToggleScreenMagnificationPreferenceFragment extends
}
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;
@@ -934,7 +940,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
// 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);

View File

@@ -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 @@ public class VolumeShortcutToggleAccessibilityServicePreferenceFragment extends
mShortcutPreference.setSummary(hardwareTitle);
mShortcutPreference.setSettingsEditable(false);
setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
setAllowedPreferredShortcutType(HARDWARE);
}
@Override
@@ -56,9 +58,9 @@ public class VolumeShortcutToggleAccessibilityServicePreferenceFragment extends
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;

View File

@@ -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 @@ public class AccessibilityShortcutPreferenceFragmentTest {
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 @@ public class AccessibilityShortcutPreferenceFragmentTest {
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 @@ public class AccessibilityShortcutPreferenceFragmentTest {
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -184,7 +187,7 @@ public class AccessibilityShortcutPreferenceFragmentTest {
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 @@ public class AccessibilityShortcutPreferenceFragmentTest {
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.HARDWARE);
assertThat(checkboxValue).isEqualTo(HARDWARE);
}
@Test
@@ -209,7 +212,7 @@ public class AccessibilityShortcutPreferenceFragmentTest {
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 @@ public class AccessibilityShortcutPreferenceFragmentTest {
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 class AccessibilityShortcutPreferenceFragmentTest {
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);

View File

@@ -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 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnTripleTapShortcut_hasOnePage() {
mShortcutTypes |= UserShortcutType.TRIPLETAP;
mShortcutTypes |= TRIPLETAP;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -114,7 +118,7 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnSoftwareShortcut_hasOnePage() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -157,8 +161,8 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnA11yGestureShortcut_linkButtonShownWithText() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ true, /* floatingButtonEnabled= */ false);
@@ -191,7 +195,7 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnA11yNavButtonShortcut_linkButtonShownWithText() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ false);
@@ -210,7 +214,7 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnFloatingButtonShortcut_linkButtonShownWithText() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= SOFTWARE;
AccessibilityTestUtils.setSoftwareShortcutMode(
mContext, /* gestureNavEnabled= */ false, /* floatingButtonEnabled= */ true);
@@ -228,7 +232,7 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnHardwareShortcut_linkButtonGone() {
mShortcutTypes |= UserShortcutType.HARDWARE;
mShortcutTypes |= HARDWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialog(mContext, mShortcutTypes, FAKE_FEATURE_NAME);
@@ -241,7 +245,7 @@ public final class AccessibilityShortcutsTutorialTest {
@Test
public void createTutorialPages_turnOnSoftwareShortcut_showFromSuW_linkButtonGone() {
mShortcutTypes |= UserShortcutType.SOFTWARE;
mShortcutTypes |= SOFTWARE;
final AlertDialog alertDialog =
createAccessibilityTutorialDialogForSetupWizard(
@@ -256,7 +260,7 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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 @@ public final class AccessibilityShortcutsTutorialTest {
@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);

View File

@@ -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 android.view.accessibility.Flags;
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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
@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 @@ public final class AccessibilityUtilTest {
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 @@ public final class AccessibilityUtilTest {
@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);
}

View File

@@ -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 androidx.test.core.app.ApplicationProvider;
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 @@ public class ToggleFeaturePreferenceFragmentTest {
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 @@ public class ToggleFeaturePreferenceFragmentTest {
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 @@ public class ToggleFeaturePreferenceFragmentTest {
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -283,7 +286,7 @@ public class ToggleFeaturePreferenceFragmentTest {
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 @@ public class ToggleFeaturePreferenceFragmentTest {
mFragment.setupEditShortcutDialog(dialog);
final int checkboxValue = mFragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.HARDWARE);
assertThat(checkboxValue).isEqualTo(HARDWARE);
}
@Test
@@ -308,7 +311,7 @@ public class ToggleFeaturePreferenceFragmentTest {
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 @@ public class ToggleFeaturePreferenceFragmentTest {
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 class ToggleFeaturePreferenceFragmentTest {
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);

View File

@@ -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;
@@ -398,7 +403,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
setMagnificationTripleTapEnabled(/* enabled= */ true);
assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
mContext, UserShortcutType.TRIPLETAP)).isTrue();
mContext, TRIPLETAP)).isTrue();
}
@Test
@@ -408,7 +413,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
mContext, UserShortcutType.TWOFINGER_DOUBLETAP)).isTrue();
mContext, TWOFINGER_DOUBLETAP)).isTrue();
}
@Test
@@ -418,13 +423,13 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -438,24 +443,24 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
@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);
}
@@ -464,7 +469,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
@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);
@@ -479,7 +484,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -491,7 +496,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
ShadowSettings.ShadowSecure.reset();
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
UserShortcutType.SOFTWARE);
SOFTWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
@@ -508,7 +513,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
UserShortcutType.SOFTWARE);
SOFTWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE,
@@ -527,7 +532,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
UserShortcutType.HARDWARE);
HARDWARE);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
@@ -545,7 +550,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(
mContext,
UserShortcutType.TRIPLETAP);
TRIPLETAP);
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE, size + 1)).isEqualTo(
@@ -560,7 +565,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -578,19 +583,19 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
}
@@ -603,7 +608,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -616,7 +621,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -636,7 +641,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
// Compare to default UserShortcutType
assertThat(expectedType).isEqualTo(UserShortcutType.SOFTWARE);
assertThat(expectedType).isEqualTo(SOFTWARE);
}
@Test
@@ -649,13 +654,13 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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();
@@ -663,7 +668,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
assertThat(expectedType).isEqualTo(UserShortcutType.TRIPLETAP);
assertThat(expectedType).isEqualTo(TRIPLETAP);
}
@Test
@@ -677,14 +682,14 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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();
@@ -692,7 +697,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
MAGNIFICATION_CONTROLLER_NAME);
assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGER_DOUBLETAP);
assertThat(expectedType).isEqualTo(TWOFINGER_DOUBLETAP);
}
@Test
@@ -707,7 +712,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
createEditShortcutDialog(fragment.getActivity()));
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.EMPTY);
assertThat(checkboxValue).isEqualTo(DEFAULT);
}
@Test
@@ -718,7 +723,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -727,7 +732,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
createEditShortcutDialog(fragment.getActivity()));
final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
assertThat(checkboxValue).isEqualTo(UserShortcutType.TRIPLETAP);
assertThat(checkboxValue).isEqualTo(TRIPLETAP);
}
@Test
@@ -739,7 +744,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -748,13 +753,13 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -769,14 +774,14 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);
@@ -790,8 +795,8 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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
@@ -1006,7 +1011,7 @@ public class ToggleScreenMagnificationPreferenceFragmentTest {
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);