use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DescriptionPreferenceControllerTest method testIsAvailable_notIfNoChannelGroupDesc.
@Test
public void testIsAvailable_notIfNoChannelGroupDesc() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
mController.onResume(appRow, null, group, null);
assertFalse(mController.isAvailable());
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BlockPreferenceControllerTest method testUpdateState_group.
@Test
public void testUpdateState_group() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
NotificationChannelGroup group = mock(NotificationChannelGroup.class);
when(group.isBlocked()).thenReturn(true);
mController.onResume(appRow, null, group, null);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = true;
mController.onResume(appRow, null, group, null);
when(group.isBlocked()).thenReturn(true);
mController.updateState(mPreference);
assertFalse(mSwitch.isChecked());
appRow.banned = false;
mController.onResume(appRow, null, group, null);
when(group.isBlocked()).thenReturn(false);
mController.updateState(mPreference);
assertTrue(mSwitch.isChecked());
}
use of android.app.NotificationChannelGroup in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationChannelSlice method getDisplayableChannels.
private List<NotificationChannel> getDisplayableChannels(NotificationBackend.AppRow appRow) {
final List<NotificationChannelGroup> channelGroupList = mNotificationBackend.getGroups(appRow.pkg, appRow.uid).getList();
final List<NotificationChannel> channels = channelGroupList.stream().flatMap(group -> group.getChannels().stream().filter(channel -> isChannelEnabled(group, channel, appRow))).collect(Collectors.toList());
// Pack the notification channel with notification sent state for sorting.
final List<NotificationChannelState> channelStates = new ArrayList<>();
for (NotificationChannel channel : channels) {
NotificationsSentState sentState = appRow.sentByChannel.get(channel.getId());
if (sentState == null) {
sentState = new NotificationsSentState();
}
channelStates.add(new NotificationChannelState(sentState, channel));
}
// Sort the notification channels with notification sent count by descending.
return channelStates.stream().sorted(CHANNEL_STATE_COMPARATOR).map(state -> state.getNotificationChannel()).limit(DEFAULT_EXPANDED_ROW_COUNT).collect(Collectors.toList());
}
use of android.app.NotificationChannelGroup in project Signal-Android by signalapp.
the class NotificationChannels method onCreate.
@TargetApi(26)
private static void onCreate(@NonNull Context context, @NonNull NotificationManager notificationManager) {
NotificationChannelGroup messagesGroup = new NotificationChannelGroup(CATEGORY_MESSAGES, context.getResources().getString(R.string.NotificationChannel_group_chats));
notificationManager.createNotificationChannelGroup(messagesGroup);
NotificationChannel messages = new NotificationChannel(getMessagesChannel(context), context.getString(R.string.NotificationChannel_channel_messages), NotificationManager.IMPORTANCE_HIGH);
NotificationChannel calls = new NotificationChannel(CALLS, context.getString(R.string.NotificationChannel_calls), NotificationManager.IMPORTANCE_HIGH);
NotificationChannel failures = new NotificationChannel(FAILURES, context.getString(R.string.NotificationChannel_failures), NotificationManager.IMPORTANCE_HIGH);
NotificationChannel backups = new NotificationChannel(BACKUPS, context.getString(R.string.NotificationChannel_backups), NotificationManager.IMPORTANCE_LOW);
NotificationChannel lockedStatus = new NotificationChannel(LOCKED_STATUS, context.getString(R.string.NotificationChannel_locked_status), NotificationManager.IMPORTANCE_LOW);
NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW);
NotificationChannel voiceNotes = new NotificationChannel(VOICE_NOTES, context.getString(R.string.NotificationChannel_voice_notes), NotificationManager.IMPORTANCE_LOW);
NotificationChannel joinEvents = new NotificationChannel(JOIN_EVENTS, context.getString(R.string.NotificationChannel_contact_joined_signal), NotificationManager.IMPORTANCE_DEFAULT);
NotificationChannel background = new NotificationChannel(BACKGROUND, context.getString(R.string.NotificationChannel_background_connection), getDefaultBackgroundChannelImportance(notificationManager));
NotificationChannel callStatus = new NotificationChannel(CALL_STATUS, context.getString(R.string.NotificationChannel_call_status), NotificationManager.IMPORTANCE_LOW);
messages.setGroup(CATEGORY_MESSAGES);
setVibrationEnabled(messages, SignalStore.settings().isMessageVibrateEnabled());
messages.setSound(SignalStore.settings().getMessageNotificationSound(), getRingtoneAudioAttributes());
setLedPreference(messages, SignalStore.settings().getMessageLedColor());
calls.setShowBadge(false);
backups.setShowBadge(false);
lockedStatus.setShowBadge(false);
other.setShowBadge(false);
setVibrationEnabled(other, false);
voiceNotes.setShowBadge(false);
joinEvents.setShowBadge(false);
background.setShowBadge(false);
callStatus.setShowBadge(false);
notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other, voiceNotes, joinEvents, background, callStatus));
if (BuildConfig.PLAY_STORE_DISABLED) {
NotificationChannel appUpdates = new NotificationChannel(APP_UPDATES, context.getString(R.string.NotificationChannel_app_updates), NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(appUpdates);
} else {
notificationManager.deleteNotificationChannel(APP_UPDATES);
}
}
use of android.app.NotificationChannelGroup in project xDrip by NightscoutFoundation.
the class NotificationChannels method getChan.
@TargetApi(26)
public static NotificationChannel getChan(NotificationCompat.Builder wip) {
final Notification temp = wip.build();
if (temp.getChannelId() == null)
return null;
// create generic audio attributes
final AudioAttributes generic_audio = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN).build();
// create notification channel for hashing purposes from the existing notification builder
NotificationChannel template = new NotificationChannel(temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT);
// mirror the notification parameters in the channel
template.setGroup(temp.getChannelId());
template.setVibrationPattern(wip.mNotification.vibrate);
template.setSound(wip.mNotification.sound, generic_audio);
template.setLightColor(wip.mNotification.ledARGB);
if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// get a nice string to identify the hash
final String mhash = my_text_hash(template);
// create another notification channel using the hash because id is immutable
final NotificationChannel channel = new NotificationChannel(template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT);
// mirror the settings from the previous channel
channel.setSound(template.getSound(), generic_audio);
if (addChannelGroup()) {
channel.setGroup(template.getGroup());
} else {
channel.setGroup(channel.getId());
}
channel.setDescription(template.getDescription());
channel.setVibrationPattern(template.getVibrationPattern());
template.setLightColor(wip.mNotification.ledARGB);
if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// create a group to hold this channel if one doesn't exist or update text
getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup())));
// create this channel if it doesn't exist or update text
getNotifManager().createNotificationChannel(channel);
return channel;
}
Aggregations