From 0142b997bf18f5d07e83b3fd403f0b3ea4736040 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 14 May 2012 14:42:40 +0900 Subject: [PATCH] Do not set "SuggestionSpan"s for suggestions from the next word predicition Bug: 6294817 Change-Id: I5010eafa5ba7e947743706adf7e722f4f0cfb415 --- .../inputmethod/compat/SuggestionSpanUtils.java | 1 + java/src/com/android/inputmethod/latin/LatinIME.java | 6 ++++-- .../com/android/inputmethod/latin/SettingsValues.java | 3 ++- java/src/com/android/inputmethod/latin/Suggest.java | 10 +++++----- .../com/android/inputmethod/latin/SuggestedWords.java | 7 +++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java index 25afef1e6..a0f48d24c 100644 --- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java +++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java @@ -108,6 +108,7 @@ public class SuggestionSpanUtils { if (!dictionaryAvailable || TextUtils.isEmpty(pickedWord) || CONSTRUCTOR_SuggestionSpan == null || suggestedWords == null || suggestedWords.size() == 0 + || suggestedWords.mIsPrediction || suggestedWords.mIsPunctuationSuggestions || OBJ_SUGGESTIONS_MAX_SIZE == null) { return pickedWord; } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 011b512e8..fb119da02 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -877,7 +877,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen false /* hasAutoCorrectionCandidate */, false /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, - false /* isObsoleteSuggestions */); + false /* isObsoleteSuggestions */, + false /* isPrediction */); // When in fullscreen mode, show completions generated by the application final boolean isAutoCorrection = false; setSuggestions(suggestedWords, isAutoCorrection); @@ -1772,7 +1773,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen false /* hasAutoCorrectionCandidate */, false /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, - true /* isObsoleteSuggestions */); + true /* isObsoleteSuggestions */, + false /* isPrediction */); showSuggestions(obsoleteSuggestedWords, typedWord); } } diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 5f9e1bc76..55b896f5a 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -166,7 +166,8 @@ public class SettingsValues { false /* hasAutoCorrectionCandidate */, false /* allowsToBeAutoCorrected */, true /* isPunctuationSuggestions */, - false /* isObsoleteSuggestions */); + false /* isObsoleteSuggestions */, + false /* isPrediction */); } private static String createWordSeparators(final String weakSpaceStrippers, diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 112bde6a3..845df81f6 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -253,13 +253,12 @@ public class Suggest implements Dictionary.WordCallback { SuggestedWordInfo.removeDups(mSuggestions); return new SuggestedWords(mSuggestions, - // TODO: Just assuming the suggestions that came from the bigram prediction are - // valid now. Need to assign a correct value for typedWordValid. - true /* typedWordValid */, + false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, false /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, - false /* isObsoleteSuggestions */); + false /* isObsoleteSuggestions */, + true /* isPrediction */); } // TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder @@ -396,7 +395,8 @@ public class Suggest implements Dictionary.WordCallback { autoCorrectionAvailable /* hasAutoCorrectionCandidate */, allowsToBeAutoCorrected /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, - false /* isObsoleteSuggestions */); + false /* isObsoleteSuggestions */, + false /* isPrediction */); } /** diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index 91110d888..497fd3bfa 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -25,13 +25,14 @@ import java.util.HashSet; public class SuggestedWords { public static final SuggestedWords EMPTY = new SuggestedWords( - new ArrayList(0), false, false, false, false, false); + new ArrayList(0), false, false, false, false, false, false); public final boolean mTypedWordValid; public final boolean mHasAutoCorrectionCandidate; public final boolean mIsPunctuationSuggestions; public final boolean mAllowsToBeAutoCorrected; public final boolean mIsObsoleteSuggestions; + public final boolean mIsPrediction; private final ArrayList mSuggestedWordInfoList; public SuggestedWords(final ArrayList suggestedWordInfoList, @@ -39,13 +40,15 @@ public class SuggestedWords { final boolean hasAutoCorrectionCandidate, final boolean allowsToBeAutoCorrected, final boolean isPunctuationSuggestions, - final boolean isObsoleteSuggestions) { + final boolean isObsoleteSuggestions, + final boolean isPrediction) { mSuggestedWordInfoList = suggestedWordInfoList; mTypedWordValid = typedWordValid; mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate; mAllowsToBeAutoCorrected = allowsToBeAutoCorrected; mIsPunctuationSuggestions = isPunctuationSuggestions; mIsObsoleteSuggestions = isObsoleteSuggestions; + mIsPrediction = isPrediction; } public int size() {