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

Commit e0568a8b authored by Yuhan Yang's avatar Yuhan Yang
Browse files

Add talkback, magnification and select_to_speak shortcuts

Add the following shortcuts to a11y category in shortcut helper:
 - KEY_GESTURE_TYPE_TOGGLE_TALKBACK
 - KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION
 - KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK

Bug: 389652455
Test: verified locally
Flag: com.android.hardware.input.enable_talkback_and_magnifier_key_gestures
Change-Id: I8b5851c1575e906a087ae2214c3c84fda0c0e164
parent 15e08804
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2384,6 +2384,12 @@
    <string name="group_accessibility_toggle_slow_keys">Toggle slow keys</string>
    <!-- User visible title for the keyboard shortcut that toggles Voice Access. [CHAR LIMIT=70] -->
    <string name="group_accessibility_toggle_voice_access">Toggle Voice Access</string>
    <!-- User visible title for the keyboard shortcut that toggles Talkback. [CHAR LIMIT=70] -->
    <string name="group_accessibility_toggle_talkback">Toggle Talkback</string>
    <!-- User visible title for the keyboard shortcut that toggles Magnification. [CHAR LIMIT=70] -->
    <string name="group_accessibility_toggle_magnification">Toggle Magnification</string>
    <!-- User visible title for the keyboard shortcut that activates Select to Speak service. [CHAR LIMIT=70] -->
    <string name="group_accessibility_activate_select_to_speak">Activate Select to Speak</string>

    <!-- SysUI Tuner: Label for screen about do not disturb settings [CHAR LIMIT=60] -->
    <string name="volume_and_do_not_disturb">Do Not Disturb</string>
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.keyboard.shortcut.data.repository

import android.content.Context
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_ALL_APPS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_BACK
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_CHANGE_SPLITSCREEN_FOCUS_LEFT
@@ -40,11 +41,13 @@ import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVI
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVIGATION_RIGHT
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TAKE_SCREENSHOT
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_BOUNCE_KEYS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAXIMIZE_FREEFORM_WINDOW
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MOUSE_KEYS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_NOTIFICATION_PANEL
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_SLOW_KEYS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_STICKY_KEYS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_TALKBACK
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.Accessibility
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.AppCategories
@@ -92,6 +95,9 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_TOGGLE_STICKY_KEYS to Accessibility,
            KEY_GESTURE_TYPE_TOGGLE_SLOW_KEYS to Accessibility,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to Accessibility,
            KEY_GESTURE_TYPE_TOGGLE_TALKBACK to Accessibility,
            KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION to Accessibility,
            KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK to Accessibility,
        )

    val gestureToInternalKeyboardShortcutGroupLabelResIdMap =
@@ -144,6 +150,10 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_TOGGLE_STICKY_KEYS to R.string.shortcutHelper_category_accessibility,
            KEY_GESTURE_TYPE_TOGGLE_SLOW_KEYS to R.string.shortcutHelper_category_accessibility,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to R.string.shortcutHelper_category_accessibility,
            KEY_GESTURE_TYPE_TOGGLE_TALKBACK to R.string.shortcutHelper_category_accessibility,
            KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION to R.string.shortcutHelper_category_accessibility,
            KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK to
                R.string.shortcutHelper_category_accessibility,
        )

    /**
@@ -192,6 +202,11 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_TOGGLE_SLOW_KEYS to R.string.group_accessibility_toggle_slow_keys,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to
                R.string.group_accessibility_toggle_voice_access,
            KEY_GESTURE_TYPE_TOGGLE_TALKBACK to R.string.group_accessibility_toggle_talkback,
            KEY_GESTURE_TYPE_TOGGLE_MAGNIFICATION to
                R.string.group_accessibility_toggle_magnification,
            KEY_GESTURE_TYPE_ACTIVATE_SELECT_TO_SPEAK to
                R.string.group_accessibility_activate_select_to_speak,
        )

    val shortcutLabelToKeyGestureTypeMap: Map<String, Int>
+32 −0
Original line number Diff line number Diff line
@@ -22,11 +22,15 @@ import android.view.KeyEvent.KEYCODE_3
import android.view.KeyEvent.KEYCODE_4
import android.view.KeyEvent.KEYCODE_5
import android.view.KeyEvent.KEYCODE_6
import android.view.KeyEvent.KEYCODE_M
import android.view.KeyEvent.KEYCODE_S
import android.view.KeyEvent.KEYCODE_T
import android.view.KeyEvent.KEYCODE_V
import android.view.KeyEvent.META_ALT_ON
import android.view.KeyEvent.META_META_ON
import android.view.KeyboardShortcutGroup
import android.view.KeyboardShortcutInfo
import com.android.hardware.input.Flags.enableTalkbackAndMagnifierKeyGestures
import com.android.hardware.input.Flags.enableVoiceAccessKeyGestures
import com.android.hardware.input.Flags.keyboardA11yShortcutControl
import com.android.systemui.dagger.qualifiers.Main
@@ -106,6 +110,34 @@ class AccessibilityShortcutsSource @Inject constructor(@Main private val resourc
            )
        }

        if (enableTalkbackAndMagnifierKeyGestures()) {
            shortcuts.add(
                // Toggle talkback:
                //  - Meta + Alt + T
                shortcutInfo(resources.getString(R.string.group_accessibility_toggle_talkback)) {
                    command(META_META_ON or META_ALT_ON, KEYCODE_T)
                }
            )
            shortcuts.add(
                // Toggle magnification:
                //  - Meta + Alt + M
                shortcutInfo(
                    resources.getString(R.string.group_accessibility_toggle_magnification)
                ) {
                    command(META_META_ON or META_ALT_ON, KEYCODE_M)
                }
            )
            shortcuts.add(
                // Activate Select to Speak:
                //  - Meta + Alt + S
                shortcutInfo(
                    resources.getString(R.string.group_accessibility_activate_select_to_speak)
                ) {
                    command(META_META_ON or META_ALT_ON, KEYCODE_S)
                }
            )
        }

        return shortcuts
    }
}