use of android.support.v7.preference.TwoStatePreference 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.TwoStatePreference 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 android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.
the class GesturePreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.
@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
// Mock a TwoStatePreference
final TwoStatePreference preference = mock(TwoStatePreference.class);
// Set the setting to be enabled.
mController.mIsPrefEnabled = true;
// Run through updateState
mController.updateState(preference);
// Verify pref is checked (as setting is enabled).
verify(preference).setChecked(true);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.
the class BadgingNotificationPreferenceControllerTest method updateState_preferenceSetUncheckedWhenSettingIsOff.
@Test
public void updateState_preferenceSetUncheckedWhenSettingIsOff() {
final TwoStatePreference preference = mock(TwoStatePreference.class);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_BADGING, 0);
mController = new BadgingNotificationPreferenceController(context);
mController.updateState(preference);
verify(preference).setChecked(false);
}
use of android.support.v7.preference.TwoStatePreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ConfigureNotificationSettings method initPulse.
// === Pulse notification light ===
private void initPulse() {
final NotificationManager nm = mContext.getSystemService(NotificationManager.class);
final PreferenceCategory category = (PreferenceCategory) findPreference("lights");
mNotificationPulse = (TwoStatePreference) category.findPreference(KEY_NOTIFICATION_PULSE);
if (mNotificationPulse == null) {
Log.i(TAG, "Preference not found: " + KEY_NOTIFICATION_PULSE);
return;
}
if (!getResources().getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed) || !nm.doLightsSupport(NotificationManager.LIGHTS_PULSATING_LED)) {
category.removePreference(mNotificationPulse);
} else {
updatePulse();
mNotificationPulse.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean val = (Boolean) newValue;
return Settings.System.putInt(getContentResolver(), Settings.System.NOTIFICATION_LIGHT_PULSE, val ? 1 : 0);
}
});
}
}
Aggregations