use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class AppNotificationSettings method populateSingleChannelPrefs.
private void populateSingleChannelPrefs(PreferenceCategory groupCategory, final NotificationChannel channel) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && isChannelBlockable(mAppRow.systemApp, channel) && isChannelConfigurable(channel));
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
channelPref.setSummary(getImportanceSummary(channel));
Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), ChannelNotificationSettings.class.getName(), channelArgs, null, R.string.notification_channel_title, null, false, getMetricsCategory());
channelPref.setIntent(channelIntent);
channelPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
boolean value = (Boolean) o;
int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
channelPref.setSummary(getImportanceSummary(channel));
mBackend.updateChannel(mPkg, mUid, channel);
return true;
}
});
groupCategory.addPreference(channelPref);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiTetherPreferenceControllerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mLifecycle = new Lifecycle();
FakeFeatureFactory.setupForTest(mFeatureFactoryContext);
mPreference = new MasterSwitchPreference(RuntimeEnvironment.application);
when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn(mConnectivityManager);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
when(mScreen.findPreference(anyString())).thenReturn(mPreference);
when(mConnectivityManager.getTetherableWifiRegexs()).thenReturn(new String[] { "1", "2" });
mController = new WifiTetherPreferenceController(mContext, mLifecycle);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by crdroidandroid.
the class AppNotificationSettings method populateSingleChannelPrefs.
private void populateSingleChannelPrefs(PreferenceCategory groupCategory, final NotificationChannel channel) {
MasterSwitchPreference channelPref = new MasterSwitchPreference(getPrefContext());
channelPref.setSwitchEnabled(mSuspendedAppsAdmin == null && isChannelBlockable(mAppRow.systemApp, channel) && isChannelConfigurable(channel));
channelPref.setKey(channel.getId());
channelPref.setTitle(channel.getName());
channelPref.setChecked(channel.getImportance() != IMPORTANCE_NONE);
channelPref.setSummary(getImportanceSummary(channel));
Bundle channelArgs = new Bundle();
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, mUid);
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mPkg);
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
Intent channelIntent = Utils.onBuildStartFragmentIntent(getActivity(), ChannelNotificationSettings.class.getName(), channelArgs, null, R.string.notification_channel_title, null, false, getMetricsCategory());
channelPref.setIntent(channelIntent);
channelPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
boolean value = (Boolean) o;
int importance = value ? IMPORTANCE_LOW : IMPORTANCE_NONE;
channel.setImportance(importance);
channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
channelPref.setSummary(getImportanceSummary(channel));
mBackend.updateChannel(mPkg, mUid, channel);
return true;
}
});
groupCategory.addPreference(channelPref);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by crdroidandroid.
the class WifiTetherPreferenceControllerTest method start_wifiApOff_shouldSetInitialStateToOff.
@Test
public void start_wifiApOff_shouldSetInitialStateToOff() {
when(mWifiManager.getWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_DISABLED);
final BroadcastReceiver receiver = ReflectionHelpers.getField(mController, "mReceiver");
final MasterSwitchPreference pref = mock(MasterSwitchPreference.class);
when(mScreen.findPreference(anyString())).thenReturn(pref);
mController.displayPreference(mScreen);
mLifecycle.onStart();
assertThat(ShadowWifiTetherSwitchBarController.onStartCalled).isTrue();
verify(mContext).registerReceiver(eq(receiver), any(IntentFilter.class));
verify(pref).setChecked(false);
}
use of com.android.settings.widget.MasterSwitchPreference in project android_packages_apps_Settings by crdroidandroid.
the class WifiTetherPreferenceControllerTest method start_wifiApOn_shouldSetInitialStateToOn.
@Test
public void start_wifiApOn_shouldSetInitialStateToOn() {
when(mWifiManager.getWifiApState()).thenReturn(WifiManager.WIFI_AP_STATE_ENABLED);
final BroadcastReceiver receiver = ReflectionHelpers.getField(mController, "mReceiver");
final MasterSwitchPreference pref = mock(MasterSwitchPreference.class);
when(mScreen.findPreference(anyString())).thenReturn(pref);
mController.displayPreference(mScreen);
mLifecycle.onStart();
assertThat(ShadowWifiTetherSwitchBarController.onStartCalled).isTrue();
verify(mContext).registerReceiver(eq(receiver), any(IntentFilter.class));
verify(pref).setChecked(true);
}
Aggregations