use of android.support.v7.preference.EditTextPreference in project ring-client-android by savoirfairelinux.
the class AdvancedAccountFragment method initView.
@Override
public void initView(AccountConfig config, ArrayList<CharSequence> networkInterfaces) {
for (ConfigKey confKey : config.getKeys()) {
Preference pref = findPreference(confKey.key());
if (pref != null) {
pref.setOnPreferenceChangeListener(this);
if (confKey == ConfigKey.LOCAL_INTERFACE) {
String val = config.get(confKey);
CharSequence[] display = networkInterfaces.toArray(new CharSequence[networkInterfaces.size()]);
ListPreference listPref = (ListPreference) pref;
listPref.setEntries(display);
listPref.setEntryValues(display);
listPref.setSummary(val);
listPref.setValue(val);
} else if (!confKey.isTwoState()) {
String val = config.get(confKey);
pref.setSummary(val);
if (pref instanceof EditTextPreference) {
((EditTextPreference) pref).setText(val);
}
} else {
((TwoStatePreference) pref).setChecked(config.getBool(confKey));
}
}
}
}
use of android.support.v7.preference.EditTextPreference in project haven by guardianproject.
the class SettingsFragment method onCreatePreferencesFix.
@Override
public void onCreatePreferencesFix(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.settings);
mActivity = getActivity();
preferences = new PreferenceManager(mActivity);
setHasOptionsMenu(true);
app = (HavenApp) mActivity.getApplication();
/*
* We create an application directory to store images and audio
*/
File directory = new File(Environment.getExternalStorageDirectory() + preferences.getDirPath());
directory.mkdirs();
if (preferences.getCameraActivation()) {
String camera = preferences.getCamera();
switch(camera) {
case PreferenceManager.FRONT:
((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(0);
break;
case PreferenceManager.BACK:
((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(1);
break;
case PreferenceManager.OFF:
((ListPreference) findPreference(PreferenceManager.CAMERA)).setValueIndex(2);
break;
}
}
if (preferences.getSmsActivation()) {
((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).setChecked(true);
}
if (checkValidString(preferences.getSmsNumber())) {
((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).setText(preferences.getSmsNumber().trim());
findPreference(PreferenceManager.SMS_NUMBER).setSummary(preferences.getSmsNumber().trim());
} else {
findPreference(PreferenceManager.SMS_NUMBER).setSummary(R.string.sms_dialog_summary);
}
if (preferences.getRemoteAccessActive()) {
((SwitchPreferenceCompat) findPreference(PreferenceManager.REMOTE_ACCESS_ACTIVE)).setChecked(true);
}
if (checkValidString(preferences.getRemoteAccessOnion())) {
((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_ONION)).setText(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT);
findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(preferences.getRemoteAccessOnion().trim() + ":" + WebServer.LOCAL_PORT);
} else {
findPreference(PreferenceManager.REMOTE_ACCESS_ONION).setSummary(R.string.remote_access_hint);
}
if (checkValidString(preferences.getRemoteAccessCredential())) {
((EditTextPreference) findPreference(PreferenceManager.REMOTE_ACCESS_CRED)).setText(preferences.getRemoteAccessCredential().trim());
findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.bullets);
} else {
findPreference(PreferenceManager.REMOTE_ACCESS_CRED).setSummary(R.string.remote_access_credential_hint);
}
if (checkValidString(preferences.getSignalUsername())) {
String signalNum = "+" + preferences.getSignalUsername().trim().replaceAll("[^0-9]", "");
findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(signalNum);
} else {
findPreference(PreferenceManager.REGISTER_SIGNAL).setSummary(R.string.register_signal_desc);
}
if (preferences.getNotificationTimeMs() > 0) {
findPreference(PreferenceManager.NOTIFICATION_TIME).setSummary(preferences.getNotificationTimeMs() / 60000 + " " + getString(R.string.minutes));
}
Preference prefCameraSensitivity = findPreference(PreferenceManager.CAMERA_SENSITIVITY);
prefCameraSensitivity.setOnPreferenceClickListener(preference -> {
startActivity(new Intent(mActivity, CameraConfigureActivity.class));
return true;
});
Preference prefConfigMovement = findPreference(PreferenceManager.CONFIG_MOVEMENT);
prefConfigMovement.setOnPreferenceClickListener(preference -> {
startActivity(new Intent(mActivity, AccelConfigureActivity.class));
return true;
});
Preference prefConfigSound = findPreference(PreferenceManager.CONFIG_SOUND);
prefConfigSound.setOnPreferenceClickListener(preference -> {
startActivity(new Intent(mActivity, MicrophoneConfigureActivity.class));
return true;
});
Preference prefConfigTimeDelay = findPreference(PreferenceManager.CONFIG_TIME_DELAY);
prefConfigTimeDelay.setOnPreferenceClickListener(preference -> {
showTimeDelayDialog(PreferenceManager.CONFIG_TIME_DELAY);
return true;
});
Preference prefConfigVideoLength = findPreference(PreferenceManager.CONFIG_VIDEO_LENGTH);
prefConfigVideoLength.setOnPreferenceClickListener(preference -> {
showTimeDelayDialog(PreferenceManager.CONFIG_VIDEO_LENGTH);
return true;
});
Preference prefDisableBatteryOpt = findPreference(PreferenceManager.DISABLE_BATTERY_OPT);
prefDisableBatteryOpt.setOnPreferenceClickListener(preference -> {
requestChangeBatteryOptimizations();
return true;
});
checkSignalUsername();
((EditTextPreference) findPreference(PreferenceManager.VERIFY_SIGNAL)).setText("");
askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, 1);
}
use of android.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 android.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 android.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;
}
});
}
Aggregations