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

Commit 6f30c461 authored by Josh's avatar Josh
Browse files

[Shortcut helper]Moved Recent Apps Shortcuts to System Category

In Shortcut helper, Recent apps shortcuts(cycle forward/back through recent apps)
which were previously under multitasking category is are being moved to System category.

Test: SystemShortcutsSourceTest
Test: MultitaskingShortcutsSourceTest
Flag: EXEMPT Trivial
Fix: 380227478
Change-Id: I3d97e7b3ea96d8fa3b5beee282e0899af3d8e5e9
parent e5a17396
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class CustomShortcutCategoriesRepositoryTest : SysuiTestCase() {

    @Test
    @EnableFlags(FLAG_ENABLE_CUSTOMIZABLE_INPUT_GESTURES, FLAG_USE_KEY_GESTURE_EVENT_HANDLER)
    fun categories_emitsCorrectlyConvertedShortcutCategories() {
    fun categories_correctlyConvertsAPIModelsToShortcutHelperModels() {
        testScope.runTest {
            whenever(inputManager.getCustomInputGestures(/* filter= */ anyOrNull()))
                .thenReturn(allCustomizableInputGesturesWithSimpleShortcutCombinations)
+71 −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.source

import android.content.res.mainResources
import android.view.KeyEvent.KEYCODE_TAB
import android.view.KeyEvent.META_ALT_ON
import android.view.KeyEvent.META_SHIFT_ON
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class MultitaskingShortcutsSourceTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope

    private val source = MultitaskingShortcutsSource(kosmos.mainResources, context)

    @Test
    fun shortcutGroups_doesNotContainCycleThroughRecentAppsShortcuts() {
        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 cycleThroughRecentAppsShortcuts =
                listOf(
                    Triple(
                        context.getString(R.string.group_system_cycle_forward),
                        META_ALT_ON,
                        KEYCODE_TAB,
                    ),
                    Triple(
                        context.getString(R.string.group_system_cycle_back),
                        META_SHIFT_ON or META_ALT_ON,
                        KEYCODE_TAB,
                    ),
                )

            assertThat(shortcuts).containsNoneIn(cycleThroughRecentAppsShortcuts)
        }
    }

    private companion object {
        private const val TEST_DEVICE_ID = 1234
    }
}
+30 −1
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ import android.view.KeyEvent
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.META_ALT_ON
import android.view.KeyEvent.META_SHIFT_ON
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_SHORTCUT_HELPER_KEY_GLYPH
@@ -132,7 +135,33 @@ class SystemShortcutsSourceTest : SysuiTestCase() {
            assertThat(shortcuts).doesNotContain(hardwareShortcut)
        }

    companion object {
    @Test
    fun shortcutGroups_containsCycleThroughRecentAppsShortcuts() {
        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 cycleThroughRecentAppsShortcuts =
                listOf(
                    Triple(
                        context.getString(R.string.group_system_cycle_forward),
                        META_ALT_ON,
                        KEYCODE_TAB,
                    ),
                    Triple(
                        context.getString(R.string.group_system_cycle_back),
                        META_SHIFT_ON or META_ALT_ON,
                        KEYCODE_TAB,
                    ),
                )

            assertThat(shortcuts).containsAtLeastElementsIn(cycleThroughRecentAppsShortcuts)
        }
    }

    private companion object {
        private const val TEST_DEVICE_ID = 1234
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -490,17 +490,15 @@ object TestShortcuts {
            simpleShortcutCategory(AppCategories, "Applications", "Email"),
            simpleShortcutCategory(AppCategories, "Applications", "Maps"),
            simpleShortcutCategory(AppCategories, "Applications", "SMS"),
            simpleShortcutCategory(MultiTasking, "Recent apps", "Cycle forward through recent apps"),
        )
    val customInputGestureTypeHome =
        simpleInputGestureData(keyGestureType = KeyGestureEvent.KEY_GESTURE_TYPE_HOME)
    val customInputGestureTypeHome = simpleInputGestureData(keyGestureType = KEY_GESTURE_TYPE_HOME)

    val allCustomizableInputGesturesWithSimpleShortcutCombinations =
        listOf(
            simpleInputGestureData(
                keyGestureType = KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_ASSISTANT
            ),
            simpleInputGestureData(keyGestureType = KeyGestureEvent.KEY_GESTURE_TYPE_HOME),
            simpleInputGestureData(keyGestureType = KEY_GESTURE_TYPE_HOME),
            simpleInputGestureData(
                keyGestureType = KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_SYSTEM_SETTINGS
            ),
+0 −4
Original line number Diff line number Diff line
@@ -3736,10 +3736,6 @@
         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] -->
Loading