diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java index a8349023a..369773428 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java @@ -366,7 +366,8 @@ public class DictionaryFacilitatorForSuggest { } 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 String[] words = suggestion.split(Constants.WORD_SEPARATOR); for (int i = 0; i < words.length; i++) { @@ -374,19 +375,20 @@ public class DictionaryFacilitatorForSuggest { final String prevWord = (i == 0) ? previousWord : words[i - 1]; final boolean wasCurrentWordAutoCapitalized = (i == 0) ? wasAutoCapitalized : false; addWordToUserHistory(dictionaries, prevWord, currentWord, - wasCurrentWordAutoCapitalized, timeStampInSeconds); + wasCurrentWordAutoCapitalized, timeStampInSeconds, blockPotentiallyOffensive); } } 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 = dictionaries.getSubDict(Dictionary.TYPE_USER_HISTORY); if (userHistoryDictionary == null) { return; } final int maxFreq = getMaxFrequency(word); - if (maxFreq == 0) { + if (maxFreq == 0 && blockPotentiallyOffensive) { return; } final String lowerCasedWord = word.toLowerCase(dictionaries.mLocale); diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index 127db8dd9..906259ff4 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -1225,7 +1225,7 @@ public final class InputLogic { final int timeStampInSeconds = (int)TimeUnit.MILLISECONDS.toSeconds( System.currentTimeMillis()); mSuggest.mDictionaryFacilitator.addToUserHistory(suggestion, wasAutoCapitalized, prevWord, - timeStampInSeconds); + timeStampInSeconds, settingsValues.mBlockPotentiallyOffensive); } public void performUpdateSuggestionStripSync(final SettingsValues settingsValues) {