Merge "Make SuggestedWords partially immutable"
commit
40b6e666e1
|
@ -1829,7 +1829,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
final SuggestedWords suggestedWords = builder.build();
|
||||
if (Utils.shouldBlockAutoCorrectionBySafetyNet(suggestedWords, mSuggest)) {
|
||||
suggestedWords.setShouldBlockAutoCorrectionBySatefyNet();
|
||||
suggestedWords.setShouldBlockAutoCorrectionBySafetyNet();
|
||||
}
|
||||
showSuggestions(builder.build(), typedWord);
|
||||
}
|
||||
|
@ -1886,7 +1886,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
@Override
|
||||
public void pickSuggestionManually(final int index, final CharSequence suggestion) {
|
||||
mComposingStateManager.onFinishComposingText();
|
||||
final SuggestedWords suggestions = mSuggestionsView.getSuggestions();
|
||||
final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();
|
||||
mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion,
|
||||
mSettingsValues.mWordSeparators);
|
||||
|
||||
|
@ -1910,8 +1910,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
if (suggestion.length() == 1 && isShowingPunctuationList()) {
|
||||
// Word separators are suggested before the user inputs something.
|
||||
// So, LatinImeLogger logs "" as a user's input.
|
||||
LatinImeLogger.logOnManualSuggestion(
|
||||
"", suggestion.toString(), index, suggestions.mWords);
|
||||
LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords);
|
||||
// Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
|
||||
final int primaryCode = suggestion.charAt(0);
|
||||
onCodeInput(primaryCode, new int[] { primaryCode },
|
||||
|
@ -1922,7 +1921,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
// We need to log before we commit, because the word composer will store away the user
|
||||
// typed word.
|
||||
LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(),
|
||||
suggestion.toString(), index, suggestions.mWords);
|
||||
suggestion.toString(), index, suggestedWords);
|
||||
mExpectingUpdateSelection = true;
|
||||
commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK,
|
||||
LastComposedWord.NOT_A_SEPARATOR);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
|
||||
public static void logOnManualSuggestion(
|
||||
String before, String after, int position, List<CharSequence> suggestions) {
|
||||
String before, String after, int position, SuggestedWords suggestedWords) {
|
||||
}
|
||||
|
||||
public static void logOnAutoCorrection(String before, String after, int separatorCode) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.text.TextUtils;
|
|||
import android.view.inputmethod.CompletionInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -27,14 +28,15 @@ import java.util.List;
|
|||
public class SuggestedWords {
|
||||
public static final SuggestedWords EMPTY = new SuggestedWords(null, false, false, false, null);
|
||||
|
||||
public final List<CharSequence> mWords;
|
||||
private final List<CharSequence> mWords;
|
||||
public final boolean mTypedWordValid;
|
||||
public final boolean mHasAutoCorrectionCandidate;
|
||||
public final boolean mIsPunctuationSuggestions;
|
||||
private final List<SuggestedWordInfo> mSuggestedWordInfoList;
|
||||
// TODO: Make the following member final.
|
||||
private boolean mShouldBlockAutoCorrectionBySafetyNet;
|
||||
|
||||
private SuggestedWords(List<CharSequence> words, boolean typedWordValid,
|
||||
SuggestedWords(List<CharSequence> words, boolean typedWordValid,
|
||||
boolean hasAutoCorrectionCandidate, boolean isPunctuationSuggestions,
|
||||
List<SuggestedWordInfo> suggestedWordInfoList) {
|
||||
if (words != null) {
|
||||
|
@ -65,11 +67,8 @@ public class SuggestedWords {
|
|||
return mHasAutoCorrectionCandidate && size() > 1 && !mTypedWordValid;
|
||||
}
|
||||
|
||||
public boolean isPunctuationSuggestions() {
|
||||
return mIsPunctuationSuggestions;
|
||||
}
|
||||
|
||||
public void setShouldBlockAutoCorrectionBySatefyNet() {
|
||||
// TODO: Remove this method.
|
||||
public void setShouldBlockAutoCorrectionBySafetyNet() {
|
||||
mShouldBlockAutoCorrectionBySafetyNet = true;
|
||||
}
|
||||
|
||||
|
@ -190,15 +189,11 @@ public class SuggestedWords {
|
|||
@Override
|
||||
public String toString() {
|
||||
// Pretty-print method to help debug
|
||||
final StringBuilder sb = new StringBuilder("StringBuilder: mTypedWordValid = "
|
||||
+ mTypedWordValid + " ; mHasMinimalSuggestion = " + mHasMinimalSuggestion
|
||||
+ " ; mIsPunctuationSuggestions = " + mIsPunctuationSuggestions
|
||||
+ " --- ");
|
||||
for (CharSequence s : mWords) {
|
||||
sb.append(s);
|
||||
sb.append(" ; ");
|
||||
}
|
||||
return sb.toString();
|
||||
return "SuggestedWords.Builder:"
|
||||
+ " mTypedWordValid = " + mTypedWordValid
|
||||
+ " mHasMinimalSuggestion = " + mHasMinimalSuggestion
|
||||
+ " mIsPunctuationSuggestions = " + mIsPunctuationSuggestions
|
||||
+ " mWords=" + Arrays.toString(mWords.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
|
|||
|
||||
public void layout(SuggestedWords suggestions, ViewGroup stripView, ViewGroup placer,
|
||||
int stripWidth) {
|
||||
if (suggestions.isPunctuationSuggestions()) {
|
||||
if (suggestions.mIsPunctuationSuggestions) {
|
||||
layoutPunctuationSuggestions(suggestions, stripView);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue