Merge "[Flag cleanup] edit_shortcuts_in_full_screen is always on now" into main

This commit is contained in:
Chun-Ku Lin
2024-07-26 17:46:52 +00:00
committed by Android (Google) Code Review
69 changed files with 31 additions and 5444 deletions

View File

@@ -19,53 +19,22 @@ package com.android.settings.accessibility;
import static com.android.settings.accessibility.ItemInfoArrayAdapter.ItemInfo;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.icu.text.MessageFormat;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import com.android.server.accessibility.Flags;
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.utils.AnnotationSpan;
import com.android.settingslib.widget.LottieColorUtils;
import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieDrawable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
/**
* Utility class for creating the edit dialog.
*/
@@ -75,25 +44,20 @@ public class AccessibilityDialogUtils {
/** Denotes the dialog emuns for show dialog. */
@Retention(RetentionPolicy.SOURCE)
public @interface DialogEnums {
/** OPEN: Settings > Accessibility > Any toggle service > Shortcut > Settings. */
int EDIT_SHORTCUT = 1;
/** OPEN: Settings > Accessibility > Magnification > Shortcut > Settings. */
int MAGNIFICATION_EDIT_SHORTCUT = 1001;
/**
* OPEN: Settings > Accessibility > Downloaded toggle service > Toggle use service to
* enable service.
*/
int ENABLE_WARNING_FROM_TOGGLE = 1002;
/** OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut checkbox. */
/**
* OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut options
* settings.
*/
int ENABLE_WARNING_FROM_SHORTCUT = 1003;
/**
* OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut checkbox
* toggle.
* OPEN: Settings > Accessibility > Downloaded toggle service > Shortcut toggle
*/
int ENABLE_WARNING_FROM_SHORTCUT_TOGGLE = 1004;
@@ -127,83 +91,6 @@ public class AccessibilityDialogUtils {
int DIALOG_RESET_SETTINGS = 1009;
}
/**
* IntDef enum for dialog type that indicates different dialog for user to choose the shortcut
* type.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({
DialogType.EDIT_SHORTCUT_GENERIC,
DialogType.EDIT_SHORTCUT_GENERIC_SUW,
DialogType.EDIT_SHORTCUT_MAGNIFICATION,
DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW,
})
public @interface DialogType {
int EDIT_SHORTCUT_GENERIC = 0;
int EDIT_SHORTCUT_GENERIC_SUW = 1;
int EDIT_SHORTCUT_MAGNIFICATION = 2;
int EDIT_SHORTCUT_MAGNIFICATION_SUW = 3;
}
/**
* Method to show the edit shortcut dialog.
*
* @param context A valid context
* @param dialogType The type of edit shortcut dialog
* @param dialogTitle The title of edit shortcut dialog
* @param listener The listener to determine the action of edit shortcut dialog
* @return A edit shortcut dialog for showing
*/
public static AlertDialog showEditShortcutDialog(Context context, int dialogType,
CharSequence dialogTitle, DialogInterface.OnClickListener listener) {
final AlertDialog alertDialog = createDialog(context, dialogType, dialogTitle, listener);
alertDialog.show();
setScrollIndicators(alertDialog);
return alertDialog;
}
/**
* Updates the shortcut content in edit shortcut dialog.
*
* @param context A valid context
* @param editShortcutDialog Need to be a type of edit shortcut dialog
* @return True if the update is successful
*/
public static boolean updateShortcutInDialog(Context context,
Dialog editShortcutDialog) {
final View container = editShortcutDialog.findViewById(R.id.container_layout);
if (container != null) {
initSoftwareShortcut(context, container);
initHardwareShortcut(context, container);
return true;
}
return false;
}
private static AlertDialog createDialog(Context context, int dialogType,
CharSequence dialogTitle, DialogInterface.OnClickListener listener) {
final AlertDialog alertDialog = new AlertDialog.Builder(context)
.setView(createEditDialogContentView(context, dialogType))
.setTitle(dialogTitle)
.setPositiveButton(R.string.save, listener)
.setNegativeButton(R.string.cancel,
(DialogInterface dialog, int which) -> dialog.dismiss())
.create();
return alertDialog;
}
/**
* Sets the scroll indicators for dialog view. The indicators appears while content view is
* out of vision for vertical scrolling.
*/
private static void setScrollIndicators(AlertDialog dialog) {
final ScrollView scrollView = dialog.findViewById(R.id.container_layout);
setScrollIndicators(scrollView);
}
/**
* Sets the scroll indicators for dialog view. The indicators appear while content view is
* out of vision for vertical scrolling.
@@ -217,284 +104,6 @@ public class AccessibilityDialogUtils {
View.SCROLL_INDICATOR_TOP | View.SCROLL_INDICATOR_BOTTOM);
}
/**
* Get a content View for the edit shortcut dialog.
*
* @param context A valid context
* @param dialogType The type of edit shortcut dialog
* @return A content view suitable for viewing
*/
private static View createEditDialogContentView(Context context, int dialogType) {
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
View contentView = null;
switch (dialogType) {
case DialogType.EDIT_SHORTCUT_GENERIC:
contentView = inflater.inflate(
R.layout.accessibility_edit_shortcut, null);
initSoftwareShortcut(context, contentView);
initHardwareShortcut(context, contentView);
break;
case DialogType.EDIT_SHORTCUT_GENERIC_SUW:
contentView = inflater.inflate(
R.layout.accessibility_edit_shortcut, null);
initSoftwareShortcutForSUW(context, contentView);
initHardwareShortcut(context, contentView);
break;
case DialogType.EDIT_SHORTCUT_MAGNIFICATION:
contentView = inflater.inflate(
R.layout.accessibility_edit_shortcut_magnification, null);
initSoftwareShortcut(context, contentView);
initHardwareShortcut(context, contentView);
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
initTwoFingerDoubleTapMagnificationShortcut(context, contentView);
}
initMagnifyShortcut(context, contentView);
initAdvancedWidget(contentView);
break;
case DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW:
contentView = inflater.inflate(
R.layout.accessibility_edit_shortcut_magnification, null);
initSoftwareShortcutForSUW(context, contentView);
initHardwareShortcut(context, contentView);
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
initTwoFingerDoubleTapMagnificationShortcut(context, contentView);
}
initMagnifyShortcut(context, contentView);
initAdvancedWidget(contentView);
break;
default:
throw new IllegalArgumentException();
}
return contentView;
}
private static void setupShortcutWidget(View view, CharSequence titleText,
CharSequence summaryText, @DrawableRes int imageResId) {
setupShortcutWidgetWithTitleAndSummary(view, titleText, summaryText);
setupShortcutWidgetWithImageResource(view, imageResId);
}
private static void setupShortcutWidgetWithImageRawResource(Context context,
View view, CharSequence titleText,
CharSequence summaryText, @RawRes int imageRawResId) {
setupShortcutWidgetWithTitleAndSummary(view, titleText, summaryText);
setupShortcutWidgetWithImageRawResource(context, view, imageRawResId);
}
private static void setupShortcutWidgetWithTitleAndSummary(View view, CharSequence titleText,
CharSequence summaryText) {
final CheckBox checkBox = view.findViewById(R.id.checkbox);
checkBox.setText(titleText);
final TextView summary = view.findViewById(R.id.summary);
if (TextUtils.isEmpty(summaryText)) {
summary.setVisibility(View.GONE);
} else {
summary.setText(summaryText);
summary.setMovementMethod(LinkMovementMethod.getInstance());
summary.setFocusable(false);
}
}
private static void setupShortcutWidgetWithImageResource(View view,
@DrawableRes int imageResId) {
final ImageView imageView = view.findViewById(R.id.image);
imageView.setImageResource(imageResId);
}
private static void setupShortcutWidgetWithImageRawResource(Context context, View view,
@RawRes int imageRawResId) {
final LottieAnimationView lottieView = view.findViewById(R.id.image);
lottieView.setFailureListener(
result -> Log.w(TAG, "Invalid image raw resource id: " + imageRawResId,
result));
lottieView.setAnimation(imageRawResId);
lottieView.setRepeatCount(LottieDrawable.INFINITE);
LottieColorUtils.applyDynamicColors(context, lottieView);
lottieView.playAnimation();
}
private static void initSoftwareShortcutForSUW(Context context, View view) {
final View dialogView = view.findViewById(R.id.software_shortcut);
final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_software);
final TextView summary = dialogView.findViewById(R.id.summary);
final int lineHeight = summary.getLineHeight();
setupShortcutWidget(dialogView, title,
retrieveSoftwareShortcutSummaryForSUW(context, lineHeight),
retrieveSoftwareShortcutImageResId(context));
}
private static void initSoftwareShortcut(Context context, View view) {
final View dialogView = view.findViewById(R.id.software_shortcut);
final TextView summary = dialogView.findViewById(R.id.summary);
final int lineHeight = summary.getLineHeight();
setupShortcutWidget(dialogView,
retrieveTitle(context),
retrieveSoftwareShortcutSummary(context, lineHeight),
retrieveSoftwareShortcutImageResId(context));
}
private static void initHardwareShortcut(Context context, View view) {
final View dialogView = view.findViewById(R.id.hardware_shortcut);
final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_hardware);
final CharSequence summary = context.getText(
R.string.accessibility_shortcut_edit_dialog_summary_hardware);
setupShortcutWidget(dialogView, title, summary,
R.drawable.a11y_shortcut_type_hardware);
}
private static void initMagnifyShortcut(Context context, View view) {
final View dialogView = view.findViewById(R.id.triple_tap_shortcut);
final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_triple_tap);
String summary = context.getString(
R.string.accessibility_shortcut_edit_dialog_summary_triple_tap);
// Format the number '3' in the summary.
final Object[] arguments = {3};
summary = MessageFormat.format(summary, arguments);
setupShortcutWidgetWithImageRawResource(context, dialogView, title, summary,
R.raw.a11y_shortcut_type_triple_tap);
}
private static void initTwoFingerDoubleTapMagnificationShortcut(Context context, View view) {
// TODO(b/306153204): Update shortcut string and image when UX provides them
final View dialogView = view.findViewById(R.id.two_finger_triple_tap_shortcut);
final CharSequence title = context.getText(
R.string.accessibility_shortcut_edit_dialog_title_two_finger_double_tap);
String summary = context.getString(
R.string.accessibility_shortcut_edit_dialog_summary_two_finger_double_tap);
// Format the number '2' in the summary.
final Object[] arguments = {2};
summary = MessageFormat.format(summary, arguments);
setupShortcutWidgetWithImageRawResource(context, dialogView, title, summary,
R.raw.a11y_shortcut_type_triple_tap);
dialogView.setVisibility(View.VISIBLE);
}
private static void initAdvancedWidget(View view) {
final LinearLayout advanced = view.findViewById(R.id.advanced_shortcut);
final View tripleTap = view.findViewById(R.id.triple_tap_shortcut);
advanced.setOnClickListener((View v) -> {
advanced.setVisibility(View.GONE);
tripleTap.setVisibility(View.VISIBLE);
});
}
private static CharSequence retrieveSoftwareShortcutSummaryForSUW(Context context,
int lineHeight) {
final SpannableStringBuilder sb = new SpannableStringBuilder();
if (!AccessibilityUtil.isFloatingMenuEnabled(context)) {
sb.append(getSummaryStringWithIcon(context, lineHeight));
}
return sb;
}
private static CharSequence retrieveTitle(Context context) {
int resId;
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
resId = R.string.accessibility_shortcut_edit_dialog_title_software;
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = R.string.accessibility_shortcut_edit_dialog_title_software_by_gesture;
} else {
resId = R.string.accessibility_shortcut_edit_dialog_title_software;
}
return context.getText(resId);
}
private static CharSequence retrieveSoftwareShortcutSummary(Context context, int lineHeight) {
final SpannableStringBuilder sb = new SpannableStringBuilder();
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
sb.append(getCustomizeAccessibilityButtonLink(context));
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
final int resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.string.accessibility_shortcut_edit_dialog_summary_software_gesture_talkback
: R.string.accessibility_shortcut_edit_dialog_summary_software_gesture;
sb.append(context.getText(resId));
sb.append("\n\n");
sb.append(getCustomizeAccessibilityButtonLink(context));
} else {
sb.append(getSummaryStringWithIcon(context, lineHeight));
sb.append("\n\n");
sb.append(getCustomizeAccessibilityButtonLink(context));
}
return sb;
}
private static int retrieveSoftwareShortcutImageResId(Context context) {
int resId;
if (AccessibilityUtil.isFloatingMenuEnabled(context)) {
resId = R.drawable.a11y_shortcut_type_software_floating;
} else if (AccessibilityUtil.isGestureNavigateEnabled(context)) {
resId = AccessibilityUtil.isTouchExploreEnabled(context)
? R.drawable.a11y_shortcut_type_software_gesture_talkback
: R.drawable.a11y_shortcut_type_software_gesture;
} else {
resId = R.drawable.a11y_shortcut_type_software;
}
return resId;
}
private static CharSequence getCustomizeAccessibilityButtonLink(Context context) {
final View.OnClickListener linkListener = v -> new SubSettingLauncher(context)
.setDestination(AccessibilityButtonFragment.class.getName())
.setSourceMetricsCategory(
SettingsEnums.SWITCH_SHORTCUT_DIALOG_ACCESSIBILITY_BUTTON_SETTINGS)
.launch();
final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, linkListener);
return AnnotationSpan.linkify(context.getText(
R.string.accessibility_shortcut_edit_dialog_summary_software_floating), linkInfo);
}
private static SpannableString getSummaryStringWithIcon(Context context, int lineHeight) {
final String summary = context
.getString(R.string.accessibility_shortcut_edit_dialog_summary_software);
final SpannableString spannableMessage = SpannableString.valueOf(summary);
// Icon
final int indexIconStart = summary.indexOf("%s");
final int indexIconEnd = indexIconStart + 2;
final Drawable icon = context.getDrawable(R.drawable.ic_accessibility_new);
final ImageSpan imageSpan = new ImageSpan(icon);
imageSpan.setContentDescription("");
icon.setBounds(0, 0, lineHeight, lineHeight);
spannableMessage.setSpan(
imageSpan, indexIconStart, indexIconEnd,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spannableMessage;
}
/**
* Returns the color associated with the specified attribute in the context's theme.
*/
@ColorInt
private static int getThemeAttrColor(final Context context, final int attributeColor) {
final int colorResId = getAttrResourceId(context, attributeColor);
return ContextCompat.getColor(context, colorResId);
}
/**
* Returns the identifier of the resolved resource assigned to the given attribute.
*/
private static int getAttrResourceId(final Context context, final int attributeColor) {
final int[] attrs = {attributeColor};
final TypedArray typedArray = context.obtainStyledAttributes(attrs);
final int colorResId = typedArray.getResourceId(0, 0);
typedArray.recycle();
return colorResId;
}
/**
* Creates a dialog with the given view.
*

View File

@@ -39,7 +39,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
@@ -66,19 +65,13 @@ import java.util.Locale;
public abstract class AccessibilityShortcutPreferenceFragment extends RestrictedDashboardFragment
implements ShortcutPreference.OnClickCallback {
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
protected static final int NOT_SET = -1;
// Save user's shortcutType value when savedInstance has value (e.g. device rotated).
protected int mSavedCheckBoxValue = NOT_SET;
protected ShortcutPreference mShortcutPreference;
protected Dialog mDialog;
private AccessibilityManager.TouchExplorationStateChangeListener
mTouchExplorationStateChangeListener;
private AccessibilitySettingsContentObserver mSettingsContentObserver;
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
private boolean mNeedsQSTooltipReshow = false;
private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;
@@ -105,10 +98,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
// Restore the user shortcut type and tooltip.
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(KEY_SAVED_USER_SHORTCUT_TYPE)) {
mSavedCheckBoxValue = savedInstanceState.getInt(KEY_SAVED_USER_SHORTCUT_TYPE,
NOT_SET);
}
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
}
@@ -153,7 +142,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
getPreferenceScreen().addPreference(mShortcutPreference);
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
removeDialog(DialogEnums.EDIT_SHORTCUT);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
};
@@ -185,8 +173,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
mSettingsContentObserver.register(getContentResolver());
updateShortcutPreferenceData();
updateShortcutPreference();
updateEditShortcutDialogIfNeeded();
}
@Override
@@ -200,10 +186,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
@Override
public void onSaveInstanceState(Bundle outState) {
final int value = getShortcutTypeCheckBoxValue();
if (value != NOT_SET) {
outState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE, value);
}
final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
@@ -215,15 +197,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
@Override
public Dialog onCreateDialog(int dialogId) {
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
? AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC_SUW :
AccessibilityDialogUtils.DialogType.EDIT_SHORTCUT_GENERIC;
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(
getPrefContext(), dialogType, getShortcutTitle(),
this::callOnAlertDialogCheckboxClicked);
setupEditShortcutDialog(mDialog);
return mDialog;
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
mDialog = AccessibilityShortcutsTutorial
@@ -250,8 +223,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
@Override
public int getDialogMetricsCategory(int dialogId) {
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_EDIT_SHORTCUT;
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
return SettingsEnums.DIALOG_ACCESSIBILITY_TUTORIAL;
default:
@@ -261,17 +232,13 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
@Override
public void onSettingsClicked(ShortcutPreference preference) {
if (Flags.editShortcutsInFullScreen()) {
EditShortcutsPreferenceFragment.showEditShortcutScreen(
getContext(),
getMetricsCategory(),
getShortcutTitle(),
getComponentName(),
getIntent()
);
} else {
showDialog(DialogEnums.EDIT_SHORTCUT);
}
EditShortcutsPreferenceFragment.showEditShortcutScreen(
getContext(),
getMetricsCategory(),
getShortcutTitle(),
getComponentName(),
getIntent()
);
}
@Override
@@ -301,38 +268,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
return KEY_SHORTCUT_PREFERENCE;
}
@VisibleForTesting
void setupEditShortcutDialog(Dialog dialog) {
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogSoftwareView, mSoftwareTypeCheckBox);
final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogHardwareView, mHardwareTypeCheckBox);
updateEditShortcutDialogCheckBox();
}
/**
* Returns accumulated {@link UserShortcutType} checkbox value or
* {@code NOT_SET} if checkboxes did not exist.
*/
protected int getShortcutTypeCheckBoxValue() {
if (mSoftwareTypeCheckBox == null || mHardwareTypeCheckBox == null) {
return NOT_SET;
}
int value = DEFAULT;
if (mSoftwareTypeCheckBox.isChecked()) {
value |= SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
value |= HARDWARE;
}
return value;
}
/**
* Returns the shortcut type list which has been checked by user.
*/
@@ -364,35 +299,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
showQuickSettingsTooltipIfNeeded();
}
/**
* This method will be invoked when a button in the edit shortcut dialog is clicked.
*
* @param dialog The dialog that received the click
* @param which The button that was clicked
*/
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
if (getComponentName() == null) {
return;
}
final int value = getShortcutTypeCheckBoxValue();
saveNonEmptyUserShortcutType(value);
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, getComponentName());
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, getComponentName());
final boolean shortcutAssigned = value != DEFAULT;
mShortcutPreference.setChecked(shortcutAssigned);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
if (mHardwareTypeCheckBox.isChecked()) {
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
}
// Show the quick setting tooltip if the shortcut assigned in the first time
if (shortcutAssigned) {
showQuickSettingsTooltipIfNeeded();
}
}
@VisibleForTesting
void initGeneralCategory() {
final PreferenceCategory generalCategory = new PreferenceCategory(getPrefContext());
@@ -402,24 +308,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
getPreferenceScreen().addPreference(generalCategory);
}
private void updateEditShortcutDialogIfNeeded() {
if (mDialog == null || !mDialog.isShowing()) {
return;
}
AccessibilityDialogUtils.updateShortcutInDialog(getContext(), mDialog);
}
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
if (type == DEFAULT) {
return;
}
final PreferredShortcut shortcut = new PreferredShortcut(
getComponentName().flattenToString(), type);
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
}
/**
* Overrides to return customized description for general category above shortcut
*
@@ -442,11 +330,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
return false;
}
private void setDialogTextAreaClickListener(View dialogView, CheckBox checkBox) {
final View dialogTextArea = dialogView.findViewById(R.id.container);
dialogTextArea.setOnClickListener(v -> checkBox.toggle());
}
protected CharSequence getShortcutTypeSummary(Context context) {
if (!mShortcutPreference.isSettingsEditable()) {
return context.getText(R.string.accessibility_shortcut_edit_dialog_title_hardware);
@@ -486,28 +369,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
null, LocaleUtils.getConcatenatedString(list));
}
private void updateEditShortcutDialogCheckBox() {
// If it is during onConfigChanged process then restore the value, or get the saved value
// when shortcutPreference is checked.
int value = restoreOnConfigChangedValue();
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
: DEFAULT;
}
mSoftwareTypeCheckBox.setChecked(
hasShortcutType(value, SOFTWARE));
mHardwareTypeCheckBox.setChecked(
hasShortcutType(value, HARDWARE));
}
private int restoreOnConfigChangedValue() {
final int savedValue = mSavedCheckBoxValue;
mSavedCheckBoxValue = NOT_SET;
return savedValue;
}
private boolean hasShortcutType(int value, @UserShortcutType int type) {
return (value & type) == type;
}

View File

@@ -17,7 +17,6 @@
package com.android.settings.accessibility;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.DialogInterface;
import com.android.settingslib.accessibility.AccessibilityUtils;
@@ -63,17 +62,4 @@ public class InvisibleToggleAccessibilityServicePreferenceFragment extends
super.onAllowButtonFromShortcutToggleClicked();
AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, true);
}
/**
* {@inheritDoc}
*
* Enables accessibility service when shortcutPreference is checked.
*/
@Override
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
super.callOnAlertDialogCheckboxClicked(dialog, which);
final boolean enabled = mShortcutPreference.isChecked();
AccessibilityUtils.setAccessibilityServiceState(getContext(), mComponentName, enabled);
}
}

