am 98353076
: Merge "Preserve punctuation character after canceling auto correction" into honeycomb
* commit '98353076909cad1c4bbdd70b9f2b3db5d48cea6d': Preserve punctuation character after canceling auto correction
This commit is contained in:
commit
d7d5da367c
1 changed files with 21 additions and 9 deletions
|
@ -1139,14 +1139,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
|
|
||||||
private void handleBackspace() {
|
private void handleBackspace() {
|
||||||
if (mVoiceConnector.logAndRevertVoiceInput()) return;
|
if (mVoiceConnector.logAndRevertVoiceInput()) return;
|
||||||
boolean deleteChar = false;
|
|
||||||
InputConnection ic = getCurrentInputConnection();
|
|
||||||
if (ic == null) return;
|
|
||||||
|
|
||||||
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
|
if (ic == null) return;
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
|
|
||||||
mVoiceConnector.handleBackspace();
|
mVoiceConnector.handleBackspace();
|
||||||
|
|
||||||
|
boolean deleteChar = false;
|
||||||
if (mHasValidSuggestions) {
|
if (mHasValidSuggestions) {
|
||||||
final int length = mComposing.length();
|
final int length = mComposing.length();
|
||||||
if (length > 0) {
|
if (length > 0) {
|
||||||
|
@ -1164,12 +1164,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
deleteChar = true;
|
deleteChar = true;
|
||||||
}
|
}
|
||||||
mHandler.postUpdateShiftKeyState();
|
mHandler.postUpdateShiftKeyState();
|
||||||
|
|
||||||
TextEntryState.backspace();
|
TextEntryState.backspace();
|
||||||
if (TextEntryState.getState() == TextEntryState.State.UNDO_COMMIT) {
|
if (TextEntryState.getState() == TextEntryState.State.UNDO_COMMIT) {
|
||||||
revertLastWord(deleteChar);
|
revertLastWord(deleteChar);
|
||||||
ic.endBatchEdit();
|
ic.endBatchEdit();
|
||||||
return;
|
return;
|
||||||
} else if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
}
|
||||||
|
|
||||||
|
if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
||||||
ic.deleteSurroundingText(mEnteredText.length(), 0);
|
ic.deleteSurroundingText(mEnteredText.length(), 0);
|
||||||
} else if (deleteChar) {
|
} else if (deleteChar) {
|
||||||
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
|
||||||
|
@ -1803,16 +1806,25 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
mHasValidSuggestions = true;
|
mHasValidSuggestions = true;
|
||||||
mJustReverted = true;
|
mJustReverted = true;
|
||||||
|
final CharSequence punctuation = ic.getTextBeforeCursor(1, 0);
|
||||||
if (deleteChar) ic.deleteSurroundingText(1, 0);
|
if (deleteChar) ic.deleteSurroundingText(1, 0);
|
||||||
int toDelete = mCommittedLength;
|
int toDelete = mCommittedLength;
|
||||||
CharSequence toTheLeft = ic.getTextBeforeCursor(mCommittedLength, 0);
|
final CharSequence toTheLeft = ic.getTextBeforeCursor(mCommittedLength, 0);
|
||||||
if (toTheLeft != null && toTheLeft.length() > 0
|
if (!TextUtils.isEmpty(toTheLeft) && isWordSeparator(toTheLeft.charAt(0))) {
|
||||||
&& isWordSeparator(toTheLeft.charAt(0))) {
|
|
||||||
toDelete--;
|
toDelete--;
|
||||||
}
|
}
|
||||||
ic.deleteSurroundingText(toDelete, 0);
|
ic.deleteSurroundingText(toDelete, 0);
|
||||||
ic.setComposingText(mComposing, 1);
|
if (deleteChar) {
|
||||||
TextEntryState.backspace();
|
ic.commitText(mComposing, 1);
|
||||||
|
TextEntryState.acceptedTyped(mComposing);
|
||||||
|
if (!TextUtils.isEmpty(punctuation) && isWordSeparator(punctuation.charAt(0))) {
|
||||||
|
ic.commitText(punctuation, 1);
|
||||||
|
TextEntryState.typedCharacter(punctuation.charAt(0), true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ic.setComposingText(mComposing, 1);
|
||||||
|
TextEntryState.backspace();
|
||||||
|
}
|
||||||
mHandler.postUpdateSuggestions();
|
mHandler.postUpdateSuggestions();
|
||||||
} else {
|
} else {
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||||
|
|
Loading…
Reference in a new issue