Merge changes I7888797c,I57b2232f
* changes: Refactor + small bugfix Refactoring
This commit is contained in:
commit
024ee9ff02
1 changed files with 8 additions and 11 deletions
|
@ -1386,13 +1386,20 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
private void handleBackspace(final int spaceState) {
|
private void handleBackspace(final int spaceState) {
|
||||||
if (mVoiceProxy.logAndRevertVoiceInput()) return;
|
if (mVoiceProxy.logAndRevertVoiceInput()) return;
|
||||||
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic == null) return;
|
if (ic == null) return;
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
|
handleBackspaceWhileInBatchEdit(spaceState, ic);
|
||||||
|
ic.endBatchEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// "ic" may not be null.
|
||||||
|
private void handleBackspaceWhileInBatchEdit(final int spaceState, final InputConnection ic) {
|
||||||
mVoiceProxy.handleBackspace();
|
mVoiceProxy.handleBackspace();
|
||||||
|
|
||||||
|
// In many cases, we may have to put the keyboard in auto-shift state again.
|
||||||
|
mHandler.postUpdateShiftKeyState();
|
||||||
|
|
||||||
if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
||||||
// Cancel multi-character input: remove the text we just entered.
|
// Cancel multi-character input: remove the text we just entered.
|
||||||
// This is triggered on backspace after a key that inputs multiple characters,
|
// This is triggered on backspace after a key that inputs multiple characters,
|
||||||
|
@ -1401,7 +1408,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// If we have mEnteredText, then we know that mHasUncommittedTypedChars == false.
|
// If we have mEnteredText, then we know that mHasUncommittedTypedChars == false.
|
||||||
// In addition we know that spaceState is false, and that we should not be
|
// In addition we know that spaceState is false, and that we should not be
|
||||||
// reverting any autocorrect at this point. So we can safely return.
|
// reverting any autocorrect at this point. So we can safely return.
|
||||||
ic.endBatchEdit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1430,21 +1436,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
} else {
|
} else {
|
||||||
ic.deleteSurroundingText(1, 0);
|
ic.deleteSurroundingText(1, 0);
|
||||||
}
|
}
|
||||||
// If we deleted the last remaining char of a word, we may have to put the keyboard
|
|
||||||
// in auto-shift state again.
|
|
||||||
mHandler.postUpdateShiftKeyState();
|
|
||||||
// If we had uncommitted chars then we know it's not time to revert any auto-correct
|
// If we had uncommitted chars then we know it's not time to revert any auto-correct
|
||||||
// and that spaceState is NONE.
|
// and that spaceState is NONE.
|
||||||
ic.endBatchEdit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mHandler.postUpdateShiftKeyState();
|
|
||||||
|
|
||||||
if (null != mWordSavedForAutoCorrectCancellation) {
|
if (null != mWordSavedForAutoCorrectCancellation) {
|
||||||
Utils.Stats.onAutoCorrectionCancellation();
|
Utils.Stats.onAutoCorrectionCancellation();
|
||||||
cancelAutoCorrect(ic);
|
cancelAutoCorrect(ic);
|
||||||
mWordSavedForAutoCorrectCancellation = null;
|
mWordSavedForAutoCorrectCancellation = null;
|
||||||
ic.endBatchEdit();
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
mWordSavedForAutoCorrectCancellation = null;
|
mWordSavedForAutoCorrectCancellation = null;
|
||||||
|
@ -1452,14 +1452,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
if (SPACE_STATE_DOUBLE == spaceState) {
|
if (SPACE_STATE_DOUBLE == spaceState) {
|
||||||
if (revertDoubleSpace(ic)) {
|
if (revertDoubleSpace(ic)) {
|
||||||
ic.endBatchEdit();
|
|
||||||
// No need to reset mSpaceState, it has already be done (that's why we
|
// No need to reset mSpaceState, it has already be done (that's why we
|
||||||
// receive it as a parameter)
|
// receive it as a parameter)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
} else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) {
|
||||||
if (revertSwapPunctuation(ic)) {
|
if (revertSwapPunctuation(ic)) {
|
||||||
ic.endBatchEdit();
|
|
||||||
// Likewise
|
// Likewise
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1483,7 +1481,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(ic);
|
restartSuggestionsOnWordBeforeCursorIfAtEndOfWord(ic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ic.endBatchEdit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleTab() {
|
private void handleTab() {
|
||||||
|
|
Loading…
Reference in a new issue