From a02965e21199fccf897d6746149a3432f865ce4a Mon Sep 17 00:00:00 2001 From: Andrei Stingaceanu Date: Fri, 8 Apr 2016 16:42:02 +0100 Subject: [PATCH] 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 --- .../res/drawable/ksh_key_item_background.xml | 21 ++++++++++++++++ .../res/layout/keyboard_shortcut_app_item.xml | 11 +++++---- .../keyboard_shortcuts_key_icon_view.xml | 2 +- .../layout/keyboard_shortcuts_key_view.xml | 3 ++- packages/SystemUI/res/values/colors.xml | 4 ++-- .../systemui/statusbar/KeyboardShortcuts.java | 24 +++++++++---------- 6 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 packages/SystemUI/res/drawable/ksh_key_item_background.xml 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 0000000000000..75ff30d25aa7c --- /dev/null +++ b/packages/SystemUI/res/drawable/ksh_key_item_background.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml b/packages/SystemUI/res/layout/keyboard_shortcut_app_item.xml index 38650208f7d58..63b759b7b2764 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 --> @@ -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"/> + android:layout_alignParentStart="true" + android:layout_centerVertical="true"/> + android:scrollHorizontally="false" + android:layout_centerVertical="true"/> 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 0cecb96fd0229..5db678958ce13 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 1215029bdda0a..31a87730a445e 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 b874e7c051dbc..3904a62885e8b 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -166,11 +166,11 @@ #ff7fcac3 - #ff00bcd4 + @color/material_deep_teal_500 #fff44336 #d9000000 @color/material_grey_600 - #eeeeee + @color/material_grey_100 #455A64 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyboardShortcuts.java index fff14914baf2d..60ac9498c397e 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 @@ public final class KeyboardShortcuts { List 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 @@ public final class KeyboardShortcuts { 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 @@ public final class KeyboardShortcuts { 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 @@ public final class KeyboardShortcuts { } } - 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 getHumanReadableShortcutKeys(KeyboardShortcutInfo info) { List shortcutKeys = getHumanReadableModifiers(info); if (shortcutKeys == null) {