Search in sources :

Example 86 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class VideoCallingPreferenceControllerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    doReturn(mTelephonyManager).when(mContext).getSystemService(TelephonyManager.class);
    doReturn(mCarrierConfigManager).when(mContext).getSystemService(CarrierConfigManager.class);
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
    mCarrierConfig = new PersistableBundle();
    mCarrierConfig.putBoolean(CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, true);
    doReturn(mCarrierConfig).when(mCarrierConfigManager).getConfigForSubId(SUB_ID);
    mQueryImsState = new MockVtQueryImsState(mContext, SUB_ID);
    mQueryImsState.setIsEnabledByUser(true);
    mQueryVoLteState = new MockVolteQueryImsState(mContext, SUB_ID);
    mQueryVoLteState.setIsEnabledByUser(true);
    mPreference = new SwitchPreference(mContext);
    mController = spy(new VideoCallingPreferenceController(mContext, "wifi_calling"));
    mController.init(SUB_ID);
    doReturn(mQueryImsState).when(mController).queryImsState(anyInt());
    doReturn(mQueryVoLteState).when(mController).queryVoLteState(anyInt());
    mPreference.setKey(mController.getPreferenceKey());
    mQueryImsState.setIsEnabledByPlatform(true);
    mQueryImsState.setIsProvisionedOnDevice(true);
    mQueryImsState.setServiceStateReady(true);
    doReturn(true).when(mTelephonyManager).isDataEnabled();
    mController.mCallState = TelephonyManager.CALL_STATE_IDLE;
}
Also used : PersistableBundle(android.os.PersistableBundle) SwitchPreference(androidx.preference.SwitchPreference) MockVolteQueryImsState(com.android.settings.network.ims.MockVolteQueryImsState) MockVtQueryImsState(com.android.settings.network.ims.MockVtQueryImsState) Before(org.junit.Before)

Example 87 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ApnEditorTest method setMockPreference.

private void setMockPreference(Context context) {
    mApnEditorUT.mName = new EditTextPreference(context);
    mApnEditorUT.mApn = new EditTextPreference(context);
    mApnEditorUT.mProxy = new EditTextPreference(context);
    mApnEditorUT.mPort = new EditTextPreference(context);
    mApnEditorUT.mUser = new EditTextPreference(context);
    mApnEditorUT.mServer = new EditTextPreference(context);
    mApnEditorUT.mPassword = new EditTextPreference(context);
    mApnEditorUT.mMmsc = new EditTextPreference(context);
    mApnEditorUT.mMcc = new EditTextPreference(context);
    mApnEditorUT.mMnc = new EditTextPreference(context);
    mApnEditorUT.mMmsProxy = new EditTextPreference(context);
    mApnEditorUT.mMmsPort = new EditTextPreference(context);
    mApnEditorUT.mAuthType = new ListPreference(context);
    mApnEditorUT.mApnType = new EditTextPreference(context);
    mApnEditorUT.mProtocol = new ListPreference(context);
    mApnEditorUT.mRoamingProtocol = new ListPreference(context);
    mApnEditorUT.mCarrierEnabled = new SwitchPreference(context);
    mApnEditorUT.mBearerMulti = new MultiSelectListPreference(context);
    mApnEditorUT.mMvnoType = new ListPreference(context);
    mApnEditorUT.mMvnoMatchData = new EditTextPreference(context);
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) EditTextPreference(androidx.preference.EditTextPreference) MultiSelectListPreference(androidx.preference.MultiSelectListPreference) ListPreference(androidx.preference.ListPreference)

Example 88 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ChargingSoundPreferenceControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    when(mSetting.getActivity()).thenReturn(mActivity);
    when(mActivity.getContentResolver()).thenReturn(mContentResolver);
    mPreference = new SwitchPreference(RuntimeEnvironment.application);
    mController = new ChargingSoundPreferenceController(mContext, mSetting, null);
    when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
    doReturn(mScreen).when(mSetting).getPreferenceScreen();
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 89 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class TogglePreferenceControllerTest method setUp.

@Before
public void setUp() {
    mContext = ApplicationProvider.getApplicationContext();
    mPreference = new SwitchPreference(mContext);
    mToggleController = new FakeToggle(mContext, "key");
}
Also used : SwitchPreference(androidx.preference.SwitchPreference) Before(org.junit.Before)

Example 90 with SwitchPreference

use of androidx.preference.SwitchPreference in project android_packages_apps_Settings by omnirom.

the class ApprovalPreferenceController method updateState.

@Override
public void updateState(Preference pref) {
    final SwitchPreference preference = (SwitchPreference) pref;
    final CharSequence label = mPkgInfo.applicationInfo.loadLabel(mPm);
    preference.setChecked(isServiceEnabled(mCn));
    preference.setOnPreferenceChangeListener((p, newValue) -> {
        final boolean access = (Boolean) newValue;
        if (!access) {
            if (!isServiceEnabled(mCn)) {
                // already disabled
                return true;
            }
            // show a friendly dialog
            new FriendlyWarningDialogFragment().setServiceInfo(mCn, label, mParent).show(mParent.getFragmentManager(), "friendlydialog");
            return false;
        } else {
            if (isServiceEnabled(mCn)) {
                // already enabled
                return true;
            }
            // show a scary dialog
            new ScaryWarningDialogFragment().setServiceInfo(mCn, label, mParent).show(mParent.getFragmentManager(), "dialog");
            return false;
        }
    });
}
Also used : SwitchPreference(androidx.preference.SwitchPreference)

Aggregations

SwitchPreference (androidx.preference.SwitchPreference)299 Test (org.junit.Test)125 Before (org.junit.Before)68 Intent (android.content.Intent)17 Preference (androidx.preference.Preference)17 ComponentName (android.content.ComponentName)10 A2dpProfile (com.android.settingslib.bluetooth.A2dpProfile)10 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)8 PbapServerProfile (com.android.settingslib.bluetooth.PbapServerProfile)8 ListPreference (androidx.preference.ListPreference)7 PreferenceScreen (androidx.preference.PreferenceScreen)7 RemoteException (android.os.RemoteException)6 PreferenceCategory (androidx.preference.PreferenceCategory)6 HashSet (java.util.HashSet)6 Context (android.content.Context)5 Parcel (android.os.Parcel)5 VisibleForTesting (androidx.annotation.VisibleForTesting)5 BluetoothDevice (android.bluetooth.BluetoothDevice)4 ChangeConfig (android.compat.Compatibility.ChangeConfig)4 ServiceInfo (android.content.pm.ServiceInfo)4