diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index edc4efd1a..f2ba7e0bb 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -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); diff --git a/java/src/com/android/inputmethod/latin/LatinImeLogger.java b/java/src/com/android/inputmethod/latin/LatinImeLogger.java index e3dadf250..5390ee39e 100644 --- a/java/src/com/android/inputmethod/latin/LatinImeLogger.java +++ b/java/src/com/android/inputmethod/latin/LatinImeLogger.java @@ -44,7 +44,7 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang } public static void logOnManualSuggestion( - String before, String after, int position, List suggestions) { + String before, String after, int position, SuggestedWords suggestedWords) { } public static void logOnAutoCorrection(String before, String after, int separatorCode) { diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java index ff8945f71..9383c89b1 100644 --- a/java/src/com/android/inputmethod/latin/SuggestedWords.java +++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java @@ -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 mWords; + private final List mWords; public final boolean mTypedWordValid; public final boolean mHasAutoCorrectionCandidate; public final boolean mIsPunctuationSuggestions; private final List mSuggestedWordInfoList; + // TODO: Make the following member final. private boolean mShouldBlockAutoCorrectionBySafetyNet; - private SuggestedWords(List words, boolean typedWordValid, + SuggestedWords(List words, boolean typedWordValid, boolean hasAutoCorrectionCandidate, boolean isPunctuationSuggestions, List 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()); } } diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java index e5638ef21..31c32bdce 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java @@ -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; }