Search in sources :

Example 31 with SwitchBar

use of com.android.settings.widget.SwitchBar in project android_packages_apps_Settings by SudaMod.

the class AutomaticStorageManagerSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mContext = spy(RuntimeEnvironment.application);
    mSwitchBar = new SwitchBar(mContext);
    Context fakeContextForFakeProvider = mock(Context.class, RETURNS_DEEP_STUBS);
    FakeFeatureFactory.setupForTest(fakeContextForFakeProvider);
    FeatureFactory featureFactory = FakeFeatureFactory.getFactory(fakeContextForFakeProvider);
    mMetricsFeatureProvider = featureFactory.getMetricsFeatureProvider();
    mPreference = new Preference(mContext);
    mController = new AutomaticStorageManagerSwitchBarController(mContext, mSwitchBar, mMetricsFeatureProvider, mPreference, mFragmentManager);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Context(android.content.Context) Preference(android.support.v7.preference.Preference) FeatureFactory(com.android.settings.overlay.FeatureFactory) FakeFeatureFactory(com.android.settings.testutils.FakeFeatureFactory) Before(org.junit.Before)

Example 32 with SwitchBar

use of com.android.settings.widget.SwitchBar in project platform_packages_apps_Settings by BlissRoms.

the class DevelopmentSwitchBarControllerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    mLifecycle = new Lifecycle();
    mSwitchBar = new SwitchBar(RuntimeEnvironment.application);
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) Lifecycle(com.android.settingslib.core.lifecycle.Lifecycle) Before(org.junit.Before)

Example 33 with SwitchBar

use of com.android.settings.widget.SwitchBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class GameDriverDashboard method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final SettingsActivity activity = (SettingsActivity) getActivity();
    final SwitchBar switchBar = activity.getSwitchBar();
    final GameDriverGlobalSwitchBarController switchBarController = new GameDriverGlobalSwitchBarController(activity, new SwitchBarController(switchBar));
    getSettingsLifecycle().addObserver(switchBarController);
    switchBar.show();
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) SettingsActivity(com.android.settings.SettingsActivity) SwitchBarController(com.android.settings.widget.SwitchBarController)

Example 34 with SwitchBar

use of com.android.settings.widget.SwitchBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 SwitchBar switchBar = activity.getSwitchBar();
    mSwitchBarController = new MultiUserSwitchBarController(activity, new SwitchBarController(switchBar), this);
    getSettingsLifecycle().addObserver(mSwitchBarController);
    switchBar.show();
}
Also used : SwitchBar(com.android.settings.widget.SwitchBar) SettingsActivity(com.android.settings.SettingsActivity) SwitchBarController(com.android.settings.widget.SwitchBarController)

Example 35 with SwitchBar

use of com.android.settings.widget.SwitchBar in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BlockPreferenceController method updateState.

public void updateState(Preference preference) {
    LayoutPreference pref = (LayoutPreference) preference;
    pref.setSelectable(false);
    SwitchBar bar = pref.findViewById(R.id.switch_bar);
    if (bar != null) {
        bar.setSwitchBarText(R.string.notification_switch_label, R.string.notification_switch_label);
        bar.show();
        try {
            bar.addOnSwitchChangeListener(this);
        } catch (IllegalStateException e) {
        // an exception is thrown if you try to add the listener twice
        }
        bar.setDisabledByAdmin(mAdmin);
        if (mChannel != null && !isChannelBlockable()) {
            bar.setEnabled(false);
        }
        if (mChannelGroup != null && !isChannelGroupBlockable()) {
            bar.setEnabled(false);
        }
        if (mChannel == null && mAppRow.systemApp && (!mAppRow.banned || mAppRow.lockedImportance)) {
            bar.setEnabled(false);
        }
        if (mChannel != null) {
            bar.setChecked(!mAppRow.banned && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
        } else if (mChannelGroup != null) {
            bar.setChecked(!mAppRow.banned && !mChannelGroup.isBlocked());
        } else {
            bar.setChecked(!mAppRow.banned);
        }
    }
}
Also used : LayoutPreference(com.android.settingslib.widget.LayoutPreference) SwitchBar(com.android.settings.widget.SwitchBar)

Aggregations

SwitchBar (com.android.settings.widget.SwitchBar)37 Before (org.junit.Before)26 SwitchBarController (com.android.settings.widget.SwitchBarController)12 SettingsActivity (com.android.settings.SettingsActivity)10 Lifecycle (com.android.settingslib.core.lifecycle.Lifecycle)8 Context (android.content.Context)7 Preference (android.support.v7.preference.Preference)6 FeatureFactory (com.android.settings.overlay.FeatureFactory)6 FakeFeatureFactory (com.android.settings.testutils.FakeFeatureFactory)6 SubscriptionInfo (android.telephony.SubscriptionInfo)1 Preference (androidx.preference.Preference)1 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)1 LayoutPreference (com.android.settingslib.widget.LayoutPreference)1 ShadowApplication (org.robolectric.shadows.ShadowApplication)1