From 2013bab89ca2f82589f99d98d9cf3b41ea5aac65 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 30 Nov 2011 17:54:58 +0900 Subject: Add Key.altCode attribute * Registering alternate code and while key is typing. * Showing press/release graphics of the key that has the above altenate code. * Showing press/release graphics of all shift keys. * Renaming Key.ignoreWhileTyping to Key.altCodeWhileTyping. Bug: 5639503 Change-Id: I67fb45bae76284a1f0deb6fd12ae5fb781d06cc3 --- .../com/android/inputmethod/keyboard/Keyboard.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/keyboard/Keyboard.java') diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 4a28bf1de..b3b20ca21 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -24,6 +24,7 @@ import com.android.inputmethod.keyboard.internal.KeyboardParams; import com.android.inputmethod.keyboard.internal.KeyboardShiftState; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -65,7 +66,6 @@ public class Keyboard { public static final int CODE_DIGIT0 = '0'; public static final int CODE_PLUS = '+'; - /** Special keys code. These should be aligned with values/keycodes.xml */ public static final int CODE_DUMMY = 0; public static final int CODE_SHIFT = -1; @@ -111,6 +111,7 @@ public class Keyboard { public final Map mUnshiftedIcons; public final KeyboardIconsSet mIconsSet; + private final Map mKeyCache = new HashMap(); private final KeyboardShiftState mShiftState = new KeyboardShiftState(); private final ProximityInfo mProximityInfo; @@ -145,6 +146,22 @@ public class Keyboard { return mProximityInfo; } + public Key getKey(int code) { + final Integer keyCode = code; + if (mKeyCache.containsKey(keyCode)) { + return mKeyCache.get(keyCode); + } + + for (final Key key : mKeys) { + if (key.mCode == code) { + mKeyCache.put(keyCode, key); + return key; + } + } + mKeyCache.put(keyCode, null); + return null; + } + public boolean hasShiftLockKey() { return !mShiftLockKeys.isEmpty(); } -- cgit v1.2.3