am ac4f8e46: Merge "Change background color for functional keys in LatinIME" into gingerbread

Merge commit 'ac4f8e4629b0206b41c1c38271d62af88e4df21b' into gingerbread-plus-aosp

* commit 'ac4f8e4629b0206b41c1c38271d62af88e4df21b':
  Change background color for functional keys in LatinIME
main
satok 2010-09-01 20:02:15 -07:00 committed by Android Git Automerger
commit 308acfa714
6 changed files with 86 additions and 49 deletions

View File

@ -16,10 +16,16 @@
<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" />
<!-- 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" />
<item android:state_checkable="true" android:state_pressed="true"
android:drawable="@drawable/btn_keyboard_key_dark_pressed_off" />

View File

@ -18,6 +18,9 @@
*/
-->
<!-- TODO: Add settings key to other languages -->
<!-- TODO: Add modifier attr to functional keys in other languages -->
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
@ -106,75 +109,75 @@
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete"
android:keyWidth="15%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:isRepeatable="true"/>
android:isRepeatable="true" android:isModifier="true"/>
</Row>
<Row android:keyboardMode="@+id/mode_normal" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:keyWidth="15%p" android:keyEdgeFlags="left"/>
android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="30%p" android:isRepeatable="true"/>
android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="25%p" android:keyEdgeFlags="right"/>
android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/>
</Row>
<Row android:keyboardMode="@+id/mode_url" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:keyWidth="15%p" android:keyEdgeFlags="left"/>
android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:keyLabel="/" android:keyWidth="10%p"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="30%p" android:isRepeatable="true"/>
android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="25%p" android:keyEdgeFlags="right"/>
android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/>
</Row>
<Row android:keyboardMode="@+id/mode_email" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:keyWidth="15%p" android:keyEdgeFlags="left"/>
android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:keyLabel="\@"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="30%p" android:isRepeatable="true"/>
android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="25%p" android:keyEdgeFlags="right"/>
android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/>
</Row>
<Row android:keyboardMode="@+id/mode_im" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:keyWidth="15%p" android:keyEdgeFlags="left"/>
android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="30%p" android:isRepeatable="true"/>
android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/>
<Key android:codes="46" android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:keyLabel=":-)" android:keyOutputText=":-) "
android:popupKeyboard="@xml/popup_smileys"
android:keyWidth="25%p" android:keyEdgeFlags="right"/>
@ -182,23 +185,23 @@
<Row android:keyboardMode="@+id/mode_webentry" android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_symbol_key"
android:keyWidth="10%p" android:keyEdgeFlags="left"/>
android:keyWidth="10%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="@integer/key_f1" android:keyIcon="@drawable/sym_keyboard_mic"
android:iconPreview="@drawable/sym_keyboard_feedback_mic"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:keyWidth="20%p" android:isRepeatable="true"/>
android:keyWidth="20%p" android:isRepeatable="true" android:isModifier="true"/>
<Key android:codes="9" android:keyIcon="@drawable/sym_keyboard_tab"
android:iconPreview="@drawable/sym_keyboard_feedback_tab"
android:keyWidth="15%p"/>
android:keyWidth="15%p" android:isModifier="true"/>
<Key android:keyLabel="." android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="15%p" android:keyEdgeFlags="right"/>
android:keyWidth="15%p" android:keyEdgeFlags="right" android:isModifier="true"/>
</Row>
</Keyboard>

View File

@ -201,5 +201,4 @@
android:iconPreview="@drawable/sym_keyboard_feedback_return"
android:keyWidth="15%p" android:keyEdgeFlags="right"/>
</Row>
</Keyboard>

View File

@ -118,25 +118,25 @@
/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" android:keyWidth="15%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:isRepeatable="true"/>
android:isRepeatable="true" android:isModifier="true"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_alpha_key"
android:keyWidth="15%p" android:keyEdgeFlags="left"/>
android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
<Key android:codes="@integer/key_f1" android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="@integer/key_f1" android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:keyWidth="30%p"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
android:isRepeatable="true" android:isModifier="true"/>
<Key android:codes="46" android:keyLabel="."
android:popupKeyboard="@xml/popup_punctuation"
android:keyWidth="10%p"/>
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return" android:keyWidth="25%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
/>
android:isModifier="true"/>
</Row>
</Keyboard>

View File

@ -85,24 +85,24 @@
/>
<Key android:codes="-5" android:keyIcon="@drawable/sym_keyboard_delete" android:keyWidth="15%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_delete"
android:isRepeatable="true"/>
android:isRepeatable="true" android:isModifier="true"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:codes="-2" android:keyLabel="@string/label_alpha_key" android:keyWidth="15%p"
android:keyEdgeFlags="left"/>
android:keyEdgeFlags="left" android:isModifier="true"/>
<Key android:codes="@integer/key_settings" android:keyIcon="@drawable/sym_keyboard_settings"
android:iconPreview="@drawable/sym_keyboard_feedback_settings"
android:keyWidth="10%p"/>
<Key android:keyLabel="„" android:keyWidth="10%p" />
android:keyWidth="10%p" android:isModifier="true"/>
<Key android:keyLabel="„" android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space"
android:keyWidth="30%p"
android:iconPreview="@drawable/sym_keyboard_feedback_space"
android:isRepeatable="true"/>
<Key android:keyLabel="…" android:keyWidth="10%p" />
android:isRepeatable="true" android:isModifier="true"/>
<Key android:keyLabel="…" android:keyWidth="10%p" android:isModifier="true"/>
<Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
android:keyWidth="25%p" android:keyEdgeFlags="right"
android:iconPreview="@drawable/sym_keyboard_feedback_return"
/>
android:isModifier="true"/>
</Row>
</Keyboard>

View File

@ -629,6 +629,17 @@ public class LatinKeyboard extends Keyboard {
class LatinKey extends Keyboard.Key {
// functional normal state (with properties)
private final int[] KEY_STATE_FUNCTIONAL_NORMAL = {
android.R.attr.state_single
};
// functional pressed state (with properties)
private final int[] KEY_STATE_FUNCTIONAL_PRESSED = {
android.R.attr.state_single,
android.R.attr.state_pressed
};
private boolean mShiftLockEnabled;
public LatinKey(Resources res, Keyboard.Row parent, int x, int y,
@ -640,10 +651,16 @@ public class LatinKeyboard extends Keyboard {
}
}
void enableShiftLock() {
private void enableShiftLock() {
mShiftLockEnabled = true;
}
// sticky is used for shift key. If a key is not sticky and is modifier,
// the key will be treated as functional.
private boolean isFunctionalKey() {
return !sticky && modifier;
}
@Override
public void onReleased(boolean inside) {
if (!mShiftLockEnabled) {
@ -665,6 +682,18 @@ public class LatinKeyboard extends Keyboard {
boolean isInsideSuper(int x, int y) {
return super.isInside(x, y);
}
@Override
public int[] getCurrentDrawableState() {
if (isFunctionalKey()) {
if (pressed) {
return KEY_STATE_FUNCTIONAL_PRESSED;
} else {
return KEY_STATE_FUNCTIONAL_NORMAL;
}
}
return super.getCurrentDrawableState();
}
}
/**