aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-04-15 04:24:01 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-04-15 04:24:01 -0700
commit34676d92cc08c5575995a36cef1df9c50c1facca (patch)
treeb05b41da96876e5f3d685c13ca0de4001ea3c57d /java/src/com/android/inputmethod/latin/SuggestedWords.java
parentd55ccbf7f95bb1af2d0b4a60994fb05af502e325 (diff)
parenta022c53882642d1669e229f4f1b8d649c09447f7 (diff)
downloadlatinime-34676d92cc08c5575995a36cef1df9c50c1facca.tar.gz
latinime-34676d92cc08c5575995a36cef1df9c50c1facca.tar.xz
latinime-34676d92cc08c5575995a36cef1df9c50c1facca.zip
am a022c538: Merge "If there are no suggestion span, recompute suggestions."
* commit 'a022c53882642d1669e229f4f1b8d649c09447f7': If there are no suggestion span, recompute suggestions.
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);
+ }
}