[ZF2] Read settings for profanity filtering.
Bug: 7226877 Change-Id: Ie0c713e1eba1529c0b288a1e5011023a79bedd6b
This commit is contained in:
parent
99e998286d
commit
bb61293675
4 changed files with 21 additions and 3 deletions
|
@ -75,6 +75,7 @@
|
||||||
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
|
||||||
false -->
|
false -->
|
||||||
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
<bool name="config_show_more_keys_keyboard_at_touched_point">false</bool>
|
||||||
|
<bool name="config_block_potentially_offensive">true</bool>
|
||||||
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer>
|
<integer name="config_gesture_floating_preview_text_linger_timeout">200</integer>
|
||||||
<integer name="config_gesture_preview_trail_fadeout_start_delay">100</integer>
|
<integer name="config_gesture_preview_trail_fadeout_start_delay">100</integer>
|
||||||
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer>
|
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer>
|
||||||
|
|
|
@ -139,6 +139,8 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
inputSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
|
inputSize, 0 /* commitPoint */, isGesture, prevWordCodePointArray,
|
||||||
mUseFullEditDistance, mOutputCodePoints, mOutputScores, mSpaceIndices,
|
mUseFullEditDistance, mOutputCodePoints, mOutputScores, mSpaceIndices,
|
||||||
mOutputTypes);
|
mOutputTypes);
|
||||||
|
final boolean blockPotentiallyOffensive =
|
||||||
|
Settings.getInstance().getBlockPotentiallyOffensive();
|
||||||
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
|
final ArrayList<SuggestedWordInfo> suggestions = CollectionUtils.newArrayList();
|
||||||
for (int j = 0; j < count; ++j) {
|
for (int j = 0; j < count; ++j) {
|
||||||
final int start = j * MAX_WORD_LENGTH;
|
final int start = j * MAX_WORD_LENGTH;
|
||||||
|
@ -148,10 +150,11 @@ public final class BinaryDictionary extends Dictionary {
|
||||||
}
|
}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
final int flags = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_FLAGS;
|
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)) {
|
&& 0 == (flags & SuggestedWordInfo.KIND_FLAG_EXACT_MATCH)) {
|
||||||
// If the word is possibly offensive, we don't output it unless it's also
|
// If we block potentially offensive words, and if the word is possibly
|
||||||
// an exact match.
|
// offensive, then we don't output it unless it's also an exact match.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int kind = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_KIND;
|
final int kind = mOutputTypes[j] & SuggestedWordInfo.KIND_MASK_KIND;
|
||||||
|
|
|
@ -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_CONTACTS_DICT = "pref_key_use_contacts_dict";
|
||||||
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD =
|
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD =
|
||||||
"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 =
|
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
|
||||||
"pref_show_language_switch_key";
|
"pref_show_language_switch_key";
|
||||||
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
|
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;
|
return mCurrentLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getBlockPotentiallyOffensive() {
|
||||||
|
return mSettingsValues.mBlockPotentiallyOffensive;
|
||||||
|
}
|
||||||
|
|
||||||
// Accessed from the settings interface, hence public
|
// Accessed from the settings interface, hence public
|
||||||
public static boolean readKeypressSoundEnabled(final SharedPreferences prefs,
|
public static boolean readKeypressSoundEnabled(final SharedPreferences prefs,
|
||||||
final Resources res) {
|
final Resources res) {
|
||||||
|
@ -165,6 +171,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
||||||
return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
|
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) {
|
public static boolean readFromBuildConfigIfGestureInputEnabled(final Resources res) {
|
||||||
return res.getBoolean(R.bool.config_gesture_input_enabled_by_build_config);
|
return res.getBoolean(R.bool.config_gesture_input_enabled_by_build_config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public final class SettingsValues {
|
||||||
public final boolean mShowsLanguageSwitchKey;
|
public final boolean mShowsLanguageSwitchKey;
|
||||||
public final boolean mUseContactsDict;
|
public final boolean mUseContactsDict;
|
||||||
public final boolean mUseDoubleSpacePeriod;
|
public final boolean mUseDoubleSpacePeriod;
|
||||||
|
public final boolean mBlockPotentiallyOffensive;
|
||||||
// Use bigrams to predict the next word when there is no input for it yet
|
// Use bigrams to predict the next word when there is no input for it yet
|
||||||
public final boolean mBigramPredictionEnabled;
|
public final boolean mBigramPredictionEnabled;
|
||||||
public final boolean mGestureInputEnabled;
|
public final boolean mGestureInputEnabled;
|
||||||
|
@ -126,6 +127,7 @@ public final class SettingsValues {
|
||||||
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs);
|
mShowsLanguageSwitchKey = Settings.readShowsLanguageSwitchKey(prefs);
|
||||||
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
|
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
|
||||||
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true);
|
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true);
|
||||||
|
mBlockPotentiallyOffensive = Settings.readBlockPotentiallyOffensive(prefs, res);
|
||||||
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
|
mAutoCorrectEnabled = Settings.readAutoCorrectEnabled(autoCorrectionThresholdRawValue, res);
|
||||||
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
|
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue