@Nullable private Notification getNotification() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) notificationManager.createNotificationChannel(new NotificationChannel(Alarmio.NOTIFICATION_CHANNEL_TIMERS, "Timers", NotificationManager.IMPORTANCE_DEFAULT)); NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String string = ""; for (TimerData timer : timers) { if (!timer.isSet()) continue; String time = FormatUtils.formatMillis(timer.getRemainingMillis()); time = time.substring(0, time.length() - 3); inboxStyle.addLine(time); string += "/" + time + "/"; } if (notificationString != null && notificationString.equals(string)) return null; notificationString = string; Intent intent = new Intent(this, MainActivity.class); if (timers.size() == 1) intent.putExtra(TimerReceiver.EXTRA_TIMER_ID, 0); return new NotificationCompat.Builder(this, Alarmio.NOTIFICATION_CHANNEL_TIMERS) .setSmallIcon(R.drawable.ic_timer_notification) .setContentTitle(getString(R.string.title_set_timer)) .setContentText("") .setContentIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)) .setStyle(inboxStyle) .build(); }
private NotificationCompat.InboxStyle makeTorrentsMoveInboxStyle(List<String> torrentsMoveSuccess, List<String> torrentsMoveFailed) { NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); boolean successNotEmpty = !torrentsMoveSuccess.isEmpty(); if (successNotEmpty) { inboxStyle.addLine(getString(R.string.torrents_move_inbox_successfully)); for (String name : torrentsMoveSuccess) { inboxStyle.addLine(name); } } if (!torrentsMoveFailed.isEmpty()) { if (successNotEmpty) { inboxStyle.addLine("\n"); } inboxStyle.addLine(getString(R.string.torrents_move_inbox_failed)); for (String name : torrentsMoveFailed) { inboxStyle.addLine(name); } } return inboxStyle; }
private static void createInboxNotification( Context ctx, Account account, List<NotificationEntity> entities, boolean feedback) { NotificationEntity lastEntity = entities.get(entities.size() - 1); NotificationCompat.Builder builder = createNotificationBuilder(ctx, account, lastEntity, feedback); NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle() .setBigContentTitle(lastEntity.mNotification.subject) .setSummaryText(getNotificationSubText(account)); for (NotificationEntity entity : entities) { style.addLine(getContentMessage(ctx, entity, false, true)); } builder.setStyle(style) .setNumber(entities.size()) .setGroup(NOTIFICATION_KEY_GROUP + account.getAccountHash()); publishNotification(ctx, builder.build(), lastEntity.mGroupId); }
inboxStyle.addLine(summary);
inboxStyle.addLine(summary);