Merge "Add empty key background type"

This commit is contained in:
Tadashi G. Takaoka 2013-08-14 10:12:14 +00:00 committed by Android (Google) Code Review
commit bdef628a35
8 changed files with 46 additions and 39 deletions

View file

@ -15,9 +15,7 @@
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Toggle keys. Use checkable/checked state. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" <item android:state_checkable="true" android:state_checked="true"
android:state_pressed="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_pressed_on" /> android:drawable="@drawable/btn_keyboard_key_pressed_on" />
@ -28,11 +26,12 @@
<item android:state_checkable="true" <item android:state_checkable="true"
android:drawable="@drawable/btn_keyboard_key_normal_off" /> android:drawable="@drawable/btn_keyboard_key_normal_off" />
<!-- Normal keys --> <!-- Empty background keys. -->
<item android:state_empty="true"
android:drawable="@drawable/transparent" />
<!-- Normal keys. -->
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_pressed" /> android:drawable="@drawable/btn_keyboard_key_pressed" />
<item <item android:drawable="@drawable/btn_keyboard_key_normal" />
android:drawable="@drawable/btn_keyboard_key_normal" />
</selector> </selector>

View file

@ -15,9 +15,7 @@
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Toggle keys. Use checkable/checked state. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" <item android:state_checkable="true" android:state_checked="true"
android:state_pressed="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_pressed_on" /> android:drawable="@drawable/btn_keyboard_key_pressed_on" />
@ -28,8 +26,11 @@
<item android:state_checkable="true" <item android:state_checkable="true"
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
<!-- Normal keys --> <!-- Empty background keys. -->
<item android:state_empty="true"
android:drawable="@drawable/transparent" />
<!-- Normal keys. -->
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" /> android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
<item android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> <item android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />

View file

@ -15,23 +15,19 @@
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Functional keys. --> <!-- Functional keys. -->
<item android:state_single="true" android:state_pressed="true" <item android:state_single="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed" />
<item android:state_single="true" <item android:state_single="true"
android:drawable="@drawable/btn_keyboard_key_dark_normal" /> android:drawable="@drawable/btn_keyboard_key_dark_normal" />
<!-- Action keys. --> <!-- Action keys. -->
<item android:state_active="true" android:state_pressed="true" <item android:state_active="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed" />
<item android:state_active="true" <item android:state_active="true"
android:drawable="@drawable/btn_keyboard_key_dark_normal" /> android:drawable="@drawable/btn_keyboard_key_dark_normal" />
<!-- Toggle keys. Use checkable/checked state. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" android:state_pressed="true" <item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed_on" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed_on" />
<item android:state_checkable="true" android:state_pressed="true" <item android:state_checkable="true" android:state_pressed="true"
@ -41,8 +37,11 @@
<item android:state_checkable="true" <item android:state_checkable="true"
android:drawable="@drawable/btn_keyboard_key_dark_normal_off" /> android:drawable="@drawable/btn_keyboard_key_dark_normal_off" />
<!-- Normal keys. --> <!-- Empty background keys. -->
<item android:state_empty="true"
android:drawable="@drawable/transparent" />
<!-- Normal keys. -->
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_light_pressed" /> android:drawable="@drawable/btn_keyboard_key_light_pressed" />
<item android:drawable="@drawable/btn_keyboard_key_light_normal" /> <item android:drawable="@drawable/btn_keyboard_key_light_normal" />

View file

@ -15,23 +15,19 @@
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Functional keys. --> <!-- Functional keys. -->
<item android:state_single="true" android:state_pressed="true" <item android:state_single="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" />
<item android:state_single="true" <item android:state_single="true"
android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
<!-- Action keys. --> <!-- Action keys. -->
<item android:state_active="true" android:state_pressed="true" <item android:state_active="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" />
<item android:state_active="true" <item android:state_active="true"
android:drawable="@drawable/btn_keyboard_key_dark_active_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_active_holo" />
<!-- Toggle keys. Use checkable/checked state. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" android:state_pressed="true" <item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed_on_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_pressed_on_holo" />
<item android:state_checkable="true" android:state_pressed="true" <item android:state_checkable="true" android:state_pressed="true"
@ -41,8 +37,11 @@
<item android:state_checkable="true" <item android:state_checkable="true"
android:drawable="@drawable/btn_keyboard_key_dark_normal_off_holo" /> android:drawable="@drawable/btn_keyboard_key_dark_normal_off_holo" />
<!-- Normal keys. --> <!-- Empty background keys. -->
<item android:state_empty="true"
android:drawable="@drawable/transparent" />
<!-- Normal keys. -->
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_light_pressed_holo" /> android:drawable="@drawable/btn_keyboard_key_light_pressed_holo" />
<item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" /> <item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />

