From e19c520b419faaf96180984528ae32b514a1bc77 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Thu, 7 Aug 2014 12:32:59 +0900 Subject: [PATCH] Align space key icon to bottom of a key The Key.keyLabelFlags's flag "alignButtom" (misspelled) has been removed by Iae3cd66744. This CL re-introduce the same flag with "alignIconToBottom". Bug: 16803172 Change-Id: I412590f394c6ca9b36358d6acfe8675071403bdd --- java/res/values/attrs.xml | 1 + java/res/xml/key_styles_number.xml | 1 + java/src/com/android/inputmethod/keyboard/Key.java | 5 +++++ .../com/android/inputmethod/keyboard/KeyboardView.java | 10 +++++++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index e6215c254..37ba3963b 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -292,6 +292,7 @@ + diff --git a/java/res/xml/key_styles_number.xml b/java/res/xml/key_styles_number.xml index f754b99b3..3038097d8 100644 --- a/java/res/xml/key_styles_number.xml +++ b/java/res/xml/key_styles_number.xml @@ -120,6 +120,7 @@ diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 55ce7dd34..aaa55d79c 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -58,6 +58,7 @@ public class Key implements Comparable { private final String mHintLabel; /** Flags of the label */ private final int mLabelFlags; + private static final int LABEL_FLAGS_ALIGN_ICON_TO_BOTTOM = 0x04; private static final int LABEL_FLAGS_ALIGN_LEFT_OF_CENTER = 0x08; // Font typeface specification. private static final int LABEL_FLAGS_FONT_MASK = 0x30; @@ -643,6 +644,10 @@ public class Key implements Comparable { return Typeface.DEFAULT_BOLD; } + public final boolean isAlignIconToBottom() { + return (mLabelFlags & LABEL_FLAGS_ALIGN_ICON_TO_BOTTOM) != 0; + } + public final boolean isAlignLeftOfCenter() { return (mLabelFlags & LABEL_FLAGS_ALIGN_LEFT_OF_CENTER) != 0; } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index 5af0be649..4a791f325 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -456,9 +456,13 @@ public class KeyboardView extends View { iconWidth = Math.min(icon.getIntrinsicWidth(), keyWidth); } final int iconHeight = icon.getIntrinsicHeight(); - // Align center. - final int iconY = (keyHeight - iconHeight) / 2; - final int iconX = (keyWidth - iconWidth) / 2; + final int iconY; + if (key.isAlignIconToBottom()) { + iconY = keyHeight - iconHeight; + } else { + iconY = (keyHeight - iconHeight) / 2; // Align vertically center. + } + final int iconX = (keyWidth - iconWidth) / 2; // Align horizontally center. drawIcon(canvas, icon, iconX, iconY, iconWidth, iconHeight); }