aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/BaseKeyboard.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-10-02 15:50:06 +0900
committerTadashi G. Takaoka <takaoka@google.com>2010-10-02 21:37:34 +0900
commit6614ac9f7b506c688abd2d6f09a0f2ae8b22fa68 (patch)
tree9c0950ca9efb97407a39d48044d9d881817243f0 /java/src/com/android/inputmethod/latin/BaseKeyboard.java
parent4fc510a7890976d9968d73ceacf3983e77f489d2 (diff)
downloadlatinime-6614ac9f7b506c688abd2d6f09a0f2ae8b22fa68.tar.gz
latinime-6614ac9f7b506c688abd2d6f09a0f2ae8b22fa68.tar.xz
latinime-6614ac9f7b506c688abd2d6f09a0f2ae8b22fa68.zip
Modify BaseKeyboard to be able to handle multiple shift keys
Change-Id: Ie840ae113ee6bd5b629a90959d7f955a5ceba95a
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BaseKeyboard.java')
-rw-r--r--java/src/com/android/inputmethod/latin/BaseKeyboard.java32
1 files changed, 12 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/BaseKeyboard.java b/java/src/com/android/inputmethod/latin/BaseKeyboard.java
index f1a08cb4a..6f32f9c1a 100644
--- a/java/src/com/android/inputmethod/latin/BaseKeyboard.java
+++ b/java/src/com/android/inputmethod/latin/BaseKeyboard.java
@@ -89,11 +89,8 @@ public class BaseKeyboard {
/** Is the keyboard in the shifted state */
private boolean mShifted;
- /** Key instance for the shift key, if present */
- private Key mShiftKey;
-
- /** Key index for the shift key, if present */
- private int mShiftKeyIndex = -1;
+ /** List of shift keys in this keyboard */
+ private final List<Key> mShiftKeys = new ArrayList<Key>();
/** Total height of the keyboard, including the padding and keys */
private int mTotalHeight;
@@ -105,19 +102,19 @@ public class BaseKeyboard {
private int mTotalWidth;
/** List of keys in this keyboard */
- private List<Key> mKeys;
+ private final List<Key> mKeys = new ArrayList<Key>();
/** List of modifier keys such as Shift & Alt, if any */
- private List<Key> mModifierKeys;
+ private final List<Key> mModifierKeys = new ArrayList<Key>();
/** Width of the screen available to fit the keyboard */
- private int mDisplayWidth;
+ private final int mDisplayWidth;
/** Height of the screen */
- private int mDisplayHeight;
+ private final int mDisplayHeight;
/** Keyboard mode, or zero, if none. */
- private int mKeyboardMode;
+ private final int mKeyboardMode;
// Variables for pre-computing nearest keys.
@@ -488,8 +485,6 @@ public class BaseKeyboard {
mDefaultWidth = mDisplayWidth / 10;
mDefaultVerticalGap = 0;
mDefaultHeight = mDefaultWidth;
- mKeys = new ArrayList<Key>();
- mModifierKeys = new ArrayList<Key>();
mKeyboardMode = modeId;
loadKeyboard(context, context.getResources().getXml(xmlLayoutResId));
}
@@ -511,8 +506,6 @@ public class BaseKeyboard {
mDefaultWidth = mDisplayWidth / 10;
mDefaultVerticalGap = 0;
mDefaultHeight = mDefaultWidth;
- mKeys = new ArrayList<Key>();
- mModifierKeys = new ArrayList<Key>();
mKeyboardMode = modeId;
loadKeyboard(context, context.getResources().getXml(xmlLayoutResId));
}
@@ -622,8 +615,8 @@ public class BaseKeyboard {
}
public boolean setShifted(boolean shiftState) {
- if (mShiftKey != null) {
- mShiftKey.on = shiftState;
+ for (final Key key : mShiftKeys) {
+ key.on = shiftState;
}
if (mShifted != shiftState) {
mShifted = shiftState;
@@ -636,8 +629,8 @@ public class BaseKeyboard {
return mShifted;
}
- public int getShiftKeyIndex() {
- return mShiftKeyIndex;
+ public List<Key> getShiftKeys() {
+ return mShiftKeys;
}
private void computeNearestNeighbors() {
@@ -725,8 +718,7 @@ public class BaseKeyboard {
key = createKeyFromXml(res, currentRow, x, y, parser);
mKeys.add(key);
if (key.codes[0] == KEYCODE_SHIFT) {
- mShiftKey = key;
- mShiftKeyIndex = mKeys.size()-1;
+ mShiftKeys.add(key);
mModifierKeys.add(key);
} else if (key.codes[0] == KEYCODE_ALT) {
mModifierKeys.add(key);