Remove a state that can never be reached, and ajust all the
callers that would always have received false.

Change-Id: Iac025568be11743428419e0772da306a4f0a0bf1
This commit is contained in:
Jean Chalard 2011-10-25 21:54:35 +09:00
parent ce668e7a0b
commit d0c5f9395a
2 changed files with 8 additions and 25 deletions

View file

@ -1630,7 +1630,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public boolean isSuggestionsStripVisible() {
if (mSuggestionsView == null)
return false;
if (mSuggestionsView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting())
if (mSuggestionsView.isShowingAddToDictionaryHint())
return true;
if (!isShowingSuggestionsStrip())
return false;
@ -1735,7 +1735,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
// Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
autoCorrectionAvailable &= !TextEntryState.isRecorrecting();
// Basically, we update the suggestion strip only when suggestion count > 1. However,
// there is an exception: We update the suggestion strip whenever typed word's length
@ -1808,7 +1807,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
mSettingsValues.mWordSeparators);
final boolean recorrecting = TextEntryState.isRecorrecting();
final InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ic.beginBatchEdit();
@ -1882,7 +1880,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
suggestion.toString(), index, suggestions.mWords);
TextEntryState.acceptedSuggestion(mComposingStringBuilder.toString(), suggestion);
// Follow it with a space
if (mInsertSpaceOnPickSuggestionManually && !recorrecting) {
if (mInsertSpaceOnPickSuggestionManually) {
sendMagicSpace();
}
@ -1902,13 +1900,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|| !AutoCorrection.isValidWord(
mSuggest.getUnigramDictionaries(), suggestion, true));
if (!recorrecting) {
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
// we just did a correction, in which case we need to stay in
// TextEntryState.State.PICKED_SUGGESTION state.
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
}
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
// we just did a correction, in which case we need to stay in
// TextEntryState.State.PICKED_SUGGESTION state.
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
if (!showingAddToDictionaryHint) {
// If we're not showing the "Touch again to save", then show corrections again.
// In case the cursor position doesn't change, make sure we show the suggestions again.

View file

@ -34,7 +34,6 @@ public class TextEntryState {
private static final int SPACE_AFTER_ACCEPTED = 6;
private static final int SPACE_AFTER_PICKED = 7;
private static final int UNDO_COMMIT = 8;
private static final int PICKED_RECORRECTION = 9;
private static int sState = UNKNOWN;
private static int sPreviousState = UNKNOWN;
@ -77,13 +76,7 @@ public class TextEntryState {
}
public static void acceptedSuggestion(CharSequence typedWord, CharSequence actualWord) {
if (sState == PICKED_RECORRECTION) {
// TODO: this seems to be the only place where setState(PICKED_RECORRECTION) is done
// so this state should never be reached. Check this and remove.
setState(PICKED_RECORRECTION);
} else {
setState(PICKED_SUGGESTION);
}
setState(PICKED_SUGGESTION);
if (DEBUG)
displayState("acceptedSuggestion", "typedWord", typedWord, "actualWord", actualWord);
}
@ -111,7 +104,6 @@ public class TextEntryState {
}
break;
case PICKED_SUGGESTION:
case PICKED_RECORRECTION:
if (isSpace) {
setState(SPACE_AFTER_PICKED);
} else if (isSeparator) {
@ -166,10 +158,6 @@ public class TextEntryState {
return sState == UNDO_COMMIT;
}
public static boolean isRecorrecting() {
return sState == PICKED_RECORRECTION;
}
public static String getState() {
return stateName(sState);
}
@ -184,7 +172,6 @@ public class TextEntryState {
case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED";
case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED";
case UNDO_COMMIT: return "UNDO_COMMIT";
case PICKED_RECORRECTION: return "PICKED_RECORRECTION";
default: return "UNKNOWN";
}
}