Refactor Key.isFunctional to more generic Key.keyType

Bug: 5232726
Change-Id: Idc861ca725f62eaf37795f57401573394a17d6d3
main
Tadashi G. Takaoka 2011-09-15 14:21:46 +09:00
parent fa52a09f21
commit 7918ed0169
6 changed files with 19 additions and 11 deletions

View File

@ -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. -->

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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 {

View File

@ -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);