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

Commit a42860d0 authored by Chris Göllner's avatar Chris Göllner Committed by Android (Google) Code Review
Browse files

Merge "Shortcut Helper - Connect interactor with system shortcuts" into main

parents 71fa2dba 0b3dfd55
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -3543,10 +3543,26 @@
         shows the user which keyboard shortcuts they can use. The "System" shortcuts are for
         example "Take a screenshot" or "Go back". [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_category_system">System</string>
    <!-- Title of the keyboard shortcut helper category "System controls". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "System controls" shortcuts
         are for example "Go to home screen" or "App apps search". [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_category_system_controls">System controls</string>
    <!-- Title of the keyboard shortcut helper category "System apps". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "System apps" shortcuts
         are for example "Settings" or "Take a note". [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_category_system_apps">System apps</string>
    <!-- Title of the keyboard shortcut helper category "Multitasking". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "Multitasking" shortcuts are
         for example "Enter split screen". [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_category_multitasking">Multitasking</string>
    <!-- Title of the keyboard shortcut helper category "Recent apps". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "Recent apps" shortcuts are
         for example "Cycle through recent apps". [CHAR LIMIT=NONE] -->
    <string name="shortcutHelper_category_recent_apps">Recent apps</string>
    <!-- Title of the keyboard shortcut helper category "Split screen". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "Split screen" shortcuts are
         for example "Move current app to left split". [CHAR LIMIT=NONE] -->
    <string name="shortcutHelper_category_split_screen">Split screen</string>
    <!-- Title of the keyboard shortcut helper category "Input". The helper is a component
         that shows the user which keyboard shortcuts they can use. The "Input" shortcuts are
         the ones provided by the keyboard. Examples are "Access emoji" or "Switch to next language"
+3 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.systemui.keyboard.shortcut
import android.app.Activity
import com.android.systemui.CoreStartable
import com.android.systemui.Flags.keyboardShortcutHelperRewrite
import com.android.systemui.keyboard.shortcut.data.repository.ShortcutHelperRepository
import com.android.systemui.keyboard.shortcut.data.repository.ShortcutHelperStateRepository
import com.android.systemui.keyboard.shortcut.ui.ShortcutHelperActivityStarter
import com.android.systemui.keyboard.shortcut.ui.view.ShortcutHelperActivity
import dagger.Binds
@@ -52,8 +52,8 @@ interface ShortcutHelperModule {

        @Provides
        @IntoMap
        @ClassKey(ShortcutHelperRepository::class)
        fun repo(implLazy: Lazy<ShortcutHelperRepository>): CoreStartable {
        @ClassKey(ShortcutHelperStateRepository::class)
        fun repo(implLazy: Lazy<ShortcutHelperStateRepository>): CoreStartable {
            return if (keyboardShortcutHelperRewrite()) {
                implLazy.get()
            } else {
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyboard.shortcut.data.source.MultitaskingShortcutsSource
import com.android.systemui.keyboard.shortcut.data.source.SystemShortcutsSource
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategory
import javax.inject.Inject

@SysUISingleton
class ShortcutHelperCategoriesRepository
@Inject
constructor(
    private val systemShortcutsSource: SystemShortcutsSource,
    private val multitaskingShortcutsSource: MultitaskingShortcutsSource,
) {

    fun systemShortcutsCategory(): ShortcutCategory =
        systemShortcutsSource.systemShortcutsCategory()

    fun multitaskingShortcutsCategory(): ShortcutCategory =
        multitaskingShortcutsSource.multitaskingShortcutCategory()
}
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext

@SysUISingleton
class ShortcutHelperRepository
class ShortcutHelperStateRepository
@Inject
constructor(
    private val commandQueue: CommandQueue,
+18 −3
Original line number Diff line number Diff line
@@ -25,13 +25,28 @@ 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 com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.MULTI_TASKING
import com.android.systemui.keyboard.shortcut.shared.model.shortcut
import com.android.systemui.keyboard.shortcut.shared.model.shortcutCategory
import com.android.systemui.res.R
import javax.inject.Inject

class MultitaskingShortcutsSource @Inject constructor(private val resources: Resources) {
class MultitaskingShortcutsSource @Inject constructor(@Main private val resources: Resources) {

    fun splitScreenShortcuts() =
    fun multitaskingShortcutCategory() =
        shortcutCategory(MULTI_TASKING) {
            subCategory(
                resources.getString(R.string.shortcutHelper_category_recent_apps),
                recentsShortcuts()
            )
            subCategory(
                resources.getString(R.string.shortcutHelper_category_split_screen),
                splitScreenShortcuts()
            )
        }

    private fun splitScreenShortcuts() =
        listOf(
            //  Enter Split screen with current app to RHS:
            //   - Meta + Ctrl + Right arrow
@@ -60,7 +75,7 @@ class MultitaskingShortcutsSource @Inject constructor(private val resources: Res
            },
        )

    fun recentsShortcuts() =
    private fun recentsShortcuts() =
        listOf(
            // Cycle through recent apps (forward):
            //  - Alt + Tab
Loading