Search in sources :

Example 96 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class FormManagementPreferences method initAutoSendPrefs.

private void initAutoSendPrefs() {
    final ListPreference autosend = (ListPreference) findPreference(KEY_AUTOSEND);
    if (autosend == null) {
        return;
    }
    autosend.setSummary(autosend.getEntry());
    autosend.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
            String entry = (String) ((ListPreference) preference).getEntries()[index];
            preference.setSummary(entry);
            return true;
        }
    });
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 97 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class FormManagementPreferences method initImageSizePrefs.

private void initImageSizePrefs() {
    final ListPreference imageSize = (ListPreference) findPreference(KEY_IMAGE_SIZE);
    if (imageSize == null) {
        return;
    }
    imageSize.setSummary(imageSize.getEntry());
    imageSize.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
            String entry = (String) ((ListPreference) preference).getEntries()[index];
            preference.setSummary(entry);
            return true;
        }
    });
}
Also used : ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) ListPreference(android.preference.ListPreference)

Example 98 with ListPreference

use of android.preference.ListPreference in project collect by opendatakit.

the class UserInterfacePreferences method initLanguagePrefs.

private void initLanguagePrefs() {
    final ListPreference pref = (ListPreference) findPreference(KEY_APP_LANGUAGE);
    if (pref != null) {
        final LocaleHelper localeHelper = new LocaleHelper();
        TreeMap<String, String> languageList = localeHelper.getEntryListValues();
        int length = languageList.size() + 1;
        ArrayList<String> entryValues = new ArrayList<>();
        entryValues.add(0, "");
        entryValues.addAll(languageList.values());
        pref.setEntryValues(entryValues.toArray(new String[length]));
        ArrayList<String> entries = new ArrayList<>();
        entries.add(0, getActivity().getResources().getString(R.string.use_device_language));
        entries.addAll(languageList.keySet());
        pref.setEntries(entries.toArray(new String[length]));
        if (pref.getValue() == null) {
            // set Default value to "Use phone locale"
            pref.setValueIndex(0);
        }
        pref.setSummary(pref.getEntry());
        pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
                int index = ((ListPreference) preference).findIndexOfValue(newValue.toString());
                String entry = (String) ((ListPreference) preference).getEntries()[index];
                preference.setSummary(entry);
                SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
                edit.putString(KEY_APP_LANGUAGE, newValue.toString());
                edit.apply();
                localeHelper.updateLocale(getActivity());
                Intent intent = new Intent(getActivity().getBaseContext(), MainMenuActivity.class);
                getActivity().startActivity(intent);
                getActivity().overridePendingTransition(0, 0);
                getActivity().finishAffinity();
                return true;
            }
        });
    }
}
Also used : LocaleHelper(org.odk.collect.android.utilities.LocaleHelper) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ListPreference(android.preference.ListPreference) MainMenuActivity(org.odk.collect.android.activities.MainMenuActivity) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference)

Example 99 with ListPreference

use of android.preference.ListPreference in project aware-client by denzilferreira.

the class Aware_Client method onSharedPreferenceChanged.

@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    String value = "";
    Map<String, ?> keys = sharedPreferences.getAll();
    if (keys.containsKey(key)) {
        Object entry = keys.get(key);
        if (entry instanceof Boolean)
            value = String.valueOf(sharedPreferences.getBoolean(key, false));
        else if (entry instanceof String)
            value = String.valueOf(sharedPreferences.getString(key, "error"));
        else if (entry instanceof Integer)
            value = String.valueOf(sharedPreferences.getInt(key, 0));
    }
    Aware.setSetting(getApplicationContext(), key, value);
    Preference pref = findPreference(key);
    if (CheckBoxPreference.class.isInstance(pref)) {
        CheckBoxPreference check = (CheckBoxPreference) findPreference(key);
        check.setChecked(Aware.getSetting(getApplicationContext(), key).equals("true"));
        // update the parent to show active/inactive
        new SettingsSync().execute(pref);
        // Start/Stop sensor
        Aware.startAWARE(getApplicationContext());
    }
    if (EditTextPreference.class.isInstance(pref)) {
        EditTextPreference text = (EditTextPreference) findPreference(key);
        text.setText(Aware.getSetting(getApplicationContext(), key));
    }
    if (ListPreference.class.isInstance(pref)) {
        ListPreference list = (ListPreference) findPreference(key);
        list.setSummary(list.getEntry());
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference)

Example 100 with ListPreference

use of android.preference.ListPreference in project Thrift-box by Sash0k.

the class SettingsFragment method getListValues.

// ============================================================================
/**
 * Заполнение списков
 */
private void getListValues(String tag, int titlesId, int valuesId) {
    ListPreference listprefence = (ListPreference) findPreference(tag);
    if (listprefence != null) {
        listprefence.setEntries(titlesId);
        listprefence.setEntryValues(valuesId);
    }
    setPrefenceTitle(tag);
}
Also used : ListPreference(android.preference.ListPreference)

Aggregations

ListPreference (android.preference.ListPreference)164 Preference (android.preference.Preference)80 CheckBoxPreference (android.preference.CheckBoxPreference)50 EditTextPreference (android.preference.EditTextPreference)35 PreferenceScreen (android.preference.PreferenceScreen)21 ArrayList (java.util.ArrayList)19 SharedPreferences (android.content.SharedPreferences)17 Intent (android.content.Intent)16 PreferenceCategory (android.preference.PreferenceCategory)16 SuppressLint (android.annotation.SuppressLint)13 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)9 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)8 File (java.io.File)8 Bundle (android.os.Bundle)7 SwitchPreference (android.preference.SwitchPreference)7 View (android.view.View)7 Context (android.content.Context)6 DialogInterface (android.content.DialogInterface)6 RingtonePreference (android.preference.RingtonePreference)6