summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Joshua Mokut <jmokut@google.com> 2024-11-28 15:24:53 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-28 15:24:53 +0000
commita76332da94461e34dac4794b81eb3a179f0dbc8f (patch)
tree0cbb8d240ed85ddb9b00edb9e92b0f11d0484d62
parentcc9d7f03d5ad9b478fe55ebc17ac83dbcaa804f2 (diff)
parent73c68764a77bd3934545fb050a43aae818fb5bd1 (diff)
Merge changes Ib4694ed5,I3d97e7b3 into main
* changes: [Shortcut Helper] Updated system shortcuts [Shortcut helper]Moved Recent Apps Shortcuts to System Category
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/repository/CustomShortcutCategoriesRepositoryTest.kt2
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSourceTest.kt71
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSourceTest.kt31
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyboard/shortcut/data/source/TestShortcuts.kt6
-rw-r--r--packages/SystemUI/res/values/strings.xml4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/repository/InputGestureMaps.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/MultitaskingShortcutsSource.kt22
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/data/source/SystemShortcutsSource.kt22
8 files changed, 117 insertions, 42 deletions
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 8740c7152620..d12c04586ac2 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
@@ -88,7 +88,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 3faba95a97b2..c287da8df135 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
@@ -491,17 +491,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 dcdf95c4719d..a0a61c74369f 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] -->
<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] -->
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
@@ -49,13 +47,9 @@ 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..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
@@ -34,8 +32,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
@@ -127,29 +127,31 @@ 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)) {
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
// - 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)
},
// Take a full screenshot: