use of android.support.v7.preference.EditTextPreference in project ring-client-android by savoirfairelinux.
the class GeneralAccountFragment method setPreferenceDetails.
private void setPreferenceDetails(AccountConfig details) {
for (ConfigKey confKey : details.getKeys()) {
Preference pref = findPreference(confKey.key());
if (pref == null) {
continue;
}
if (!confKey.isTwoState()) {
String val = details.get(confKey);
((EditTextPreference) pref).setText(val);
if (pref instanceof PasswordPreference) {
StringBuilder tmp = new StringBuilder();
for (int i = 0; i < val.length(); ++i) {
tmp.append("*");
}
pref.setSummary(tmp.toString());
} else {
pref.setSummary(val);
}
} else {
((TwoStatePreference) pref).setChecked(details.getBool(confKey));
}
}
}
use of android.support.v7.preference.EditTextPreference in project MPW by shineangelic.
the class SettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.preferences);
// Crashlytics.getInstance().crash();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity());
PoolEnum mPool = PoolEnum.valueOf(prefs.getString("poolEnum", ""));
CurrencyEnum mCur = CurrencyEnum.valueOf(prefs.getString("curEnum", ""));
final android.support.v7.preference.SwitchPreferenceCompat globalNotifications = (SwitchPreferenceCompat) findPreference("pref_notify");
final android.support.v7.preference.EditTextPreference walletAddr = (EditTextPreference) findPreference("wallet_addr");
final android.support.v7.preference.SwitchPreferenceCompat service = (SwitchPreferenceCompat) findPreference("pref_sync");
final android.support.v7.preference.ListPreference listFreqPreference = (ListPreference) findPreference("pref_sync_freq");
final android.support.v7.preference.SwitchPreferenceCompat offlineNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_offline");
final android.support.v7.preference.SwitchPreferenceCompat blockNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_block");
final android.support.v7.preference.SwitchPreferenceCompat paymentNotifications = (SwitchPreferenceCompat) findPreference("pref_notify_payment");
// Service Enabled listener
Preference.OnPreferenceChangeListener listenerServ = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
// newValue is the value you choose
listFreqPreference.setEnabled((Boolean) newValue);
Boolean nv = (Boolean) newValue;
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(getActivity()));
dispatcher.cancelAll();
if (nv) {
Job myJob = MPWService.getJobUpdate(prefs, dispatcher, true);
int res = dispatcher.schedule(myJob);
if (res != dispatcher.SCHEDULE_RESULT_SUCCESS) {
Toast.makeText(getActivity(), "Cannot enable service. Is Play Services up to date? Notifications won't work", Toast.LENGTH_SHORT).show();
return false;
}
Log.w(Constants.TAG, "SERVICE ACTIVE, schedule res: " + res);
}
// firebase log event
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, nv.toString());
mFirebaseAnalytics.logEvent("service_active", bundle);
return true;
}
};
service.setOnPreferenceChangeListener(listenerServ);
// Service FREQ listener
Preference.OnPreferenceChangeListener listenerServF = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Integer nv = Integer.valueOf((String) newValue);
// newValue is the value you choose
Log.w(Constants.TAG, "Changed FREQ setting to: " + nv);
// pezza perche il val ancora non c'e
prefs.edit().putString("pref_sync_freq", "" + nv).apply();
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(getActivity()));
Job myJob = MPWService.getJobUpdate(prefs, dispatcher, true);
dispatcher.schedule(myJob);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "" + nv);
mFirebaseAnalytics.logEvent("service_freq", bundle);
return true;
}
};
listFreqPreference.setOnPreferenceChangeListener(listenerServF);
// Notification global
Preference.OnPreferenceChangeListener listener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Log.w(Constants.TAG, "Changed NOTIF setting to: " + newValue);
Boolean nv = (Boolean) newValue;
// newValue is the value you choose
blockNotifications.setEnabled(nv);
offlineNotifications.setEnabled(nv);
paymentNotifications.setEnabled(nv);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "" + nv);
mFirebaseAnalytics.logEvent("service_notifications", bundle);
return true;
}
};
globalNotifications.setOnPreferenceChangeListener(listener);
// Listener x controllo correttezza
walletAddr.setOnPreferenceChangeListener(new WalletPrefChangeListener(getActivity(), mPool, mCur));
walletAddr.setSummary(getString(R.string.wallet_info, mPool.toString(), mCur.toString()));
walletAddr.setDialogTitle(mPool.toString() + " Network Login");
}
use of android.support.v7.preference.EditTextPreference in project i2p.i2p-bote by i2p.
the class AdvancedPreferenceFragment method createPortField.
private static EditTextPreference createPortField(Context context) {
EditTextPreference p = new SummaryEditTextPreference(context);
p.setKey("i2pbote.i2cp.tcp.port");
p.setTitle(R.string.pref_title_i2cp_port);
p.setSummary("%s");
p.setDefaultValue("internal");
p.setEnabled(false);
return p;
}
use of android.support.v7.preference.EditTextPreference in project Rashr by DsLNeXuS.
the class SettingsFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preferences);
EditTextPreference recovery_path = (EditTextPreference) findPreference(App.PREF_KEY_RECOVERY_PATH);
recovery_path.setText(App.Preferences.getString(App.PREF_KEY_RECOVERY_PATH, null));
EditTextPreference kernel_path = (EditTextPreference) findPreference(App.PREF_KEY_KERNEL_PATH);
kernel_path.setText(App.Preferences.getString(App.PREF_KEY_KERNEL_PATH, null));
EditTextPreference device_name = (EditTextPreference) findPreference(App.PREF_KEY_DEVICE_NAME);
device_name.setText(App.Device.getName());
device_name.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
View v = getView();
if (v == null)
return true;
if (!newValue.toString().equals("")) {
Snackbar.make(v, R.string.please_restart, Snackbar.LENGTH_INDEFINITE).show();
}
return true;
}
});
Preference changelog = findPreference(App.PREF_KEY_CHANGELOG);
changelog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showChangelog(getContext());
return false;
}
});
Preference showlogs = findPreference(App.PREF_KEY_SHOW_LOGS);
showlogs.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showLogs();
return false;
}
});
Preference report = findPreference(App.PREF_KEY_REPORT);
report.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new ReportDialog(getActivity(), "").show();
return false;
}
});
Preference licenses = findPreference(App.PREF_KEY_LICENSES);
licenses.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new LicensesDialog.Builder(getContext()).setNotices(R.raw.licenses_notice).setIncludeOwnLicense(true).build().show();
return false;
}
});
Preference reset = findPreference(App.PREF_KEY_RESET_APP);
reset.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, true);
return true;
}
});
Preference clearCache = findPreference(App.PREF_KEY_CLEAR_CACHE);
clearCache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
final AlertDialog.Builder ConfirmationDialog = new AlertDialog.Builder(getContext());
ConfirmationDialog.setTitle(R.string.warning);
ConfirmationDialog.setMessage(R.string.delete_confirmation);
ConfirmationDialog.setPositiveButton(R.string.positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Common.deleteFolder(App.PathToCWM, false) || !Common.deleteFolder(App.PathToTWRP, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToCM, false) || !Common.deleteFolder(App.PathToPhilz, false) || !Common.deleteFolder(App.PathToStockRecovery, false) || !Common.deleteFolder(App.PathToStockKernel, false)) {
Toast.makeText(getActivity(), R.string.delete_failed, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity(), R.string.files_deleted, Toast.LENGTH_SHORT).show();
}
}
});
ConfirmationDialog.setNegativeButton(R.string.negative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
ConfirmationDialog.show();
return false;
}
});
}
use of android.support.v7.preference.EditTextPreference in project ring-client-android by savoirfairelinux.
the class SecurityAccountFragment method setDetails.
@Override
public void setDetails(AccountConfig config, String[] tlsMethods) {
for (int i = 0; i < tlsCategory.getPreferenceCount(); ++i) {
final Preference current = tlsCategory.getPreference(i);
final ConfigKey key = ConfigKey.fromString(current.getKey());
if (current instanceof TwoStatePreference) {
((TwoStatePreference) current).setChecked(config.getBool(key));
} else {
if (key == ConfigKey.TLS_CA_LIST_FILE) {
File crt = new File(config.get(ConfigKey.TLS_CA_LIST_FILE));
current.setSummary(crt.getName());
setFeedbackIcon(current);
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_PRIVATE_KEY_FILE) {
current.setSummary(new File(config.get(ConfigKey.TLS_PRIVATE_KEY_FILE)).getName());
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_CERTIFICATE_FILE) {
File pem = new File(config.get(ConfigKey.TLS_CERTIFICATE_FILE));
current.setSummary(pem.getName());
setFeedbackIcon(current);
checkForRSAKey();
current.setOnPreferenceClickListener(filePickerListener);
} else if (key == ConfigKey.TLS_METHOD) {
ListPreference listPref = (ListPreference) current;
String curVal = config.get(key);
listPref.setEntries(tlsMethods);
listPref.setEntryValues(tlsMethods);
listPref.setValue(curVal);
current.setSummary(curVal);
} else if (current instanceof EditTextPreference) {
String val = config.get(key);
((EditTextPreference) current).setText(val);
current.setSummary(val);
} else {
current.setSummary(config.get(key));
}
}
current.setOnPreferenceChangeListener(tlsListener);
}
}
Aggregations