aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2010-12-31 03:28:35 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-31 03:28:35 -0800
commit611044ab30769db75ce7f7d1b0a30379b7ef78c6 (patch)
tree249f2b6ec8f0aba149751ef07cd405fa4b928ae0 /java/src
parent1a6fba570260ca9f837e5a6874274f39a3c0a734 (diff)
parent5f922caff80d5067c5af2bbbae2731ef25c9572a (diff)
downloadlatinime-611044ab30769db75ce7f7d1b0a30379b7ef78c6.tar.gz
latinime-611044ab30769db75ce7f7d1b0a30379b7ef78c6.tar.xz
latinime-611044ab30769db75ce7f7d1b0a30379b7ef78c6.zip
Merge "Snap back to the previous keyboard when sliding input is canceled"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java12
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java19
-rw-r--r--java/src/com/android/inputmethod/keyboard/KeyboardView.java3
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java7
4 files changed, 25 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
index 848cc9693..00f3a5153 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
@@ -20,7 +20,7 @@ public interface KeyboardActionListener {
/**
* Called when the user presses a key. This is sent before the
- * {@link #onKey} is called. For keys that repeat, this is only
+ * {@link #onCodeInput} is called. For keys that repeat, this is only
* called once.
*
* @param primaryCode
@@ -31,7 +31,7 @@ public interface KeyboardActionListener {
/**
* Called when the user releases a key. This is sent after the
- * {@link #onKey} is called. For keys that repeat, this is only
+ * {@link #onCodeInput} is called. For keys that repeat, this is only
* called once.
*
* @param primaryCode
@@ -54,11 +54,11 @@ public interface KeyboardActionListener {
* accidental presses of a key adjacent to the intended
* key.
* @param x
- * x-coordinate pixel of touched event. If onKey is not called by onTouchEvent,
- * the value should be NOT_A_TOUCH_COORDINATE.
+ * x-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
+ * onTouchEvent, the value should be NOT_A_TOUCH_COORDINATE.
* @param y
- * y-coordinate pixel of touched event. If onKey is not called by onTouchEvent,
- * the value should be NOT_A_TOUCH_COORDINATE.
+ * y-coordinate pixel of touched event. If {@link #onCodeInput} is not called by
+ * onTouchEvent, the value should be NOT_A_TOUCH_COORDINATE.
*/
void onCodeInput(int primaryCode, int[] keyCodes, int x, int y);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index d085030a1..331c8db6a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -505,6 +505,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
mSymbolKeyState.onOtherKeyPressed();
}
+ public void onCancelInput() {
+ // Snap back to the previous keyboard mode if the user cancels sliding input.
+ if (mAutoModeSwitchState == AUTO_MODE_SWITCH_STATE_MOMENTARY && getPointerCount() == 1)
+ changeKeyboardMode();
+ }
+
private void toggleShiftInSymbol() {
if (isAlphabetMode())
return;
@@ -563,11 +569,12 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
switch (mAutoModeSwitchState) {
case AUTO_MODE_SWITCH_STATE_MOMENTARY:
// Only distinct multi touch devices can be in this state.
- // On non-distinct multi touch devices, mode change key is handled by {@link onKey},
- // not by {@link onPress} and {@link onRelease}. So, on such devices,
- // {@link mAutoModeSwitchState} starts from {@link AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN},
- // or {@link AUTO_MODE_SWITCH_STATE_ALPHA}, not from
- // {@link AUTO_MODE_SWITCH_STATE_MOMENTARY}.
+ // On non-distinct multi touch devices, mode change key is handled by
+ // {@link LatinIME#onCodeInput}, not by {@link LatinIME#onPress} and
+ // {@link LatinIME#onRelease}. So, on such devices, {@link #mAutoModeSwitchState} starts
+ // from {@link #AUTO_MODE_SWITCH_STATE_SYMBOL_BEGIN}, or
+ // {@link #AUTO_MODE_SWITCH_STATE_ALPHA}, not from
+ // {@link #AUTO_MODE_SWITCH_STATE_MOMENTARY}.
if (key == Keyboard.CODE_SWITCH_ALPHA_SYMBOL) {
// Detected only the mode change key has been pressed, and then released.
if (mIsSymbols) {
@@ -578,6 +585,8 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
} else if (getPointerCount() == 1) {
// Snap back to the previous keyboard mode if the user pressed the mode change key
// and slid to other key, then released the finger.
+ // If the user cancels the sliding input, snapping back to the previous keyboard
+ // mode is handled by {@link #onCancelInput}.
changeKeyboardMode();
} else {
// Chording input is being started. The keyboard mode will be snapped back to the
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index dd552f0fc..e0835d7ed 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -550,7 +550,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
}
/**
- * When enabled, calls to {@link KeyboardActionListener#onKey} will include key
+ * When enabled, calls to {@link KeyboardActionListener#onCodeInput} will include key
* codes for adjacent keys. When disabled, only the primary key code will be
* reported.
* @param enabled whether or not the proximity correction is enabled
@@ -1106,6 +1106,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
@Override
public void onCancelInput() {
+ mKeyboardActionListener.onCancelInput();
dismissPopupKeyboard();
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 51b56ec14..e785eb76f 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1048,8 +1048,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return mOptionsDialog != null && mOptionsDialog.isShowing();
}
- // Implementation of KeyboardViewListener
-
+ // Implementation of {@link KeyboardActionListener}.
@Override
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
long when = SystemClock.uptimeMillis();
@@ -1132,7 +1131,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ic.commitText(text, 1);
ic.endBatchEdit();
mKeyboardSwitcher.updateShiftState();
- mKeyboardSwitcher.onKey(0); // dummy key code.
+ mKeyboardSwitcher.onKey(Keyboard.CODE_DUMMY);
mJustReverted = false;
mJustAddedAutoSpace = false;
mEnteredText = text;
@@ -1141,6 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override
public void onCancelInput() {
// User released a finger outside any key
+ mKeyboardSwitcher.onCancelInput();
}
private void handleBackspace() {
@@ -1836,7 +1836,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void sendSpace() {
sendKeyChar((char)Keyboard.CODE_SPACE);
mKeyboardSwitcher.updateShiftState();
- //onKey(KEY_SPACE[0], KEY_SPACE);
}
public boolean preferCapitalization() {