aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-09-15 01:51:15 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-15 01:51:15 -0700
commit3dcb281fb0bf3d7741123cd255562fe5fd5c735a (patch)
tree8e7b24b0828aac46f691c06e2cd263e6b5b1f758 /java/src
parent39fe5bfc3c791a6854663e999f49fdf0cec0c403 (diff)
parenta6d3a4d61b9655816128aa929331b7624476df64 (diff)
downloadlatinime-3dcb281fb0bf3d7741123cd255562fe5fd5c735a.tar.gz
latinime-3dcb281fb0bf3d7741123cd255562fe5fd5c735a.tar.xz
latinime-3dcb281fb0bf3d7741123cd255562fe5fd5c735a.zip
Merge "Make action key background more visually prominent"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index c4d5e857d..9959a78f9 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -107,6 +107,7 @@ public class Key {
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;
/** Whether this key repeats itself when held down */
public final boolean mRepeatable;
@@ -163,6 +164,17 @@ public class Key {
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.
private static final Map<Integer, Integer> sRtlParenthesisMap = new HashMap<Integer, Integer>();
@@ -545,36 +557,24 @@ public class Key {
*/
public int[] getCurrentDrawableState() {
final boolean pressed = mPressed;
- if (!mSticky && mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
- if (pressed) {
- return KEY_STATE_FUNCTIONAL_PRESSED;
+
+ // TODO: "Sticky" should be one of backgroundType.
+ if (mSticky) {
+ if (mHighlightOn) {
+ return pressed ? KEY_STATE_PRESSED_ON : KEY_STATE_NORMAL_ON;
} else {
- return KEY_STATE_FUNCTIONAL_NORMAL;
+ return pressed ? KEY_STATE_PRESSED_OFF : KEY_STATE_NORMAL_OFF;
}
}
- int[] states = KEY_STATE_NORMAL;
-
- if (mHighlightOn) {
- if (pressed) {
- states = KEY_STATE_PRESSED_ON;
- } else {
- states = KEY_STATE_NORMAL_ON;
- }
- } else {
- if (mSticky) {
- if (pressed) {
- states = KEY_STATE_PRESSED_OFF;
- } else {
- states = KEY_STATE_NORMAL_OFF;
- }
- } else {
- if (pressed) {
- states = KEY_STATE_PRESSED;
- }
- }
+ switch (mBackgroundType) {
+ case BACKGROUND_TYPE_FUNCTIONAL:
+ return pressed ? KEY_STATE_FUNCTIONAL_PRESSED : KEY_STATE_FUNCTIONAL_NORMAL;
+ case BACKGROUND_TYPE_ACTION:
+ return pressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
+ default: /* BACKGROUND_TYPE_NORMAL */
+ return pressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
}
- return states;
}
public static class Spacer extends Key {