Search in sources :

Example 11 with SettingsMainSwitchBar

use of com.android.settings.widget.SettingsMainSwitchBar in project android_packages_apps_Settings by omnirom.

the class WifiCallingSettingsForSubTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    doReturn(mContext.getTheme()).when(mActivity).getTheme();
    mFragment = spy(new TestFragment());
    doReturn(mActivity).when(mFragment).getActivity();
    doReturn(mContext).when(mFragment).getContext();
    doReturn(mock(Intent.class)).when(mActivity).getIntent();
    doReturn(mContext.getResources()).when(mFragment).getResources();
    doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
    doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
    final Bundle bundle = new Bundle();
    when(mFragment.getArguments()).thenReturn(bundle);
    doNothing().when(mFragment).addPreferencesFromResource(anyInt());
    doReturn(mock(ListWithEntrySummaryPreference.class)).when(mFragment).findPreference(any());
    doReturn(mButtonWfcMode).when(mFragment).findPreference(BUTTON_WFC_MODE);
    doReturn(mButtonWfcRoamingMode).when(mFragment).findPreference(BUTTON_WFC_ROAMING_MODE);
    doNothing().when(mFragment).finish();
    doReturn(mView).when(mFragment).getView();
    mEmptyView = new TextView(mContext);
    doReturn(mEmptyView).when(mView).findViewById(android.R.id.empty);
    mSwitchBar = new SettingsMainSwitchBar(mContext);
    doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
    mQueryImsState = new MockWifiCallingQueryImsState(mContext, SUB_ID);
    doReturn(mImsMmTelManager).when(mFragment).getImsMmTelManager();
    mQueryImsState.setIsProvisionedOnDevice(true);
    mQueryImsState.setIsEnabledByPlatform(true);
    mQueryImsState.setIsEnabledByUser(true);
    mQueryImsState.setIsTtyOnVolteEnabled(true);
    doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED).when(mImsMmTelManager).getVoWiFiModeSetting();
    doReturn(ImsMmTelManager.WIFI_MODE_WIFI_PREFERRED).when(mImsMmTelManager).getVoWiFiRoamingModeSetting();
    doReturn(mBundle).when(sCarrierConfigManager).getConfigForSubId(anyInt());
    setDefaultCarrierConfigValues();
    doReturn(sCarrierConfigManager).when(mActivity).getSystemService(CarrierConfigManager.class);
    doReturn(mContext.getResources()).when(mFragment).getResourcesForSubId();
    doNothing().when(mFragment).startActivityForResult(any(Intent.class), anyInt());
    mFragment.onAttach(mContext);
    mFragment.onCreate(null);
    mFragment.onActivityCreated(null);
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent) TextView(android.widget.TextView) MockWifiCallingQueryImsState(com.android.settings.network.ims.MockWifiCallingQueryImsState) Before(org.junit.Before)

Example 12 with SettingsMainSwitchBar

use of com.android.settings.widget.SettingsMainSwitchBar in project android_packages_apps_Settings by omnirom.

the class WifiTetherSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (mUnavailable) {
        return;
    }
    // Assume we are in a SettingsActivity. This is only safe because we currently use
    // SettingsActivity as base for all preference fragments.
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
    switchBar.setTitle(getContext().getString(R.string.use_wifi_hotsopt_main_switch_title));
    mSwitchBarController = new WifiTetherSwitchBarController(activity, switchBar);
    getSettingsLifecycle().addObserver(mSwitchBarController);
    switchBar.show();
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) SettingsActivity(com.android.settings.SettingsActivity)

Example 13 with SettingsMainSwitchBar

use of com.android.settings.widget.SettingsMainSwitchBar in project android_packages_apps_Settings by omnirom.

