Perform editor action IME_ACTION_NEXT/PREVIOUS by tab key
Bug: 3122995 Change-Id: I44280fe1c6cc27f429b311edec71e1027178222dmain
parent
07f903afba
commit
45911256fd
|
@ -462,18 +462,26 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateShiftState() {
|
public void updateShiftState() {
|
||||||
|
final ShiftKeyState shiftKeyState = mShiftKeyState;
|
||||||
if (DEBUG_STATE)
|
if (DEBUG_STATE)
|
||||||
Log.d(TAG, "updateShiftState:"
|
Log.d(TAG, "updateShiftState:"
|
||||||
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
|
+ " autoCaps=" + mInputMethodService.getCurrentAutoCapsState()
|
||||||
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||||
+ " shiftKeyState=" + mShiftKeyState);
|
+ " shiftKeyState=" + shiftKeyState);
|
||||||
if (isAlphabetMode() && !isShiftLocked() && !mShiftKeyState.isIgnoring()) {
|
if (isAlphabetMode()) {
|
||||||
if (mInputMethodService.getCurrentAutoCapsState()) {
|
if (!isShiftLocked() && !shiftKeyState.isIgnoring()) {
|
||||||
|
if (shiftKeyState.isReleasing() && mInputMethodService.getCurrentAutoCapsState()) {
|
||||||
|
// Only when shift key is releasing, automatic temporary upper case will be set.
|
||||||
setAutomaticTemporaryUpperCase();
|
setAutomaticTemporaryUpperCase();
|
||||||
} else {
|
} else {
|
||||||
setManualTemporaryUpperCase(mShiftKeyState.isMomentary());
|
setManualTemporaryUpperCase(shiftKeyState.isMomentary());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// In symbol keyboard mode, we should clear shift key state because only alphabet
|
||||||
|
// keyboard has shift key.
|
||||||
|
shiftKeyState.onRelease();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeKeyboardMode() {
|
public void changeKeyboardMode() {
|
||||||
|
@ -565,6 +573,11 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOtherKeyPressed() {
|
public void onOtherKeyPressed() {
|
||||||
|
if (DEBUG_STATE)
|
||||||
|
Log.d(TAG, "onOtherKeyPressed:"
|
||||||
|
+ " keyboard=" + getLatinKeyboard().getKeyboardShiftState()
|
||||||
|
+ " shiftKeyState=" + mShiftKeyState
|
||||||
|
+ " symbolKeyState=" + mSymbolKeyState);
|
||||||
mShiftKeyState.onOtherKeyPressed();
|
mShiftKeyState.onOtherKeyPressed();
|
||||||
mSymbolKeyState.onOtherKeyPressed();
|
mSymbolKeyState.onOtherKeyPressed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -572,7 +572,8 @@ public class LatinIME extends InputMethodService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartInputView(EditorInfo attribute, boolean restarting) {
|
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.
|
// In landscape mode, this method gets called without the input view being created.
|
||||||
if (inputView == null) {
|
if (inputView == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -678,9 +679,9 @@ public class LatinIME extends InputMethodService
|
||||||
mJustAddedAutoSpace = false;
|
mJustAddedAutoSpace = false;
|
||||||
|
|
||||||
loadSettings(attribute);
|
loadSettings(attribute);
|
||||||
mKeyboardSwitcher.loadKeyboard(mode, attribute.imeOptions, mVoiceButtonEnabled,
|
switcher.loadKeyboard(mode, attribute.imeOptions, mVoiceButtonEnabled,
|
||||||
mVoiceButtonOnPrimary);
|
mVoiceButtonOnPrimary);
|
||||||
mKeyboardSwitcher.updateShiftState();
|
switcher.updateShiftState();
|
||||||
|
|
||||||
setCandidatesViewShownInternal(isCandidateStripVisible(),
|
setCandidatesViewShownInternal(isCandidateStripVisible(),
|
||||||
false /* needsInputViewShown */ );
|
false /* needsInputViewShown */ );
|
||||||
|
@ -1228,7 +1229,7 @@ public class LatinIME extends InputMethodService
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEYCODE_TAB:
|
case KEYCODE_TAB:
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_TAB);
|
handleTab();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (primaryCode != KEYCODE_ENTER) {
|
if (primaryCode != KEYCODE_ENTER) {
|
||||||
|
@ -1343,6 +1344,30 @@ public class LatinIME extends InputMethodService
|
||||||
ic.endBatchEdit();
|
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) {
|
private void abortCorrection(boolean force) {
|
||||||
if (force || TextEntryState.isCorrecting()) {
|
if (force || TextEntryState.isCorrecting()) {
|
||||||
TextEntryState.onAbortCorrection();
|
TextEntryState.onAbortCorrection();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class LatinKeyboardShiftState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
Log.d(TAG, "setShifted: " + toString(oldState) + " > " + this);
|
Log.d(TAG, "setShifted(" + newShiftState + "): " + toString(oldState) + " > " + this);
|
||||||
return mState != oldState;
|
return mState != oldState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,8 @@ public class LatinKeyboardShiftState {
|
||||||
mState = NORMAL;
|
mState = NORMAL;
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
Log.d(TAG, "setShiftLocked: " + toString(oldState) + " > " + this);
|
Log.d(TAG, "setShiftLocked(" + newShiftLockState + "): " + toString(oldState)
|
||||||
|
+ " > " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutomaticTemporaryUpperCase() {
|
public void setAutomaticTemporaryUpperCase() {
|
||||||
|
|
|
@ -55,6 +55,10 @@ public class ModifierKeyState {
|
||||||
Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
|
Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isReleasing() {
|
||||||
|
return mState == RELEASING;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isMomentary() {
|
public boolean isMomentary() {
|
||||||
return mState == MOMENTARY;
|
return mState == MOMENTARY;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue