private static void sendSingleThreadNotification( Context context, MasterSecret masterSecret, NotificationState notificationState, boolean signal) { if (notificationState.getNotifications().isEmpty()) { ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .cancel(NOTIFICATION_ID); return; } SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder( context, masterSecret, SMSSecurePreferences.getNotificationPrivacy(context)); List<NotificationItem> notifications = notificationState.getNotifications(); builder.setSender(notifications.get(0).getIndividualRecipient()); builder.setMessageCount(notificationState.getMessageCount()); builder.setPrimaryMessageBody( notifications.get(0).getText(), notifications.get(0).getSlideDeck()); builder.setContentIntent(notifications.get(0).getPendingIntent(context)); long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); builder.addActions( masterSecret, notificationState.getMarkAsReadIntent(context), notificationState.getQuickReplyIntent(context, notifications.get(0).getRecipients()), notificationState.getWearableReplyIntent(context, notifications.get(0).getRecipients())); ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size()); while (iterator.hasPrevious()) { builder.addMessageBody(iterator.previous().getText()); } if (signal) { builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate()); builder.setTicker( notifications.get(0).getIndividualRecipient(), notifications.get(0).getText()); } ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)) .notify(NOTIFICATION_ID, builder.build()); }