View file

@ -15,23 +15,19 @@
--> -->
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Functional keys. --> <!-- Functional keys. -->
<item android:state_single="true" android:state_pressed="true" <item android:state_single="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
<item android:state_single="true" <item android:state_single="true"
android:drawable="@drawable/btn_keyboard_key_normal_stone" /> android:drawable="@drawable/btn_keyboard_key_normal_stone" />
<!-- Action keys. --> <!-- Action keys. -->
<item android:state_active="true" android:state_pressed="true" <item android:state_active="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
<item android:state_active="true" <item android:state_active="true"
android:drawable="@drawable/btn_keyboard_key_normal_stone" /> android:drawable="@drawable/btn_keyboard_key_normal_stone" />
<!-- Toggle keys. Use checkable/checked state. --> <!-- Toggle keys. Use checkable/checked state. -->
<item android:state_checkable="true" android:state_checked="true" <item android:state_checkable="true" android:state_checked="true"
android:state_pressed="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_normal_on_stone" /> android:drawable="@drawable/btn_keyboard_key_normal_on_stone" />
@ -42,8 +38,11 @@
<item android:state_checkable="true" <item android:state_checkable="true"
android:drawable="@drawable/btn_keyboard_key_normal_off_stone" /> android:drawable="@drawable/btn_keyboard_key_normal_off_stone" />
<!-- Normal keys. --> <!-- Empty background keys. -->
<item android:state_empty="true"
android:drawable="@drawable/transparent" />
<!-- Normal keys. -->
<item android:state_pressed="true" <item android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" /> android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
<item android:drawable="@drawable/btn_keyboard_key_normal_stone" /> <item android:drawable="@drawable/btn_keyboard_key_normal_stone" />

View file

@ -240,11 +240,12 @@
<attr name="maxMoreKeysColumn" format="integer" /> <attr name="maxMoreKeysColumn" format="integer" />
<attr name="backgroundType" format="enum"> <attr name="backgroundType" format="enum">
<!-- This should be aligned with Key.BACKGROUND_TYPE_* --> <!-- This should be aligned with Key.BACKGROUND_TYPE_* -->
<enum name="normal" value="0" /> <enum name="empty" value="0" />
<enum name="functional" value="1" /> <enum name="normal" value="1" />
<enum name="action" value="2" /> <enum name="functional" value="2" />
<enum name="stickyOff" value="3" /> <enum name="action" value="3" />
<enum name="stickyOn" value="4" /> <enum name="stickyOff" value="4" />
<enum name="stickyOn" value="5" />
</attr> </attr>
<!-- The key action flags. --> <!-- The key action flags. -->
<attr name="keyActionFlags" format="integer"> <attr name="keyActionFlags" format="integer">

View file

