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