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);
}
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);
}
}
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;
}
});
}
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;
}
Aggregations