aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-01-30 03:44:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-01-30 03:44:54 +0000
commite5040f6b0d4101c55c11d5e200dc2b203b7cbdc0 (patch)
treee6ce61955b96d5c7bc50732c83ba3468b4fd3da4 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parent26bd46095a05843e7574dfcf7db53406f215525d (diff)
parent1d2e4f9dccfba925dda75a1ded569c3b62f639ed (diff)
downloadlatinime-e5040f6b0d4101c55c11d5e200dc2b203b7cbdc0.tar.gz
latinime-e5040f6b0d4101c55c11d5e200dc2b203b7cbdc0.tar.xz
latinime-e5040f6b0d4101c55c11d5e200dc2b203b7cbdc0.zip
Merge "[IL103] Save the typed word separately in SuggestedWords."
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 982a97a5e..dbaf822e4 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -68,6 +68,21 @@ public final class SuggestedWords {
final boolean isObsoleteSuggestions,
final boolean isPrediction,
final int sequenceNumber) {
+ this(suggestedWordInfoList,
+ suggestedWordInfoList.isEmpty() ? null
+ : suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
+ typedWordValid, willAutoCorrect, isPunctuationSuggestions,
+ isObsoleteSuggestions, isPrediction, sequenceNumber);
+ }
+
+ public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
+ final String typedWord,
+ final boolean typedWordValid,
+ final boolean willAutoCorrect,
+ final boolean isPunctuationSuggestions,
+ final boolean isObsoleteSuggestions,
+ final boolean isPrediction,
+ final int sequenceNumber) {
mSuggestedWordInfoList = suggestedWordInfoList;
mTypedWordValid = typedWordValid;
mWillAutoCorrect = willAutoCorrect;
@@ -75,7 +90,7 @@ public final class SuggestedWords {
mIsObsoleteSuggestions = isObsoleteSuggestions;
mIsPrediction = isPrediction;
mSequenceNumber = sequenceNumber;
- mTypedWord = suggestedWordInfoList.isEmpty() ? null : getWord(INDEX_OF_TYPED_WORD);
+ mTypedWord = typedWord;
}
public boolean isEmpty() {
@@ -279,17 +294,21 @@ public final class SuggestedWords {
// 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();
+ String typedWord = null;
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
final SuggestedWordInfo info = mSuggestedWordInfoList.get(i);
if (SuggestedWordInfo.KIND_TYPED != info.mKind) {
newSuggestions.add(info);
+ } else {
+ assert(null == typedWord);
+ typedWord = info.mWord;
}
}
// 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 */,
+ return new SuggestedWords(newSuggestions, typedWord, true /* typedWordValid */,
false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions,
- mIsPrediction);
+ mIsPrediction, NOT_A_SEQUENCE_NUMBER);
}
// Creates a new SuggestedWordInfo from the currently suggested words that removes all but the