diff --git a/java/res/values/config.xml b/java/res/values/config.xml
index f2e76bd29..5b11e0711 100644
--- a/java/res/values/config.xml
+++ b/java/res/values/config.xml
@@ -75,6 +75,7 @@
false
+ true
200
100
800
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 03f7d1c10..c8c7bb456 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -139,6 +139,8 @@ public final class BinaryDictionary extends Dictionary {
inputSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
mUseFullEditDistance, mOutputCodePoints, mOutputScores, mSpaceIndices,
mOutputTypes);
+ final boolean blockPotentiallyOffensive =
+ Settings.getInstance().getBlockPotentiallyOffensive();
final ArrayList suggestions = CollectionUtils.newArrayList();
for (int j = 0; j < count; ++j) {
final int start = j * MAX_WORD_LENGTH;
@@ -148,10 +150,11 @@ public final class BinaryDictionary extends Dictionary {
}
if (len > 0) {
final int flags = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_FLAGS;
- if (0 != (flags & SuggestedWordInfo.KIND_FLAG_POSSIBLY_OFFENSIVE)
+ if (blockPotentiallyOffensive
+ && 0 != (flags & SuggestedWordInfo.KIND_FLAG_POSSIBLY_OFFENSIVE)
&& 0 == (flags & SuggestedWordInfo.KIND_FLAG_EXACT_MATCH)) {
- // If the word is possibly offensive, we don't output it unless it's also
- // an exact match.
+ // If we block potentially offensive words, and if the word is possibly
+ // offensive, then we don't output it unless it's also an exact match.
continue;
}
final int kind = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_KIND;
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 22ec01558..9fefb58a6 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -47,6 +47,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEY_USE_CONTACTS_DICT = "pref_key_use_contacts_dict";
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD =
"pref_key_use_double_space_period";
+ public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE =
+ "pref_key_block_potentially_offensive";
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
"pref_show_language_switch_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
@@ -144,6 +146,10 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return mCurrentLocale;
}
+ public boolean getBlockPotentiallyOffensive() {
+ return mSettingsValues.mBlockPotentiallyOffensive;
+ }
+
// Accessed from the settings interface, hence public
public static boolean readKeypressSoundEnabled(final SharedPreferences prefs,
final Resources res) {
@@ -165,6 +171,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
}
+ public static boolean readBlockPotentiallyOffensive(final SharedPreferences prefs,
+ final Resources res) {
+ return prefs.getBoolean(Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE,
+ res.getBoolean(R.bool.config_block_potentially_offensive));
+ }
+
public static boolean readFromBuildConfigIfGestureInputEnabled(final Resources res) {
return res.getBoolean(R.bool.config_gesture_input_enabled_by_build_config);
}
diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java
index 838863c71..615b2dfab 100644
--- a/java/src/com/android/inputmethod/latin/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/SettingsValues.java
@@ -57,6 +57,7 @@ public final class SettingsValues {
public final boolean mShowsLanguageSwitchKey;
public final boolean mUseContactsDict;
public final boolean mUseDoubleSpacePeriod;
+ public final boolean mBlockPotentiallyOffensive;
// Use bigrams to predict the next word when there is no input for it yet
public final boolean mBigramPredictionEnabled;
public final boolean mGestureInputEnabled;
@@ -126,6 +127,7 @@ public final class SettingsValues {
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs);
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true);
+ mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);