am bab1f045: Straighten out members extracted from resources.
* commit 'bab1f045f4856e987f9d8b7b952f3765303528a7': Straighten out members extracted from resources.main
commit
5b9a2a828b
|
@ -34,12 +34,12 @@ public class SettingsValues {
|
||||||
|
|
||||||
// From resources:
|
// From resources:
|
||||||
public final int mDelayUpdateOldSuggestions;
|
public final int mDelayUpdateOldSuggestions;
|
||||||
public final String mWordSeparators;
|
|
||||||
public final String mMagicSpaceStrippers;
|
public final String mMagicSpaceStrippers;
|
||||||
public final String mMagicSpaceSwappers;
|
public final String mMagicSpaceSwappers;
|
||||||
public final String mSuggestPuncs;
|
public final String mSuggestPuncs;
|
||||||
public final SuggestedWords mSuggestPuncList;
|
public final SuggestedWords mSuggestPuncList;
|
||||||
private final String mSymbolsExcludedFromWordSeparators;
|
private final String mSymbolsExcludedFromWordSeparators;
|
||||||
|
public final String mWordSeparators;
|
||||||
public final CharSequence mHintToSaveText;
|
public final CharSequence mHintToSaveText;
|
||||||
|
|
||||||
// From preferences, in the same order as xml/prefs.xml:
|
// From preferences, in the same order as xml/prefs.xml:
|
||||||
|
@ -83,23 +83,16 @@ public class SettingsValues {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the resources
|
// Get the resources
|
||||||
mDelayUpdateOldSuggestions = res.getInteger(
|
mDelayUpdateOldSuggestions = res.getInteger(R.integer.config_delay_update_old_suggestions);
|
||||||
R.integer.config_delay_update_old_suggestions);
|
|
||||||
mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols);
|
mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols);
|
||||||
mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols);
|
mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols);
|
||||||
String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers
|
|
||||||
+ res.getString(R.string.magic_space_promoting_symbols);
|
|
||||||
final String symbolsExcludedFromWordSeparators =
|
|
||||||
res.getString(R.string.symbols_excluded_from_word_separators);
|
|
||||||
for (int i = symbolsExcludedFromWordSeparators.length() - 1; i >= 0; --i) {
|
|
||||||
wordSeparators = wordSeparators.replace(
|
|
||||||
symbolsExcludedFromWordSeparators.substring(i, i + 1), "");
|
|
||||||
}
|
|
||||||
mSymbolsExcludedFromWordSeparators = symbolsExcludedFromWordSeparators;
|
|
||||||
mWordSeparators = wordSeparators;
|
|
||||||
mSuggestPuncs = res.getString(R.string.suggested_punctuations);
|
mSuggestPuncs = res.getString(R.string.suggested_punctuations);
|
||||||
// TODO: it would be nice not to recreate this each time we change the configuration
|
// TODO: it would be nice not to recreate this each time we change the configuration
|
||||||
mSuggestPuncList = createSuggestPuncList(mSuggestPuncs);
|
mSuggestPuncList = createSuggestPuncList(mSuggestPuncs);
|
||||||
|
mSymbolsExcludedFromWordSeparators =
|
||||||
|
res.getString(R.string.symbols_excluded_from_word_separators);
|
||||||
|
mWordSeparators = createWordSeparators(mMagicSpaceStrippers, mMagicSpaceSwappers,
|
||||||
|
mSymbolsExcludedFromWordSeparators, res);
|
||||||
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
||||||
|
|
||||||
// Get the settings preferences
|
// Get the settings preferences
|
||||||
|
@ -137,6 +130,29 @@ public class SettingsValues {
|
||||||
LocaleUtils.setSystemLocale(res, savedLocale);
|
LocaleUtils.setSystemLocale(res, savedLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper functions to create member values.
|
||||||
|
private static SuggestedWords createSuggestPuncList(final String puncs) {
|
||||||
|
SuggestedWords.Builder builder = new SuggestedWords.Builder();
|
||||||
|
if (puncs != null) {
|
||||||
|
for (int i = 0; i < puncs.length(); i++) {
|
||||||
|
builder.addWord(puncs.subSequence(i, i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.setIsPunctuationSuggestions().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String createWordSeparators(final String magicSpaceStrippers,
|
||||||
|
final String magicSpaceSwappers, final String symbolsExcludedFromWordSeparators,
|
||||||
|
final Resources res) {
|
||||||
|
String wordSeparators = magicSpaceStrippers + magicSpaceSwappers
|
||||||
|
+ res.getString(R.string.magic_space_promoting_symbols);
|
||||||
|
for (int i = symbolsExcludedFromWordSeparators.length() - 1; i >= 0; --i) {
|
||||||
|
wordSeparators = wordSeparators.replace(
|
||||||
|
symbolsExcludedFromWordSeparators.substring(i, i + 1), "");
|
||||||
|
}
|
||||||
|
return wordSeparators;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSuggestedPunctuation(int code) {
|
public boolean isSuggestedPunctuation(int code) {
|
||||||
return mSuggestPuncs.contains(String.valueOf((char)code));
|
return mSuggestPuncs.contains(String.valueOf((char)code));
|
||||||
}
|
}
|
||||||
|
@ -226,16 +242,6 @@ public class SettingsValues {
|
||||||
return autoCorrectionThreshold;
|
return autoCorrectionThreshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SuggestedWords createSuggestPuncList(final String puncs) {
|
|
||||||
SuggestedWords.Builder builder = new SuggestedWords.Builder();
|
|
||||||
if (puncs != null) {
|
|
||||||
for (int i = 0; i < puncs.length(); i++) {
|
|
||||||
builder.addWord(puncs.subSequence(i, i + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.setIsPunctuationSuggestions().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isShowSettingsKeyOption(final Resources resources) {
|
public static boolean isShowSettingsKeyOption(final Resources resources) {
|
||||||
return resources.getBoolean(R.bool.config_enable_show_settings_key_option);
|
return resources.getBoolean(R.bool.config_enable_show_settings_key_option);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue