aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2011-01-05 23:00:54 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-05 23:00:54 -0800
commit0b157cc66f6ea9b7a638c425111dc5ae0f6d9709 (patch)
tree1392472f723d912957bd0a9e99b2358b56ecc813 /java/src/com/android/inputmethod/latin/LatinIME.java
parent7b3e2b79dafd135cc2d0605775c03653fe31426d (diff)
parent7aedc8a054aca41e6c80d8faf0ed2dd47f9815c4 (diff)
downloadlatinime-0b157cc66f6ea9b7a638c425111dc5ae0f6d9709.tar.gz
latinime-0b157cc66f6ea9b7a638c425111dc5ae0f6d9709.tar.xz
latinime-0b157cc66f6ea9b7a638c425111dc5ae0f6d9709.zip
am 7aedc8a0: Automaticaly snap back to the previous mode from sliding input (DO NOT MERGE)
* commit '7aedc8a054aca41e6c80d8faf0ed2dd47f9815c4': Automaticaly snap back to the previous mode from sliding input (DO NOT MERGE)
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index ffca22e45..b1689f886 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -342,6 +342,7 @@ public class LatinIME extends InputMethodService
@Override
public void onCreate() {
LatinImeLogger.init(this);
+ KeyboardSwitcher.init(this);
super.onCreate();
//setStatusIcon(R.drawable.ime_qwerty);
mResources = getResources();
@@ -349,7 +350,7 @@ public class LatinIME extends InputMethodService
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mLanguageSwitcher = new LanguageSwitcher(this);
mLanguageSwitcher.loadLocales(prefs);
- mKeyboardSwitcher = new KeyboardSwitcher(this);
+ mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mKeyboardSwitcher.setLanguageSwitcher(mLanguageSwitcher);
mSystemLocale = conf.locale.toString();
mLanguageSwitcher.setSystemLocale(conf.locale);
@@ -1247,9 +1248,7 @@ public class LatinIME extends InputMethodService
// Cancel the just reverted state
mJustRevertedSeparator = null;
}
- if (mKeyboardSwitcher.onKey(primaryCode)) {
- changeKeyboardMode();
- }
+ mKeyboardSwitcher.onKey(primaryCode);
// Reset after any single keystroke
mEnteredText = null;
}
@@ -1269,6 +1268,7 @@ public class LatinIME extends InputMethodService
ic.commitText(text, 1);
ic.endBatchEdit();
updateShiftKeyState(getCurrentInputEditorInfo());
+ mKeyboardSwitcher.onKey(0); // dummy key code.
mJustRevertedSeparator = null;
mJustAddedAutoSpace = false;
mEnteredText = text;
@@ -1276,6 +1276,7 @@ public class LatinIME extends InputMethodService
public void onCancel() {
// User released a finger outside any key
+ mKeyboardSwitcher.onCancelInput();
}
private void handleBackspace() {
@@ -2283,15 +2284,18 @@ public class LatinIME extends InputMethodService
}
public void onPress(int primaryCode) {
- vibrate();
- playKeyClick(primaryCode);
+ if (mKeyboardSwitcher.isVibrateAndSoundFeedbackRequired()) {
+ vibrate();
+ playKeyClick(primaryCode);
+ }
final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_SHIFT) {
mShiftKeyState.onPress();
handleShift();
} else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
- mSymbolKeyState.onPress();
changeKeyboardMode();
+ mSymbolKeyState.onPress();
+ mKeyboardSwitcher.setAutoModeSwitchStateMomentary();
} else {
mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed();
@@ -2308,7 +2312,9 @@ public class LatinIME extends InputMethodService
resetShift();
mShiftKeyState.onRelease();
} else if (distinctMultiTouch && primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
- if (mSymbolKeyState.isMomentary())
+ // Snap back to the previous keyboard mode if the user chords the mode change key and
+ // other key, then released the mode change key.
+ if (mKeyboardSwitcher.isInChordingAutoModeSwitchState())
changeKeyboardMode();
mSymbolKeyState.onRelease();
}
@@ -2562,7 +2568,7 @@ public class LatinIME extends InputMethodService
mOptionsDialog.show();
}
- private void changeKeyboardMode() {
+ public void changeKeyboardMode() {
mKeyboardSwitcher.toggleSymbols();
if (mCapsLock && mKeyboardSwitcher.isAlphabetMode()) {
mKeyboardSwitcher.setShiftLocked(mCapsLock);