aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java41
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java2
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java27
3 files changed, 39 insertions, 31 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index adebfc08c..e8ea5e39d 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -193,9 +193,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (msg.arg2 == ARG2_WITH_TYPED_WORD) {
final Pair<SuggestedWords, String> p =
(Pair<SuggestedWords, String>) msg.obj;
- latinIme.showSuggestionStripWithTypedWord(p.first, p.second);
+ // [IL]: this is the only place where the second arg is not
+ // suggestedWords.mTypedWord.
+ latinIme.showSuggestionStrip(p.first, p.second);
} else {
- latinIme.showSuggestionStrip((SuggestedWords) msg.obj);
+ final SuggestedWords suggestedWords = (SuggestedWords) msg.obj;
+ latinIme.showSuggestionStrip(suggestedWords, suggestedWords.mTypedWord);
}
} else {
latinIme.showGesturePreviewAndSuggestionStrip((SuggestedWords) msg.obj,
@@ -1270,7 +1273,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// This method must run on the UI Thread.
private void showGesturePreviewAndSuggestionStrip(final SuggestedWords suggestedWords,
final boolean dismissGestureFloatingPreviewText) {
- showSuggestionStrip(suggestedWords);
+ showSuggestionStrip(suggestedWords, suggestedWords.mTypedWord);
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
mainKeyboardView.showGestureFloatingPreviewText(suggestedWords);
if (dismissGestureFloatingPreviewText) {
@@ -1324,25 +1327,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
// TODO[IL]: Define a clear interface for this
- public void setSuggestedWords(final SuggestedWords words, final boolean shouldShow) {
- mInputLogic.mSuggestedWords = words;
- final boolean newAutoCorrectionIndicator = words.mWillAutoCorrect;
- // Put a blue underline to a word in TextView which will be auto-corrected.
- if (mInputLogic.mIsAutoCorrectionIndicatorOn != newAutoCorrectionIndicator
- && mInputLogic.mWordComposer.isComposingWord()) {
- mInputLogic.mIsAutoCorrectionIndicatorOn = newAutoCorrectionIndicator;
- final CharSequence textWithUnderline =
- mInputLogic.getTextWithUnderline(mInputLogic.mWordComposer.getTypedWord());
- // TODO: when called from an updateSuggestionStrip() call that results from a posted
- // message, this is called outside any batch edit. Potentially, this may result in some
- // janky flickering of the screen, although the display speed makes it unlikely in
- // the practice.
- mInputLogic.mConnection.setComposingText(textWithUnderline, 1);
- }
+ public void setSuggestedWords(final SuggestedWords suggestedWords, final boolean shouldShow) {
+ mInputLogic.setSuggestedWords(suggestedWords);
if (mSuggestionStripView != null) {
- mSuggestionStripView.setSuggestions(
- words, SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
- mKeyboardSwitcher.onAutoCorrectionStateChanged(words.mWillAutoCorrect);
+ mSuggestionStripView.setSuggestions(suggestedWords,
+ SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype()));
+ mKeyboardSwitcher.onAutoCorrectionStateChanged(suggestedWords.mWillAutoCorrect);
setSuggestionStripShownInternal(shouldShow, true /* needsInputViewShown */);
}
}
@@ -1418,7 +1408,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
- private void showSuggestionStripWithTypedWord(final SuggestedWords sourceSuggestedWords,
+ // TODO[IL]: Define a clean interface for this
+ public void showSuggestionStrip(final SuggestedWords sourceSuggestedWords,
final String typedWord) {
final SuggestedWords suggestedWords =
sourceSuggestedWords.isEmpty() ? SuggestedWords.EMPTY : sourceSuggestedWords;
@@ -1439,12 +1430,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
AccessibilityUtils.getInstance().setAutoCorrection(suggestedWords, typedWord);
}
- // TODO[IL]: Define a clean interface for this
- public void showSuggestionStrip(final SuggestedWords suggestedWords) {
- showSuggestionStripWithTypedWord(suggestedWords, suggestedWords.isEmpty() ? null
- : suggestedWords.getWord(SuggestedWords.INDEX_OF_TYPED_WORD));
- }
-
// Called from {@link SuggestionStripView} through the {@link SuggestionStripView#Listener}
// interface
@Override
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index bb34b7ba9..982a97a5e 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -39,6 +39,7 @@ public final class SuggestedWords {
public static final SuggestedWords EMPTY = new SuggestedWords(
EMPTY_WORD_INFO_LIST, false, false, false, false, false);
+ public final String mTypedWord;
public final boolean mTypedWordValid;
// Note: this INCLUDES cases where the word will auto-correct to itself. A good definition
// of what this flag means would be "the top suggestion is strong enough to auto-correct",
@@ -74,6 +75,7 @@ public final class SuggestedWords {
mIsObsoleteSuggestions = isObsoleteSuggestions;
mIsPrediction = isPrediction;
mSequenceNumber = sequenceNumber;
+ mTypedWord = suggestedWordInfoList.isEmpty() ? null : getWord(INDEX_OF_TYPED_WORD);
}
public boolean isEmpty() {
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index 16e032051..ce3ef5374 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -482,6 +482,25 @@ public final class InputLogic {
SuggestedWords.EMPTY, true /* dismissGestureFloatingPreviewText */);
}
+ // TODO: on the long term, this method should become private, but it will be difficult.
+ // Especially, how do we deal with InputMethodService.onDisplayCompletions?
+ public void setSuggestedWords(final SuggestedWords suggestedWords) {
+ mSuggestedWords = suggestedWords;
+ final boolean newAutoCorrectionIndicator = suggestedWords.mWillAutoCorrect;
+ // Put a blue underline to a word in TextView which will be auto-corrected.
+ if (mIsAutoCorrectionIndicatorOn != newAutoCorrectionIndicator
+ && mWordComposer.isComposingWord()) {
+ mIsAutoCorrectionIndicatorOn = newAutoCorrectionIndicator;
+ final CharSequence textWithUnderline =
+ getTextWithUnderline(mWordComposer.getTypedWord());
+ // TODO: when called from an updateSuggestionStrip() call that results from a posted
+ // message, this is called outside any batch edit. Potentially, this may result in some
+ // janky flickering of the screen, although the display speed makes it unlikely in
+ // the practice.
+ mConnection.setComposingText(textWithUnderline, 1);
+ }
+ }
+
/**
* Handle inputting a code point to the editor.
*
@@ -1101,7 +1120,7 @@ public final class InputLogic {
final SuggestedWords suggestedWords = holder.get(null,
Constants.GET_SUGGESTED_WORDS_TIMEOUT);
if (suggestedWords != null) {
- mLatinIME.showSuggestionStrip(suggestedWords);
+ mLatinIME.showSuggestionStrip(suggestedWords, suggestedWords.mTypedWord);
}
}
@@ -1603,8 +1622,10 @@ public final class InputLogic {
final int indexOfLastSpace = batchInputText.lastIndexOf(Constants.CODE_SPACE) + 1;
if (0 != indexOfLastSpace) {
mConnection.commitText(batchInputText.substring(0, indexOfLastSpace), 1);
- mLatinIME.showSuggestionStrip(
- suggestedWords.getSuggestedWordsForLastWordOfPhraseGesture());
+ final SuggestedWords suggestedWordsForLastWordOfPhraseGesture =
+ suggestedWords.getSuggestedWordsForLastWordOfPhraseGesture();
+ mLatinIME.showSuggestionStrip(suggestedWordsForLastWordOfPhraseGesture,
+ suggestedWordsForLastWordOfPhraseGesture.mTypedWord);
}
final String lastWord = batchInputText.substring(indexOfLastSpace);
mWordComposer.setBatchInputWord(lastWord);