Perform editor action IME_ACTION_NEXT/PREVIOUS by tab key

Bug: 3122995
Change-Id: I44280fe1c6cc27f429b311edec71e1027178222d
This commit is contained in:
Tadashi G. Takaoka 2010-11-12 15:49:56 -08:00
parent 07f903afba
commit 45911256fd
4 changed files with 55 additions and 12 deletions

View file

@ -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();
}

View file

@ -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();

View file

@ -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() {

View file

@ -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;
}