Adjust edit shortcuts page to display button & gesture

Page is altered to display the FAB shortcut
and gesture shortcut simultaneously when the user is in
gesture navigation mode.
The gesture option does not display the "more options" link.
Additionally, the gesture option controller uses the GESTURE type,
which means it will read from & write to the gesture setting.
All this behavior is flag protected.

Bug: 300318311
Test: atest FloatingButtonShortcutOptionControllerTest GestureShortcutOptionControllerTest
Flag: android.provider.a11y_standalone_gesture_enabled
Change-Id: I915f05b2102ce499bb906df2c13e0870ae0a36d5
This commit is contained in:
Riley Jones
2024-07-02 03:22:41 +00:00
parent b22a9d03af
commit 1e80db4ee3
6 changed files with 109 additions and 33 deletions

View File

@@ -20,6 +20,7 @@ import static android.app.Activity.RESULT_CANCELED;
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_MODE;
import static android.provider.Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS;
import static android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED;
import static android.provider.Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS;
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED;
import static android.provider.Settings.Secure.ACCESSIBILITY_QS_TARGETS;
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
@@ -93,7 +94,8 @@ public class EditShortcutsPreferenceFragment extends DashboardFragment {
Settings.Secure.getUriFor(ACCESSIBILITY_BUTTON_MODE);
private static final Uri BUTTON_SHORTCUT_SETTING =
Settings.Secure.getUriFor(ACCESSIBILITY_BUTTON_TARGETS);
private static final Uri GESTURE_SHORTCUT_SETTING =
Settings.Secure.getUriFor(ACCESSIBILITY_GESTURE_TARGETS);
private static final Uri TRIPLE_TAP_SHORTCUT_SETTING =
Settings.Secure.getUriFor(ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
private static final Uri TWO_FINGERS_DOUBLE_TAP_SHORTCUT_SETTING =
@@ -107,6 +109,7 @@ public class EditShortcutsPreferenceFragment extends DashboardFragment {
VOLUME_KEYS_SHORTCUT_SETTING,
BUTTON_SHORTCUT_MODE_SETTING,
BUTTON_SHORTCUT_SETTING,
GESTURE_SHORTCUT_SETTING,
TRIPLE_TAP_SHORTCUT_SETTING,
TWO_FINGERS_DOUBLE_TAP_SHORTCUT_SETTING,
QUICK_SETTINGS_SHORTCUT_SETTING,
@@ -173,6 +176,8 @@ public class EditShortcutsPreferenceFragment extends DashboardFragment {
} else if (BUTTON_SHORTCUT_MODE_SETTING.equals(uri)
|| BUTTON_SHORTCUT_SETTING.equals(uri)) {
refreshSoftwareShortcutControllers();
} else if (GESTURE_SHORTCUT_SETTING.equals(uri)) {
refreshPreferenceController(GestureShortcutOptionController.class);
} else if (TRIPLE_TAP_SHORTCUT_SETTING.equals(uri)) {
refreshPreferenceController(TripleTapShortcutOptionController.class);
} else if (TWO_FINGERS_DOUBLE_TAP_SHORTCUT_SETTING.equals(uri)) {

View File

@@ -50,7 +50,14 @@ public class FloatingButtonShortcutOptionController
@Override
protected boolean isShortcutAvailable() {
return AccessibilityUtil.isFloatingMenuEnabled(mContext);
if (android.provider.Flags.a11yStandaloneGestureEnabled()) {
// FAB should be available when in gesture navigation mode,
// or if we're in the FAB button mode while in navbar navigation mode.
return AccessibilityUtil.isGestureNavigateEnabled(mContext)
|| AccessibilityUtil.isFloatingMenuEnabled(mContext);
} else {
return AccessibilityUtil.isFloatingMenuEnabled(mContext);
}
}
@Nullable

View File

@@ -16,6 +16,8 @@
package com.android.settings.accessibility.shortcuts;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE;
import android.content.Context;
import android.text.SpannableStringBuilder;
@@ -51,11 +53,22 @@ public class GestureShortcutOptionController extends SoftwareShortcutOptionPrefe
}
}
@Override
protected int getShortcutType() {
return android.provider.Flags.a11yStandaloneGestureEnabled()
? GESTURE : super.getShortcutType();
}
@Override
protected boolean isShortcutAvailable() {
return !isInSetupWizard()
&& !AccessibilityUtil.isFloatingMenuEnabled(mContext)
&& AccessibilityUtil.isGestureNavigateEnabled(mContext);
if (android.provider.Flags.a11yStandaloneGestureEnabled()) {
return !isInSetupWizard()
&& AccessibilityUtil.isGestureNavigateEnabled(mContext);
} else {
return !isInSetupWizard()
&& AccessibilityUtil.isGestureNavigateEnabled(mContext)
&& !AccessibilityUtil.isFloatingMenuEnabled(mContext);
}
}
@Override
@@ -68,9 +81,8 @@ public class GestureShortcutOptionController extends SoftwareShortcutOptionPrefe
final SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append(instruction);
if (!isInSetupWizard()) {
sb.append("\n\n");
sb.append(getCustomizeAccessibilityButtonLink());
if (!isInSetupWizard() && !android.provider.Flags.a11yStandaloneGestureEnabled()) {
sb.append("\n\n").append(getCustomizeAccessibilityButtonLink());
}
return sb;