Cleanup.
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:
parent
ce668e7a0b
commit
d0c5f9395a
2 changed files with 8 additions and 25 deletions
|
@ -1630,7 +1630,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
public boolean isSuggestionsStripVisible() {
|
public boolean isSuggestionsStripVisible() {
|
||||||
if (mSuggestionsView == null)
|
if (mSuggestionsView == null)
|
||||||
return false;
|
return false;
|
||||||
if (mSuggestionsView.isShowingAddToDictionaryHint() || TextEntryState.isRecorrecting())
|
if (mSuggestionsView.isShowingAddToDictionaryHint())
|
||||||
return true;
|
return true;
|
||||||
if (!isShowingSuggestionsStrip())
|
if (!isShowingSuggestionsStrip())
|
||||||
return false;
|
return false;
|
||||||
|
@ -1735,7 +1735,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
// Don't auto-correct words with multiple capital letter
|
// Don't auto-correct words with multiple capital letter
|
||||||
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
||||||
autoCorrectionAvailable &= !TextEntryState.isRecorrecting();
|
|
||||||
|
|
||||||
// Basically, we update the suggestion strip only when suggestion count > 1. However,
|
// 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
|
// 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,
|
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
|
||||||
mSettingsValues.mWordSeparators);
|
mSettingsValues.mWordSeparators);
|
||||||
|
|
||||||
final boolean recorrecting = TextEntryState.isRecorrecting();
|
|
||||||
final InputConnection ic = getCurrentInputConnection();
|
final InputConnection ic = getCurrentInputConnection();
|
||||||
if (ic != null) {
|
if (ic != null) {
|
||||||
ic.beginBatchEdit();
|
ic.beginBatchEdit();
|
||||||
|
@ -1882,7 +1880,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
suggestion.toString(), index, suggestions.mWords);
|
suggestion.toString(), index, suggestions.mWords);
|
||||||
TextEntryState.acceptedSuggestion(mComposingStringBuilder.toString(), suggestion);
|
TextEntryState.acceptedSuggestion(mComposingStringBuilder.toString(), suggestion);
|
||||||
// Follow it with a space
|
// Follow it with a space
|
||||||
if (mInsertSpaceOnPickSuggestionManually && !recorrecting) {
|
if (mInsertSpaceOnPickSuggestionManually) {
|
||||||
sendMagicSpace();
|
sendMagicSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1902,13 +1900,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|| !AutoCorrection.isValidWord(
|
|| !AutoCorrection.isValidWord(
|
||||||
mSuggest.getUnigramDictionaries(), suggestion, true));
|
mSuggest.getUnigramDictionaries(), suggestion, true));
|
||||||
|
|
||||||
if (!recorrecting) {
|
|
||||||
// Fool the state watcher so that a subsequent backspace will not do a revert, unless
|
// 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
|
// we just did a correction, in which case we need to stay in
|
||||||
// TextEntryState.State.PICKED_SUGGESTION state.
|
// TextEntryState.State.PICKED_SUGGESTION state.
|
||||||
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
|
TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
|
||||||
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
|
||||||
}
|
|
||||||
if (!showingAddToDictionaryHint) {
|
if (!showingAddToDictionaryHint) {
|
||||||
// If we're not showing the "Touch again to save", then show corrections again.
|
// 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.
|
// In case the cursor position doesn't change, make sure we show the suggestions again.
|
||||||
|
|
|
@ -34,7 +34,6 @@ public class TextEntryState {
|
||||||
private static final int SPACE_AFTER_ACCEPTED = 6;
|
private static final int SPACE_AFTER_ACCEPTED = 6;
|
||||||
private static final int SPACE_AFTER_PICKED = 7;
|
private static final int SPACE_AFTER_PICKED = 7;
|
||||||
private static final int UNDO_COMMIT = 8;
|
private static final int UNDO_COMMIT = 8;
|
||||||
private static final int PICKED_RECORRECTION = 9;
|
|
||||||
|
|
||||||
private static int sState = UNKNOWN;
|
private static int sState = UNKNOWN;
|
||||||
private static int sPreviousState = UNKNOWN;
|
private static int sPreviousState = UNKNOWN;
|
||||||
|
@ -77,13 +76,7 @@ public class TextEntryState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void acceptedSuggestion(CharSequence typedWord, CharSequence actualWord) {
|
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)
|
if (DEBUG)
|
||||||
displayState("acceptedSuggestion", "typedWord", typedWord, "actualWord", actualWord);
|
displayState("acceptedSuggestion", "typedWord", typedWord, "actualWord", actualWord);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +104,6 @@ public class TextEntryState {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PICKED_SUGGESTION:
|
case PICKED_SUGGESTION:
|
||||||
case PICKED_RECORRECTION:
|
|
||||||
if (isSpace) {
|
if (isSpace) {
|
||||||
setState(SPACE_AFTER_PICKED);
|
setState(SPACE_AFTER_PICKED);
|
||||||
} else if (isSeparator) {
|
} else if (isSeparator) {
|
||||||
|
@ -166,10 +158,6 @@ public class TextEntryState {
|
||||||
return sState == UNDO_COMMIT;
|
return sState == UNDO_COMMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRecorrecting() {
|
|
||||||
return sState == PICKED_RECORRECTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getState() {
|
public static String getState() {
|
||||||
return stateName(sState);
|
return stateName(sState);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +172,6 @@ public class TextEntryState {
|
||||||
case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED";
|
case SPACE_AFTER_ACCEPTED: return "SPACE_AFTER_ACCEPTED";
|
||||||
case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED";
|
case SPACE_AFTER_PICKED: return "SPACE_AFTER_PICKED";
|
||||||
case UNDO_COMMIT: return "UNDO_COMMIT";
|
case UNDO_COMMIT: return "UNDO_COMMIT";
|
||||||
case PICKED_RECORRECTION: return "PICKED_RECORRECTION";
|
|
||||||
default: return "UNKNOWN";
|
default: return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue