am c03aaa1b: Merge "[ZF2] Read settings for profanity filtering."

* commit 'c03aaa1bde589f582daa83f1ecdc66ce8a4691b2':
  [ZF2] Read settings for profanity filtering.
main
Jean Chalard 2013-04-26 01:26:08 -07:00 committed by Android Git Automerger
commit 330072b014
4 changed files with 21 additions and 3 deletions

View File

@ -75,6 +75,7 @@
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
false -->
<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_preview_trail_fadeout_start_delay">100</integer>
<integer name="config_gesture_preview_trail_fadeout_duration">800</integer>

View File

@ -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<SuggestedWordInfo> 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;

View File

@ -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);
}

View File

@ -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);