From 6f30c461203d9cd9ba5de38b7e09338fc7369c95 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 28 Nov 2024 11:17:52 +0000 Subject: [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 --- .../CustomShortcutCategoriesRepositoryTest.kt | 2 +- .../data/source/MultitaskingShortcutsSourceTest.kt | 71 ++++++++++++++++++++++ .../data/source/SystemShortcutsSourceTest.kt | 31 +++++++++- .../keyboard/shortcut/data/source/TestShortcuts.kt | 6 +- packages/SystemUI/res/values/strings.xml | 4 -- .../shortcut/data/repository/InputGestureMaps.kt | 1 - .../data/source/MultitaskingShortcutsSource.kt | 22 +------ .../shortcut/data/source/SystemShortcutsSource.kt | 12 ++++ 8 files changed, 117 insertions(+), 32 deletions(-) create mode 100644 packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSourceTest.kt diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt index 0d32b7fb1b3e..6f0194339b6d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt @@ -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) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSourceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSourceTest.kt new file mode 100644 index 000000000000..60d70897a6fa --- /dev/null +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSourceTest.kt @@ -0,0 +1,71 @@ +/* + * 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 + } +} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSourceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSourceTest.kt index 495e98d0edfb..b9fb3e64777d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSourceTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSourceTest.kt @@ -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 } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/TestShortcuts.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/TestShortcuts.kt index 6d22b4903920..5abf32fc4773 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/TestShortcuts.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/TestShortcuts.kt @@ -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 ), diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 4bf67a12963a..b9de811c03ec 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -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] --> Multitasking - - Recent apps diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/InputGestureMaps.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/InputGestureMaps.kt index ecc076178d2d..1c380c26c6c3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/InputGestureMaps.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/InputGestureMaps.kt @@ -104,7 +104,6 @@ class InputGestureMaps @Inject constructor(private val context: Context) { R.string.shortcut_helper_category_system_apps, // Multitasking Category - KEY_GESTURE_TYPE_RECENT_APPS_SWITCHER to R.string.shortcutHelper_category_recent_apps, KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVIGATION_LEFT to R.string.shortcutHelper_category_split_screen, KEY_GESTURE_TYPE_SPLIT_SCREEN_NAVIGATION_RIGHT to diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSource.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSource.kt index 5ef869e6d848..df6b04e2afd3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSource.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSource.kt @@ -26,11 +26,9 @@ 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 @@ -48,14 +46,10 @@ constructor(@Main private val resources: Resources, @Application private val con override suspend fun shortcutGroups(deviceId: Int) = listOf( - KeyboardShortcutGroup( - resources.getString(R.string.shortcutHelper_category_recent_apps), - recentsShortcuts(), - ), KeyboardShortcutGroup( resources.getString(R.string.shortcutHelper_category_split_screen), splitScreenShortcuts(), - ), + ) ) private fun splitScreenShortcuts() = buildList { @@ -140,18 +134,4 @@ constructor(@Main private val resources: Resources, @Application private val con ) } } - - private fun recentsShortcuts() = - listOf( - // Cycle through recent apps (forward): - // - Alt + Tab - shortcutInfo(resources.getString(R.string.group_system_cycle_forward)) { - command(META_ALT_ON, KEYCODE_TAB) - }, - // Cycle through recent apps (back): - // - Shift + Alt + Tab - shortcutInfo(resources.getString(R.string.group_system_cycle_back)) { - command(META_SHIFT_ON or META_ALT_ON, KEYCODE_TAB) - }, - ) } diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt index a650cd889381..6748b4bec0dd 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt @@ -34,8 +34,10 @@ 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.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.systemui.Flags.shortcutHelperKeyGlyph @@ -139,6 +141,16 @@ constructor(@Main private val resources: Resources, private val inputManager: In shortcutInfo(resources.getString(R.string.group_system_overview_open_apps)) { command(META_META_ON, KEYCODE_TAB) }, + // Cycle through recent apps (forward): + // - Alt + Tab + shortcutInfo(resources.getString(R.string.group_system_cycle_forward)) { + command(META_ALT_ON, KEYCODE_TAB) + }, + // Cycle through recent apps (back): + // - Shift + Alt + Tab + shortcutInfo(resources.getString(R.string.group_system_cycle_back)) { + command(META_SHIFT_ON or META_ALT_ON, KEYCODE_TAB) + }, // Back: go back to previous state (back button) // - Meta + Escape OR // - Meta + Backspace OR -- cgit v1.2.3-59-g8ed1b From 73c68764a77bd3934545fb050a43aae818fb5bd1 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 28 Nov 2024 12:10:07 +0000 Subject: [Shortcut Helper] Updated system shortcuts + Removed Meta + Enter from go to home screen shortcut + Removed Meta + Backspace from Go back shortcut Test: Manual - open shortcut helper, ensure the shortcuts listed above don't show up Flag: EXEMPT Trivial fix Fix: 370923953 Fix: 370928529 Change-Id: Ib4694ed5d3e1899e03435459aad76919a303dd58 --- .../keyboard/shortcut/data/source/SystemShortcutsSource.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt index 6748b4bec0dd..687ad9550b16 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt @@ -21,9 +21,7 @@ import android.hardware.input.InputManager import android.hardware.input.KeyGlyphMap import android.view.KeyEvent.KEYCODE_A import android.view.KeyEvent.KEYCODE_BACK -import android.view.KeyEvent.KEYCODE_DEL import android.view.KeyEvent.KEYCODE_DPAD_LEFT -import android.view.KeyEvent.KEYCODE_ENTER import android.view.KeyEvent.KEYCODE_ESCAPE import android.view.KeyEvent.KEYCODE_H import android.view.KeyEvent.KEYCODE_HOME @@ -129,13 +127,9 @@ constructor(@Main private val resources: Resources, private val inputManager: In }, // Access home screen: // - Meta + H - // - Meta + Enter shortcutInfo(resources.getString(R.string.group_system_access_home_screen)) { command(META_META_ON, KEYCODE_H) }, - shortcutInfo(resources.getString(R.string.group_system_access_home_screen)) { - command(META_META_ON, KEYCODE_ENTER) - }, // Overview of open apps: // - Meta + Tab shortcutInfo(resources.getString(R.string.group_system_overview_open_apps)) { @@ -153,14 +147,10 @@ constructor(@Main private val resources: Resources, private val inputManager: In }, // Back: go back to previous state (back button) // - Meta + Escape OR - // - Meta + Backspace OR // - Meta + Left arrow shortcutInfo(resources.getString(R.string.group_system_go_back)) { command(META_META_ON, KEYCODE_ESCAPE) }, - shortcutInfo(resources.getString(R.string.group_system_go_back)) { - command(META_META_ON, KEYCODE_DEL) - }, shortcutInfo(resources.getString(R.string.group_system_go_back)) { command(META_META_ON, KEYCODE_DPAD_LEFT) }, -- cgit v1.2.3-59-g8ed1b