Keyboard shortcuts: UI polish 1
* title color for system groups is now: "material_deep_teal_500"
* background behind shortcut keys:
** Now has 2dp rounded corners
** changed color from "material_grey_200" to "material_grey_100"
* the text items now have a minimum width equal to their height.
This means that now the text items with one character are always
the same (square) size as the icon items. Makes the UI look much
cleaner thus easier to read
* the line item now has a minimum height of 48dp and the content
is vertically centered
* minor variable renaming for increased readability
Bug: 28075364
Change-Id: Id7090b607b9c604c55513e7c393ed1084a1c8df0
diff --git a/packages/SystemUI/res/drawable/ksh_key_item_background.xml b/packages/SystemUI/res/drawable/ksh_key_item_background.xml
new file mode 100644
index 0000000..75ff30d
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ksh_key_item_background.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2016 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
+ -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <solid android:color="@color/ksh_key_item_background" />
+ <corners android:radius="2dp" />
+</shape>
diff --git a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
index 3865020..63b759b 100644
--- a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
+++ b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml
@@ -15,10 +15,10 @@
~ limitations under the License
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/keyboard_shortcuts_keyword_wrapper"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:minHeight="48dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp">
@@ -29,7 +29,8 @@
android:layout_marginEnd="32dp"
android:layout_gravity="center_vertical"
android:visibility="gone"
- android:layout_alignParentStart="true"/>
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"/>
<TextView
android:id="@+id/keyboard_shortcuts_keyword"
android:layout_toEndOf="@+id/keyboard_shortcuts_icon"
@@ -41,7 +42,8 @@
android:maxLines="5"
android:singleLine="false"
android:scrollHorizontally="false"
- android:layout_alignParentStart="true"/>
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"/>
<com.android.systemui.statusbar.KeyboardShortcutKeysLayout
android:id="@+id/keyboard_shortcuts_item_container"
android:layout_toEndOf="@+id/keyboard_shortcuts_keyword"
@@ -50,5 +52,6 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textSize="14sp"
- android:scrollHorizontally="false"/>
+ android:scrollHorizontally="false"
+ android:layout_centerVertical="true"/>
</RelativeLayout>
diff --git a/packages/SystemUI/res/layout/keyboard_shortcuts_key_icon_view.xml b/packages/SystemUI/res/layout/keyboard_shortcuts_key_icon_view.xml
index 0cecb96..5db6789 100644
--- a/packages/SystemUI/res/layout/keyboard_shortcuts_key_icon_view.xml
+++ b/packages/SystemUI/res/layout/keyboard_shortcuts_key_icon_view.xml
@@ -21,4 +21,4 @@
android:padding="@dimen/ksh_item_padding"
android:layout_marginStart="@dimen/ksh_item_margin_start"
android:scaleType="fitXY"
- android:background="@color/ksh_key_item_background"/>
+ android:background="@drawable/ksh_key_item_background"/>
diff --git a/packages/SystemUI/res/layout/keyboard_shortcuts_key_view.xml b/packages/SystemUI/res/layout/keyboard_shortcuts_key_view.xml
index 1215029..31a8773 100644
--- a/packages/SystemUI/res/layout/keyboard_shortcuts_key_view.xml
+++ b/packages/SystemUI/res/layout/keyboard_shortcuts_key_view.xml
@@ -19,7 +19,8 @@
android:layout_height="wrap_content"
android:padding="@dimen/ksh_item_padding"
android:layout_marginStart="@dimen/ksh_item_margin_start"
- android:background="@color/ksh_key_item_background"
+ android:background="@drawable/ksh_key_item_background"
android:textColor="@color/ksh_key_item_color"
android:singleLine="true"
+ android:gravity="center"
android:textSize="@dimen/ksh_item_text_size"/>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index b874e7c..3904a62 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -166,11 +166,11 @@
<color name="switch_accent_color">#ff7fcac3</color>
<!-- Keyboard shortcuts colors -->
- <color name="ksh_system_group_color">#ff00bcd4</color>
+ <color name="ksh_system_group_color">@color/material_deep_teal_500</color>
<color name="ksh_application_group_color">#fff44336</color>
<color name="ksh_keyword_color">#d9000000</color>
<color name="ksh_key_item_color">@color/material_grey_600</color>
- <color name="ksh_key_item_background">#eeeeee</color>
+ <color name="ksh_key_item_background">@color/material_grey_100</color>
<!-- Background color of edit overflow -->
<color name="qs_edit_overflow_bg">#455A64</color>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
index fff1491..60ac949 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java
@@ -471,8 +471,15 @@
List<KeyboardShortcutGroup> keyboardShortcutGroups) {
LayoutInflater inflater = LayoutInflater.from(mContext);
final int keyboardShortcutGroupsSize = keyboardShortcutGroups.size();
+ TextView shortcutsKeyView = (TextView) inflater.inflate(
+ R.layout.keyboard_shortcuts_key_view, null, false);
+ shortcutsKeyView.measure(
+ View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
+ final int shortcutKeyTextItemMinWidth = shortcutsKeyView.getMeasuredHeight();
// Needed to be able to scale the image items to the same height as the text items.
- final int shortcutTextItemHeight = getShortcutTextItemHeight(inflater);
+ final int shortcutKeyIconItemHeightWidth = shortcutsKeyView.getMeasuredHeight()
+ - shortcutsKeyView.getPaddingTop()
+ - shortcutsKeyView.getPaddingBottom();
for (int i = 0; i < keyboardShortcutGroupsSize; i++) {
KeyboardShortcutGroup group = keyboardShortcutGroups.get(i);
TextView categoryTitle = (TextView) inflater.inflate(
@@ -529,8 +536,8 @@
ImageView shortcutKeyIconView = (ImageView) inflater.inflate(
R.layout.keyboard_shortcuts_key_icon_view, shortcutItemsContainer,
false);
- Bitmap bitmap = Bitmap.createBitmap(shortcutTextItemHeight,
- shortcutTextItemHeight, Bitmap.Config.ARGB_8888);
+ Bitmap bitmap = Bitmap.createBitmap(shortcutKeyIconItemHeightWidth,
+ shortcutKeyIconItemHeightWidth, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
shortcutRepresentation.drawable.setBounds(0, 0, canvas.getWidth(),
canvas.getHeight());
@@ -541,6 +548,7 @@
TextView shortcutKeyTextView = (TextView) inflater.inflate(
R.layout.keyboard_shortcuts_key_view, shortcutItemsContainer,
false);
+ shortcutKeyTextView.setMinimumWidth(shortcutKeyTextItemMinWidth);
shortcutKeyTextView.setText(shortcutRepresentation.string);
shortcutItemsContainer.addView(shortcutKeyTextView);
}
@@ -557,16 +565,6 @@
}
}
- private int getShortcutTextItemHeight(LayoutInflater inflater) {
- TextView shortcutKeyTextView = (TextView) inflater.inflate(
- R.layout.keyboard_shortcuts_key_view, null, false);
- shortcutKeyTextView.measure(
- View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
- return shortcutKeyTextView.getMeasuredHeight()
- - shortcutKeyTextView.getPaddingTop()
- - shortcutKeyTextView.getPaddingBottom();
- }
-
private List<StringOrDrawable> getHumanReadableShortcutKeys(KeyboardShortcutInfo info) {
List<StringOrDrawable> shortcutKeys = getHumanReadableModifiers(info);
if (shortcutKeys == null) {