View File

@@ -40,7 +40,6 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.CompoundButton;
@@ -411,17 +410,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
}
}
private void onDialogButtonFromEnableToggleClicked(View view) {
final int viewId = view.getId();
if (viewId == R.id.permission_enable_allow_button) {
onAllowButtonFromEnableToggleClicked();
} else if (viewId == R.id.permission_enable_deny_button) {
onDenyButtonFromEnableToggleClicked();
} else {
throw new IllegalArgumentException("Unexpected view id");
}
}
private void onDialogButtonFromUninstallClicked() {
mWarningDialog.dismiss();
final Intent uninstallIntent = createUninstallPackageActivityIntent();
@@ -491,17 +479,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
mWarningDialog.dismiss();
}
void onDialogButtonFromShortcutToggleClicked(View view) {
final int viewId = view.getId();
if (viewId == R.id.permission_enable_allow_button) {
onAllowButtonFromShortcutToggleClicked();
} else if (viewId == R.id.permission_enable_deny_button) {
onDenyButtonFromShortcutToggleClicked();
} else {
throw new IllegalArgumentException("Unexpected view id");
}
}
void onAllowButtonFromShortcutToggleClicked() {
mShortcutPreference.setChecked(true);
@@ -526,17 +503,13 @@ public class ToggleAccessibilityServicePreferenceFragment extends
private void onAllowButtonFromShortcutClicked() {
mIsDialogShown.set(false);
if (Flags.editShortcutsInFullScreen()) {
EditShortcutsPreferenceFragment.showEditShortcutScreen(
getContext(),
getMetricsCategory(),
getShortcutTitle(),
mComponentName,
getIntent()
);
} else {
showPopupDialog(DialogEnums.EDIT_SHORTCUT);
}
EditShortcutsPreferenceFragment.showEditShortcutScreen(
getContext(),
getMetricsCategory(),
getShortcutTitle(),
mComponentName,
getIntent()
);
if (mWarningDialog != null) {
mWarningDialog.dismiss();

View File

@@ -47,7 +47,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
@@ -62,7 +61,6 @@ 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.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.dashboard.DashboardFragment;
@@ -88,11 +86,9 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
public static final String KEY_GENERAL_CATEGORY = "general_categories";
public static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
public static final int NOT_SET = -1;
protected static final String KEY_TOP_INTRO_PREFERENCE = "top_intro";
protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service";
protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description";
protected static final String KEY_SAVED_USER_SHORTCUT_TYPE = "shortcut_type";
protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";
protected static final String KEY_SAVED_QS_TOOLTIP_TYPE = "qs_tooltip_type";
protected static final String KEY_ANIMATED_IMAGE = "animated_image";
@@ -117,15 +113,10 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
protected Uri mImageUri;
protected CharSequence mHtmlDescription;
protected CharSequence mTopIntroTitle;
// Save user's shortcutType value when savedInstance has value (e.g. device rotated).
protected int mSavedCheckBoxValue = NOT_SET;
private CharSequence mDescription;
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private AccessibilitySettingsContentObserver mSettingsContentObserver;
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
private boolean mNeedsQSTooltipReshow = false;
private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;
@@ -148,10 +139,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
onProcessArguments(getArguments());
// Restore the user shortcut type and tooltip.
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(KEY_SAVED_USER_SHORTCUT_TYPE)) {
mSavedCheckBoxValue = savedInstanceState.getInt(KEY_SAVED_USER_SHORTCUT_TYPE,
NOT_SET);
}
if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
}
@@ -209,7 +196,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
updateToggleServiceTitle(mToggleServiceSwitchPreference);
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
removeDialog(DialogEnums.EDIT_SHORTCUT);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
};
@@ -220,14 +206,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
@Override
public Dialog onCreateDialog(int dialogId) {
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
final int dialogType = isAnySetupWizard()
? DialogType.EDIT_SHORTCUT_GENERIC_SUW : DialogType.EDIT_SHORTCUT_GENERIC;
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(
getPrefContext(), dialogType, getShortcutTitle(),
this::callOnAlertDialogCheckboxClicked);
setupEditShortcutDialog(mDialog);
return mDialog;
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
if (isAnySetupWizard()) {
mDialog = AccessibilityShortcutsTutorial
@@ -278,8 +256,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
mSettingsContentObserver.register(getContentResolver());
updateShortcutPreferenceData();
updateShortcutPreference();
updateEditShortcutDialogIfNeeded();
}
@Override
@@ -293,10 +269,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
@Override
public void onSaveInstanceState(Bundle outState) {
final int value = getShortcutTypeCheckBoxValue();
if (value != NOT_SET) {
outState.putInt(KEY_SAVED_USER_SHORTCUT_TYPE, value);
}
final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
@@ -318,8 +290,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
@Override
public int getDialogMetricsCategory(int dialogId) {
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
return SettingsEnums.DIALOG_ACCESSIBILITY_SERVICE_EDIT_SHORTCUT;
case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
return SettingsEnums.DIALOG_ACCESSIBILITY_TUTORIAL;
default:
@@ -656,69 +626,10 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
mFooterPreferenceController.displayPreference(screen);
}
@VisibleForTesting
void setupEditShortcutDialog(Dialog dialog) {
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogSoftwareView, mSoftwareTypeCheckBox);
final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogHardwareView, mHardwareTypeCheckBox);
updateEditShortcutDialogCheckBox();
}
private void setDialogTextAreaClickListener(View dialogView, CheckBox checkBox) {
final View dialogTextArea = dialogView.findViewById(R.id.container);
dialogTextArea.setOnClickListener(v -> checkBox.toggle());
}
private void updateEditShortcutDialogCheckBox() {
// If it is during onConfigChanged process then restore the value, or get the saved value
// when shortcutPreference is checked.
int value = restoreOnConfigChangedValue();
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
: DEFAULT;
}
mSoftwareTypeCheckBox.setChecked(
hasShortcutType(value, SOFTWARE));
mHardwareTypeCheckBox.setChecked(
hasShortcutType(value, HARDWARE));
}
private int restoreOnConfigChangedValue() {
final int savedValue = mSavedCheckBoxValue;
mSavedCheckBoxValue = NOT_SET;
return savedValue;
}
private boolean hasShortcutType(int value, @UserShortcutType int type) {
return (value & type) == type;
}
/**
* Returns accumulated {@link UserShortcutType} checkbox value or {@code NOT_SET} if checkboxes
* did not exist.
*/
protected int getShortcutTypeCheckBoxValue() {
if (mSoftwareTypeCheckBox == null || mHardwareTypeCheckBox == null) {
return NOT_SET;
}
int value = DEFAULT;
if (mSoftwareTypeCheckBox.isChecked()) {
value |= SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
value |= HARDWARE;
}
return value;
}
protected CharSequence getShortcutTypeSummary(Context context) {
if (!mShortcutPreference.isSettingsEditable()) {
return context.getText(R.string.accessibility_shortcut_edit_dialog_title_hardware);
@@ -782,35 +693,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
showQuickSettingsTooltipIfNeeded();
}
/**
* This method will be invoked when a button in the edit shortcut dialog is clicked.
*
* @param dialog The dialog that received the click
* @param which The button that was clicked
*/
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
if (mComponentName == null) {
return;
}
final int value = getShortcutTypeCheckBoxValue();
saveNonEmptyUserShortcutType(value);
AccessibilityUtil.optInAllValuesToSettings(getPrefContext(), value, mComponentName);
AccessibilityUtil.optOutAllValuesFromSettings(getPrefContext(), ~value, mComponentName);
final boolean shortcutAssigned = value != DEFAULT;
mShortcutPreference.setChecked(shortcutAssigned);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
if (mHardwareTypeCheckBox.isChecked()) {
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
}
// Show the quick setting tooltip if the shortcut assigned in the first time
if (shortcutAssigned) {
showQuickSettingsTooltipIfNeeded();
}
}
protected void updateShortcutPreferenceData() {
if (mComponentName == null) {
return;
@@ -861,13 +743,9 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
@Override
public void onSettingsClicked(ShortcutPreference preference) {
if (com.android.settings.accessibility.Flags.editShortcutsInFullScreen()) {
EditShortcutsPreferenceFragment.showEditShortcutScreen(
requireContext(), getMetricsCategory(), getShortcutTitle(),
mComponentName, getIntent());
} else {
showDialog(DialogEnums.EDIT_SHORTCUT);
}
EditShortcutsPreferenceFragment.showEditShortcutScreen(
requireContext(), getMetricsCategory(), getShortcutTitle(),
mComponentName, getIntent());
}
/**
@@ -904,24 +782,6 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
}
}
private void updateEditShortcutDialogIfNeeded() {
if (mDialog == null || !mDialog.isShowing()) {
return;
}
AccessibilityDialogUtils.updateShortcutInDialog(getContext(), mDialog);
}
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
if (type == DEFAULT) {
return;
}
final PreferredShortcut shortcut = new PreferredShortcut(
mComponentName.flattenToString(), type);
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
}
/**
* Shows the quick settings tooltip if the quick settings feature is assigned. The tooltip only
* shows once.

View File

@@ -33,7 +33,6 @@ import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.icu.text.CaseMap;
import android.icu.text.MessageFormat;
@@ -48,7 +47,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
import android.widget.CheckBox;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
@@ -62,7 +60,6 @@ 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.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.utils.LocaleUtils;
@@ -92,10 +89,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
// TODO(b/147021230): Move duplicated functions with android/internal/accessibility into util.
private TouchExplorationStateChangeListener mTouchExplorationStateChangeListener;
private CheckBox mSoftwareTypeCheckBox;
private CheckBox mHardwareTypeCheckBox;
private CheckBox mTripleTapTypeCheckBox;
@Nullable private CheckBox mTwoFingerTripleTapTypeCheckBox;
private DialogCreatable mDialogDelegate;
@Nullable
@@ -119,7 +112,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
.appendPath(String.valueOf(R.raw.a11y_magnification_banner))
.build();
mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
removeDialog(DialogEnums.EDIT_SHORTCUT);
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
};
@@ -184,15 +176,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
case DialogEnums.GESTURE_NAVIGATION_TUTORIAL:
return AccessibilityShortcutsTutorial
.showAccessibilityGestureTutorialDialog(getPrefContext());
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
final CharSequence dialogTitle = getShortcutTitle();
final int dialogType = mInSetupWizard
? DialogType.EDIT_SHORTCUT_MAGNIFICATION_SUW
: DialogType.EDIT_SHORTCUT_MAGNIFICATION;
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(getPrefContext(),
dialogType, dialogTitle, this::callOnAlertDialogCheckboxClicked);
setupMagnificationEditShortcutDialog(mDialog);
return mDialog;
default:
return super.onCreateDialog(dialogId);
}
@@ -365,95 +348,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
mDialogDelegate = delegate;
}
@Override
protected int getShortcutTypeCheckBoxValue() {
if (mSoftwareTypeCheckBox == null || mHardwareTypeCheckBox == null) {
return NOT_SET;
}
int value = DEFAULT;
if (mSoftwareTypeCheckBox.isChecked()) {
value |= SOFTWARE;
}
if (mHardwareTypeCheckBox.isChecked()) {
value |= HARDWARE;
}
if (mTripleTapTypeCheckBox.isChecked()) {
value |= TRIPLETAP;
}
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
if (mTwoFingerTripleTapTypeCheckBox.isChecked()) {
value |= TWOFINGER_DOUBLETAP;
}
}
return value;
}
@VisibleForTesting
void setupMagnificationEditShortcutDialog(Dialog dialog) {
final View dialogSoftwareView = dialog.findViewById(R.id.software_shortcut);
mSoftwareTypeCheckBox = dialogSoftwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogSoftwareView, mSoftwareTypeCheckBox);
final View dialogHardwareView = dialog.findViewById(R.id.hardware_shortcut);
mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogHardwareView, mHardwareTypeCheckBox);
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
final View dialogTwoFignerTripleTapView =
dialog.findViewById(R.id.two_finger_triple_tap_shortcut);
mTwoFingerTripleTapTypeCheckBox = dialogTwoFignerTripleTapView.findViewById(
R.id.checkbox);
setDialogTextAreaClickListener(
dialogTwoFignerTripleTapView, mTwoFingerTripleTapTypeCheckBox);
}
final View dialogTripleTapView = dialog.findViewById(R.id.triple_tap_shortcut);
mTripleTapTypeCheckBox = dialogTripleTapView.findViewById(R.id.checkbox);
setDialogTextAreaClickListener(dialogTripleTapView, mTripleTapTypeCheckBox);
final View advancedView = dialog.findViewById(R.id.advanced_shortcut);
if (mTripleTapTypeCheckBox.isChecked()) {
advancedView.setVisibility(View.GONE);
dialogTripleTapView.setVisibility(View.VISIBLE);
}
updateMagnificationEditShortcutDialogCheckBox();
}
private void setDialogTextAreaClickListener(View dialogView, CheckBox checkBox) {
final View dialogTextArea = dialogView.findViewById(R.id.container);
dialogTextArea.setOnClickListener(v -> checkBox.toggle());
}
private void updateMagnificationEditShortcutDialogCheckBox() {
// If it is during onConfigChanged process then restore the value, or get the saved value
// when shortcutPreference is checked.
int value = restoreOnConfigChangedValue();
if (value == NOT_SET) {
final int lastNonEmptyUserShortcutType = getUserPreferredShortcutTypes();
value = mShortcutPreference.isChecked() ? lastNonEmptyUserShortcutType
: DEFAULT;
}
mSoftwareTypeCheckBox.setChecked(
hasShortcutType(value, SOFTWARE));
mHardwareTypeCheckBox.setChecked(
hasShortcutType(value, HARDWARE));
mTripleTapTypeCheckBox.setChecked(
hasShortcutType(value, TRIPLETAP));
if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
mTwoFingerTripleTapTypeCheckBox.setChecked(
hasShortcutType(value, TWOFINGER_DOUBLETAP));
}
}
private int restoreOnConfigChangedValue() {
final int savedValue = mSavedCheckBoxValue;
mSavedCheckBoxValue = NOT_SET;
return savedValue;
}
private boolean hasShortcutType(int value, @UserShortcutType int type) {
return (value & type) == type;
}
@@ -572,22 +466,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
null, LocaleUtils.getConcatenatedString(list));
}
@Override
protected void callOnAlertDialogCheckboxClicked(DialogInterface dialog, int which) {
final int value = getShortcutTypeCheckBoxValue();
saveNonEmptyUserShortcutType(value);
optInAllMagnificationValuesToSettings(getPrefContext(), value);
optOutAllMagnificationValuesFromSettings(getPrefContext(), ~value);
mShortcutPreference.setChecked(value != DEFAULT);
mShortcutPreference.setSummary(
getShortcutTypeSummary(getPrefContext()));
if (mHardwareTypeCheckBox.isChecked()) {
AccessibilityUtil.skipVolumeShortcutDialogTimeoutRestriction(getPrefContext());
}
}
@Override
public int getHelpResource() {
return R.string.help_url_magnification;
@@ -613,8 +491,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_GESTURE_NAVIGATION;
case DialogEnums.ACCESSIBILITY_BUTTON_TUTORIAL:
return SettingsEnums.DIALOG_TOGGLE_SCREEN_MAGNIFICATION_ACCESSIBILITY_BUTTON;
case DialogEnums.MAGNIFICATION_EDIT_SHORTCUT:
return SettingsEnums.DIALOG_MAGNIFICATION_EDIT_SHORTCUT;
default:
return super.getDialogMetricsCategory(dialogId);
}
@@ -664,16 +540,12 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
public void onSettingsClicked(ShortcutPreference preference) {
if (com.android.settings.accessibility.Flags.editShortcutsInFullScreen()) {
EditShortcutsPreferenceFragment.showEditShortcutScreen(
requireContext(),
getMetricsCategory(),
getShortcutTitle(),
MAGNIFICATION_COMPONENT_NAME,
getIntent());
} else {
showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
}
EditShortcutsPreferenceFragment.showEditShortcutScreen(
requireContext(),
getMetricsCategory(),
getShortcutTitle(),
MAGNIFICATION_COMPONENT_NAME,
getIntent());
}
@Override
@@ -712,17 +584,6 @@ public class ToggleScreenMagnificationPreferenceFragment extends
mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
}
@VisibleForTesting
void saveNonEmptyUserShortcutType(int type) {
if (type == DEFAULT) {
return;
}
final PreferredShortcut shortcut = new PreferredShortcut(
MAGNIFICATION_CONTROLLER_NAME, type);
PreferredShortcuts.saveUserShortcutType(getPrefContext(), shortcut);
}
@VisibleForTesting
static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
if ((shortcutTypes & SOFTWARE) == SOFTWARE) {

View File

@@ -60,7 +60,6 @@ import com.android.internal.accessibility.dialog.AccessibilityTargetHelper;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.accessibility.AccessibilitySetupWizardUtils;
import com.android.settings.accessibility.Flags;
import com.android.settings.accessibility.PreferredShortcuts;
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.dashboard.DashboardFragment;
@@ -199,8 +198,7 @@ public class EditShortcutsPreferenceFragment extends DashboardFragment {
Activity activity = getActivity();
if (!activity.getIntent().getAction().equals(
Settings.ACTION_ACCESSIBILITY_SHORTCUT_SETTINGS)
|| !Flags.editShortcutsInFullScreen()) {
Settings.ACTION_ACCESSIBILITY_SHORTCUT_SETTINGS)) {
return;
}