diff options
author | Jim Miller <jaggies@google.com> | 2011-01-19 22:01:25 -0800 |
---|---|---|
committer | Jim Miller <jaggies@google.com> | 2011-01-20 18:20:12 -0800 |
commit | 6465f7753783a614948fb3ffbd8c072345b4eea1 (patch) | |
tree | 20e2267a4993d8d28ba6836e0058aac0bde0b64d /core/java/android/inputmethodservice/Keyboard.java | |
parent | 9c91c7e27fbfff5abc34e19779a9477239ab9b10 (diff) | |
download | frameworks_base-6465f7753783a614948fb3ffbd8c072345b4eea1.zip frameworks_base-6465f7753783a614948fb3ffbd8c072345b4eea1.tar.gz frameworks_base-6465f7753783a614948fb3ffbd8c072345b4eea1.tar.bz2 |
Fix 3374446: Allow multiple shift keys in Keyboard.
This fixes a bug introduced in 3c6dd8f9 because we now
have two shift keys. The code now tracks a global state
and looks for up to two shift keys.
Update after review and added code to handle extra
invalidate required by additional shift key.
Change-Id: Ic1728dd0ceec089089cd1beca1b0b30565d6e658
Diffstat (limited to 'core/java/android/inputmethodservice/Keyboard.java')
-rw-r--r-- | core/java/android/inputmethodservice/Keyboard.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/core/java/android/inputmethodservice/Keyboard.java b/core/java/android/inputmethodservice/Keyboard.java index 75c945b..10386f8 100644 --- a/core/java/android/inputmethodservice/Keyboard.java +++ b/core/java/android/inputmethodservice/Keyboard.java @@ -97,11 +97,11 @@ public class Keyboard { private boolean mShifted; /** Key instance for the shift key, if present */ - private Key mShiftKey; - + private Key[] mShiftKeys = { null, null }; + /** Key index for the shift key, if present */ - private int mShiftKeyIndex = -1; - + private int[] mShiftKeyIndices = {-1, -1}; + /** Current key width, while loading the keyboard */ private int mKeyWidth; @@ -656,8 +656,10 @@ public class Keyboard { } public boolean setShifted(boolean shiftState) { - if (mShiftKey != null) { - mShiftKey.on = shiftState; + for (Key shiftKey : mShiftKeys) { + if (shiftKey != null) { + shiftKey.on = shiftState; + } } if (mShifted != shiftState) { mShifted = shiftState; @@ -670,8 +672,15 @@ public class Keyboard { return mShifted; } + /** + * @hide + */ + public int[] getShiftKeyIndices() { + return mShiftKeyIndices; + } + public int getShiftKeyIndex() { - return mShiftKeyIndex; + return mShiftKeyIndices[0]; } private void computeNearestNeighbors() { @@ -760,8 +769,14 @@ public class Keyboard { key = createKeyFromXml(res, currentRow, x, y, parser); mKeys.add(key); if (key.codes[0] == KEYCODE_SHIFT) { - mShiftKey = key; - mShiftKeyIndex = mKeys.size()-1; + // Find available shift key slot and put this shift key in it + for (int i = 0; i < mShiftKeys.length; i++) { + if (mShiftKeys[i] == null) { + mShiftKeys[i] = key; + mShiftKeyIndices[i] = mKeys.size()-1; + break; + } + } mModifierKeys.add(key); } else if (key.codes[0] == KEYCODE_ALT) { mModifierKeys.add(key); |