Use string-array resource to define predefined-subtypes

Bug: 6809603
Change-Id: Icafe4652ec17844838b28c04977deb88bcb9aa8f
main
Tadashi G. Takaoka 2012-09-04 16:54:01 +09:00
parent 147a62a8a8
commit 848331222e
4 changed files with 126 additions and 102 deletions

View File

@ -18,6 +18,9 @@
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Predefined subtypes (language:layout[:extraValue]) in semicolon separated format -->
<string name="predefined_subtypes" translatable="false">de:qwerty:AsciiCapable;fr:qwertz:AsciiCapable</string>
<!-- Predefined subtypes (language:layout[:extraValue]) -->
<string-array name="predefined_subtypes" translatable="false">
<item>de:qwerty:AsciiCapable</item>
<item>fr:qwertz:AsciiCapable</item>
</string-array>
</resources>

View File

@ -27,22 +27,22 @@ import android.view.inputmethod.InputMethodSubtype;
import java.util.ArrayList;
public class AdditionalSubtype {
public final class AdditionalSubtype {
private static final InputMethodSubtype[] EMPTY_SUBTYPE_ARRAY = new InputMethodSubtype[0];
private AdditionalSubtype() {
// This utility class is not publicly instantiable.
}
public static boolean isAdditionalSubtype(InputMethodSubtype subtype) {
public static boolean isAdditionalSubtype(final InputMethodSubtype subtype) {
return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
}
private static final String LOCALE_AND_LAYOUT_SEPARATOR = ":";
public static final String PREF_SUBTYPE_SEPARATOR = ";";
private static final String PREF_SUBTYPE_SEPARATOR = ";";
public static InputMethodSubtype createAdditionalSubtype(
String localeString, String keyboardLayoutSetName, String extraValue) {
public static InputMethodSubtype createAdditionalSubtype(final String localeString,
final String keyboardLayoutSetName, final String extraValue) {
final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
final String layoutDisplayNameExtraValue;
if (Build.VERSION.SDK_INT >= /* JELLY_BEAN */ 15
@ -62,7 +62,7 @@ public class AdditionalSubtype {
layoutExtraValue + "," + additionalSubtypeExtraValue, false, false);
}
public static String getPrefSubtype(InputMethodSubtype subtype) {
public static String getPrefSubtype(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype);
final String layoutExtraValue = KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName;
@ -74,7 +74,7 @@ public class AdditionalSubtype {
: basePrefSubtype + LOCALE_AND_LAYOUT_SEPARATOR + extraValue;
}
public static InputMethodSubtype createAdditionalSubtype(String prefSubtype) {
public static InputMethodSubtype createAdditionalSubtype(final String prefSubtype) {
final String elems[] = prefSubtype.split(LOCALE_AND_LAYOUT_SEPARATOR);
if (elems.length < 2 || elems.length > 3) {
throw new RuntimeException("Unknown additional subtype specified: " + prefSubtype);
@ -85,7 +85,7 @@ public class AdditionalSubtype {
return createAdditionalSubtype(localeString, keyboardLayoutSetName, extraValue);
}
public static InputMethodSubtype[] createAdditionalSubtypesArray(String prefSubtypes) {
public static InputMethodSubtype[] createAdditionalSubtypesArray(final String prefSubtypes) {
if (TextUtils.isEmpty(prefSubtypes)) {
return EMPTY_SUBTYPE_ARRAY;
}
@ -103,4 +103,32 @@ public class AdditionalSubtype {
}
return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]);
}
public static String createPrefSubtypes(final InputMethodSubtype[] subtypes) {
if (subtypes == null || subtypes.length == 0) {
return "";
}
final StringBuilder sb = new StringBuilder();
for (final InputMethodSubtype subtype : subtypes) {
if (sb.length() > 0) {
sb.append(PREF_SUBTYPE_SEPARATOR);
}
sb.append(getPrefSubtype(subtype));
}
return sb.toString();
}
public static String createPrefSubtypes(final String[] prefSubtypes) {
if (prefSubtypes == null || prefSubtypes.length == 0) {
return "";
}
final StringBuilder sb = new StringBuilder();
for (final String prefSubtype : prefSubtypes) {
if (sb.length() > 0) {
sb.append(PREF_SUBTYPE_SEPARATOR);
}
sb.append(prefSubtype);
}
return sb.toString();
}
}

View File

@ -63,13 +63,13 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
private static final String KEY_IS_SUBTYPE_ENABLER_NOTIFICATION_DIALOG_OPEN =
"is_subtype_enabler_notification_dialog_open";
private static final String KEY_SUBTYPE_FOR_SUBTYPE_ENABLER = "subtype_for_subtype_enabler";
static class SubtypeLocaleItem extends Pair<String, String>
static final class SubtypeLocaleItem extends Pair<String, String>
implements Comparable<SubtypeLocaleItem> {
public SubtypeLocaleItem(String localeString, String displayName) {
public SubtypeLocaleItem(final String localeString, final String displayName) {
super(localeString, displayName);
}
public SubtypeLocaleItem(String localeString) {
public SubtypeLocaleItem(final String localeString) {
this(localeString, SubtypeLocale.getSubtypeLocaleDisplayName(localeString));
}
@ -79,13 +79,13 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public int compareTo(SubtypeLocaleItem o) {
public int compareTo(final SubtypeLocaleItem o) {
return first.compareTo(o.first);
}
}
static class SubtypeLocaleAdapter extends ArrayAdapter<SubtypeLocaleItem> {
public SubtypeLocaleAdapter(Context context) {
static final class SubtypeLocaleAdapter extends ArrayAdapter<SubtypeLocaleItem> {
public SubtypeLocaleAdapter(final Context context) {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -102,7 +102,8 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
addAll(items);
}
public static SubtypeLocaleItem createItem(Context context, String localeString) {
public static SubtypeLocaleItem createItem(final Context context,
final String localeString) {
if (localeString.equals(SubtypeLocale.NO_LANGUAGE)) {
final String displayName = context.getString(R.string.subtype_no_language);
return new SubtypeLocaleItem(localeString, displayName);
@ -112,8 +113,8 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
}
static class KeyboardLayoutSetItem extends Pair<String, String> {
public KeyboardLayoutSetItem(InputMethodSubtype subtype) {
static final class KeyboardLayoutSetItem extends Pair<String, String> {
public KeyboardLayoutSetItem(final InputMethodSubtype subtype) {
super(SubtypeLocale.getKeyboardLayoutSetName(subtype),
SubtypeLocale.getKeyboardLayoutSetDisplayName(subtype));
}
@ -124,8 +125,8 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
}
static class KeyboardLayoutSetAdapter extends ArrayAdapter<KeyboardLayoutSetItem> {
public KeyboardLayoutSetAdapter(Context context) {
static final class KeyboardLayoutSetAdapter extends ArrayAdapter<KeyboardLayoutSetItem> {
public KeyboardLayoutSetAdapter(final Context context) {
super(context, android.R.layout.simple_spinner_item);
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -147,7 +148,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
public KeyboardLayoutSetAdapter getKeyboardLayoutSetAdapter();
}
static class SubtypePreference extends DialogPreference
static final class SubtypePreference extends DialogPreference
implements DialogInterface.OnCancelListener {
private static final String KEY_PREFIX = "subtype_pref_";
private static final String KEY_NEW_SUBTYPE = KEY_PREFIX + "new";
@ -159,13 +160,13 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
private Spinner mSubtypeLocaleSpinner;
private Spinner mKeyboardLayoutSetSpinner;
public static SubtypePreference newIncompleteSubtypePreference(
Context context, SubtypeDialogProxy proxy) {
public static SubtypePreference newIncompleteSubtypePreference(final Context context,
final SubtypeDialogProxy proxy) {
return new SubtypePreference(context, null, proxy);
}
public SubtypePreference(Context context, InputMethodSubtype subtype,
SubtypeDialogProxy proxy) {
public SubtypePreference(final Context context, final InputMethodSubtype subtype,
final SubtypeDialogProxy proxy) {
super(context, null);
setDialogLayoutResource(R.layout.additional_subtype_dialog);
setPersistent(false);
@ -185,7 +186,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
return mSubtype;
}
public void setSubtype(InputMethodSubtype subtype) {
public void setSubtype(final InputMethodSubtype subtype) {
mPreviousSubtype = mSubtype;
mSubtype = subtype;
if (isIncomplete()) {
@ -221,7 +222,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
protected void onPrepareDialogBuilder(final AlertDialog.Builder builder) {
final Context context = builder.getContext();
builder.setCancelable(true).setOnCancelListener(this);
if (isIncomplete()) {
@ -239,7 +240,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
}
private static void setSpinnerPosition(Spinner spinner, Object itemToSelect) {
private static void setSpinnerPosition(final Spinner spinner, final Object itemToSelect) {
final SpinnerAdapter adapter = spinner.getAdapter();
final int count = adapter.getCount();
for (int i = 0; i < count; i++) {
@ -252,14 +253,14 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onCancel(DialogInterface dialog) {
public void onCancel(final DialogInterface dialog) {
if (isIncomplete()) {
mProxy.onRemovePressed(this);
}
}
@Override
public void onClick(DialogInterface dialog, int which) {
public void onClick(final DialogInterface dialog, final int which) {
super.onClick(dialog, which);
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
@ -287,12 +288,12 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
}
private static int getSpinnerPosition(Spinner spinner) {
private static int getSpinnerPosition(final Spinner spinner) {
if (spinner == null) return -1;
return spinner.getSelectedItemPosition();
}
private static void setSpinnerPosition(Spinner spinner, int position) {
private static void setSpinnerPosition(final Spinner spinner, final int position) {
if (spinner == null || position < 0) return;
spinner.setSelection(position);
}
@ -313,7 +314,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
protected void onRestoreInstanceState(final Parcelable state) {
if (!(state instanceof SavedState)) {
super.onRestoreInstanceState(state);
return;
@ -326,24 +327,24 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
setSubtype(myState.mSubtype);
}
static class SavedState extends Preference.BaseSavedState {
static final class SavedState extends Preference.BaseSavedState {
InputMethodSubtype mSubtype;
int mSubtypeLocaleSelectedPos;
int mKeyboardLayoutSetSelectedPos;
public SavedState(Parcelable superState) {
public SavedState(final Parcelable superState) {
super(superState);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
public void writeToParcel(final Parcel dest, final int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mSubtypeLocaleSelectedPos);
dest.writeInt(mKeyboardLayoutSetSelectedPos);
dest.writeParcelable(mSubtype, 0);
}
public SavedState(Parcel source) {
public SavedState(final Parcel source) {
super(source);
mSubtypeLocaleSelectedPos = source.readInt();
mKeyboardLayoutSetSelectedPos = source.readInt();
@ -354,12 +355,12 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
public static final Parcelable.Creator<SavedState> CREATOR =
new Parcelable.Creator<SavedState>() {
@Override
public SavedState createFromParcel(Parcel source) {
public SavedState createFromParcel(final Parcel source) {
return new SavedState(source);
}
@Override
public SavedState[] newArray(int size) {
public SavedState[] newArray(final int size) {
return new SavedState[size];
}
};
@ -371,7 +372,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.additional_subtype_settings);
@ -381,7 +382,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
public void onActivityCreated(final Bundle savedInstanceState) {
final Context context = getActivity();
mSubtypeLocaleAdapter = new SubtypeLocaleAdapter(context);
mKeyboardLayoutSetAdapter = new KeyboardLayoutSetAdapter(context);
@ -411,7 +412,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
if (mIsAddingNewSubtype) {
outState.putBoolean(KEY_IS_ADDING_NEW_SUBTYPE, true);
@ -426,7 +427,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
private final SubtypeDialogProxy mSubtypeProxy = new SubtypeDialogProxy() {
@Override
public void onRemovePressed(SubtypePreference subtypePref) {
public void onRemovePressed(final SubtypePreference subtypePref) {
mIsAddingNewSubtype = false;
final PreferenceGroup group = getPreferenceScreen();
group.removePreference(subtypePref);
@ -434,7 +435,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onSavePressed(SubtypePreference subtypePref) {
public void onSavePressed(final SubtypePreference subtypePref) {
final InputMethodSubtype subtype = subtypePref.getSubtype();
if (!subtypePref.hasBeenModified()) {
return;
@ -453,7 +454,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onAddPressed(SubtypePreference subtypePref) {
public void onAddPressed(final SubtypePreference subtypePref) {
mIsAddingNewSubtype = false;
final InputMethodSubtype subtype = subtypePref.getSubtype();
if (findDuplicatedSubtype(subtype) == null) {
@ -481,7 +482,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
};
private void showSubtypeAlreadyExistsToast(InputMethodSubtype subtype) {
private void showSubtypeAlreadyExistsToast(final InputMethodSubtype subtype) {
final Context context = getActivity();
final Resources res = context.getResources();
final String message = res.getString(R.string.custom_input_style_already_exists,
@ -489,14 +490,15 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
private InputMethodSubtype findDuplicatedSubtype(InputMethodSubtype subtype) {
private InputMethodSubtype findDuplicatedSubtype(final InputMethodSubtype subtype) {
final String localeString = subtype.getLocale();
final String keyboardLayoutSetName = SubtypeLocale.getKeyboardLayoutSetName(subtype);
return ImfUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
getActivity(), localeString, keyboardLayoutSetName);
}
private AlertDialog createDialog(SubtypePreference subtypePref) {
private AlertDialog createDialog(
@SuppressWarnings("unused") final SubtypePreference subtypePref) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.custom_input_styles_title)
.setMessage(R.string.custom_input_style_note_message)
@ -519,7 +521,7 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
return builder.create();
}
private void setPrefSubtypes(String prefSubtypes, Context context) {
private void setPrefSubtypes(final String prefSubtypes, final Context context) {
final PreferenceGroup group = getPreferenceScreen();
group.removeAll();
final InputMethodSubtype[] subtypesArray =
@ -547,23 +549,12 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
return subtypes.toArray(new InputMethodSubtype[subtypes.size()]);
}
private String getPrefSubtypes(InputMethodSubtype[] subtypes) {
final StringBuilder sb = new StringBuilder();
for (final InputMethodSubtype subtype : subtypes) {
if (sb.length() > 0) {
sb.append(AdditionalSubtype.PREF_SUBTYPE_SEPARATOR);
}
sb.append(AdditionalSubtype.getPrefSubtype(subtype));
}
return sb.toString();
}
@Override
public void onPause() {
super.onPause();
final String oldSubtypes = SettingsValues.getPrefAdditionalSubtypes(mPrefs, getResources());
final InputMethodSubtype[] subtypes = getSubtypes();
final String prefSubtypes = getPrefSubtypes(subtypes);
final String prefSubtypes = AdditionalSubtype.createPrefSubtypes(subtypes);
if (prefSubtypes.equals(oldSubtypes)) {
return;
}
@ -578,13 +569,13 @@ public class AdditionalSubtypeSettings extends PreferenceFragment {
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
final MenuItem addSubtypeMenu = menu.add(0, MENU_ADD_SUBTYPE, 0, R.string.add_style);
addSubtypeMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(final MenuItem item) {
final int itemId = item.getItemId();
if (itemId == MENU_ADD_SUBTYPE) {
final SubtypePreference newSubtype =

View File

@ -35,7 +35,7 @@ import java.util.HashMap;
* When you call the constructor of this class, you may want to change the current system locale by
* using {@link LocaleUtils.RunInLocale}.
*/
public class SettingsValues {
public final class SettingsValues {
private static final String TAG = SettingsValues.class.getSimpleName();
private static final int SUGGESTION_VISIBILITY_SHOW_VALUE
@ -246,64 +246,65 @@ public class SettingsValues {
&& orientation == Configuration.ORIENTATION_PORTRAIT);
}
public boolean isWordSeparator(int code) {
public boolean isWordSeparator(final int code) {
return mWordSeparators.contains(String.valueOf((char)code));
}
public boolean isSymbolExcludedFromWordSeparators(int code) {
public boolean isSymbolExcludedFromWordSeparators(final int code) {
return mSymbolsExcludedFromWordSeparators.contains(String.valueOf((char)code));
}
public boolean isWeakSpaceStripper(int code) {
public boolean isWeakSpaceStripper(final int code) {
// TODO: this does not work if the code does not fit in a char
return mWeakSpaceStrippers.contains(String.valueOf((char)code));
}
public boolean isWeakSpaceSwapper(int code) {
public boolean isWeakSpaceSwapper(final int code) {
// TODO: this does not work if the code does not fit in a char
return mWeakSpaceSwappers.contains(String.valueOf((char)code));
}
public boolean isPhantomSpacePromotingSymbol(int code) {
public boolean isPhantomSpacePromotingSymbol(final int code) {
// TODO: this does not work if the code does not fit in a char
return mPhantomSpacePromotingSymbols.contains(String.valueOf((char)code));
}
private static boolean isAutoCorrectEnabled(final Resources resources,
private static boolean isAutoCorrectEnabled(final Resources res,
final String currentAutoCorrectionSetting) {
final String autoCorrectionOff = resources.getString(
final String autoCorrectionOff = res.getString(
R.string.auto_correction_threshold_mode_index_off);
return !currentAutoCorrectionSetting.equals(autoCorrectionOff);
}
// Public to access from KeyboardSwitcher. Should it have access to some
// process-global instance instead?
public static boolean isKeyPreviewPopupEnabled(SharedPreferences sp, Resources resources) {
final boolean showPopupOption = resources.getBoolean(
public static boolean isKeyPreviewPopupEnabled(final SharedPreferences prefs,
final Resources res) {
final boolean showPopupOption = res.getBoolean(
R.bool.config_enable_show_popup_on_keypress_option);
if (!showPopupOption) return resources.getBoolean(R.bool.config_default_popup_preview);
return sp.getBoolean(Settings.PREF_POPUP_ON,
resources.getBoolean(R.bool.config_default_popup_preview));
if (!showPopupOption) return res.getBoolean(R.bool.config_default_popup_preview);
return prefs.getBoolean(Settings.PREF_POPUP_ON,
res.getBoolean(R.bool.config_default_popup_preview));
}
// Likewise
public static int getKeyPreviewPopupDismissDelay(SharedPreferences sp,
Resources resources) {
public static int getKeyPreviewPopupDismissDelay(final SharedPreferences prefs,
final Resources res) {
// TODO: use mKeyPreviewPopupDismissDelayRawValue instead of reading it again here.
return Integer.parseInt(sp.getString(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(resources.getInteger(
return Integer.parseInt(prefs.getString(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout))));
}
private static boolean isBigramPredictionEnabled(final SharedPreferences sp,
final Resources resources) {
return sp.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, resources.getBoolean(
private static boolean isBigramPredictionEnabled(final SharedPreferences prefs,
final Resources res) {
return prefs.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, res.getBoolean(
R.bool.config_default_next_word_prediction));
}
private static float getAutoCorrectionThreshold(final Resources resources,
private static float getAutoCorrectionThreshold(final Resources res,
final String currentAutoCorrectionSetting) {
final String[] autoCorrectionThresholdValues = resources.getStringArray(
final String[] autoCorrectionThresholdValues = res.getStringArray(
R.array.auto_correction_threshold_values);
// When autoCorrectionThreshold is greater than 1.0, it's like auto correction is off.
float autoCorrectionThreshold = Float.MAX_VALUE;
@ -335,11 +336,11 @@ public class SettingsValues {
return mVoiceKeyOnMain;
}
public static boolean isLanguageSwitchKeySupressed(SharedPreferences sp) {
return sp.getBoolean(Settings.PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
public static boolean isLanguageSwitchKeySupressed(final SharedPreferences prefs) {
return prefs.getBoolean(Settings.PREF_SUPPRESS_LANGUAGE_SWITCH_KEY, false);
}
public boolean isLanguageSwitchKeyEnabled(Context context) {
public boolean isLanguageSwitchKeyEnabled(final Context context) {
if (mIsLanguageSwitchKeySuppressed) {
return false;
}
@ -352,7 +353,7 @@ public class SettingsValues {
}
}
public boolean isFullscreenModeAllowed(Resources res) {
public boolean isFullscreenModeAllowed(final Resources res) {
return res.getBoolean(R.bool.config_use_fullscreen_mode);
}
@ -362,15 +363,16 @@ public class SettingsValues {
public static String getPrefAdditionalSubtypes(final SharedPreferences prefs,
final Resources res) {
final String prefSubtypes = res.getString(R.string.predefined_subtypes, "");
return prefs.getString(Settings.PREF_CUSTOM_INPUT_STYLES, prefSubtypes);
final String predefinedPrefSubtypes = AdditionalSubtype.createPrefSubtypes(
res.getStringArray(R.array.predefined_subtypes));
return prefs.getString(Settings.PREF_CUSTOM_INPUT_STYLES, predefinedPrefSubtypes);
}
// Accessed from the settings interface, hence public
public static float getCurrentKeypressSoundVolume(final SharedPreferences sp,
final Resources res) {
public static float getCurrentKeypressSoundVolume(final SharedPreferences prefs,
final Resources res) {
// TODO: use mVibrationDurationSettingsRawValue instead of reading it again here
final float volume = sp.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f);
final float volume = prefs.getFloat(Settings.PREF_KEYPRESS_SOUND_VOLUME, -1.0f);
if (volume >= 0) {
return volume;
}
@ -380,10 +382,10 @@ public class SettingsValues {
}
// Likewise
public static int getCurrentVibrationDuration(final SharedPreferences sp,
final Resources res) {
public static int getCurrentVibrationDuration(final SharedPreferences prefs,
final Resources res) {
// TODO: use mKeypressVibrationDuration instead of reading it again here
final int ms = sp.getInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, -1);
final int ms = prefs.getInt(Settings.PREF_VIBRATION_DURATION_SETTINGS, -1);
if (ms >= 0) {
return ms;
}
@ -398,8 +400,8 @@ public class SettingsValues {
return prefs.getBoolean(Settings.PREF_USABILITY_STUDY_MODE, true);
}
public static long getLastUserHistoryWriteTime(
final SharedPreferences prefs, final String locale) {
public static long getLastUserHistoryWriteTime(final SharedPreferences prefs,
final String locale) {
final String str = prefs.getString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, "");
final HashMap<String, Long> map = LocaleUtils.localeAndTimeStrToHashMap(str);
if (map.containsKey(locale)) {
@ -408,8 +410,8 @@ public class SettingsValues {
return 0;
}
public static void setLastUserHistoryWriteTime(
final SharedPreferences prefs, final String locale) {
public static void setLastUserHistoryWriteTime(final SharedPreferences prefs,
final String locale) {
final String oldStr = prefs.getString(Settings.PREF_LAST_USER_DICTIONARY_WRITE_TIME, "");
final HashMap<String, Long> map = LocaleUtils.localeAndTimeStrToHashMap(oldStr);
map.put(locale, System.currentTimeMillis());