Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8631fafd authored by Daniel Norman's avatar Daniel Norman Committed by Android (Google) Code Review
Browse files

Merge "Hide the A11yMenu UI before performing actions instead of after." into main

parents f619577c 2e993276
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
    description: "Provides/restores back button functionality for the a11yMenu settings page. Also, fixes sizing problems with large shortcut buttons."
    bug: "298467628"
}

flag {
    name: "a11y_menu_hide_before_taking_action"
    namespace: "accessibility"
    description: "Hides the AccessibilityMenuService UI before taking action instead of after."
    bug: "292020123"
}
 No newline at end of file
+24 −13
Original line number Diff line number Diff line
@@ -260,6 +260,27 @@ public class AccessibilityMenuService extends AccessibilityService
        // Shortcuts are repeatable in a11y menu rather than unique, so use tag ID to handle.
        int viewTag = (int) view.getTag();

        // First check if this was a shortcut which should keep a11y menu visible. If so,
        // perform the shortcut and return without hiding the UI.
        if (viewTag == ShortcutId.ID_BRIGHTNESS_UP_VALUE.ordinal()) {
            adjustBrightness(BRIGHTNESS_UP_INCREMENT_GAMMA);
            return;
        } else if (viewTag == ShortcutId.ID_BRIGHTNESS_DOWN_VALUE.ordinal()) {
            adjustBrightness(BRIGHTNESS_DOWN_INCREMENT_GAMMA);
            return;
        } else if (viewTag == ShortcutId.ID_VOLUME_UP_VALUE.ordinal()) {
            adjustVolume(AudioManager.ADJUST_RAISE);
            return;
        } else if (viewTag == ShortcutId.ID_VOLUME_DOWN_VALUE.ordinal()) {
            adjustVolume(AudioManager.ADJUST_LOWER);
            return;
        }

        if (Flags.a11yMenuHideBeforeTakingAction()) {
            // Hide the a11y menu UI before performing the following shortcut actions.
            mA11yMenuLayout.hideMenu();
        }

        if (viewTag == ShortcutId.ID_ASSISTANT_VALUE.ordinal()) {
            // Always restart the voice command activity, so that the UI is reloaded.
            startActivityIfIntentIsSafe(
@@ -281,22 +302,12 @@ public class AccessibilityMenuService extends AccessibilityService
            performGlobalActionInternal(GLOBAL_ACTION_NOTIFICATIONS);
        } else if (viewTag == ShortcutId.ID_SCREENSHOT_VALUE.ordinal()) {
            performGlobalActionInternal(GLOBAL_ACTION_TAKE_SCREENSHOT);
        } else if (viewTag == ShortcutId.ID_BRIGHTNESS_UP_VALUE.ordinal()) {
            adjustBrightness(BRIGHTNESS_UP_INCREMENT_GAMMA);
            return;
        } else if (viewTag == ShortcutId.ID_BRIGHTNESS_DOWN_VALUE.ordinal()) {
            adjustBrightness(BRIGHTNESS_DOWN_INCREMENT_GAMMA);
            return;
        } else if (viewTag == ShortcutId.ID_VOLUME_UP_VALUE.ordinal()) {
            adjustVolume(AudioManager.ADJUST_RAISE);
            return;
        } else if (viewTag == ShortcutId.ID_VOLUME_DOWN_VALUE.ordinal()) {
            adjustVolume(AudioManager.ADJUST_LOWER);
            return;
        }

        if (!Flags.a11yMenuHideBeforeTakingAction()) {
            mA11yMenuLayout.hideMenu();
        }
    }

    /**
     * Adjusts brightness using the same logic and utils class as the SystemUI brightness slider.