am c7c152de: Guard against wrong auto-correction cancellation (A6)

* commit 'c7c152de4b42853086fc6fd918387ad0583d0e3e':
  Guard against wrong auto-correction cancellation (A6)
main
Jean Chalard 2012-01-26 03:02:17 -08:00 committed by Android Git Automerger
commit f108ec1103
1 changed files with 9 additions and 2 deletions

View File

@ -1274,6 +1274,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacesTimer();
} }
boolean didAutoCorrect = false;
switch (primaryCode) { switch (primaryCode) {
case Keyboard.CODE_DELETE: case Keyboard.CODE_DELETE:
mSpaceState = SPACE_STATE_NONE; mSpaceState = SPACE_STATE_NONE;
@ -1310,7 +1311,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
default: default:
mSpaceState = SPACE_STATE_NONE; mSpaceState = SPACE_STATE_NONE;
if (mSettingsValues.isWordSeparator(primaryCode)) { if (mSettingsValues.isWordSeparator(primaryCode)) {
handleSeparator(primaryCode, x, y, spaceState); didAutoCorrect = handleSeparator(primaryCode, x, y, spaceState);
} else { } else {
handleCharacter(primaryCode, keyCodes, x, y, spaceState); handleCharacter(primaryCode, keyCodes, x, y, spaceState);
} }
@ -1319,6 +1320,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
switcher.onCodeInput(primaryCode); switcher.onCodeInput(primaryCode);
// Reset after any single keystroke // Reset after any single keystroke
if (!didAutoCorrect)
mLastComposedWord.deactivate();
mEnteredText = null; mEnteredText = null;
} }
@ -1562,7 +1565,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
} }
private void handleSeparator(final int primaryCode, final int x, final int y, // Returns true if we did an autocorrection, false otherwise.
private boolean handleSeparator(final int primaryCode, final int x, final int y,
final int spaceState) { final int spaceState) {
mVoiceProxy.handleSeparator(); mVoiceProxy.handleSeparator();
mComposingStateManager.onFinishComposingText(); mComposingStateManager.onFinishComposingText();
@ -1573,6 +1577,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mHandler.postUpdateSuggestions(); mHandler.postUpdateSuggestions();
} }
boolean didAutoCorrect = false;
// Handle separator // Handle separator
final InputConnection ic = getCurrentInputConnection(); final InputConnection ic = getCurrentInputConnection();
if (ic != null) { if (ic != null) {
@ -1587,6 +1592,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
&& !mInputAttributes.mInputTypeNoAutoCorrect; && !mInputAttributes.mInputTypeNoAutoCorrect;
if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) {
commitCurrentAutoCorrection(primaryCode, ic); commitCurrentAutoCorrection(primaryCode, ic);
didAutoCorrect = true;
} else { } else {
commitTyped(ic); commitTyped(ic);
} }
@ -1642,6 +1648,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (ic != null) { if (ic != null) {
ic.endBatchEdit(); ic.endBatchEdit();
} }
return didAutoCorrect;
} }
private CharSequence getTextWithUnderline(final CharSequence text) { private CharSequence getTextWithUnderline(final CharSequence text) {