aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-01-11 22:54:26 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-01-11 22:54:26 -0800
commita5627e4e1f7765b4b62a87fc8843179b5519cf18 (patch)
treea2bdedcc8d197c863be7b1babf83a9f5ca98e551 /java/src
parente332d45253edfec4f544218e39c9e88b90945793 (diff)
parentee66e6fa90596e26d9519ac7bb261644377d32c8 (diff)
downloadlatinime-a5627e4e1f7765b4b62a87fc8843179b5519cf18.tar.gz
latinime-a5627e4e1f7765b4b62a87fc8843179b5519cf18.tar.xz
latinime-a5627e4e1f7765b4b62a87fc8843179b5519cf18.zip
Merge "Reset old keyboard state before switching to new keyboard" into honeycomb
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboard.java7
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java13
2 files changed, 13 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
index d6dfd0da5..77dde8d1b 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboard.java
@@ -48,7 +48,7 @@ public class LatinKeyboard extends Keyboard {
private final Drawable mButtonArrowLeftIcon;
private final Drawable mButtonArrowRightIcon;
private final int mSpaceBarTextShadowColor;
- private int mSpaceKeyIndex = -1;
+ private final int[] mSpaceKeyIndexArray;
private int mSpaceDragStartX;
private int mSpaceDragLastDiff;
private final Context mContext;
@@ -92,7 +92,8 @@ public class LatinKeyboard extends Keyboard {
mButtonArrowRightIcon = res.getDrawable(R.drawable.sym_keyboard_language_arrows_right);
sSpacebarVerticalCorrection = res.getDimensionPixelOffset(
R.dimen.spacebar_vertical_correction);
- mSpaceKeyIndex = indexOf(CODE_SPACE);
+ // The index of space key is available only after Keyboard constructor has finished.
+ mSpaceKeyIndexArray = new int[] { indexOf(CODE_SPACE) };
}
/**
@@ -418,7 +419,7 @@ public class LatinKeyboard extends Keyboard {
@Override
public int[] getNearestKeys(int x, int y) {
if (mCurrentlyInSpace) {
- return new int[] { mSpaceKeyIndex };
+ return mSpaceKeyIndexArray;
} else {
// Avoid dead pixels at edges of the keyboard
return super.getNearestKeys(Math.max(0, Math.min(x, getMinWidth() - 1)),
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index 6b052c7e7..51bfbf1f9 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -62,13 +62,18 @@ public class LatinKeyboardView extends KeyboardView {
}
}
- public void setLatinKeyboard(LatinKeyboard k) {
- super.setKeyboard(k);
+ public void setLatinKeyboard(LatinKeyboard newKeyboard) {
+ final LatinKeyboard oldKeyboard = getLatinKeyboard();
+ if (oldKeyboard != null) {
+ // Reset old keyboard state before switching to new keyboard.
+ oldKeyboard.keyReleased();
+ }
+ super.setKeyboard(newKeyboard);
// One-seventh of the keyboard width seems like a reasonable threshold
- mJumpThresholdSquare = k.getMinWidth() / 7;
+ mJumpThresholdSquare = newKeyboard.getMinWidth() / 7;
mJumpThresholdSquare *= mJumpThresholdSquare;
// Assuming there are 4 rows, this is the coordinate of the last row
- mLastRowY = (k.getHeight() * 3) / 4;
+ mLastRowY = (newKeyboard.getHeight() * 3) / 4;
}
public LatinKeyboard getLatinKeyboard() {