use of android.support.v7.preference.TwoStatePreference 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 android.support.v7.preference.TwoStatePreference 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);
}
}
use of android.support.v7.preference.TwoStatePreference 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.TwoStatePreference in project android_packages_apps_Settings by omnirom.
the class AssistFlashScreenPreferenceController method updatePreference.
private void updatePreference() {
if (mPreference == null || !(mPreference instanceof TwoStatePreference)) {
return;
}
if (isAvailable()) {
if (mScreen.findPreference(getPreferenceKey()) == null) {
// add it if it's not on scree
mScreen.addPreference(mPreference);
}
} else {
mScreen.removePreference(mPreference);
}
ComponentName assistant = getCurrentAssist();
boolean isContextChecked = AssistContextPreferenceController.isChecked(mContext);
mPreference.setEnabled(isContextChecked && isPreInstalledAssistant(assistant));
((TwoStatePreference) mPreference).setChecked(willShowFlash(assistant));
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.
the class VibrateWhenRingPreferenceControllerTest method updateState_settingIsOff_preferenceShouldNotBeChecked.
@Test
public void updateState_settingIsOff_preferenceShouldNotBeChecked() {
final TwoStatePreference preference = mock(TwoStatePreference.class);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 0);
mController = new VibrateWhenRingPreferenceController(context);
mController.updateState(preference);
verify(preference).setChecked(false);
}
Aggregations