Extract a method to reset the ime state
Change-Id: I921184b85b94418cf360508ee3f67e85b10b3d72main
parent
5eeff7cf54
commit
2649e42d75
|
@ -894,29 +894,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (((mWordComposer.isComposingWord())
|
if (((mWordComposer.isComposingWord())
|
||||||
|| mVoiceProxy.isVoiceInputHighlighted())
|
|| mVoiceProxy.isVoiceInputHighlighted())
|
||||||
&& (selectionChanged || noComposingSpan)) {
|
&& (selectionChanged || noComposingSpan)) {
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
resetEntireInputState();
|
||||||
updateSuggestions();
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
|
||||||
if (ic != null) {
|
|
||||||
ic.finishComposingText();
|
|
||||||
}
|
|
||||||
mComposingStateManager.onFinishComposingText();
|
|
||||||
mVoiceProxy.setVoiceInputHighlighted(false);
|
|
||||||
} else if (!mWordComposer.isComposingWord()) {
|
} else if (!mWordComposer.isComposingWord()) {
|
||||||
// We need to do this to clear the last composed word.
|
resetEntireInputState();
|
||||||
resetComposingState(true /* alsoResetLastComposedWord */);
|
|
||||||
updateSuggestions();
|
|
||||||
// Calling finishComposingText() here is harmless because there
|
|
||||||
// is no composing word, so it's a no-op.
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
|
||||||
if (ic != null) {
|
|
||||||
ic.finishComposingText();
|
|
||||||
}
|
|
||||||
// Likewise, this is a no-op since we are not composing text
|
|
||||||
mComposingStateManager.onFinishComposingText();
|
|
||||||
// The cursor moved so it's safe to assume that the voice input
|
|
||||||
// is not highlighted
|
|
||||||
mVoiceProxy.setVoiceInputHighlighted(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mHandler.postUpdateShiftState();
|
mHandler.postUpdateShiftState();
|
||||||
|
@ -1126,6 +1106,20 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This will reset the whole input state to the starting state. It will clear
|
||||||
|
// the composing word, reset the last composed word, tell the inputconnection
|
||||||
|
// and the composingStateManager about it.
|
||||||
|
private void resetEntireInputState() {
|
||||||
|
resetComposingState(true /* alsoResetLastComposedWord */);
|
||||||
|
updateSuggestions();
|
||||||
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
|
if (ic != null) {
|
||||||
|
ic.finishComposingText();
|
||||||
|
}
|
||||||
|
mComposingStateManager.onFinishComposingText();
|
||||||
|
mVoiceProxy.setVoiceInputHighlighted(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void resetComposingState(final boolean alsoResetLastComposedWord) {
|
private void resetComposingState(final boolean alsoResetLastComposedWord) {
|
||||||
mWordComposer.reset();
|
mWordComposer.reset();
|
||||||
if (alsoResetLastComposedWord)
|
if (alsoResetLastComposedWord)
|
||||||
|
|
Loading…
Reference in New Issue