use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiWakeupPreferenceControllerTest method handlePreferenceTreeClick_nonMatchingKey_shouldDoNothing.
@Test
public void handlePreferenceTreeClick_nonMatchingKey_shouldDoNothing() {
final SwitchPreference pref = new SwitchPreference(mContext);
assertThat(mController.handlePreferenceTreeClick(pref)).isFalse();
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiWakeupPreferenceControllerTest method updateState_preferenceSetUncheckedWhenWakeupSettingDisabled.
@Test
public void updateState_preferenceSetUncheckedWhenWakeupSettingDisabled() {
final SwitchPreference preference = new SwitchPreference(mContext);
Settings.Global.putInt(mContext.getContentResolver(), WIFI_WAKEUP_ENABLED, 0);
mController.updateState(preference);
assertThat(preference.isChecked()).isFalse();
assertThat(preference.getSummary()).isEqualTo(mContext.getString(R.string.wifi_wakeup_summary));
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UseOpenWifiPreferenceControllerTest method updateState_noScorer_preferenceDisabled_summaryChanged.
@Test
public void updateState_noScorer_preferenceDisabled_summaryChanged() {
when(mNetworkScoreManager.getAllValidScorers()).thenReturn(new ArrayList<>());
createController();
final SwitchPreference preference = mock(SwitchPreference.class);
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE, sEnableActivityComponent.getPackageName());
mController.updateState(preference);
verify(preference).setChecked(false);
verify(preference).setSummary(R.string.use_open_wifi_automatically_summary_scoring_disabled);
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UseOpenWifiPreferenceControllerTest method onPreferenceChange_matchingKeyAndAvailable_disableShouldUpdateSetting.
@Test
public void onPreferenceChange_matchingKeyAndAvailable_disableShouldUpdateSetting() {
setupScorers(Lists.newArrayList(sAppData, sAppDataNoActivity));
Settings.Global.putString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE, sEnableActivityComponent.getPackageName());
createController();
final SwitchPreference pref = new SwitchPreference(mContext);
pref.setKey(mController.getPreferenceKey());
assertThat(mController.onPreferenceChange(pref, null)).isTrue();
assertThat(Settings.Global.getString(mContext.getContentResolver(), USE_OPEN_WIFI_PACKAGE)).isEqualTo("");
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotifyOpenNetworksPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (!(preference instanceof SwitchPreference)) {
return;
}
final SwitchPreference notifyOpenNetworks = (SwitchPreference) preference;
notifyOpenNetworks.setChecked(Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, 0) == 1);
}
Aggregations