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/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) {