aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/android/inputmethod/latin/LatinKeyboardView.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-01-29 20:09:49 -0800
committerAmith Yamasani <yamasani@google.com>2010-02-01 09:49:24 -0800
commit3f7d75060afb2bb7e74879bcbbdcb9700ec5c2d6 (patch)
treee874805b667ed13d257b7b29cfa6ea19a905fa29 /src/com/android/inputmethod/latin/LatinKeyboardView.java
parent41a519729505a877844f2c57a33509c302dddbce (diff)
downloadlatinime-3f7d75060afb2bb7e74879bcbbdcb9700ec5c2d6.tar.gz
latinime-3f7d75060afb2bb7e74879bcbbdcb9700ec5c2d6.tar.xz
latinime-3f7d75060afb2bb7e74879bcbbdcb9700ec5c2d6.zip
Language switching with slide gesture on spacebar. Bug: 2331173
Shows the language on the spacebar and in the preview bubble. Allows dragging of the spacebar from side to side to switch to previous or next languages.
Diffstat (limited to 'src/com/android/inputmethod/latin/LatinKeyboardView.java')
-rw-r--r--src/com/android/inputmethod/latin/LatinKeyboardView.java35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/com/android/inputmethod/latin/LatinKeyboardView.java b/src/com/android/inputmethod/latin/LatinKeyboardView.java
index a88c1818c..05f8aff36 100644
--- a/src/com/android/inputmethod/latin/LatinKeyboardView.java
+++ b/src/com/android/inputmethod/latin/LatinKeyboardView.java
@@ -38,9 +38,15 @@ public class LatinKeyboardView extends KeyboardView {
static final int KEYCODE_VOICE = -102;
static final int KEYCODE_F1 = -103;
static final int KEYCODE_NEXT_LANGUAGE = -104;
+ static final int KEYCODE_PREV_LANGUAGE = -105;
private Keyboard mPhoneKeyboard;
+ private boolean mExtensionVisible;
+ private LatinKeyboardView mExtension;
+ private PopupWindow mExtensionPopup;
+ private boolean mFirstEvent;
+
public LatinKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -66,22 +72,33 @@ public class LatinKeyboardView extends KeyboardView {
// Long pressing on 0 in phone number keypad gives you a '+'.
getOnKeyboardActionListener().onKey('+', null);
return true;
- } else if (key.codes[0] == ' ' && ((LatinKeyboard)getKeyboard()).mLocale != null) {
- getOnKeyboardActionListener().onKey(KEYCODE_NEXT_LANGUAGE, null);
- return true;
} else {
return super.onLongPress(key);
}
}
- private boolean mExtensionVisible;
- private LatinKeyboardView mExtension;
- private PopupWindow mExtensionPopup;
- private boolean mFirstEvent;
-
@Override
public boolean onTouchEvent(MotionEvent me) {
- if (((LatinKeyboard) getKeyboard()).getExtension() == 0) {
+ LatinKeyboard keyboard = (LatinKeyboard) getKeyboard();
+ // Reset any bounding box controls in the keyboard
+ if (me.getAction() == MotionEvent.ACTION_DOWN) {
+ keyboard.keyReleased();
+ }
+
+ if (me.getAction() == MotionEvent.ACTION_UP) {
+ int languageDirection = keyboard.getLanguageChangeDirection();
+ if (languageDirection != 0) {
+ getOnKeyboardActionListener().onKey(
+ languageDirection == 1 ? KEYCODE_NEXT_LANGUAGE : KEYCODE_PREV_LANGUAGE,
+ null);
+ me.setAction(MotionEvent.ACTION_CANCEL);
+ keyboard.keyReleased();
+ return super.onTouchEvent(me);
+ }
+ }
+
+ // If we don't have an extension keyboard, don't go any further.
+ if (keyboard.getExtension() == 0) {
return super.onTouchEvent(me);
}
if (me.getY() < 0) {