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

Commit 14746f6d authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add task resizing keyboard shortcuts into Android Shortcut Helper.

Fixes: 341294006
Flag: com.android.window.flags.enable_task_resizing_keyboard_shortcuts
Test: manual test on device
Change-Id: Ic022d9ca6fb77f7d1ec9f2c93efcbb14477b7050
parent 543b24e2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2287,6 +2287,14 @@
    <string name="system_multitasking_replace">During split screen: replace an app from one to another</string>
    <!-- User visible title for the keyboard shortcut that moves a focused task to a next display [CHAR LIMIT=70] -->
    <string name="system_multitasking_move_to_next_display">Move active window between displays</string>
    <!-- User visible title for the keyboard shortcut that snaps a task to the left in desktop mode [CHAR LIMIT=70] -->
    <string name="system_desktop_mode_snap_left_window">Move window to the left</string>
    <!-- User visible title for the keyboard shortcut that snaps a task to the right in desktop mode [CHAR LIMIT=70] -->
    <string name="system_desktop_mode_snap_right_window">Move window to the right</string>
    <!-- User visible title for the keyboard shortcut that toggles between maximizing and restoring a task's previous bounds in desktop mode [CHAR LIMIT=70] -->
    <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 input keyboard shortcuts list. [CHAR LIMIT=70] -->
    <string name="keyboard_shortcut_group_input">Input</string>
+45 −1
Original line number Diff line number Diff line
@@ -16,24 +16,34 @@

package com.android.systemui.keyboard.shortcut.data.source

import android.content.Context
import android.content.res.Resources
import android.view.KeyEvent.KEYCODE_D
import android.view.KeyEvent.KEYCODE_DPAD_LEFT
import android.view.KeyEvent.KEYCODE_DPAD_RIGHT
import android.view.KeyEvent.KEYCODE_DPAD_UP
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_TAB
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 com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyboard.shortcut.data.model.shortcutInfo
import com.android.systemui.res.R
import com.android.window.flags.Flags.enableMoveToNextDisplayShortcut
import com.android.window.flags.Flags.enableTaskResizingKeyboardShortcuts
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import javax.inject.Inject

class MultitaskingShortcutsSource @Inject constructor(@Main private val resources: Resources) :
class MultitaskingShortcutsSource
@Inject
constructor(@Main private val resources: Resources, @Application private val context: Context) :
    KeyboardShortcutGroupsSource {

    override suspend fun shortcutGroups(deviceId: Int) =
@@ -95,6 +105,40 @@ class MultitaskingShortcutsSource @Inject constructor(@Main private val resource
                }
            )
        }
        if (
            DesktopModeStatus.canEnterDesktopMode(context) && enableTaskResizingKeyboardShortcuts()
        ) {
            // Snap a freeform window to the left
            //  - Meta + Left bracket
            add(
                shortcutInfo(resources.getString(R.string.system_desktop_mode_snap_left_window)) {
                    command(META_META_ON, KEYCODE_LEFT_BRACKET)
                }
            )
            // Snap a freeform window to the right
            //  - Meta + Right bracket
            add(
                shortcutInfo(resources.getString(R.string.system_desktop_mode_snap_right_window)) {
                    command(META_META_ON, KEYCODE_RIGHT_BRACKET)
                }
            )
            // Toggle maximize a freeform window
            //  - Meta + Equals
            add(
                shortcutInfo(
                    resources.getString(R.string.system_desktop_mode_toggle_maximize_window)
                ) {
                    command(META_META_ON, KEYCODE_EQUALS)
                }
            )
            // Minimize a freeform window
            //  - Meta + Minus
            add(
                shortcutInfo(resources.getString(R.string.system_desktop_mode_minimize_window)) {
                    command(META_META_ON, KEYCODE_MINUS)
                }
            )
        }
    }

    private fun recentsShortcuts() =
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ var Kosmos.shortcutHelperSystemShortcutsSource: KeyboardShortcutGroupsSource by
    Kosmos.Fixture { SystemShortcutsSource(mainResources) }

var Kosmos.shortcutHelperMultiTaskingShortcutsSource: KeyboardShortcutGroupsSource by
    Kosmos.Fixture { MultitaskingShortcutsSource(mainResources) }
    Kosmos.Fixture { MultitaskingShortcutsSource(mainResources, applicationContext) }

val Kosmos.shortcutHelperStateRepository by
    Kosmos.Fixture {