am 490e6846: Merge "Add freq=0 words to user history depending on the option."

* commit '490e6846a144313e842c2cdcb257072e0e2b6980':
  Add freq=0 words to user history depending on the option.
main
Keisuke Kuroyanagi 2014-05-12 11:18:22 +00:00 committed by Android Git Automerger
commit 714d36e765
2 changed files with 7 additions and 5 deletions

View File

@ -370,7 +370,8 @@ public class DictionaryFacilitatorForSuggest {
} }
public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized, public void addToUserHistory(final String suggestion, final boolean wasAutoCapitalized,
final String previousWord, final int timeStampInSeconds) { final String previousWord, final int timeStampInSeconds,
final boolean blockPotentiallyOffensive) {
final Dictionaries dictionaries = mDictionaries; final Dictionaries dictionaries = mDictionaries;
final String[] words = suggestion.split(Constants.WORD_SEPARATOR); final String[] words = suggestion.split(Constants.WORD_SEPARATOR);
for (int i = 0; i < words.length; i++) { for (int i = 0; i < words.length; i++) {
@ -378,19 +379,20 @@ public class DictionaryFacilitatorForSuggest {
final String prevWord = (i == 0) ? previousWord : words[i - 1]; final String prevWord = (i == 0) ? previousWord : words[i - 1];
final boolean wasCurrentWordAutoCapitalized = (i == 0) ? wasAutoCapitalized : false; final boolean wasCurrentWordAutoCapitalized = (i == 0) ? wasAutoCapitalized : false;
addWordToUserHistory(dictionaries, prevWord, currentWord, addWordToUserHistory(dictionaries, prevWord, currentWord,
wasCurrentWordAutoCapitalized, timeStampInSeconds); wasCurrentWordAutoCapitalized, timeStampInSeconds, blockPotentiallyOffensive);
} }
} }
private void addWordToUserHistory(final Dictionaries dictionaries, final String prevWord, private void addWordToUserHistory(final Dictionaries dictionaries, final String prevWord,
final String word, final boolean wasAutoCapitalized, final int timeStampInSeconds) { final String word, final boolean wasAutoCapitalized, final int timeStampInSeconds,
final boolean blockPotentiallyOffensive) {
final ExpandableBinaryDictionary userHistoryDictionary = final ExpandableBinaryDictionary userHistoryDictionary =
dictionaries.getSubDict(Dictionary.TYPE_USER_HISTORY); dictionaries.getSubDict(Dictionary.TYPE_USER_HISTORY);
if (userHistoryDictionary == null) { if (userHistoryDictionary == null) {
return; return;
} }
final int maxFreq = getMaxFrequency(word); final int maxFreq = getMaxFrequency(word);
if (maxFreq == 0) { if (maxFreq == 0 && blockPotentiallyOffensive) {
return; return;
} }
final String lowerCasedWord = word.toLowerCase(dictionaries.mLocale); final String lowerCasedWord = word.toLowerCase(dictionaries.mLocale);

View File

@ -1241,7 +1241,7 @@ public final class InputLogic {
final int timeStampInSeconds = (int)TimeUnit.MILLISECONDS.toSeconds( final int timeStampInSeconds = (int)TimeUnit.MILLISECONDS.toSeconds(
System.currentTimeMillis()); System.currentTimeMillis());
mSuggest.mDictionaryFacilitator.addToUserHistory(suggestion, wasAutoCapitalized, prevWord, mSuggest.mDictionaryFacilitator.addToUserHistory(suggestion, wasAutoCapitalized, prevWord,
timeStampInSeconds); timeStampInSeconds, settingsValues.mBlockPotentiallyOffensive);
} }
public void performUpdateSuggestionStripSync(final SettingsValues settingsValues) { public void performUpdateSuggestionStripSync(final SettingsValues settingsValues) {