am be147f1f: Remove DictionaryFacilitatorForSuggest.getMainDictionary().

* commit 'be147f1fdcfb5d192f64eb97e508b43da1fd9509':
  Remove DictionaryFacilitatorForSuggest.getMainDictionary().
main
Keisuke Kuroyanagi 2013-12-26 03:59:06 -08:00 committed by Android Git Automerger
commit 9a25b2374d
3 changed files with 20 additions and 30 deletions

View File

@ -125,10 +125,6 @@ public class DictionaryFacilitatorForSuggest {
return mIsCurrentlyWaitingForMainDictionary;
}
public Dictionary getMainDictionary() {
return mMainDictionary;
}
private void setMainDictionary(final Dictionary mainDictionary) {
mMainDictionary = mainDictionary;
addOrReplaceDictionary(Dictionary.TYPE_MAIN, mainDictionary);
@ -319,6 +315,13 @@ public class DictionaryFacilitatorForSuggest {
}
}
public boolean isValidMainDictWord(final String word) {
if (TextUtils.isEmpty(word) || !hasMainDictionary()) {
return false;
}
return mMainDictionary.isValidWord(word);
}
public boolean isValidWord(final String word, final boolean ignoreCase) {
if (TextUtils.isEmpty(word)) {
return false;

View File

@ -99,14 +99,14 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
mDictionaryForTesting = dictionary;
}
private Dictionary getDictionary() {
private boolean isValidDictWord(final String word) {
if (mDictionaryForTesting != null) {
return mDictionaryForTesting;
return mDictionaryForTesting.isValidWord(word);
}
if (mDictionaryFacilitator == null || !mDictionaryFacilitator.hasMainDictionary()) {
return null;
if (mDictionaryFacilitator != null) {
return mDictionaryFacilitator.isValidMainDictWord(word);
}
return mDictionaryFacilitator.getMainDictionary();
return false;
}
public void setIsStopping() {
@ -155,8 +155,8 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
}
// Reload the dictionary in case it has changed (e.g., because the user has changed
// languages).
final Dictionary dictionary = getDictionary();
if (dictionary == null) {
if ((mDictionaryFacilitator == null || !mDictionaryFacilitator.hasMainDictionary())
&& mDictionaryForTesting == null) {
// Main dictionary is unavailable. Since we cannot check it, we cannot tell if a
// word is out-of-vocabulary or not. Therefore, we must judge the entire buffer
// contents to potentially pose a privacy risk.
@ -166,7 +166,6 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
// Check each word in the buffer. If any word poses a privacy threat, we cannot upload
// the complete buffer contents in detail.
int numWordsInLogUnitList = 0;
final int length = logUnits.size();
for (final LogUnit logUnit : logUnits) {
if (!logUnit.hasOneOrMoreWords()) {
// Digits outside words are a privacy threat.
@ -178,11 +177,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
final String[] words = logUnit.getWordsAsStringArray();
for (final String word : words) {
// Words not in the dictionary are a privacy threat.
if (ResearchLogger.hasLetters(word) && !(dictionary.isValidWord(word))) {
if (ResearchLogger.hasLetters(word) && !isValidDictWord(word)) {
if (DEBUG) {
Log.d(TAG, "\"" + word + "\" NOT SAFE!: hasLetters: "
+ ResearchLogger.hasLetters(word)
+ ", isValid: " + (dictionary.isValidWord(word)));
+ ", isValid: " + isValidDictWord(word));
}
return PUBLISHABILITY_UNPUBLISHABLE_NOT_IN_DICTIONARY;
}

View File

@ -52,7 +52,6 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.MainKeyboardView;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.Dictionary;
import com.android.inputmethod.latin.DictionaryFacilitatorForSuggest;
import com.android.inputmethod.latin.LatinIME;
import com.android.inputmethod.latin.R;
@ -254,10 +253,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
+ ", cipd: " + canIncludePrivateData);
}
for (final String word : logUnit.getWordsAsStringArray()) {
final Dictionary dictionary = getDictionary();
final boolean isDictionaryWord = mDictionaryFacilitator != null
&& mDictionaryFacilitator.isValidMainDictWord(word);
mStatistics.recordWordEntered(
dictionary != null && dictionary.isValidWord(word),
logUnit.containsUserDeletions());
isDictionaryWord, logUnit.containsUserDeletions());
}
}
publishLogUnits(logUnits, mMainResearchLog, canIncludePrivateData);
@ -664,13 +663,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
}
private Dictionary getDictionary() {
if (mDictionaryFacilitator == null) {
return null;
}
return mDictionaryFacilitator.getMainDictionary();
}
private void setIsPasswordView(boolean isPasswordView) {
mIsPasswordView = isPasswordView;
}
@ -964,11 +956,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
}
private String scrubWord(String word) {
final Dictionary dictionary = getDictionary();
if (dictionary == null) {
return WORD_REPLACEMENT_STRING;
}
if (dictionary.isValidWord(word)) {
if (mDictionaryFacilitator != null && mDictionaryFacilitator.isValidMainDictWord(word)) {
return word;
}
return WORD_REPLACEMENT_STRING;