@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 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 inboxStyle = new NotificationCompat.InboxStyle() .setBigContentTitle(inboxStyleEmailAppData.getBigContentTitle()) .setSummaryText(inboxStyleEmailAppData.getSummaryText()); inboxStyle.addLine(summary);
InboxStyle inboxStyle = new NotificationCompat.InboxStyle() .setBigContentTitle(inboxStyleEmailAppData.getBigContentTitle()) .setSummaryText(inboxStyleEmailAppData.getSummaryText()); inboxStyle.addLine(summary);
private NotificationCompat.InboxStyle makeDetailNotifyInboxStyle() NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); ++downloadingCount; template = getString(R.string.downloading_torrent_notify_template); inboxStyle.addLine( String.format( template, inboxStyle.addLine( String.format( template, inboxStyle.addLine( String.format( template, inboxStyle.setBigContentTitle(String.format( titleTemplate, downloadingCount, TorrentEngine.getInstance().tasksCount())); inboxStyle.setSummaryText((isNetworkOnline ? getString(R.string.network_online) : getString(R.string.network_offline)));
@TargetApi(Build.VERSION_CODES.N) private static void createSummaryGroupNotification( Context ctx, Account account, Set<String> notifications, boolean feedback) { int notificationId = FowlerNollVo.fnv1_32(account.getAccountHash().getBytes()).intValue(); NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx, account.getAccountHash()) .setContentTitle(getNotificationSubText(account)) .setSubText(getNotificationSubText(account)) .setSmallIcon(R.drawable.ic_stat_notify) .setAutoCancel(true) .setCategory(NotificationCompat.CATEGORY_SOCIAL) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setDefaults(feedback ? NotificationCompat.DEFAULT_ALL : 0) .setColor(ContextCompat.getColor(ctx, R.color.primaryDark)) .setContentIntent( getViewAccountChangesPendingIntent(ctx, account, notificationId)) .setDeleteIntent( getDeleteAccountNotificationPendingIntent(ctx, account, notificationId)) .setOnlyAlertOnce(true) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC); NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle() .setSummaryText(getNotificationSubText(account)); builder.setStyle(style) .setNumber(notifications.size()) .setGroupSummary(true) .setGroup(NOTIFICATION_KEY_GROUP + account.getAccountHash()); publishNotification(ctx, builder.build(), notificationId); }
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; }