diff options
| author | Tadashi G. Takaoka <takaoka@google.com> | 2011-11-30 17:54:58 +0900 |
|---|---|---|
| committer | Tadashi G. Takaoka <takaoka@google.com> | 2011-11-30 20:06:47 +0900 |
| commit | 2013bab89ca2f82589f99d98d9cf3b41ea5aac65 (patch) | |
| tree | 07f759fd0814c52163a02915aefe007f5d357b2a /java/src/com/android/inputmethod/keyboard/Keyboard.java | |
| parent | 70b8934f0e919b8a85067c6b5bc09471888cf666 (diff) | |
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
Diffstat (limited to 'java/src/com/android/inputmethod/keyboard/Keyboard.java')
| -rw-r--r-- | java/src/com/android/inputmethod/keyboard/Keyboard.java | 19 |
1 files changed, 18 insertions, 1 deletions
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<Key, Drawable> mUnshiftedIcons; public final KeyboardIconsSet mIconsSet; + private final Map<Integer, Key> mKeyCache = new HashMap<Integer, Key>(); 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(); } |
