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