aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-04-10 18:30:11 +0900
committerJean Chalard <jchalard@google.com>2013-04-15 19:33:23 +0900
commit0e9ee4d3bf75459560670ca5c28ff4c4f7c346fb (patch)
tree34a080015b3e3df7df78c809b7f957aeb0244ca3 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parent059e084e983ce4a1440dc065f5167d278d8939e7 (diff)
downloadlatinime-0e9ee4d3bf75459560670ca5c28ff4c4f7c346fb.tar.gz
latinime-0e9ee4d3bf75459560670ca5c28ff4c4f7c346fb.tar.xz
latinime-0e9ee4d3bf75459560670ca5c28ff4c4f7c346fb.zip
If there are no suggestion span, recompute suggestions.
Bug: 8084810 Change-Id: I1743c09c43ca6835bb2f607684b037bf17d36335
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 158cc1155..616e1911b 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -195,4 +195,21 @@ public final class SuggestedWords {
}
}
}
+
+ // SuggestedWords is an immutable object, as much as possible. We must not just remove
+ // words from the member ArrayList as some other parties may expect the object to never change.
+ public SuggestedWords getSuggestedWordsExcludingTypedWord() {
+ final ArrayList<SuggestedWordInfo> newSuggestions = CollectionUtils.newArrayList();
+ for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
+ final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
+ if (SuggestedWordInfo.KIND_TYPED != info.mKind) {
+ newSuggestions.add(info);
+ }
+ }
+ // We should never autocorrect, so we say the typed word is valid. Also, in this case,
+ // no auto-correction should take place hence willAutoCorrect = false.
+ return new SuggestedWords(newSuggestions, true /* typedWordValid */,
+ false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions,
+ mIsPrediction);
+ }
}