From 7918ed016960908700582e47322e52d74c328cc7 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Thu, 15 Sep 2011 14:21:46 +0900 Subject: [PATCH] Refactor Key.isFunctional to more generic Key.keyType Bug: 5232726 Change-Id: Idc861ca725f62eaf37795f57401573394a17d6d3 --- java/res/values/attrs.xml | 7 +++++-- java/res/xml-sw600dp/kbd_key_styles.xml | 2 +- java/res/xml-sw768dp/kbd_key_styles.xml | 2 +- java/res/xml/kbd_key_styles.xml | 2 +- .../src/com/android/inputmethod/keyboard/Key.java | 15 ++++++++++----- .../inputmethod/keyboard/internal/KeyStyles.java | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 9358c9085a..3275cd0174 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -194,8 +194,11 @@ <attr name="moreKeys" format="string" /> <!-- Maximum column of more keys keyboard --> <attr name="maxMoreKeysColumn" format="integer" /> - <!-- Whether this is a functional key which has different key top than normal key. --> - <attr name="isFunctional" format="boolean" /> + <attr name="backgroundType" format="enum"> + <!-- This should be aligned with Key.BACKGROUND_TYPE_* --> + <enum name="normal" value="0" /> + <enum name="functional" value="1" /> + </attr> <!-- Whether this is a toggle key. --> <attr name="isSticky" format="boolean" /> <!-- Whether long-pressing on this key will make it repeat. --> diff --git a/java/res/xml-sw600dp/kbd_key_styles.xml b/java/res/xml-sw600dp/kbd_key_styles.xml index 2c31e27e4a..dfc7409adf 100644 --- a/java/res/xml-sw600dp/kbd_key_styles.xml +++ b/java/res/xml-sw600dp/kbd_key_styles.xml @@ -24,7 +24,7 @@ <!-- Base key style for the functional key --> <key-style latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> + latin:backgroundType="functional" /> <!-- Base key style for the key which may have settings key as popup key --> <switch> <case diff --git a/java/res/xml-sw768dp/kbd_key_styles.xml b/java/res/xml-sw768dp/kbd_key_styles.xml index 6570ebccba..f7dcc2026f 100644 --- a/java/res/xml-sw768dp/kbd_key_styles.xml +++ b/java/res/xml-sw768dp/kbd_key_styles.xml @@ -24,7 +24,7 @@ <!-- Functional key styles --> <key-style latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> + latin:backgroundType="functional" /> <key-style latin:styleName="shiftKeyStyle" latin:code="@integer/key_shift" diff --git a/java/res/xml/kbd_key_styles.xml b/java/res/xml/kbd_key_styles.xml index 84b1900f01..e1f68d4e24 100644 --- a/java/res/xml/kbd_key_styles.xml +++ b/java/res/xml/kbd_key_styles.xml @@ -24,7 +24,7 @@ <!-- Base key style for the functional key --> <key-style latin:styleName="functionalKeyStyle" - latin:isFunctional="true" /> + latin:backgroundType="functional" /> <!-- Base key style for the key which may have settings or tab key as popup key. --> <switch> <case diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 06d248e3a7..c4d5e857dd 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -102,8 +102,12 @@ public class Key { * {@link Keyboard#EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM}. */ private int mEdgeFlags; - /** Whether this is a functional key which has different key top than normal key */ - public final boolean mFunctional; + + /** Background type that represents different key background visual than normal one. */ + public final int mBackgroundType; + public static final int BACKGROUND_TYPE_NORMAL = 0; + public static final int BACKGROUND_TYPE_FUNCTIONAL = 1; + /** Whether this key repeats itself when held down */ public final boolean mRepeatable; @@ -225,7 +229,7 @@ public class Key { mEdgeFlags = edgeFlags; mHintLabel = hintLabel; mLabelOption = 0; - mFunctional = false; + mBackgroundType = BACKGROUND_TYPE_NORMAL; mSticky = false; mRepeatable = false; mMoreKeys = null; @@ -325,8 +329,9 @@ public class Key { mMaxMoreKeysColumn = style.getInt(keyboardAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn, params.mMaxMiniKeyboardColumn); + mBackgroundType = style.getInt( + keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL); mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false); - mFunctional = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional, false); mSticky = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky, false); mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true); mEdgeFlags = 0; @@ -540,7 +545,7 @@ public class Key { */ public int[] getCurrentDrawableState() { final boolean pressed = mPressed; - if (!mSticky && mFunctional) { + if (!mSticky && mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) { if (pressed) { return KEY_STATE_FUNCTIONAL_PRESSED; } else { diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java index 6d78e85339..9800f245a7 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java @@ -172,7 +172,7 @@ public class KeyStyles { readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview); readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted); readInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn); - readBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional); + readInt(keyAttr, R.styleable.Keyboard_Key_backgroundType); readBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky); readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable); readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled); -- GitLab