Search in sources :

Example 6 with SettingsMainSwitchBar

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

the class AllInOneTetherSettings 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 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null) {
        adapter.getProfileProxy(activity.getApplicationContext(), mProfileServiceListener, BluetoothProfile.PAN);
    }
    final SettingsMainSwitchBar mainSwitch = activity.getSwitchBar();
    mTetherEnabler = new TetherEnabler(activity, new MainSwitchBarController(mainSwitch), mBluetoothPan);
    getSettingsLifecycle().addObserver(mTetherEnabler);
    use(UsbTetherPreferenceController.class).setTetherEnabler(mTetherEnabler);
    use(BluetoothTetherPreferenceController.class).setTetherEnabler(mTetherEnabler);
    use(EthernetTetherPreferenceController.class).setTetherEnabler(mTetherEnabler);
    use(WifiTetherDisablePreferenceController.class).setTetherEnabler(mTetherEnabler);
    mainSwitch.show();
}
Also used : MainSwitchBarController(com.android.settings.widget.MainSwitchBarController) EthernetTetherPreferenceController(com.android.settings.network.EthernetTetherPreferenceController) WifiTetherDisablePreferenceController(com.android.settings.network.WifiTetherDisablePreferenceController) TetherEnabler(com.android.settings.network.TetherEnabler) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) BluetoothTetherPreferenceController(com.android.settings.network.BluetoothTetherPreferenceController) UsbTetherPreferenceController(com.android.settings.network.UsbTetherPreferenceController) BluetoothAdapter(android.bluetooth.BluetoothAdapter)

Example 7 with SettingsMainSwitchBar

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

the class ToggleFeaturePreferenceFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
    switchBar.hide();
    updatePreferenceOrder();
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) SettingsActivity(com.android.settings.SettingsActivity)

Example 8 with SettingsMainSwitchBar

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

the class ProfileSelectLocationFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SettingsMainSwitchBar switchBar = activity.getSwitchBar();
    switchBar.setTitle(getContext().getString(R.string.location_settings_primary_switch_title));
    final LocationSwitchBarController switchBarController = new LocationSwitchBarController(activity, switchBar, getSettingsLifecycle());
    switchBar.show();
}
Also used : LocationSwitchBarController(com.android.settings.location.LocationSwitchBarController) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) SettingsActivity(com.android.settings.SettingsActivity)

Example 9 with SettingsMainSwitchBar

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

the class DevelopmentSettingsDashboardFragmentTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = RuntimeEnvironment.application;
    SettingsMainSwitchBar switchBar = new SettingsMainSwitchBar(mContext);
    mSwitch = switchBar.getSwitch();
    mDashboard = spy(new DevelopmentSettingsDashboardFragment());
    ReflectionHelpers.setField(mDashboard, "mSwitchBar", switchBar);
    mShadowUserManager = Shadow.extract(mContext.getSystemService(Context.USER_SERVICE));
    mShadowUserManager.setIsAdminUser(true);
}
Also used : SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) Before(org.junit.Before)

Example 10 with SettingsMainSwitchBar

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

the class DevelopmentSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    final Context context = RuntimeEnvironment.application;
    ShadowUserManager.getShadow().setIsAdminUser(true);
    mLifecycleOwner = () -> mLifecycle;
    mLifecycle = new Lifecycle(mLifecycleOwner);
    mSwitchBar = new SettingsMainSwitchBar(context);
    when(mSettings.getContext()).thenReturn(context);
}
Also used : Context(android.content.Context) SettingsMainSwitchBar(com.android.settings.widget.SettingsMainSwitchBar) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) 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