use of cx.ring.model.ConfigKey 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 cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.
the class SecurityAccountFragment method onActivityResult.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_CANCELED) {
return;
}
Uri uri = data.getData();
if (uri == null) {
return;
}
File myFile = new File(uri.getEncodedPath());
ConfigKey key = null;
Preference preference;
switch(requestCode) {
case SELECT_CA_LIST_RC:
preference = tlsCategory.findPreference(ConfigKey.TLS_CA_LIST_FILE.key());
preference.setSummary(myFile.getName());
key = ConfigKey.TLS_CA_LIST_FILE;
setFeedbackIcon(preference);
break;
case SELECT_PRIVATE_KEY_RC:
tlsCategory.findPreference(ConfigKey.TLS_PRIVATE_KEY_FILE.key()).setSummary(myFile.getName());
key = ConfigKey.TLS_PRIVATE_KEY_FILE;
break;
case SELECT_CERTIFICATE_RC:
preference = tlsCategory.findPreference(ConfigKey.TLS_CERTIFICATE_FILE.key());
preference.setSummary(myFile.getName());
key = ConfigKey.TLS_CERTIFICATE_FILE;
setFeedbackIcon(preference);
checkForRSAKey();
break;
default:
break;
}
presenter.fileActivityResult(key, myFile.getAbsolutePath());
}
use of cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.
the class AdvancedAccountFragment method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final ConfigKey key = ConfigKey.fromString(preference.getKey());
presenter.preferenceChanged(key, newValue);
if (preference instanceof TwoStatePreference) {
presenter.twoStatePreferenceChanged(key, newValue);
} else if (preference instanceof PasswordPreference) {
presenter.passwordPreferenceChanged(key, newValue);
preference.setSummary(TextUtils.isEmpty(newValue.toString()) ? "" : "******");
} else {
presenter.preferenceChanged(key, newValue);
preference.setSummary(newValue.toString());
}
return true;
}
use of cx.ring.model.ConfigKey in project ring-client-android by savoirfairelinux.
the class MediaPreferenceFragment method setPreferenceDetails.
private void setPreferenceDetails(AccountConfig details) {
for (ConfigKey confKey : details.getKeys()) {
Preference pref = findPreference(confKey.key());
if (pref != null) {
if (pref instanceof TwoStatePreference) {
((TwoStatePreference) pref).setChecked(details.getBool(confKey));
} else if (confKey == ConfigKey.ACCOUNT_DTMF_TYPE) {
pref.setDefaultValue(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
pref.setSummary(details.get(confKey).contentEquals("overrtp") ? "RTP" : "SIP");
} else if (confKey == ConfigKey.RINGTONE_PATH) {
File tmp = new File(details.get(confKey));
pref.setSummary(tmp.getName());
} else {
pref.setSummary(details.get(confKey));
}
}
}
}
use of cx.ring.model.ConfigKey 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