Refactor Key.isFunctional to more generic Key.keyType
Bug: 5232726 Change-Id: Idc861ca725f62eaf37795f57401573394a17d6d3main
parent
fa52a09f21
commit
7918ed0169
|
@ -194,8 +194,11 @@
|
||||||
<attr name="moreKeys" format="string" />
|
<attr name="moreKeys" format="string" />
|
||||||
<!-- Maximum column of more keys keyboard -->
|
<!-- Maximum column of more keys keyboard -->
|
||||||
<attr name="maxMoreKeysColumn" format="integer" />
|
<attr name="maxMoreKeysColumn" format="integer" />
|
||||||
<!-- Whether this is a functional key which has different key top than normal key. -->
|
<attr name="backgroundType" format="enum">
|
||||||
<attr name="isFunctional" format="boolean" />
|
<!-- 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. -->
|
<!-- Whether this is a toggle key. -->
|
||||||
<attr name="isSticky" format="boolean" />
|
<attr name="isSticky" format="boolean" />
|
||||||
<!-- Whether long-pressing on this key will make it repeat. -->
|
<!-- Whether long-pressing on this key will make it repeat. -->
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<!-- Base key style for the functional key -->
|
<!-- Base key style for the functional key -->
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="functionalKeyStyle"
|
latin:styleName="functionalKeyStyle"
|
||||||
latin:isFunctional="true" />
|
latin:backgroundType="functional" />
|
||||||
<!-- Base key style for the key which may have settings key as popup key -->
|
<!-- Base key style for the key which may have settings key as popup key -->
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<!-- Functional key styles -->
|
<!-- Functional key styles -->
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="functionalKeyStyle"
|
latin:styleName="functionalKeyStyle"
|
||||||
latin:isFunctional="true" />
|
latin:backgroundType="functional" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="shiftKeyStyle"
|
latin:styleName="shiftKeyStyle"
|
||||||
latin:code="@integer/key_shift"
|
latin:code="@integer/key_shift"
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<!-- Base key style for the functional key -->
|
<!-- Base key style for the functional key -->
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="functionalKeyStyle"
|
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. -->
|
<!-- Base key style for the key which may have settings or tab key as popup key. -->
|
||||||
<switch>
|
<switch>
|
||||||
<case
|
<case
|
||||||
|
|
|
@ -102,8 +102,12 @@ public class Key {
|
||||||
* {@link Keyboard#EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM}.
|
* {@link Keyboard#EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM}.
|
||||||
*/
|
*/
|
||||||
private int mEdgeFlags;
|
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 */
|
/** Whether this key repeats itself when held down */
|
||||||
public final boolean mRepeatable;
|
public final boolean mRepeatable;
|
||||||
|
|
||||||
|
@ -225,7 +229,7 @@ public class Key {
|
||||||
mEdgeFlags = edgeFlags;
|
mEdgeFlags = edgeFlags;
|
||||||
mHintLabel = hintLabel;
|
mHintLabel = hintLabel;
|
||||||
mLabelOption = 0;
|
mLabelOption = 0;
|
||||||
mFunctional = false;
|
mBackgroundType = BACKGROUND_TYPE_NORMAL;
|
||||||
mSticky = false;
|
mSticky = false;
|
||||||
mRepeatable = false;
|
mRepeatable = false;
|
||||||
mMoreKeys = null;
|
mMoreKeys = null;
|
||||||
|
@ -325,8 +329,9 @@ public class Key {
|
||||||
mMaxMoreKeysColumn = style.getInt(keyboardAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn,
|
mMaxMoreKeysColumn = style.getInt(keyboardAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn,
|
||||||
params.mMaxMiniKeyboardColumn);
|
params.mMaxMiniKeyboardColumn);
|
||||||
|
|
||||||
|
mBackgroundType = style.getInt(
|
||||||
|
keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
|
||||||
mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false);
|
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);
|
mSticky = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky, false);
|
||||||
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
|
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
|
||||||
mEdgeFlags = 0;
|
mEdgeFlags = 0;
|
||||||
|
@ -540,7 +545,7 @@ public class Key {
|
||||||
*/
|
*/
|
||||||
public int[] getCurrentDrawableState() {
|
public int[] getCurrentDrawableState() {
|
||||||
final boolean pressed = mPressed;
|
final boolean pressed = mPressed;
|
||||||
if (!mSticky && mFunctional) {
|
if (!mSticky && mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
return KEY_STATE_FUNCTIONAL_PRESSED;
|
return KEY_STATE_FUNCTIONAL_PRESSED;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class KeyStyles {
|
||||||
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
|
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
|
||||||
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
|
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
|
||||||
readInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn);
|
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_isSticky);
|
||||||
readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
|
readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
|
||||||
readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
|
readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
|
||||||
|
|
Loading…
Reference in New Issue