Search in sources :

Example 16 with SwitchPreference

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();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 17 with SwitchPreference

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));
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 18 with SwitchPreference

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);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 19 with SwitchPreference

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("");
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Test(org.junit.Test)

Example 20 with SwitchPreference

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);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)139 Test (org.junit.Test)61 Before (org.junit.Before)29 Intent (android.content.Intent)9 Preference (androidx.preference.Preference)6 ComponentName (android.content.ComponentName)5 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)5 ListPreference (androidx.preference.ListPreference)4 PreferenceScreen (androidx.preference.PreferenceScreen)4 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)4 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Context (android.content.Context)2 ServiceInfo (android.content.pm.ServiceInfo)2 KeyboardLayout (android.hardware.input.KeyboardLayout)2 Parcel (android.os.Parcel)2 PersistableBundle (android.os.PersistableBundle)2 RemoteException (android.os.RemoteException)2 TelephonyManager (android.telephony.TelephonyManager)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 MultiSelectListPreference (androidx.preference.MultiSelectListPreference)2