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;
}
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);
}
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();
}
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");
}
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;
}
});
}
Aggregations