Merge "Add support for keyboard shortcuts panel on TV"
This commit is contained in:
committed by
Android (Google) Code Review
commit
5210caeb1d
21
packages/SystemUI/res/drawable/list_item_background.xml
Normal file
21
packages/SystemUI/res/drawable/list_item_background.xml
Normal file
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user