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

Commit 1d621cf1 authored by Wenyu Zhang's avatar Wenyu Zhang Committed by Android (Google) Code Review
Browse files

Merge "Add toggle voice access shortcut to shortcut helper" into main

parents a2271189 a4873b5c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2309,6 +2309,9 @@
    <string name="group_system_lock_screen">Lock screen</string>
    <!-- User visible title for the keyboard shortcut that pulls up Notes app for quick memo. [CHAR LIMIT=70] -->
    <string name="group_system_quick_memo">Take a note</string>
    <!-- TODO(b/383734125): make it translatable once string is finalized by UXW.-->
    <!-- User visible title for the keyboard shortcut that toggles Voice Access. [CHAR LIMIT=70] -->
    <string name="group_system_toggle_voice_access" translatable="false">Toggle Voice Access</string>

    <!-- User visible title for the multitasking keyboard shortcuts list. [CHAR LIMIT=70] -->
    <string name="keyboard_shortcut_group_system_multitasking">Multitasking</string>
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVI
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TAKE_SCREENSHOT
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_MAXIMIZE_FREEFORM_WINDOW
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_NOTIFICATION_PANEL
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS
import com.android.hardware.input.Flags.enableVoiceAccessKeyGestures
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.AppCategories
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.MultiTasking
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.System
@@ -63,6 +65,7 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_LAUNCH_ASSISTANT to System,
            KEY_GESTURE_TYPE_LAUNCH_VOICE_ASSISTANT to System,
            KEY_GESTURE_TYPE_ALL_APPS to System,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to System,

            // Multitasking Category
            KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER to MultiTasking,
@@ -100,6 +103,7 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_LAUNCH_ASSISTANT to R.string.shortcut_helper_category_system_apps,
            KEY_GESTURE_TYPE_LAUNCH_VOICE_ASSISTANT to
                R.string.shortcut_helper_category_system_apps,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to R.string.shortcut_helper_category_system_apps,

            // Multitasking Category
            KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVIGATION_LEFT to
@@ -148,6 +152,7 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_LAUNCH_ASSISTANT to R.string.group_system_access_google_assistant,
            KEY_GESTURE_TYPE_LAUNCH_VOICE_ASSISTANT to
                R.string.group_system_access_google_assistant,
            KEY_GESTURE_TYPE_TOGGLE_VOICE_ACCESS to R.string.group_system_toggle_voice_access,

            // Multitasking Category
            KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER to R.string.group_system_cycle_forward,
+17 −2
Original line number Diff line number Diff line
@@ -32,12 +32,14 @@ import android.view.KeyEvent.KEYCODE_RECENT_APPS
import android.view.KeyEvent.KEYCODE_S
import android.view.KeyEvent.KEYCODE_SLASH
import android.view.KeyEvent.KEYCODE_TAB
import android.view.KeyEvent.KEYCODE_V
import android.view.KeyEvent.META_ALT_ON
import android.view.KeyEvent.META_CTRL_ON
import android.view.KeyEvent.META_META_ON
import android.view.KeyEvent.META_SHIFT_ON
import android.view.KeyboardShortcutGroup
import android.view.KeyboardShortcutInfo
import com.android.hardware.input.Flags.enableVoiceAccessKeyGestures
import com.android.systemui.Flags.shortcutHelperKeyGlyph
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyboard.shortcut.data.model.shortcutInfo
@@ -118,8 +120,8 @@ constructor(@Main private val resources: Resources, private val inputManager: In
        return shortcuts
    }

    private fun systemControlsShortcuts() =
        listOf(
    private fun systemControlsShortcuts(): List<KeyboardShortcutInfo>  {
        val shortcuts = mutableListOf(
            // Access list of all apps and search (i.e. Search/Launcher):
            //  - Meta
            shortcutInfo(resources.getString(R.string.group_system_access_all_apps_search)) {
@@ -176,6 +178,19 @@ constructor(@Main private val resources: Resources, private val inputManager: In
            },
        )

        if (enableVoiceAccessKeyGestures()) {
            shortcuts.add(
                // Toggle voice access:
                //  - Meta + Alt + V
                shortcutInfo(resources.getString(R.string.group_system_toggle_voice_access)) {
                    command(META_META_ON or META_ALT_ON, KEYCODE_V)
                }
            )
        }

        return shortcuts
    }

    private fun systemAppsShortcuts() =
        listOf(
            // Pull up Notes app for quick memo: