Merge "Refactoring Accessibility settings to use ShortcutConstants.UserShortcutType" into main
This commit is contained in:
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
|
@@ -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(
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
@@ -677,13 +681,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() {
|
||||
@@ -705,12 +709,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;
|
||||
}
|
||||
@@ -730,16 +734,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);
|
||||
@@ -793,7 +797,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()));
|
||||
|
||||
@@ -814,7 +818,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);
|
||||
@@ -909,7 +913,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
|
||||
|
||||
@VisibleForTesting
|
||||
void saveNonEmptyUserShortcutType(int type) {
|
||||
if (type == UserShortcutType.EMPTY) {
|
||||
if (type == DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -996,7 +1000,7 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
|
||||
*/
|
||||
@ShortcutConstants.UserShortcutType
|
||||
protected int getDefaultShortcutTypes() {
|
||||
return ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
return SOFTWARE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
@@ -51,13 +57,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;
|
||||
@@ -365,19 +371,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;
|
||||
@@ -427,18 +433,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,28 +535,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);
|
||||
@@ -573,7 +579,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()));
|
||||
|
||||
@@ -673,7 +679,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);
|
||||
@@ -708,7 +714,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
|
||||
|
||||
@VisibleForTesting
|
||||
void saveNonEmptyUserShortcutType(int type) {
|
||||
if (type == UserShortcutType.EMPTY) {
|
||||
if (type == DEFAULT) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -719,25 +725,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -757,14 +763,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,
|
||||
@@ -790,7 +796,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)
|
||||
@@ -804,25 +810,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -842,14 +848,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,
|
||||
@@ -884,20 +890,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;
|
||||
@@ -905,13 +911,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;
|
||||
@@ -937,19 +943,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;
|
||||
@@ -964,7 +970,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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user