aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-03-05 16:56:58 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-03-05 22:11:13 +0900
commit8cc8f26adfe0f06cebc697dac43a856326cf7afc (patch)
treee9b325af864e558e49a7fca9ea7c358137fe6d63 /java/src
parentd5b6360549c1e97958a2ec25e5c20ab4d8b455b1 (diff)
downloadlatinime-8cc8f26adfe0f06cebc697dac43a856326cf7afc.tar.gz
latinime-8cc8f26adfe0f06cebc697dac43a856326cf7afc.tar.xz
latinime-8cc8f26adfe0f06cebc697dac43a856326cf7afc.zip
Make SuggestedWords partially immutable
Change-Id: I72a2f71d7f6565a30c06e563b0a64f496542cde9
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java9
-rw-r--r--java/src/com/android/inputmethod/latin/LatinImeLogger.java2
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java27
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionsView.java2
4 files changed, 17 insertions, 23 deletions
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<CharSequence> 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<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());
}
}
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;
}