Search in sources :

Example 56 with EditTextPreference

use of android.preference.EditTextPreference in project Osmand by osmandapp.

the class SettingsBaseActivity method registerEditTextPreference.

public void registerEditTextPreference(OsmandPreference<String> b, PreferenceScreen screen) {
    EditTextPreference p = (EditTextPreference) screen.findPreference(b.getId());
    p.setOnPreferenceChangeListener(this);
    screenPreferences.put(b.getId(), p);
    editTextPreferences.put(b.getId(), b);
}
Also used : EditTextPreference(android.preference.EditTextPreference)

Example 57 with EditTextPreference

use of android.preference.EditTextPreference in project OpenBikeSharing by bparmentier.

the class SettingsFragment method updatePreference.

private void updatePreference(String key) {
    if (key.equals(PREF_KEY_API_URL)) {
        Preference preference = findPreference(key);
        // if (preference instanceof EditTextPreference){
        EditTextPreference editTextPreference = (EditTextPreference) preference;
        editTextPreference.setSummary(editTextPreference.getText());
    // }
    } else if (key.equals(PREF_KEY_NETWORK_ID)) {
        Preference preference = findPreference(key);
        String networkName = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(PREF_KEY_NETWORK_NAME, "");
        String networkCity = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(PREF_KEY_NETWORK_CITY, "");
        if (!networkName.isEmpty() && !networkCity.isEmpty()) {
            preference.setSummary(networkName + " (" + networkCity + ")");
        }
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference) Preference(android.preference.Preference) EditTextPreference(android.preference.EditTextPreference)

Example 58 with EditTextPreference

use of android.preference.EditTextPreference in project Gladys-Android-App by LeptitGeek.

the class settingsActivity method updatePreferences.

private void updatePreferences(Preference p) {
    if (p instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) p;
        p.setSummary(editTextPref.getText());
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference)

Example 59 with EditTextPreference

use of android.preference.EditTextPreference in project openScale by oliexdev.

the class BluetoothPreferences method updatePrefSummary.

private void updatePrefSummary(Preference p) {
    if (smartAssignEnable.isChecked()) {
        ignoreOutOfRangeEnable.setEnabled(true);
    } else {
        ignoreOutOfRangeEnable.setEnabled(false);
    }
    if (p instanceof ListPreference) {
        ListPreference listPref = (ListPreference) p;
        p.setSummary(listPref.getTitle());
    }
    if (p instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) p;
        if (p.getTitle().toString().contains("assword")) {
            p.setSummary("******");
        } else {
            p.setSummary(editTextPref.getText());
        }
    }
    if (p instanceof MultiSelectListPreference) {
        MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
        CharSequence[] entries = editMultiListPref.getEntries();
        CharSequence[] entryValues = editMultiListPref.getEntryValues();
        List<String> currentEntries = new ArrayList<>();
        Set<String> currentEntryValues = editMultiListPref.getValues();
        for (int i = 0; i < entries.length; i++) if (currentEntryValues.contains(entryValues[i]))
            currentEntries.add(entries[i].toString());
        p.setSummary(currentEntries.toString());
    }
}
Also used : ArrayList(java.util.ArrayList) MultiSelectListPreference(android.preference.MultiSelectListPreference) MultiSelectListPreference(android.preference.MultiSelectListPreference) ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference)

Example 60 with EditTextPreference

use of android.preference.EditTextPreference in project openScale by oliexdev.

the class GraphPreferences method updatePrefSummary.

private void updatePrefSummary(Preference p) {
    if (p instanceof ListPreference) {
        ListPreference listPref = (ListPreference) p;
        p.setSummary(listPref.getEntry());
    }
    if (p instanceof EditTextPreference) {
        EditTextPreference editTextPref = (EditTextPreference) p;
        if (p.getTitle().toString().contains("assword")) {
            p.setSummary("******");
        } else {
            p.setSummary(editTextPref.getText());
        }
    }
    if (p instanceof MultiSelectListPreference) {
        MultiSelectListPreference editMultiListPref = (MultiSelectListPreference) p;
        CharSequence[] entries = editMultiListPref.getEntries();
        CharSequence[] entryValues = editMultiListPref.getEntryValues();
        List<String> currentEntries = new ArrayList<>();
        Set<String> currentEntryValues = editMultiListPref.getValues();
        for (int i = 0; i < entries.length; i++) {
            if (currentEntryValues.contains(entryValues[i].toString()))
                currentEntries.add(entries[i].toString());
        }
        p.setSummary(currentEntries.toString());
    }
}
Also used : ArrayList(java.util.ArrayList) MultiSelectListPreference(android.preference.MultiSelectListPreference) MultiSelectListPreference(android.preference.MultiSelectListPreference) ListPreference(android.preference.ListPreference) EditTextPreference(android.preference.EditTextPreference)

Aggregations

EditTextPreference (android.preference.EditTextPreference)77 ListPreference (android.preference.ListPreference)32 Preference (android.preference.Preference)32 CheckBoxPreference (android.preference.CheckBoxPreference)17 SharedPreferences (android.content.SharedPreferences)11 PreferenceScreen (android.preference.PreferenceScreen)11 Test (org.junit.Test)9 MultiSelectListPreference (android.preference.MultiSelectListPreference)8 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)8 Intent (android.content.Intent)7 ArrayList (java.util.ArrayList)7 DialogInterface (android.content.DialogInterface)6 Bundle (android.os.Bundle)6 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)5 View (android.view.View)5 SwitchPreference (android.preference.SwitchPreference)4 EditText (android.widget.EditText)4 File (java.io.File)4 Activity (android.app.Activity)3 AlertDialog (android.app.AlertDialog)3