aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/KeyboardSwitcher.java25
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java33
-rw-r--r--java/src/com/android/inputmethod/latin/LatinKeyboardShiftState.java5
-rw-r--r--java/src/com/android/inputmethod/latin/ModifierKeyState.java4
4 files changed, 55 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
index 0d116dcf9..7ae597f75 100644
--- a/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/KeyboardSwitcher.java
@@ -462,17 +462,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
public void updateShiftState() {
+ final ShiftKeyState shiftKeyState = mShiftKeyState;
if (DEBUG_STATE)
Log.d(TAG, "updateShiftState:"
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
- + " shiftKeyState=" + mShiftKeyState);
- if (isAlphabetMode() && !isShiftLocked() && !mShiftKeyState.isIgnoring()) {
- if (mInputMethodService.getCurrentAutoCapsState()) {
- setAutomaticTemporaryUpperCase();
- } else {
- setManualTemporaryUpperCase(mShiftKeyState.isMomentary());
+ + " shiftKeyState=" + shiftKeyState);
+ if (isAlphabetMode()) {
+ if (!isShiftLocked() && !shiftKeyState.isIgnoring()) {
+ if (shiftKeyState.isReleasing() && mInputMethodService.getCurrentAutoCapsState()) {
+ // Only when shift key is releasing, automatic temporary upper case will be set.
+ setAutomaticTemporaryUpperCase();
+ } else {
+ setManualTemporaryUpperCase(shiftKeyState.isMomentary());
+ }
}
+ } else {
+ // In symbol keyboard mode, we should clear shift key state because only alphabet
+ // keyboard has shift key.
+ shiftKeyState.onRelease();
}
}
@@ -565,6 +573,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
}
public void onOtherKeyPressed() {
+ if (DEBUG_STATE)
+ Log.d(TAG, "onOtherKeyPressed:"
+ + " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
+ + " shiftKeyState=" + mShiftKeyState
+ + " symbolKeyState=" + mSymbolKeyState);
mShiftKeyState.onOtherKeyPressed();
mSymbolKeyState.onOtherKeyPressed();
}
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 307021a37..e24bc0e6d 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -572,7 +572,8 @@ public class LatinIME extends InputMethodService
@Override
public void onStartInputView(EditorInfo attribute, boolean restarting) {
- LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
+ final KeyboardSwitcher switcher = mKeyboardSwitcher;
+ LatinKeyboardView inputView = switcher.getInputView();
// In landscape mode, this method gets called without the input view being created.
if (inputView == null) {
return;
@@ -678,9 +679,9 @@ public class LatinIME extends InputMethodService
mJustAddedAutoSpace = false;
loadSettings(attribute);
- mKeyboardSwitcher.loadKeyboard(mode, attribute.imeOptions, mVoiceButtonEnabled,
+ switcher.loadKeyboard(mode, attribute.imeOptions, mVoiceButtonEnabled,
mVoiceButtonOnPrimary);
- mKeyboardSwitcher.updateShiftState();
+ switcher.updateShiftState();
setCandidatesViewShownInternal(isCandidateStripVisible(),
false /* needsInputViewShown */ );
@@ -1228,7 +1229,7 @@ public class LatinIME extends InputMethodService
}
break;
case KEYCODE_TAB:
- sendDownUpKeyEvents(KeyEvent.KEYCODE_TAB);
+ handleTab();
break;
default:
if (primaryCode != KEYCODE_ENTER) {
@@ -1343,6 +1344,30 @@ public class LatinIME extends InputMethodService
ic.endBatchEdit();
}
+ private void handleTab() {
+ final int imeOptions = getCurrentInputEditorInfo().imeOptions;
+ final int navigationFlags =
+ EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
+ if ((imeOptions & navigationFlags) == 0) {
+ sendDownUpKeyEvents(KeyEvent.KEYCODE_TAB);
+ return;
+ }
+
+ final InputConnection ic = getCurrentInputConnection();
+ if (ic == null)
+ return;
+
+ // True if keyboard is in either chording shift or manual temporary upper case mode.
+ final boolean isManualTemporaryUpperCase = mKeyboardSwitcher.isManualTemporaryUpperCase();
+ if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0
+ && !isManualTemporaryUpperCase) {
+ ic.performEditorAction(EditorInfo.IME_ACTION_NEXT);
+ } else if ((imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0
+ && isManualTemporaryUpperCase) {
+ ic.performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
+ }
+ }
+
private void abortCorrection(boolean force) {
if (force || TextEntryState.isCorrecting()) {
TextEntryState.onAbortCorrection();
diff --git a/java/src/com/android/inputmethod/latin/LatinKeyboardShiftState.java b/java/src/com/android/inputmethod/latin/LatinKeyboardShiftState.java
index 74c474293..e916306c8 100644
--- a/java/src/com/android/inputmethod/latin/LatinKeyboardShiftState.java
+++ b/java/src/com/android/inputmethod/latin/LatinKeyboardShiftState.java
@@ -30,7 +30,7 @@ public class LatinKeyboardShiftState {
}
}
if (DEBUG)
- Log.d(TAG, "setShifted: " + toString(oldState) + " > " + this);
+ Log.d(TAG, "setShifted(" + newShiftState + "): " + toString(oldState) + " > " + this);
return mState != oldState;
}
@@ -44,7 +44,8 @@ public class LatinKeyboardShiftState {
mState = NORMAL;
}
if (DEBUG)
- Log.d(TAG, "setShiftLocked: " + toString(oldState) + " > " + this);
+ Log.d(TAG, "setShiftLocked(" + newShiftLockState + "): " + toString(oldState)
+ + " > " + this);
}
public void setAutomaticTemporaryUpperCase() {
diff --git a/java/src/com/android/inputmethod/latin/ModifierKeyState.java b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
index 8443be433..eb1204f70 100644
--- a/java/src/com/android/inputmethod/latin/ModifierKeyState.java
+++ b/java/src/com/android/inputmethod/latin/ModifierKeyState.java
@@ -55,6 +55,10 @@ public class ModifierKeyState {
Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
}
+ public boolean isReleasing() {
+ return mState == RELEASING;
+ }
+
public boolean isMomentary() {
return mState == MOMENTARY;
}