Search in sources :

Example 11 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project network-monitor by caarmen.

the class EmailPreferencesActivity method updatePreferenceSummary.

private void updatePreferenceSummary(CharSequence key, int summaryResId) {
    Preference pref = mPreferenceFragment.findPreference(key);
    CharSequence value;
    if (key.equals(EmailPreferences.PREF_EMAIL_LAST_EMAIL_SENT)) {
        long lastEmailSent = EmailPreferences.getInstance(this).getLastEmailSent();
        if (lastEmailSent > 0)
            value = DateUtils.formatDateTime(this, lastEmailSent, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_YEAR);
        else
            value = getString(R.string.pref_value_email_report_interval_never);
    } else if (pref instanceof EditTextPreference)
        value = ((EditTextPreference) pref).getText();
    else if (pref instanceof MultiSelectListPreference)
        value = getSummary((MultiSelectListPreference) pref, ((MultiSelectListPreference) pref).getValues());
    else if (pref instanceof ListPreference)
        value = ((ListPreference) pref).getEntry();
    else
        return;
    if (value == null) {
        value = "";
    }
    String summary = getString(summaryResId, value);
    pref.setSummary(summary);
}
Also used : ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) MultiSelectListPreference(android.support.v14.preference.MultiSelectListPreference) MultiSelectListPreference(android.support.v14.preference.MultiSelectListPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) ListPreference(android.support.v7.preference.ListPreference) MultiSelectListPreference(android.support.v14.preference.MultiSelectListPreference)

Example 12 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project network-monitor by caarmen.

the class SpeedTestPreferencesActivity method updatePreferenceSummary.

private void updatePreferenceSummary(CharSequence key, int summaryResId) {
    Preference pref = mPreferenceFragment.findPreference(key);
    if (pref instanceof EditTextPreference) {
        CharSequence value = ((EditTextPreference) pref).getText();
        if (value == null) {
            value = "";
        }
        String summary = getString(summaryResId, value);
        pref.setSummary(summary);
    }
}
Also used : Preference(android.support.v7.preference.Preference) EditTextPreference(android.support.v7.preference.EditTextPreference) EditTextPreference(android.support.v7.preference.EditTextPreference)

Example 13 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project i2p.i2p-bote by i2p.

the class AdvancedPreferenceFragment method setupI2PCategory.

private static void setupI2PCategory(Context context, PreferenceCategory i2pCat) {
    final ListPreference routerChoice = createRouterChoice(context);
    final EditTextPreference hostField = createHostField(context);
    final EditTextPreference portField = createPortField(context);
    i2pCat.addPreference(routerChoice);
    i2pCat.addPreference(hostField);
    i2pCat.addPreference(portField);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
        routerChoice.setSummary(routerChoice.getEntry());
    if ("remote".equals(routerChoice.getValue())) {
        hostField.setEnabled(true);
        portField.setEnabled(true);
    }
    routerChoice.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {
            final String val = newValue.toString();
            int index = routerChoice.findIndexOfValue(val);
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
                routerChoice.setSummary(routerChoice.getEntries()[index]);
            if (index == 2) {
                hostField.setEnabled(true);
                hostField.setText("127.0.0.1");
                portField.setEnabled(true);
                portField.setText("7654");
            } else {
                hostField.setEnabled(false);
                hostField.setText("internal");
                portField.setEnabled(false);
                portField.setText("internal");
            }
            return true;
        }
    });
}
Also used : Preference(android.support.v7.preference.Preference) SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) ListPreference(android.support.v7.preference.ListPreference) SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference) EditTextPreference(android.support.v7.preference.EditTextPreference)

Example 14 with EditTextPreference

use of com.takisoft.fix.support.v7.preference.EditTextPreference in project i2p.i2p-bote by i2p.

the class AdvancedPreferenceFragment method createHostField.

private static EditTextPreference createHostField(Context context) {
    EditTextPreference p = new SummaryEditTextPreference(context);
    p.setKey("i2pbote.i2cp.tcp.host");
    p.setTitle(R.string.pref_title_i2cp_host);
    p.setSummary("%s");
    p.setDefaultValue("internal");
    p.setEnabled(false);
    return p;
}
Also used : SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference) EditTextPreference(android.support.v7.preference.EditTextPreference) SummaryEditTextPreference(i2p.bote.android.config.util.SummaryEditTextPreference)

Aggregations

EditTextPreference (android.support.v7.preference.EditTextPreference)11 Preference (android.support.v7.preference.Preference)10 ListPreference (android.support.v7.preference.ListPreference)8 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)3 SwitchPreferenceCompat (android.support.v7.preference.SwitchPreferenceCompat)3 TwoStatePreference (android.support.v7.preference.TwoStatePreference)3 EditTextPreference (com.takisoft.fix.support.v7.preference.EditTextPreference)3 ConfigKey (cx.ring.model.ConfigKey)3 SummaryEditTextPreference (i2p.bote.android.config.util.SummaryEditTextPreference)3 EditTextIntegerPreference (cx.ring.views.EditTextIntegerPreference)2 PasswordPreference (cx.ring.views.PasswordPreference)2 File (java.io.File)2 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 MultiSelectListPreference (android.support.v14.preference.MultiSelectListPreference)1 SwitchPreference (android.support.v14.preference.SwitchPreference)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1