@ -122,11 +122,12 @@ public class Key implements Comparable<Key> {
/** Background type that represents different key background visual than normal one. */ /** Background type that represents different key background visual than normal one. */
public final int mBackgroundType; public final int mBackgroundType;
public static final int BACKGROUND_TYPE_NORMAL = 0; public static final int BACKGROUND_TYPE_EMPTY = 0;
public static final int BACKGROUND_TYPE_FUNCTIONAL = 1; public static final int BACKGROUND_TYPE_NORMAL = 1;
public static final int BACKGROUND_TYPE_ACTION = 2; public static final int BACKGROUND_TYPE_FUNCTIONAL = 2;
public static final int BACKGROUND_TYPE_STICKY_OFF = 3; public static final int BACKGROUND_TYPE_ACTION = 3;
public static final int BACKGROUND_TYPE_STICKY_ON = 4; public static final int BACKGROUND_TYPE_STICKY_OFF = 4;
public static final int BACKGROUND_TYPE_STICKY_ON = 5;
private final int mActionFlags; private final int mActionFlags;
private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01; private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01;
@ -175,7 +176,7 @@ public class Key implements Comparable<Key> {
public Key(final KeyboardParams params, final MoreKeySpec moreKeySpec, final int x, final int y, public Key(final KeyboardParams params, final MoreKeySpec moreKeySpec, final int x, final int y,
final int width, final int height, final int labelFlags) { final int width, final int height, final int labelFlags) {
this(params, moreKeySpec.mLabel, null, moreKeySpec.mIconId, moreKeySpec.mCode, this(params, moreKeySpec.mLabel, null, moreKeySpec.mIconId, moreKeySpec.mCode,
moreKeySpec.mOutputText, x, y, width, height, labelFlags); moreKeySpec.mOutputText, x, y, width, height, labelFlags, BACKGROUND_TYPE_NORMAL);
} }
/** /**
@ -183,12 +184,12 @@ public class Key implements Comparable<Key> {
*/ */
public Key(final KeyboardParams params, final String label, final String hintLabel, public Key(final KeyboardParams params, final String label, final String hintLabel,
final int iconId, final int code, final String outputText, final int x, final int y, final int iconId, final int code, final String outputText, final int x, final int y,
final int width, final int height, final int labelFlags) { final int width, final int height, final int labelFlags, final int backgroundType) {
mHeight = height - params.mVerticalGap; mHeight = height - params.mVerticalGap;
mWidth = width - params.mHorizontalGap; mWidth = width - params.mHorizontalGap;
mHintLabel = hintLabel; mHintLabel = hintLabel;
mLabelFlags = labelFlags; mLabelFlags = labelFlags;
mBackgroundType = BACKGROUND_TYPE_NORMAL; mBackgroundType = backgroundType;
mActionFlags = 0; mActionFlags = 0;
mMoreKeys = null; mMoreKeys = null;
mMoreKeysColumnAndFlags = 0; mMoreKeysColumnAndFlags = 0;
@ -465,6 +466,7 @@ public class Key implements Comparable<Key> {
private static String backgroundName(final int backgroundType) { private static String backgroundName(final int backgroundType) {
switch (backgroundType) { switch (backgroundType) {
case BACKGROUND_TYPE_EMPTY: return "empty";
case BACKGROUND_TYPE_NORMAL: return "normal"; case BACKGROUND_TYPE_NORMAL: return "normal";
case BACKGROUND_TYPE_FUNCTIONAL: return "functional"; case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
case BACKGROUND_TYPE_ACTION: return "action"; case BACKGROUND_TYPE_ACTION: return "action";
@ -788,6 +790,10 @@ public class Key implements Comparable<Key> {
android.R.attr.state_pressed android.R.attr.state_pressed
}; };
private final static int[] KEY_STATE_EMPTY = {
android.R.attr.state_empty
};
// functional normal state (with properties) // functional normal state (with properties)
private static final int[] KEY_STATE_FUNCTIONAL_NORMAL = { private static final int[] KEY_STATE_FUNCTIONAL_NORMAL = {
android.R.attr.state_single android.R.attr.state_single
@ -825,6 +831,8 @@ public class Key implements Comparable<Key> {
return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF; return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
case BACKGROUND_TYPE_STICKY_ON: case BACKGROUND_TYPE_STICKY_ON:
return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON; return mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
case BACKGROUND_TYPE_EMPTY:
return mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
default: /* BACKGROUND_TYPE_NORMAL */ default: /* BACKGROUND_TYPE_NORMAL */
return mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL; return mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
} }
@ -842,7 +850,7 @@ public class Key implements Comparable<Key> {
protected Spacer(final KeyboardParams params, final int x, final int y, final int width, protected Spacer(final KeyboardParams params, final int x, final int y, final int width,
final int height) { final int height) {
super(params, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED, super(params, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED,
null, x, y, width, height, 0); null, x, y, width, height, 0, BACKGROUND_TYPE_EMPTY);
} }
} }
} }

View file

@ -210,7 +210,8 @@ public final class MoreSuggestions extends Keyboard {
final int indexInMoreSuggestions = index + SUGGESTION_CODE_BASE; final int indexInMoreSuggestions = index + SUGGESTION_CODE_BASE;
final Key key = new Key( final Key key = new Key(
params, word, info, KeyboardIconsSet.ICON_UNDEFINED, indexInMoreSuggestions, params, word, info, KeyboardIconsSet.ICON_UNDEFINED, indexInMoreSuggestions,
null, x, y, width, params.mDefaultRowHeight, 0); null /* outputText */, x, y, width, params.mDefaultRowHeight,
0 /* labelFlags */, Key.BACKGROUND_TYPE_NORMAL);
params.markAsEdgeKey(key, index); params.markAsEdgeKey(key, index);
params.onAddKey(key); params.onAddKey(key);
final int columnNumber = params.getColumnNumber(index); final int columnNumber = params.getColumnNumber(index);