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

Commit 567195db authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move "Close window" shortcut to Multitasking category" into main

parents 159d9693 7b1b294c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.view.KeyEvent.KEYCODE_LEFT_BRACKET
import android.view.KeyEvent.KEYCODE_MINUS
import android.view.KeyEvent.KEYCODE_RIGHT_BRACKET
import android.view.KeyEvent.KEYCODE_TAB
import android.view.KeyEvent.KEYCODE_W
import android.view.KeyEvent.META_ALT_ON
import android.view.KeyEvent.META_CTRL_ON
import android.view.KeyEvent.META_META_ON
@@ -95,6 +96,11 @@ class MultitaskingShortcutsSourceTest : SysuiTestCase() {
                META_META_ON,
                KEYCODE_MINUS,
            ),
            Triple(
                context.getString(R.string.system_desktop_mode_close_window),
                META_META_ON or META_CTRL_ON,
                KEYCODE_W,
            ),
            Triple(
                context.getString(R.string.system_multiple_desktop_mode_switch_between_desks),
                META_META_ON or META_CTRL_ON,
@@ -159,6 +165,7 @@ class MultitaskingShortcutsSourceTest : SysuiTestCase() {
        Flags.FLAG_ENABLE_MOVE_TO_NEXT_DISPLAY_SHORTCUT,
        Flags.FLAG_ENABLE_TASK_RESIZING_KEYBOARD_SHORTCUTS,
        Flags.FLAG_KEYBOARD_SHORTCUTS_TO_SWITCH_DESKS,
        Flags.FLAG_CLOSE_TASK_KEYBOARD_SHORTCUT,
    )
    fun shortcutGroups_desktopDisabled_doesNotContainDesktopShortcuts() {
        testScope.runTest {
+0 −22
Original line number Diff line number Diff line
@@ -27,9 +27,7 @@ import android.view.KeyEvent.KEYCODE_BACK
import android.view.KeyEvent.KEYCODE_HOME
import android.view.KeyEvent.KEYCODE_RECENT_APPS
import android.view.KeyEvent.KEYCODE_TAB
import android.view.KeyEvent.KEYCODE_W
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 androidx.test.ext.junit.runners.AndroidJUnit4
@@ -164,26 +162,6 @@ class SystemShortcutsSourceTest : SysuiTestCase() {
        }
    }

    @Test
    @EnableFlags(com.android.window.flags.Flags.FLAG_CLOSE_TASK_KEYBOARD_SHORTCUT)
    fun shortcutGroups_containsCloseWindowShortcut() {
        testScope.runTest {
            val groups = source.shortcutGroups(TEST_DEVICE_ID)

            val shortcuts =
                groups.flatMap { it.items }.map { c -> Triple(c.label, c.modifiers, c.keycode) }

            val closeWindowShortcut =
                Triple(
                    context.getString(R.string.group_system_close_window),
                    META_META_ON or META_CTRL_ON,
                    KEYCODE_W,
                )

            assertThat(shortcuts).contains(closeWindowShortcut)
        }
    }

    private companion object {
        private const val TEST_DEVICE_ID = 1234
    }
+3 −2
Original line number Diff line number Diff line
@@ -2564,8 +2564,6 @@
    <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>
    <!-- User visible title for the keyboard shortcut that closes a focused task [CHAR LIMIT=70] -->
    <string name="group_system_close_window">Close current window</string>

    <!-- User visible title for the multitasking keyboard shortcuts list. [CHAR LIMIT=70] -->
    <string name="keyboard_shortcut_group_system_multitasking">Multitasking</string>
@@ -2593,6 +2591,9 @@
    <string name="system_desktop_mode_toggle_maximize_window">Maximize window</string>
    <!-- User visible title for the keyboard shortcut that minimizes a task in desktop mode [CHAR LIMIT=70] -->
    <string name="system_desktop_mode_minimize_window">Minimize window</string>
    <!-- User visible title for the keyboard shortcut that closes a focused task
         [CHAR LIMIT=70 BACKUP_MESSAGE_ID=1506354809787837043] -->
    <string name="system_desktop_mode_close_window">Close current window</string>
    <!-- User visible title for the keyboard shortcut that switches between desktops in multiple desktop mode [CHAR LIMIT=70] -->
    <string name="system_multiple_desktop_mode_switch_between_desks">Move between desktops</string>

+5 −4
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_MINIMIZE_FREEFORM
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_MOVE_TO_NEXT_DISPLAY
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_MULTI_WINDOW_NAVIGATION
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_OPEN_SHORTCUT_HELPER
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_QUIT_FOCUSED_TASK
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_QUIT_FOCUSED_DESKTOP_TASK
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_RECENT_APPS
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER
import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_SNAP_LEFT_FREEFORM_WINDOW
@@ -74,7 +74,6 @@ 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_QUIT_FOCUSED_TASK to System,

            // Multitasking Category
            KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER to MultiTasking,
@@ -89,6 +88,7 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_TOGGLE_MAXIMIZE_FREEFORM_WINDOW to MultiTasking,
            KEY_GESTURE_TYPE_MOVE_TO_NEXT_DISPLAY to MultiTasking,
            KEY_GESTURE_TYPE_DESKTOP_MODE to MultiTasking,
            KEY_GESTURE_TYPE_QUIT_FOCUSED_DESKTOP_TASK to MultiTasking,

            // App Category
            KEY_GESTURE_TYPE_LAUNCH_APPLICATION to AppCategories,
@@ -119,7 +119,6 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
                R.string.shortcut_helper_category_system_controls,
            KEY_GESTURE_TYPE_LOCK_SCREEN to R.string.shortcut_helper_category_system_controls,
            KEY_GESTURE_TYPE_ALL_APPS to R.string.shortcut_helper_category_system_controls,
            KEY_GESTURE_TYPE_QUIT_FOCUSED_TASK to R.string.shortcut_helper_category_system_controls,
            KEY_GESTURE_TYPE_LAUNCH_SYSTEM_SETTINGS to
                R.string.shortcut_helper_category_system_apps,
            KEY_GESTURE_TYPE_LAUNCH_ASSISTANT to R.string.shortcut_helper_category_system_apps,
@@ -147,6 +146,8 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
                R.string.shortcutHelper_category_split_screen,
            KEY_GESTURE_TYPE_MOVE_TO_NEXT_DISPLAY to R.string.shortcutHelper_category_split_screen,
            KEY_GESTURE_TYPE_DESKTOP_MODE to R.string.shortcutHelper_category_split_screen,
            KEY_GESTURE_TYPE_QUIT_FOCUSED_DESKTOP_TASK to
                R.string.shortcutHelper_category_split_screen,

            // App Category
            KEY_GESTURE_TYPE_LAUNCH_APPLICATION to R.string.keyboard_shortcut_group_applications,
@@ -186,7 +187,6 @@ 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_QUIT_FOCUSED_TASK to R.string.group_system_close_window,

            // Multitasking Category
            KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER to R.string.group_system_cycle_forward,
@@ -204,6 +204,7 @@ class InputGestureMaps @Inject constructor(private val context: Context) {
            KEY_GESTURE_TYPE_MOVE_TO_NEXT_DISPLAY to
                R.string.system_multitasking_move_to_next_display,
            KEY_GESTURE_TYPE_DESKTOP_MODE to R.string.system_multitasking_desktop_view,
            KEY_GESTURE_TYPE_QUIT_FOCUSED_DESKTOP_TASK to R.string.system_desktop_mode_close_window,

            // Accessibility Category
            KEY_GESTURE_TYPE_TOGGLE_BOUNCE_KEYS to R.string.group_accessibility_toggle_bounce_keys,
+10 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.KeyEvent.KEYCODE_EQUALS
import android.view.KeyEvent.KEYCODE_LEFT_BRACKET
import android.view.KeyEvent.KEYCODE_MINUS
import android.view.KeyEvent.KEYCODE_RIGHT_BRACKET
import android.view.KeyEvent.KEYCODE_W
import android.view.KeyEvent.META_CTRL_ON
import android.view.KeyEvent.META_META_ON
import android.view.KeyboardShortcutGroup
@@ -135,7 +136,15 @@ constructor(
                    }
                )
            }

            if (DesktopExperienceFlags.CLOSE_TASK_KEYBOARD_SHORTCUT.isTrue()) {
                // Close focused task:
                //  - Meta + Ctrl + W
                add(
                    shortcutInfo(resources.getString(R.string.system_desktop_mode_close_window)) {
                        command(META_META_ON or META_CTRL_ON, KEYCODE_W)
                    }
                )
            }
            if (DesktopExperienceFlags.ENABLE_KEYBOARD_SHORTCUTS_TO_SWITCH_DESKS.isTrue) {
                // Move between desktops
                //  - Meta + Ctrl + [ or ]
Loading