Fix states for showing PunctuationList and correction
- Fixed the visibility of the suggestion strip
Change-Id: I63ad561c71464657521661dbd25c72dd34841834
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index cb50cfb..60828c3 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -667,7 +667,7 @@
mVoiceButtonOnPrimary);
updateShiftKeyState(attribute);
- setCandidatesViewShownInternal(isCandidateStripVisible() || mCompletionOn,
+ setCandidatesViewShownInternal(isCandidateStripVisible(),
false /* needsInputViewShown */ );
updateSuggestions();
@@ -827,7 +827,7 @@
if (mCandidateView != null
&& !mSuggestPuncList.equals(mCandidateView.getSuggestions())
&& !mCandidateView.isShowingAddToDictionaryHint()) {
- setNextSuggestions();
+ setPunctuationSuggestions();
}
}
}
@@ -1408,6 +1408,8 @@
private void abortCorrection(boolean force) {
if (force || TextEntryState.isCorrecting()) {
+ TextEntryState.onAbortCorrection();
+ setCandidatesViewShown(isCandidateStripVisible());
getCurrentInputConnection().finishComposingText();
clearSuggestions();
}
@@ -1598,7 +1600,8 @@
}
private boolean isCandidateStripVisible() {
- return isPredictionOn() && mShowSuggestions;
+ return (isPredictionOn() && mShowSuggestions) || mCompletionOn
+ || mCandidateView.isShowingAddToDictionaryHint() || TextEntryState.isCorrecting();
}
public void onCancelVoice() {
@@ -1614,7 +1617,7 @@
if (mKeyboardSwitcher.getInputView() != null) {
setInputView(mKeyboardSwitcher.getInputView());
}
- setCandidatesViewShown(true);
+ setCandidatesViewShown(isCandidateStripVisible());
updateInputViewShown();
postUpdateSuggestions();
}});
@@ -1815,7 +1818,7 @@
}
if (!mPredicting) {
- setNextSuggestions();
+ setPunctuationSuggestions();
return;
}
showSuggestions(mWord);
@@ -1883,7 +1886,7 @@
} else {
mBestWord = null;
}
- setCandidatesViewShown(isCandidateStripVisible() || mCompletionOn);
+ setCandidatesViewShown(isCandidateStripVisible());
}
private boolean pickDefaultSuggestion() {
@@ -1977,7 +1980,7 @@
// we just did a correction, in which case we need to stay in
// TextEntryState.State.PICKED_SUGGESTION state.
TextEntryState.typedCharacter((char) KEYCODE_SPACE, true);
- setNextSuggestions();
+ setPunctuationSuggestions();
} else 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.
@@ -2039,7 +2042,7 @@
}
// If we just corrected a word, then don't show punctuations
if (!correcting) {
- setNextSuggestions();
+ setPunctuationSuggestions();
}
updateShiftKeyState(getCurrentInputEditorInfo());
}
@@ -2148,14 +2151,16 @@
ic.endBatchEdit();
} else {
abortCorrection(true);
- setNextSuggestions(); // Show the punctuation suggestions list
+ setPunctuationSuggestions(); // Show the punctuation suggestions list
}
} else {
abortCorrection(true);
}
}
- private void setNextSuggestions() {
+ private void setPunctuationSuggestions() {
+ TextEntryState.onShowPunctuationsList();
+ setCandidatesViewShown(isCandidateStripVisible());
setSuggestions(mSuggestPuncList, false, false, false);
}
diff --git a/java/src/com/android/inputmethod/latin/TextEntryState.java b/java/src/com/android/inputmethod/latin/TextEntryState.java
index 1d7659c..48a7734 100644
--- a/java/src/com/android/inputmethod/latin/TextEntryState.java
+++ b/java/src/com/android/inputmethod/latin/TextEntryState.java
@@ -62,7 +62,8 @@
SPACE_AFTER_PICKED,
UNDO_COMMIT,
CORRECTING,
- PICKED_CORRECTION;
+ PICKED_CORRECTION,
+ SHOWING_PUNCTUATIONS_LIST;
}
private static State sState = State.UNKNOWN;
@@ -97,7 +98,7 @@
}
try {
sKeyLocationFile.close();
- // Write to log file
+ // Write to log file
// Write timestamp, settings,
String out = DateFormat.format("MM:dd hh:mm:ss", Calendar.getInstance().getTime())
.toString()
@@ -169,6 +170,18 @@
displayState();
}
+ public static void onAbortCorrection() {
+ if (isCorrecting()) {
+ sState = State.START;
+ }
+ displayState();
+ }
+
+ public static void onShowPunctuationsList() {
+ sState = State.SHOWING_PUNCTUATIONS_LIST;
+ displayState();
+ }
+
public static void typedCharacter(char c, boolean isSeparator) {
boolean isSpace = c == ' ';
switch (sState) {