From dd8dd9fc1b10d0457a0b4b74c1c1899ff5350601 Mon Sep 17 00:00:00 2001 From: satok Date: Wed, 1 Sep 2010 23:33:43 +0900 Subject: [PATCH] Change background color for functional keys in LatinIME Change-Id: I45f13c1fd139ce43478e5d0b2cdb62e56e9f77a8 --- .../drawable/btn_keyboard_key_gingerbread.xml | 10 +++- java/res/xml/kbd_qwerty.xml | 59 ++++++++++--------- java/res/xml/kbd_qwerty_black.xml | 1 - java/res/xml/kbd_symbols.xml | 14 ++--- java/res/xml/kbd_symbols_shift.xml | 14 ++--- .../inputmethod/latin/LatinKeyboard.java | 37 ++++++++++-- 6 files changed, 86 insertions(+), 49 deletions(-) diff --git a/java/res/drawable/btn_keyboard_key_gingerbread.xml b/java/res/drawable/btn_keyboard_key_gingerbread.xml index 24a547974..4a113a8a1 100644 --- a/java/res/drawable/btn_keyboard_key_gingerbread.xml +++ b/java/res/drawable/btn_keyboard_key_gingerbread.xml @@ -16,10 +16,16 @@ + + + + + - diff --git a/java/res/xml/kbd_qwerty.xml b/java/res/xml/kbd_qwerty.xml index 59c61e4c8..d7d1ee0d5 100755 --- a/java/res/xml/kbd_qwerty.xml +++ b/java/res/xml/kbd_qwerty.xml @@ -18,6 +18,9 @@ */ --> + + + + android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="25%p" android:keyEdgeFlags="right" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="30%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> @@ -182,23 +185,23 @@ + android:keyWidth="10%p" android:keyEdgeFlags="left" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="20%p" android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="15%p" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="right" android:isModifier="true"/> diff --git a/java/res/xml/kbd_qwerty_black.xml b/java/res/xml/kbd_qwerty_black.xml index 076359c95..286547283 100755 --- a/java/res/xml/kbd_qwerty_black.xml +++ b/java/res/xml/kbd_qwerty_black.xml @@ -201,5 +201,4 @@ android:iconPreview="@drawable/sym_keyboard_feedback_return" android:keyWidth="15%p" android:keyEdgeFlags="right"/> - diff --git a/java/res/xml/kbd_symbols.xml b/java/res/xml/kbd_symbols.xml index 3f6b8ac85..fad3ebc10 100755 --- a/java/res/xml/kbd_symbols.xml +++ b/java/res/xml/kbd_symbols.xml @@ -118,25 +118,25 @@ /> + android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="15%p" android:keyEdgeFlags="left" android:isModifier="true"/> - + android:keyWidth="10%p" android:isModifier="true"/> + + android:isRepeatable="true" android:isModifier="true"/> + android:keyWidth="10%p" android:isModifier="true"/> + android:isModifier="true"/> diff --git a/java/res/xml/kbd_symbols_shift.xml b/java/res/xml/kbd_symbols_shift.xml index 0ec4c713c..b0693917e 100755 --- a/java/res/xml/kbd_symbols_shift.xml +++ b/java/res/xml/kbd_symbols_shift.xml @@ -85,24 +85,24 @@ /> + android:isRepeatable="true" android:isModifier="true"/> + android:keyEdgeFlags="left" android:isModifier="true"/> - + android:keyWidth="10%p" android:isModifier="true"/> + - + android:isRepeatable="true" android:isModifier="true"/> + + android:isModifier="true"/> diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboard.java b/java/src/com/android/inputmethod/latin/LatinKeyboard.java index 15e22f318..33519e4be 100644 --- a/java/src/com/android/inputmethod/latin/LatinKeyboard.java +++ b/java/src/com/android/inputmethod/latin/LatinKeyboard.java @@ -628,9 +628,20 @@ 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, XmlResourceParser parser) { super(res, parent, x, y, parser); @@ -639,11 +650,17 @@ public class LatinKeyboard extends Keyboard { popupResId = 0; } } - - 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(); + } } /**