use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class UseOpenWifiPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (!(preference instanceof SwitchPreference)) {
return;
}
final SwitchPreference useOpenWifiPreference = (SwitchPreference) preference;
boolean isScorerSet = mNetworkScoreManager.getActiveScorerPackage() != null;
boolean doesActiveScorerSupportFeature = mEnableUseWifiComponentName != null;
useOpenWifiPreference.setChecked(isSettingEnabled());
useOpenWifiPreference.setVisible(isAvailable());
useOpenWifiPreference.setEnabled(isScorerSet && doesActiveScorerSupportFeature);
if (!isScorerSet) {
useOpenWifiPreference.setSummary(R.string.use_open_wifi_automatically_summary_scoring_disabled);
} else if (!doesActiveScorerSupportFeature) {
useOpenWifiPreference.setSummary(R.string.use_open_wifi_automatically_summary_scorer_unsupported_disabled);
} else {
useOpenWifiPreference.setSummary(R.string.use_open_wifi_automatically_summary);
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiWakeupPreferenceController method handlePreferenceTreeClick.
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!TextUtils.equals(preference.getKey(), KEY_ENABLE_WIFI_WAKEUP)) {
return false;
}
if (!(preference instanceof SwitchPreference)) {
return false;
}
// Toggle wifi-wakeup setting between 1/0 based on its current state, and some other checks.
if (isWifiWakeupAvailable()) {
setWifiWakeupEnabled(false);
} else {
if (!mLocationManager.isLocationEnabled()) {
final Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mFragment.startActivityForResult(intent, WIFI_WAKEUP_REQUEST_CODE);
return true;
} else if (!getWifiScanningEnabled()) {
showScanningDialog();
} else {
setWifiWakeupEnabled(true);
}
}
updateState(mPreference);
return true;
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiWakeupPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
if (!(preference instanceof SwitchPreference)) {
return;
}
final SwitchPreference enableWifiWakeup = (SwitchPreference) preference;
enableWifiWakeup.setChecked(isWifiWakeupAvailable());
if (!mLocationManager.isLocationEnabled()) {
preference.setSummary(getNoLocationSummary());
} else {
preference.setSummary(R.string.wifi_wakeup_summary);
}
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InstantAppWebActionPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mContentResolver = mContext.getContentResolver();
mController = new InstantAppWebActionPreferenceController(mContext, PREF_KEY);
mSwitchPreference = new SwitchPreference(mContext);
mEnableEphemeralFeature = Settings.Global.getInt(mContentResolver, ENABLE_EPHEMERAL_FEATURE, 1);
}
use of androidx.preference.SwitchPreference in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BillingCycleSettingsTest method onCreate_emptyArguments_shouldSetDefaultNetworkTemplate.
@Test
public void onCreate_emptyArguments_shouldSetDefaultNetworkTemplate() {
final BillingCycleSettings billingCycleSettings = spy(new BillingCycleSettings());
when(billingCycleSettings.getContext()).thenReturn(mContext);
when(billingCycleSettings.getArguments()).thenReturn(Bundle.EMPTY);
final FragmentActivity activity = mock(FragmentActivity.class);
when(billingCycleSettings.getActivity()).thenReturn(activity);
final Resources.Theme theme = mContext.getTheme();
when(activity.getTheme()).thenReturn(theme);
doNothing().when(billingCycleSettings).onCreatePreferences(any(Bundle.class), nullable(String.class));
when(mContext.getSystemService(Context.NETWORK_POLICY_SERVICE)).thenReturn(mNetworkPolicyManager);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
when(mConnectivityManager.isNetworkSupported(anyInt())).thenReturn(true);
final SwitchPreference preference = mock(SwitchPreference.class);
when(billingCycleSettings.findPreference(anyString())).thenReturn(preference);
final FooterPreferenceMixinCompat footer = mock(FooterPreferenceMixinCompat.class);
ReflectionHelpers.setField(billingCycleSettings, "mFooterPreferenceMixin", footer);
when(footer.createFooterPreference()).thenReturn(mock(FooterPreference.class));
billingCycleSettings.onCreate(Bundle.EMPTY);
assertThat(billingCycleSettings.mNetworkTemplate).isNotNull();
}
Aggregations