Merge "Remove the other deprecated constructor to SuggestedWords"

main
Jean Chalard 2014-11-19 08:30:02 +00:00 committed by Android (Google) Code Review
commit fde0cce103
6 changed files with 42 additions and 35 deletions

View File

@ -1171,9 +1171,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
SuggestedWords.getFromApplicationSpecifiedCompletions( SuggestedWords.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions); applicationSpecifiedCompletions);
final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords, final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords,
null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */, null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */); SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
// When in fullscreen mode, show completions generated by the application forcibly // When in fullscreen mode, show completions generated by the application forcibly
setSuggestedWords(suggestedWords); setSuggestedWords(suggestedWords);
} }

View File

@ -33,10 +33,12 @@ public final class PunctuationSuggestions extends SuggestedWords {
private PunctuationSuggestions(final ArrayList<SuggestedWordInfo> punctuationsList) { private PunctuationSuggestions(final ArrayList<SuggestedWordInfo> punctuationsList) {
super(punctuationsList, super(punctuationsList,
null /* rawSuggestions */, null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */, false /* typedWordValid */,
false /* hasAutoCorrectionCandidate */, false /* hasAutoCorrectionCandidate */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
INPUT_STYLE_NONE /* inputStyle */); INPUT_STYLE_NONE /* inputStyle */,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
} }
/** /**

View File

@ -50,8 +50,9 @@ public class SuggestedWords {
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0); private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
@Nonnull @Nonnull
private static final SuggestedWords EMPTY = new SuggestedWords( private static final SuggestedWords EMPTY = new SuggestedWords(
EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false /* typedWordValid */, EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, null /* typedWord */,
false /* willAutoCorrect */, false /* isObsoleteSuggestions */, INPUT_STYLE_NONE); false /* typedWordValid */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, INPUT_STYLE_NONE, NOT_A_SEQUENCE_NUMBER);
public final String mTypedWord; public final String mTypedWord;
public final boolean mTypedWordValid; public final boolean mTypedWordValid;
@ -67,19 +68,6 @@ public class SuggestedWords {
protected final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList; protected final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList;
public final ArrayList<SuggestedWordInfo> mRawSuggestions; public final ArrayList<SuggestedWordInfo> mRawSuggestions;
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
final ArrayList<SuggestedWordInfo> rawSuggestions,
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
final int inputStyle) {
this(suggestedWordInfoList, rawSuggestions,
(suggestedWordInfoList.isEmpty() || isPrediction(inputStyle)) ? null
: suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
typedWordValid, willAutoCorrect,
isObsoleteSuggestions, inputStyle, NOT_A_SEQUENCE_NUMBER);
}
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
final ArrayList<SuggestedWordInfo> rawSuggestions, final ArrayList<SuggestedWordInfo> rawSuggestions,
final String typedWord, final String typedWord,
@ -423,8 +411,10 @@ public class SuggestedWords {
info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX, info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX,
SuggestedWordInfo.NOT_A_CONFIDENCE)); SuggestedWordInfo.NOT_A_CONFIDENCE));
} }
return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid, return new SuggestedWords(newSuggestions, null /* rawSuggestions */,
mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH); newSuggestions.isEmpty() ? null : newSuggestions.get(0).mWord /* typedWord */,
mTypedWordValid, mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH,
NOT_A_SEQUENCE_NUMBER);
} }
/** /**

View File

@ -1884,8 +1884,9 @@ public final class InputLogic {
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions = final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords); SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */, return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */,
false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, typedWord, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */,
true /* isObsoleteSuggestions */, oldSuggestedWords.mInputStyle); true /* isObsoleteSuggestions */, oldSuggestedWords.mInputStyle,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
} }
/** /**

View File

@ -102,11 +102,11 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
} }
public void testGetTextWithSuggestionSpan() { public void testGetTextWithSuggestionSpan() {
final SuggestedWordInfo predicition1 = final SuggestedWordInfo prediction1 =
createWordInfo("Quality", SuggestedWordInfo.KIND_PREDICTION); createWordInfo("Quality", SuggestedWordInfo.KIND_PREDICTION);
final SuggestedWordInfo predicition2 = final SuggestedWordInfo prediction2 =
createWordInfo("Speed", SuggestedWordInfo.KIND_PREDICTION); createWordInfo("Speed", SuggestedWordInfo.KIND_PREDICTION);
final SuggestedWordInfo predicition3 = final SuggestedWordInfo prediction3 =
createWordInfo("Price", SuggestedWordInfo.KIND_PREDICTION); createWordInfo("Price", SuggestedWordInfo.KIND_PREDICTION);
final SuggestedWordInfo typed = final SuggestedWordInfo typed =
@ -122,13 +122,15 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
// is specified. // is specified.
{ {
final SuggestedWords predictedWords = new SuggestedWords( final SuggestedWords predictedWords = new SuggestedWords(
new ArrayList<>(Arrays.asList(predicition1, predicition2, predicition3)), new ArrayList<>(Arrays.asList(prediction1, prediction2, prediction3)),
null /* rawSuggestions */, null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */, false /* typedWordValid */,
false /* willAutoCorrect */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_PREDICTION); SuggestedWords.INPUT_STYLE_PREDICTION,
final String PICKED_WORD = predicition2.mWord; SuggestedWords.NOT_A_SEQUENCE_NUMBER);
final String PICKED_WORD = prediction2.mWord;
assertNotSuggestionSpan( assertNotSuggestionSpan(
PICKED_WORD, PICKED_WORD,
SuggestionSpanUtils.getTextWithSuggestionSpan(getContext(), PICKED_WORD, SuggestionSpanUtils.getTextWithSuggestionSpan(getContext(), PICKED_WORD,
@ -137,17 +139,19 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
final ArrayList<SuggestedWordInfo> suggestedWordList = new ArrayList<>(); final ArrayList<SuggestedWordInfo> suggestedWordList = new ArrayList<>();
suggestedWordList.add(typed); suggestedWordList.add(typed);
suggestedWordList.add(predicition1); suggestedWordList.add(prediction1);
suggestedWordList.add(predicition2); suggestedWordList.add(prediction2);
suggestedWordList.add(predicition3); suggestedWordList.add(prediction3);
suggestedWordList.addAll(Arrays.asList(corrections)); suggestedWordList.addAll(Arrays.asList(corrections));
final SuggestedWords typedAndCollectedWords = new SuggestedWords( final SuggestedWords typedAndCollectedWords = new SuggestedWords(
suggestedWordList, suggestedWordList,
null /* rawSuggestions */, null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */, false /* typedWordValid */,
false /* willAutoCorrect */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_TYPING); SuggestedWords.INPUT_STYLE_TYPING,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
for (final SuggestedWordInfo pickedWord : suggestedWordList) { for (final SuggestedWordInfo pickedWord : suggestedWordList) {
final String PICKED_WORD = pickedWord.mWord; final String PICKED_WORD = pickedWord.mWord;

View File

@ -99,10 +99,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
// Make sure getTypedWordInfoOrNull() returns non-null object. // Make sure getTypedWordInfoOrNull() returns non-null object.
final SuggestedWords wordsWithTypedWord = new SuggestedWords( final SuggestedWords wordsWithTypedWord = new SuggestedWords(
list, null /* rawSuggestions */, list, null /* rawSuggestions */,
TYPED_WORD,
false /* typedWordValid */, false /* typedWordValid */,
false /* willAutoCorrect */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_NONE); SuggestedWords.INPUT_STYLE_NONE,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull(); final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull();
assertNotNull(typedWord); assertNotNull(typedWord);
assertEquals(TYPED_WORD, typedWord.mWord); assertEquals(TYPED_WORD, typedWord.mWord);
@ -111,10 +113,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
list.remove(0); list.remove(0);
final SuggestedWords wordsWithoutTypedWord = new SuggestedWords( final SuggestedWords wordsWithoutTypedWord = new SuggestedWords(
list, null /* rawSuggestions */, list, null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */, false /* typedWordValid */,
false /* willAutoCorrect */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_NONE); SuggestedWords.INPUT_STYLE_NONE,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull()); assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
// Make sure getTypedWordInfoOrNull() returns null. // Make sure getTypedWordInfoOrNull() returns null.
@ -122,10 +126,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
final SuggestedWords emptySuggestedWords = new SuggestedWords( final SuggestedWords emptySuggestedWords = new SuggestedWords(
new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */, new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */,
null /* typedWord */,
false /* typedWordValid */, false /* typedWordValid */,
false /* willAutoCorrect */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
SuggestedWords.INPUT_STYLE_NONE); SuggestedWords.INPUT_STYLE_NONE,
SuggestedWords.NOT_A_SEQUENCE_NUMBER);
assertNull(emptySuggestedWords.getTypedWordInfoOrNull()); assertNull(emptySuggestedWords.getTypedWordInfoOrNull());
assertNull(SuggestedWords.getEmptyInstance().getTypedWordInfoOrNull()); assertNull(SuggestedWords.getEmptyInstance().getTypedWordInfoOrNull());