the class UserSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Assume we are in a SettingsActivity. This is only safe because we currently use
    // SettingsActivity as base for all preference fragments.
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
    switchBar.setTitle(getContext().getString(R.string.multiple_users_main_switch_title));
    switchBar.show();
    mSwitchBarController = new MultiUserSwitchBarController(activity, new MainSwitchBarController(switchBar), this);
    getSettingsLifecycle().addObserver(mSwitchBarController);
}
Also used : MainSwitchBarController(com.android.settings.widget.MainSwitchBarController) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) SettingsActivity(com.android.settings.SettingsActivity)

Example 14 with SettingsMainSwitchBar

use of com.android.settings.widget.SettingsMainSwitchBar in project android_packages_apps_Settings by omnirom.

the class AutomaticStorageManagerSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mSwitchBar = new SettingsMainSwitchBar(mContext);
    mMetricsFeatureProvider = FakeFeatureFactory.setupForTest().getMetricsFeatureProvider();
    mPreference = new Preference(mContext);
    mController = new AutomaticStorageManagerSwitchBarController(mContext, mSwitchBar, mMetricsFeatureProvider, mPreference, mFragmentManager);
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) Preference(androidx.preference.Preference) Before(org.junit.Before)

Example 15 with SettingsMainSwitchBar

use of com.android.settings.widget.SettingsMainSwitchBar in project android_packages_apps_Settings by omnirom.

the class SmartAutoRotatePreferenceFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = spy(RuntimeEnvironment.application);
    ContentResolver mContentResolver = RuntimeEnvironment.application.getContentResolver();
    when(context.getPackageManager()).thenReturn(mPackageManager);
    when(context.getContentResolver()).thenReturn(mContentResolver);
    doReturn(PACKAGE_NAME).when(mPackageManager).getRotationResolverPackageName();
    doReturn(PackageManager.PERMISSION_GRANTED).when(mPackageManager).checkPermission(Manifest.permission.CAMERA, PACKAGE_NAME);
    final ResolveInfo resolveInfo = new ResolveInfoBuilder(PACKAGE_NAME).build();
    resolveInfo.serviceInfo = new ServiceInfo();
    when(mPackageManager.resolveService(any(), anyInt())).thenReturn(resolveInfo);
    mFragment = spy(new SmartAutoRotatePreferenceFragment());
    when(mActivity.getPackageManager()).thenReturn(mPackageManager);
    when(mFragment.getActivity()).thenReturn(mActivity);
    when(mFragment.getContext()).thenReturn(context);
    doReturn(mView).when(mFragment).getView();
    when(mFragment.findPreference(AUTO_ROTATE_SWITCH_PREFERENCE_ID)).thenReturn(mRotateSwitchPreference);
    mSwitchBar = spy(new SettingsMainSwitchBar(context));
    when(mActivity.getSwitchBar()).thenReturn(mSwitchBar);
    doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) ResolveInfoBuilder(com.android.settings.testutils.ResolveInfoBuilder) ContentResolver(android.content.ContentResolver) Before(org.junit.Before)

Aggregations

SettingsMainSwitchBar (com.android.settings.widget.SettingsMainSwitchBar)16 SettingsActivity (com.android.settings.SettingsActivity)8 Before (org.junit.Before)6 MainSwitchBarController (com.android.settings.widget.MainSwitchBarController)4 Context (android.content.Context)2 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 ServiceInfo (android.content.pm.ServiceInfo)1 Bundle (android.os.Bundle)1 PersistableBundle (android.os.PersistableBundle)1 TextView (android.widget.TextView)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Preference (androidx.preference.Preference)1 LocationSwitchBarController (com.android.settings.location.LocationSwitchBarController)1 BluetoothTetherPreferenceController (com.android.settings.network.BluetoothTetherPreferenceController)1 EthernetTetherPreferenceController (com.android.settings.network.EthernetTetherPreferenceController)1 TetherEnabler (com.android.settings.network.TetherEnabler)1 UsbTetherPreferenceController (com.android.settings.network.UsbTetherPreferenceController)1