use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by SudaMod.
the class AppNotificationSettings method populateChannelList.
private void populateChannelList() {
if (!mChannelGroups.isEmpty()) {
// If there's anything in mChannelGroups, we've called populateChannelList twice.
// Clear out existing channels and log.
Log.w(TAG, "Notification channel group posted twice to settings - old size " + mChannelGroups.size() + ", new size " + mChannelGroupList.size());
for (Preference p : mChannelGroups) {
getPreferenceScreen().removePreference(p);
}
}
if (mChannelGroupList.isEmpty()) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
groupCategory.setTitle(R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
Preference empty = new Preference(getPrefContext());
empty.setTitle(R.string.no_channels);
empty.setEnabled(false);
groupCategory.addPreference(empty);
} else {
for (NotificationChannelGroup group : mChannelGroupList) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
if (group.getId() == null) {
groupCategory.setTitle(mChannelGroupList.size() > 1 ? R.string.notification_channels_other : R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
groupCategory.setKey(group.getId());
}
groupCategory.setOrderingAsAdded(true);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
final List<NotificationChannel> channels = group.getChannels();
Collections.sort(channels, mChannelComparator);
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
populateSingleChannelPrefs(groupCategory, channel);
}
}
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
if (deletedChannelCount > 0 && getPreferenceScreen().findPreference(KEY_DELETED) == null) {
mDeletedChannels = new FooterPreference(getPrefContext());
mDeletedChannels.setSelectable(false);
mDeletedChannels.setTitle(getResources().getQuantityString(R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
mDeletedChannels.setEnabled(false);
mDeletedChannels.setKey(KEY_DELETED);
mDeletedChannels.setOrder(ORDER_LAST);
getPreferenceScreen().addPreference(mDeletedChannels);
}
}
updateDependents(mAppRow.banned);
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChannelListPreferenceController method populateGroupList.
private void populateGroupList() {
for (NotificationChannelGroup group : mChannelGroupList) {
PreferenceCategory groupCategory = new PreferenceCategory(mContext);
groupCategory.setOrderingAsAdded(true);
mPreference.addPreference(groupCategory);
if (group.getId() == null) {
if (mChannelGroupList.size() > 1) {
groupCategory.setTitle(R.string.notification_channels_other);
}
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
groupCategory.setKey(group.getId());
populateGroupToggle(groupCategory, group);
}
if (!group.isBlocked()) {
final List<NotificationChannel> channels = group.getChannels();
Collections.sort(channels, mChannelComparator);
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
populateSingleChannelPrefs(groupCategory, channel, group.isBlocked());
}
}
}
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationPreferenceControllerTest method isAvailable_notIfChannelBlocked.
@Test
public void isAvailable_notIfChannelBlocked() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
NotificationChannel channel = mock(NotificationChannel.class);
when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);
mController.onResume(appRow, channel, group, null);
assertFalse(mController.isAvailable());
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationPreferenceControllerTest method testOnResume.
@Test
public void testOnResume() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannel channel = mock(NotificationChannel.class);
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
RestrictedLockUtils.EnforcedAdmin admin = mock(RestrictedLockUtils.EnforcedAdmin.class);
mController.onResume(appRow, channel, group, admin);
assertEquals(appRow, mController.mAppRow);
assertEquals(channel, mController.mChannel);
assertEquals(group, mController.mChannelGroup);
assertEquals(admin, mController.mAdmin);
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationPreferenceControllerTest method testIsChannelGroupBlockable_nonSystemBlockable.
@Test
public void testIsChannelGroupBlockable_nonSystemBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.systemApp = false;
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(false);
mController.onResume(appRow, null, group, null);
assertTrue(mController.isChannelGroupBlockable());
}
Aggregations