Merge "Make action key background more visually prominent"

main
Tadashi G. Takaoka 2011-09-15 01:51:15 -07:00 committed by Android (Google) Code Review
commit 3dcb281fb0
7 changed files with 39 additions and 31 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

View File

@ -23,6 +23,13 @@
<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. -->
<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. --> <!-- 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"
@ -34,7 +41,7 @@
<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 --> <!-- 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" />

View File

@ -198,6 +198,7 @@
<!-- This should be aligned with Key.BACKGROUND_TYPE_* --> <!-- This should be aligned with Key.BACKGROUND_TYPE_* -->
<enum name="normal" value="0" /> <enum name="normal" value="0" />
<enum name="functional" value="1" /> <enum name="functional" value="1" />
<enum name="action" value="2" />
</attr> </attr>
<!-- Whether this is a toggle key. --> <!-- Whether this is a toggle key. -->
<attr name="isSticky" format="boolean" /> <attr name="isSticky" format="boolean" />

View File

@ -102,7 +102,7 @@
latin:code="@integer/key_return" latin:code="@integer/key_return"
latin:keyLabel="@string/label_go_key" latin:keyLabel="@string/label_go_key"
latin:keyLabelOption="autoXScale" latin:keyLabelOption="autoXScale"
latin:parentStyle="functionalKeyStyle" /> latin:backgroundType="action" />
</case> </case>
<case <case
latin:imeAction="actionNext" latin:imeAction="actionNext"
@ -112,7 +112,7 @@
latin:code="@integer/key_return" latin:code="@integer/key_return"
latin:keyLabel="@string/label_next_key" latin:keyLabel="@string/label_next_key"
latin:keyLabelOption="autoXScale" latin:keyLabelOption="autoXScale"
latin:parentStyle="functionalKeyStyle" /> latin:backgroundType="action" />
</case> </case>
<case <case
latin:imeAction="actionDone" latin:imeAction="actionDone"
@ -122,7 +122,7 @@
latin:code="@integer/key_return" latin:code="@integer/key_return"
latin:keyLabel="@string/label_done_key" latin:keyLabel="@string/label_done_key"
latin:keyLabelOption="autoXScale" latin:keyLabelOption="autoXScale"
latin:parentStyle="functionalKeyStyle" /> latin:backgroundType="action" />
</case> </case>
<case <case
latin:imeAction="actionSend" latin:imeAction="actionSend"
@ -132,7 +132,7 @@
latin:code="@integer/key_return" latin:code="@integer/key_return"
latin:keyLabel="@string/label_send_key" latin:keyLabel="@string/label_send_key"
latin:keyLabelOption="autoXScale" latin:keyLabelOption="autoXScale"
latin:parentStyle="functionalKeyStyle" /> latin:backgroundType="action" />
</case> </case>
<case <case
latin:imeAction="actionSearch" latin:imeAction="actionSearch"
@ -141,7 +141,7 @@
latin:styleName="returnKeyStyle" latin:styleName="returnKeyStyle"
latin:code="@integer/key_return" latin:code="@integer/key_return"
latin:keyIcon="iconSearchKey" latin:keyIcon="iconSearchKey"
latin:parentStyle="functionalKeyStyle" /> latin:backgroundType="action" />
</case> </case>
<default> <default>
<key-style <key-style

View File

@ -107,6 +107,7 @@ public class Key {
public final int mBackgroundType; public final int mBackgroundType;
public static final int BACKGROUND_TYPE_NORMAL = 0; public static final int BACKGROUND_TYPE_NORMAL = 0;
public static final int BACKGROUND_TYPE_FUNCTIONAL = 1; public static final int BACKGROUND_TYPE_FUNCTIONAL = 1;
public static final int BACKGROUND_TYPE_ACTION = 2;
/** Whether this key repeats itself when held down */ /** Whether this key repeats itself when held down */
public final boolean mRepeatable; public final boolean mRepeatable;
@ -163,6 +164,17 @@ public class Key {
android.R.attr.state_pressed android.R.attr.state_pressed
}; };
// action normal state (with properties)
private static final int[] KEY_STATE_ACTIVE_NORMAL = {
android.R.attr.state_active
};
// action pressed state (with properties)
private static final int[] KEY_STATE_ACTIVE_PRESSED = {
android.R.attr.state_active,
android.R.attr.state_pressed
};
// RTL parenthesis character swapping map. // RTL parenthesis character swapping map.
private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>(); private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>();
@ -545,36 +557,24 @@ public class Key {
*/ */
public int[] getCurrentDrawableState() { public int[] getCurrentDrawableState() {
final boolean pressed = mPressed; final boolean pressed = mPressed;
if (!mSticky && mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
if (pressed) { // TODO: "Sticky" should be one of backgroundType.
return KEY_STATE_FUNCTIONAL_PRESSED; if (mSticky) {
if (mHighlightOn) {
return pressed ? KEY_STATE_PRESSED_ON : KEY_STATE_NORMAL_ON;
} else { } else {
return KEY_STATE_FUNCTIONAL_NORMAL; return pressed ? KEY_STATE_PRESSED_OFF : KEY_STATE_NORMAL_OFF;
} }
} }
int[] states = KEY_STATE_NORMAL; switch (mBackgroundType) {
case BACKGROUND_TYPE_FUNCTIONAL:
if (mHighlightOn) { return pressed ? KEY_STATE_FUNCTIONAL_PRESSED : KEY_STATE_FUNCTIONAL_NORMAL;
if (pressed) { case BACKGROUND_TYPE_ACTION:
states = KEY_STATE_PRESSED_ON; return pressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
} else { default: /* BACKGROUND_TYPE_NORMAL */
states = KEY_STATE_NORMAL_ON; return pressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
}
} else {
if (mSticky) {
if (pressed) {
states = KEY_STATE_PRESSED_OFF;
} else {
states = KEY_STATE_NORMAL_OFF;
}
} else {
if (pressed) {
states = KEY_STATE_PRESSED;
}
}
} }
return states;
} }
public static class Spacer extends Key { public static class Spacer extends Key {