Merge "Add empty key background type"
This commit is contained in:
commit
bdef628a35
8 changed files with 46 additions and 39 deletions
|
@ -15,9 +15,7 @@
|
|||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
|
||||
<item android:state_checkable="true" android:state_checked="true"
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_pressed_on" />
|
||||
|
@ -28,11 +26,12 @@
|
|||
<item android:state_checkable="true"
|
||||
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"
|
||||
android:drawable="@drawable/btn_keyboard_key_pressed" />
|
||||
<item
|
||||
android:drawable="@drawable/btn_keyboard_key_normal" />
|
||||
|
||||
<item android:drawable="@drawable/btn_keyboard_key_normal" />
|
||||
</selector>
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
|
||||
<item android:state_checkable="true" android:state_checked="true"
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_pressed_on" />
|
||||
|
@ -28,8 +26,11 @@
|
|||
<item android:state_checkable="true"
|
||||
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"
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_normal" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
|
||||
|
|
|
@ -15,23 +15,19 @@
|
|||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Functional keys. -->
|
||||
|
||||
<item android:state_single="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed" />
|
||||
<item android:state_single="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_normal" />
|
||||
|
||||
<!-- Action keys. -->
|
||||
|
||||
<item android:state_active="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed" />
|
||||
<item android:state_active="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_normal" />
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
|
||||
<item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed_on" />
|
||||
<item android:state_checkable="true" android:state_pressed="true"
|
||||
|
@ -41,8 +37,11 @@
|
|||
<item android:state_checkable="true"
|
||||
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"
|
||||
android:drawable="@drawable/btn_keyboard_key_light_pressed" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_light_normal" />
|
||||
|
|
|
@ -15,23 +15,19 @@
|
|||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Functional keys. -->
|
||||
|
||||
<item android:state_single="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" />
|
||||
<item android:state_single="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_normal_holo" />
|
||||
|
||||
<!-- Action keys. -->
|
||||
|
||||
<item android:state_active="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed_holo" />
|
||||
<item android:state_active="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_active_holo" />
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
|
||||
<item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_dark_pressed_on_holo" />
|
||||
<item android:state_checkable="true" android:state_pressed="true"
|
||||
|
@ -41,8 +37,11 @@
|
|||
<item android:state_checkable="true"
|
||||
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"
|
||||
android:drawable="@drawable/btn_keyboard_key_light_pressed_holo" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_light_normal_holo" />
|
||||
|
|
|
@ -15,23 +15,19 @@
|
|||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Functional keys. -->
|
||||
|
||||
<item android:state_single="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
|
||||
<item android:state_single="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_normal_stone" />
|
||||
|
||||
<!-- Action keys. -->
|
||||
|
||||
<item android:state_active="true" android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
|
||||
<item android:state_active="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_normal_stone" />
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
|
||||
<item android:state_checkable="true" android:state_checked="true"
|
||||
android:state_pressed="true"
|
||||
android:drawable="@drawable/btn_keyboard_key_normal_on_stone" />
|
||||
|
@ -42,8 +38,11 @@
|
|||
<item android:state_checkable="true"
|
||||
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"
|
||||
android:drawable="@drawable/btn_keyboard_key_fulltrans_pressed" />
|
||||
<item android:drawable="@drawable/btn_keyboard_key_normal_stone" />
|
||||
|
|
|
@ -240,11 +240,12 @@
|
|||
<attr name="maxMoreKeysColumn" format="integer" />
|
||||
<attr name="backgroundType" format="enum">
|
||||
<!-- This should be aligned with Key.BACKGROUND_TYPE_* -->
|
||||
<enum name="normal" value="0" />
|
||||
<enum name="functional" value="1" />
|
||||
<enum name="action" value="2" />
|
||||
<enum name="stickyOff" value="3" />
|
||||
<enum name="stickyOn" value="4" />
|
||||
<enum name="empty" value="0" />
|
||||
<enum name="normal" value="1" />
|
||||
<enum name="functional" value="2" />
|
||||
<enum name="action" value="3" />
|
||||
<enum name="stickyOff" value="4" />
|
||||
<enum name="stickyOn" value="5" />
|
||||
</attr>
|
||||
<!-- The key action flags. -->
|
||||
<attr name="keyActionFlags" format="integer">
|
||||
|
|
|
@ -122,11 +122,12 @@ public class Key implements Comparable<Key> {
|
|||
|
||||
/** 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;
|
||||
public static final int BACKGROUND_TYPE_ACTION = 2;
|
||||
public static final int BACKGROUND_TYPE_STICKY_OFF = 3;
|
||||
public static final int BACKGROUND_TYPE_STICKY_ON = 4;
|
||||
public static final int BACKGROUND_TYPE_EMPTY = 0;
|
||||
public static final int BACKGROUND_TYPE_NORMAL = 1;
|
||||
public static final int BACKGROUND_TYPE_FUNCTIONAL = 2;
|
||||
public static final int BACKGROUND_TYPE_ACTION = 3;
|
||||
public static final int BACKGROUND_TYPE_STICKY_OFF = 4;
|
||||
public static final int BACKGROUND_TYPE_STICKY_ON = 5;
|
||||
|
||||
private final int mActionFlags;
|
||||
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,
|
||||
final int width, final int height, final int labelFlags) {
|
||||
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,
|
||||
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;
|
||||
mWidth = width - params.mHorizontalGap;
|
||||
mHintLabel = hintLabel;
|
||||
mLabelFlags = labelFlags;
|
||||
mBackgroundType = BACKGROUND_TYPE_NORMAL;
|
||||
mBackgroundType = backgroundType;
|
||||
mActionFlags = 0;
|
||||
mMoreKeys = null;
|
||||
mMoreKeysColumnAndFlags = 0;
|
||||
|
@ -465,6 +466,7 @@ public class Key implements Comparable<Key> {
|
|||
|
||||
private static String backgroundName(final int backgroundType) {
|
||||
switch (backgroundType) {
|
||||
case BACKGROUND_TYPE_EMPTY: return "empty";
|
||||
case BACKGROUND_TYPE_NORMAL: return "normal";
|
||||
case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
|
||||
case BACKGROUND_TYPE_ACTION: return "action";
|
||||
|
@ -788,6 +790,10 @@ public class Key implements Comparable<Key> {
|
|||
android.R.attr.state_pressed
|
||||
};
|
||||
|
||||
private final static int[] KEY_STATE_EMPTY = {
|
||||
android.R.attr.state_empty
|
||||
};
|
||||
|
||||
// functional normal state (with properties)
|
||||
private static final int[] KEY_STATE_FUNCTIONAL_NORMAL = {
|
||||
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;
|
||||
case BACKGROUND_TYPE_STICKY_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 */
|
||||
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,
|
||||
final int height) {
|
||||
super(params, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED,
|
||||
null, x, y, width, height, 0);
|
||||
null, x, y, width, height, 0, BACKGROUND_TYPE_EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,8 @@ public final class MoreSuggestions extends Keyboard {
|
|||
final int indexInMoreSuggestions = index + SUGGESTION_CODE_BASE;
|
||||
final Key key = new Key(
|
||||
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.onAddKey(key);
|
||||
final int columnNumber = params.getColumnNumber(index);
|
||||
|
|
Loading…
Reference in a new issue