aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-07-28 15:27:40 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-28 15:27:40 -0700
commitb9538bc44770d818fadbd0c93d3a6ba30b5c0b48 (patch)
treee2378c979e9fa7b01bb2b342cb92ae7b4ebe0075 /java/src
parentc3d175c01ff1956ddb1c2d608d69af1793b4ad8a (diff)
parent851c3267d4ab21f892b4164783bb4959c88b44ff (diff)
downloadlatinime-b9538bc44770d818fadbd0c93d3a6ba30b5c0b48.tar.gz
latinime-b9538bc44770d818fadbd0c93d3a6ba30b5c0b48.tar.xz
latinime-b9538bc44770d818fadbd0c93d3a6ba30b5c0b48.zip
Merge "Fix that long pressing shift on symbol keyboard registers caps lock code"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Keyboard.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java60
2 files changed, 32 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 19847c5ec..01cabf840 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -77,6 +77,8 @@ public class Keyboard {
public static final int CODE_CLOSING_SQUARE_BRACKET = ']';
public static final int CODE_CLOSING_CURLY_BRACKET = '}';
public static final int CODE_CLOSING_ANGLE_BRACKET = '>';
+ public static final int CODE_DIGIT0 = '0';
+ public static final int CODE_PLUS = '+';
/** Special keys code. These should be aligned with values/keycodes.xml */
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index c404a5dfb..b78fd94ea 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -53,55 +53,55 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
@Override
public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) {
- LatinKeyboard latinKeyboard = getLatinKeyboard();
- if (latinKeyboard != null
- && (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) {
- // Phone and number keyboard never shows popup preview (except language switch).
- super.setKeyPreviewPopupEnabled(false, delay);
- } else {
- super.setKeyPreviewPopupEnabled(previewEnabled, delay);
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard instanceof LatinKeyboard) {
+ final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard;
+ if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) {
+ // Phone and number keyboard never shows popup preview.
+ super.setKeyPreviewPopupEnabled(false, delay);
+ return;
+ }
}
+ super.setKeyPreviewPopupEnabled(previewEnabled, delay);
}
@Override
public void setKeyboard(Keyboard newKeyboard) {
super.setKeyboard(newKeyboard);
// One-seventh of the keyboard width seems like a reasonable threshold
- mJumpThresholdSquare = newKeyboard.getMinWidth() / 7;
- mJumpThresholdSquare *= mJumpThresholdSquare;
- }
-
- private LatinKeyboard getLatinKeyboard() {
- Keyboard keyboard = getKeyboard();
- if (keyboard instanceof LatinKeyboard) {
- return (LatinKeyboard)keyboard;
- } else {
- return null;
- }
+ final int jumpThreshold = newKeyboard.getMinWidth() / 7;
+ mJumpThresholdSquare = jumpThreshold * jumpThreshold;
}
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
- final LatinKeyboard currentKeyboard = getLatinKeyboard();
+ final Keyboard keyboard = getKeyboard();
// We should not set text fade factor to the keyboard which does not display the language on
// its spacebar.
- if (currentKeyboard != null && currentKeyboard == oldKeyboard)
- currentKeyboard.setSpacebarTextFadeFactor(fadeFactor, this);
+ if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
+ ((LatinKeyboard)keyboard).setSpacebarTextFadeFactor(fadeFactor, this);
+ }
}
@Override
protected boolean onLongPress(Key key, PointerTracker tracker) {
- int primaryCode = key.mCode;
+ final int primaryCode = key.mCode;
+ final Keyboard keyboard = getKeyboard();
+ if (keyboard instanceof LatinKeyboard) {
+ final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard;
+ if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) {
+ tracker.onLongPressed();
+ // Long pressing on 0 in phone number keypad gives you a '+'.
+ return invokeOnKey(Keyboard.CODE_PLUS);
+ }
+ if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) {
+ tracker.onLongPressed();
+ return invokeOnKey(Keyboard.CODE_CAPSLOCK);
+ }
+ }
if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) {
tracker.onLongPressed();
// Both long pressing settings key and space key invoke IME switcher dialog.
return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS);
- } else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) {
- tracker.onLongPressed();
- // Long pressing on 0 in phone number keypad gives you a '+'.
- return invokeOnKey('+');
- } else if (primaryCode == Keyboard.CODE_SHIFT) {
- tracker.onLongPressed();
- return invokeOnKey(Keyboard.CODE_CAPSLOCK);
} else {
return super.onLongPress(key, tracker);
}
@@ -194,7 +194,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView {
@Override
public boolean onTouchEvent(MotionEvent me) {
- if (getLatinKeyboard() == null) return true;
+ if (getKeyboard() == null) return true;
// If there was a sudden jump, return without processing the actual motion event.
if (handleSuddenJump(me)) {