From 3410e16907d4c1058bcc7ccf05e9a8382a9b59bb Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Tue, 5 Aug 2014 17:32:53 +0900 Subject: [PATCH] Make popup hint letter theme-aware Bug: 16351091 Change-Id: I6af18ea210c00916157138b9cfbeb073aee6ca1b --- java/res/values/attrs.xml | 4 +++- java/res/values/themes-ics.xml | 2 ++ java/res/values/themes-klp.xml | 2 ++ java/res/values/themes-lxx-dark.xml | 1 + java/res/values/themes-lxx-light.xml | 1 + .../android/inputmethod/keyboard/KeyboardView.java | 13 +++++++++---- 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 003b011f3a..9a2227321d 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -52,7 +52,9 @@ <attr name="spacebarIconWidthRatio" format="float" /> <!-- Right padding of hint letter to the edge of the key.--> <attr name="keyHintLetterPadding" format="dimension" /> - <!-- Bottom padding of popup hint letter "..." to the edge of the key.--> + <!-- Popup hint letter string--> + <attr name="keyPopupHintLetter" format="string" /> + <!-- Bottom padding of popup hint letter to the edge of the key.--> <attr name="keyPopupHintLetterPadding" format="dimension" /> <!-- Right padding of shifted letter hint to the edge of the key.--> <attr name="keyShiftedLetterHintPadding" format="dimension" /> diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index 6118ce1779..a6f390cbbd 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -60,6 +60,8 @@ <item name="keyPreviewTextColor">@color/key_text_color_holo</item> <!-- A negative value to disable key text shadow layer. --> <item name="keyTextShadowRadius">-1.0</item> + <!-- U+2026: "…" HORIZONTAL ELLIPSIS --> + <item name="keyPopupHintLetter">…</item> </style> <style name="MainKeyboardView.ICS" diff --git a/java/res/values/themes-klp.xml b/java/res/values/themes-klp.xml index 193386062d..8782a76aab 100644 --- a/java/res/values/themes-klp.xml +++ b/java/res/values/themes-klp.xml @@ -60,6 +60,8 @@ <item name="keyPreviewTextColor">@color/key_text_color_holo</item> <!-- A negative value to disable key text shadow layer. --> <item name="keyTextShadowRadius">-1.0</item> + <!-- U+2026: "…" HORIZONTAL ELLIPSIS --> + <item name="keyPopupHintLetter">…</item> </style> <style name="MainKeyboardView.KLP" diff --git a/java/res/values/themes-lxx-dark.xml b/java/res/values/themes-lxx-dark.xml index 0a13158588..fa6aa62e5a 100644 --- a/java/res/values/themes-lxx-dark.xml +++ b/java/res/values/themes-lxx-dark.xml @@ -61,6 +61,7 @@ <item name="keyPreviewTextColor">@color/key_text_color_lxx_dark</item> <!-- A negative value to disable key text shadow layer. --> <item name="keyTextShadowRadius">-1.0</item> + <item name="keyPopupHintLetter"></item> <!-- No popup hint letter --> </style> <style name="MainKeyboardView.LXX_Dark" diff --git a/java/res/values/themes-lxx-light.xml b/java/res/values/themes-lxx-light.xml index eccecdd876..e7350f924f 100644 --- a/java/res/values/themes-lxx-light.xml +++ b/java/res/values/themes-lxx-light.xml @@ -61,6 +61,7 @@ <item name="keyPreviewTextColor">@color/key_text_color_lxx_light</item> <!-- A negative value to disable key text shadow layer. --> <item name="keyTextShadowRadius">-1.0</item> + <item name="keyPopupHintLetter"></item> <!-- No popup hint letter --> </style> <style name="MainKeyboardView.LXX_Light" diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java index f967f620a5..5af0be6495 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java @@ -29,6 +29,7 @@ import android.graphics.Region; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.graphics.drawable.NinePatchDrawable; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; @@ -48,6 +49,7 @@ import java.util.HashSet; * @attr ref R.styleable#KeyboardView_spacebarBackground * @attr ref R.styleable#KeyboardView_spacebarIconWidthRatio * @attr ref R.styleable#KeyboardView_keyHintLetterPadding + * @attr ref R.styleable#KeyboardView_keyPopupHintLetter * @attr ref R.styleable#KeyboardView_keyPopupHintLetterPadding * @attr ref R.styleable#KeyboardView_keyShiftedLetterHintPadding * @attr ref R.styleable#KeyboardView_keyTextShadowRadius @@ -74,6 +76,7 @@ public class KeyboardView extends View { // XML attributes private final KeyVisualAttributes mKeyVisualAttributes; private final float mKeyHintLetterPadding; + private final String mKeyPopupHintLetter; private final float mKeyPopupHintLetterPadding; private final float mKeyShiftedLetterHintPadding; private final float mKeyTextShadowRadius; @@ -85,9 +88,6 @@ public class KeyboardView extends View { private final Rect mKeyBackgroundPadding = new Rect(); private static final float KET_TEXT_SHADOW_RADIUS_DISABLED = -1.0f; - // HORIZONTAL ELLIPSIS "...", character for popup hint. - private static final String POPUP_HINT_CHAR = "\u2026"; - // The maximum key label width in the proportion to the key width. private static final float MAX_LABEL_RATIO = 0.90f; @@ -132,6 +132,8 @@ public class KeyboardView extends View { R.styleable.KeyboardView_spacebarIconWidthRatio, 1.0f); mKeyHintLetterPadding = keyboardViewAttr.getDimension( R.styleable.KeyboardView_keyHintLetterPadding, 0.0f); + mKeyPopupHintLetter = keyboardViewAttr.getString( + R.styleable.KeyboardView_keyPopupHintLetter); mKeyPopupHintLetterPadding = keyboardViewAttr.getDimension( R.styleable.KeyboardView_keyPopupHintLetterPadding, 0.0f); mKeyShiftedLetterHintPadding = keyboardViewAttr.getDimension( @@ -468,6 +470,9 @@ public class KeyboardView extends View { // Draw popup hint "..." at the bottom right corner of the key. protected void drawKeyPopupHint(final Key key, final Canvas canvas, final Paint paint, final KeyDrawParams params) { + if (TextUtils.isEmpty(mKeyPopupHintLetter)) { + return; + } final int keyWidth = key.getDrawWidth(); final int keyHeight = key.getHeight(); @@ -478,7 +483,7 @@ public class KeyboardView extends View { final float hintX = keyWidth - mKeyHintLetterPadding - TypefaceUtils.getReferenceCharWidth(paint) / 2.0f; final float hintY = keyHeight - mKeyPopupHintLetterPadding; - canvas.drawText(POPUP_HINT_CHAR, hintX, hintY, paint); + canvas.drawText(mKeyPopupHintLetter, hintX, hintY, paint); } protected static void drawIcon(final Canvas canvas, final Drawable icon, final int x, -- GitLab