use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by LineageOS.
the class BadgingNotificationPreferenceControllerTest method updateState_preferenceSetCheckedWhenSettingIsOn.
@Test
public void updateState_preferenceSetCheckedWhenSettingIsOn() {
final TwoStatePreference preference = mock(TwoStatePreference.class);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.Secure.putInt(context.getContentResolver(), NOTIFICATION_BADGING, 1);
mController = new BadgingNotificationPreferenceController(context);
mController.updateState(preference);
verify(preference).setChecked(true);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by LineageOS.
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 android_packages_apps_Settings by LineageOS.
the class TimeFormatPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (!(preference instanceof TwoStatePreference)) {
return;
}
((TwoStatePreference) preference).setChecked(is24Hour());
final Calendar now = Calendar.getInstance();
mDummyDate.setTimeZone(now.getTimeZone());
// We use December 31st because it's unambiguous when demonstrating the date format.
// We use 13:00 so we can demonstrate the 12/24 hour options.
mDummyDate.set(now.get(Calendar.YEAR), 11, 31, 13, 0, 0);
final Date dummyDate = mDummyDate.getTime();
preference.setSummary(DateFormat.getTimeFormat(mContext).format(dummyDate));
}
use of android.support.v7.preference.TwoStatePreference in project vlc-android by videolan.
the class PreferencesExtensionFragment method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(Preference preference) {
String key = preference.getKey();
if (key == null || !key.startsWith(mExtensionKey))
return false;
if (key.equals(mExtensionKey)) {
SwitchPreferenceCompat switchPreference = (SwitchPreferenceCompat) preference;
mSettings.edit().putBoolean(key, switchPreference.isChecked()).apply();
if (switchPreference.isChecked()) {
for (Preference checkbox : preferences) checkbox.setEnabled(true);
} else {
for (Preference checkbox : preferences) {
((CheckBoxPreference) checkbox).setChecked(false);
mSettings.edit().putBoolean(checkbox.getKey(), false).apply();
checkbox.setEnabled(false);
}
}
} else if (key.endsWith("_" + ExtensionsManager.ANDROID_AUTO_SUFFIX)) {
mSettings.edit().putBoolean(preference.getKey(), ((TwoStatePreference) preference).isChecked()).apply();
}
return super.onPreferenceTreeClick(preference);
}
use of android.support.v7.preference.TwoStatePreference in project android_packages_apps_Settings by omnirom.
the class VibrateWhenRingPreferenceControllerTest method updateState_settingIsOn_preferenceShouldBeChecked.
@Test
public void updateState_settingIsOn_preferenceShouldBeChecked() {
final TwoStatePreference preference = mock(TwoStatePreference.class);
final Context context = ShadowApplication.getInstance().getApplicationContext();
Settings.System.putInt(context.getContentResolver(), VIBRATE_WHEN_RINGING, 1);
mController = new VibrateWhenRingPreferenceController(context);
mController.updateState(preference);
verify(preference).setChecked(true);
}
Aggregations