diff options
| author | 2023-06-30 09:24:01 +0000 | |
|---|---|---|
| committer | 2023-06-30 09:24:01 +0000 | |
| commit | 5210caeb1d06a3353b458aa101c6164f023b2aac (patch) | |
| tree | 08681b0be7d4d26d232f55d6d1984e117dbe28d3 | |
| parent | f2caa37206987fd62212aaea17a875d7ad695caf (diff) | |
| parent | bcb0d40688e8886cd01773f8ed4fdcf033c63f38 (diff) | |
Merge "Add support for keyboard shortcuts panel on TV"
6 files changed, 52 insertions, 9 deletions
diff --git a/packages/SystemUI/res/drawable/list_item_background.xml b/packages/SystemUI/res/drawable/list_item_background.xml new file mode 100644 index 000000000000..2dbab9cfe984 --- /dev/null +++ b/packages/SystemUI/res/drawable/list_item_background.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2023 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_focused="true" android:drawable="@*android:drawable/list_choice_background_material" /> + <item android:drawable="@android:color/transparent" /> +</selector>
\ No newline at end of file diff --git a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml index 3786812db827..fcf9638440c7 100644 --- a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml +++ b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml @@ -17,6 +17,8 @@ <com.android.systemui.statusbar.KeyboardShortcutAppItemLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" + android:background="@drawable/list_item_background" + android:focusable="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="48dp" @@ -55,6 +57,5 @@ android:layout_alignParentEnd="true" android:textSize="14sp" android:scrollHorizontally="false" - android:layout_centerVertical="true" - android:focusable="true"/> + android:layout_centerVertical="true"/> </com.android.systemui.statusbar.KeyboardShortcutAppItemLayout> diff --git a/packages/SystemUI/res/layout/keyboard_shortcuts_category_title.xml b/packages/SystemUI/res/layout/keyboard_shortcuts_category_title.xml index 8414223b7654..0759990f1677 100644 --- a/packages/SystemUI/res/layout/keyboard_shortcuts_category_title.xml +++ b/packages/SystemUI/res/layout/keyboard_shortcuts_category_title.xml @@ -16,10 +16,11 @@ ~ limitations under the License --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="14sp" android:fontFamily="sans-serif-medium" + android:importantForAccessibility="yes" android:paddingStart="24dp" android:paddingTop="20dp" android:paddingEnd="24dp" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java index a3fd82e9b140..ae3d41e19b5f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java @@ -440,10 +440,15 @@ public final class KeyboardShortcuts { mContext.getString(R.string.keyboard_shortcut_group_system_back), KeyEvent.KEYCODE_DEL, KeyEvent.META_META_ON)); - systemGroup.addItem(new KeyboardShortcutInfo( - mContext.getString(R.string.keyboard_shortcut_group_system_recents), - KeyEvent.KEYCODE_TAB, - KeyEvent.META_ALT_ON)); + + // Some devices (like TV) don't have recents + if (mContext.getResources().getBoolean(com.android.internal.R.bool.config_hasRecents)) { + systemGroup.addItem(new KeyboardShortcutInfo( + mContext.getString(R.string.keyboard_shortcut_group_system_recents), + KeyEvent.KEYCODE_TAB, + KeyEvent.META_ALT_ON)); + } + systemGroup.addItem(new KeyboardShortcutInfo( mContext.getString( R.string.keyboard_shortcut_group_system_notifications), @@ -683,8 +688,10 @@ public final class KeyboardShortcuts { ViewGroup shortcutItemsContainer = (ViewGroup) shortcutView .findViewById(R.id.keyboard_shortcuts_item_container); final int shortcutKeysSize = shortcutKeys.size(); + final List<String> humanReadableShortcuts = new ArrayList<>(); for (int k = 0; k < shortcutKeysSize; k++) { StringDrawableContainer shortcutRepresentation = shortcutKeys.get(k); + humanReadableShortcuts.add(shortcutRepresentation.mString); if (shortcutRepresentation.mDrawable != null) { ImageView shortcutKeyIconView = (ImageView) inflater.inflate( R.layout.keyboard_shortcuts_key_icon_view, shortcutItemsContainer, @@ -714,6 +721,11 @@ public final class KeyboardShortcuts { shortcutItemsContainer.addView(shortcutKeyTextView); } } + CharSequence contentDescription = info.getLabel(); + if (!humanReadableShortcuts.isEmpty()) { + contentDescription += ": " + String.join(", ", humanReadableShortcuts); + } + shortcutView.setContentDescription(contentDescription); shortcutContainer.addView(shortcutView); } keyboardShortcutsLayout.addView(shortcutContainer); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java index b1b8341d9584..d35d34063d1e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tv/TvStatusBar.java @@ -27,11 +27,12 @@ import com.android.systemui.CoreStartable; import com.android.systemui.assist.AssistManager; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.statusbar.CommandQueue; - -import javax.inject.Inject; +import com.android.systemui.statusbar.KeyboardShortcuts; import dagger.Lazy; +import javax.inject.Inject; + /** * Status bar implementation for "large screen" products that mostly present no on-screen nav. * Serves as a collection of UI components, rather than showing its own UI. @@ -78,4 +79,9 @@ public class TvStatusBar implements CoreStartable, CommandQueue.Callbacks { new Intent(ACTION_SHOW_PIP_MENU).setPackage(mContext.getPackageName()), SYSTEMUI_PERMISSION); } + + @Override + public void toggleKeyboardShortcutsMenu(int deviceId) { + KeyboardShortcuts.show(mContext, deviceId); + } } diff --git a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java index d9a8e0cfb53a..3f31ff94fee7 100644 --- a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java @@ -48,6 +48,7 @@ import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeControllerImpl; import com.android.systemui.shade.ShadeExpansionStateManager; import com.android.systemui.statusbar.CommandQueue; +import com.android.systemui.statusbar.KeyboardShortcutsModule; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationLockscreenUserManager; import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; @@ -96,6 +97,7 @@ import javax.inject.Named; ReferenceScreenshotModule.class, StatusBarEventsModule.class, VolumeModule.class, + KeyboardShortcutsModule.class } ) public abstract class TvSystemUIModule { |