Fix for 2559069 IME ".com" should be erasable with one backspace
Change-Id: Ifef97a9b66e051fef7ca8b0a92bfe21f3d1e6cf6main
parent
0fef498a07
commit
dad0e792aa
|
@ -226,6 +226,9 @@ public class LatinIME extends InputMethodService
|
||||||
private long mSwipeTriggerTimeMillis;
|
private long mSwipeTriggerTimeMillis;
|
||||||
private boolean mConfigurationChanging;
|
private boolean mConfigurationChanging;
|
||||||
|
|
||||||
|
// Keeps track of most recently inserted text (multi-character key) for reverting
|
||||||
|
private CharSequence mEnteredText;
|
||||||
|
|
||||||
// For each word, a list of potential replacements, usually from voice.
|
// For each word, a list of potential replacements, usually from voice.
|
||||||
private Map<String, List<CharSequence>> mWordToSuggestions =
|
private Map<String, List<CharSequence>> mWordToSuggestions =
|
||||||
new HashMap<String, List<CharSequence>>();
|
new HashMap<String, List<CharSequence>>();
|
||||||
|
@ -452,6 +455,8 @@ public class LatinIME extends InputMethodService
|
||||||
mCompletions = null;
|
mCompletions = null;
|
||||||
mCapsLock = false;
|
mCapsLock = false;
|
||||||
mEmailText = false;
|
mEmailText = false;
|
||||||
|
mEnteredText = null;
|
||||||
|
|
||||||
switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
|
switch (attribute.inputType & EditorInfo.TYPE_MASK_CLASS) {
|
||||||
case EditorInfo.TYPE_CLASS_NUMBER:
|
case EditorInfo.TYPE_CLASS_NUMBER:
|
||||||
case EditorInfo.TYPE_CLASS_DATETIME:
|
case EditorInfo.TYPE_CLASS_DATETIME:
|
||||||
|
@ -981,6 +986,8 @@ public class LatinIME extends InputMethodService
|
||||||
if (mKeyboardSwitcher.onKey(primaryCode)) {
|
if (mKeyboardSwitcher.onKey(primaryCode)) {
|
||||||
changeKeyboardMode();
|
changeKeyboardMode();
|
||||||
}
|
}
|
||||||
|
// Reset after any single keystroke
|
||||||
|
mEnteredText = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onText(CharSequence text) {
|
public void onText(CharSequence text) {
|
||||||
|
@ -999,6 +1006,7 @@ public class LatinIME extends InputMethodService
|
||||||
updateShiftKeyState(getCurrentInputEditorInfo());
|
updateShiftKeyState(getCurrentInputEditorInfo());
|
||||||
mJustRevertedSeparator = null;
|
mJustRevertedSeparator = null;
|
||||||
mJustAddedAutoSpace = false;
|
mJustAddedAutoSpace = false;
|
||||||
|
mEnteredText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleBackspace() {
|
private void handleBackspace() {
|
||||||
|
@ -1045,6 +1053,8 @@ public class LatinIME extends InputMethodService
|
||||||
if (TextEntryState.getState() == TextEntryState.STATE_UNDO_COMMIT) {
|
if (TextEntryState.getState() == TextEntryState.STATE_UNDO_COMMIT) {
|
||||||
revertLastWord(deleteChar);
|
revertLastWord(deleteChar);
|
||||||
return;
|
return;
|
||||||
|
} else if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
|
||||||
|
ic.deleteSurroundingText(mEnteredText.length(), 0);
|
||||||
} else if (deleteChar) {
|
} else if (deleteChar) {
|
||||||
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
|
||||||
if (mDeleteCount > DELETE_ACCELERATE_AT) {
|
if (mDeleteCount > DELETE_ACCELERATE_AT) {
|
||||||
|
@ -1594,6 +1604,11 @@ public class LatinIME extends InputMethodService
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sameAsTextBeforeCursor(InputConnection ic, CharSequence text) {
|
||||||
|
CharSequence beforeText = ic.getTextBeforeCursor(text.length(), 0);
|
||||||
|
return TextUtils.equals(text, beforeText);
|
||||||
|
}
|
||||||
|
|
||||||
public void revertLastWord(boolean deleteChar) {
|
public void revertLastWord(boolean deleteChar) {
|
||||||
final int length = mComposing.length();
|
final int length = mComposing.length();
|
||||||
if (!mPredicting && length > 0) {
|
if (!mPredicting && length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue