From 4296085d6577059acfb2fc8d3bbfa3279774f53f Mon Sep 17 00:00:00 2001 From: Alan Evans Date: Tue, 8 Sep 2020 10:05:29 -0300 Subject: [PATCH] Show no notification actions when the message content is hidden. Fixes #9928 --- .../notifications/DefaultMessageNotifier.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java b/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java index 1cc60e1f3..664d8ca7c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java @@ -57,6 +57,7 @@ import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.messages.IncomingMessageObserver; import org.thoughtcrime.securesms.mms.Slide; import org.thoughtcrime.securesms.mms.SlideDeck; +import org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference; import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.recipients.RecipientUtil; import org.thoughtcrime.securesms.service.KeyCachingService; @@ -346,9 +347,10 @@ public class DefaultMessageNotifier implements MessageNotifier { return; } - SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context)); - List notifications = notificationState.getNotifications(); - Recipient recipient = notifications.get(0).getRecipient(); + NotificationPrivacyPreference notificationPrivacy = TextSecurePreferences.getNotificationPrivacy(context); + SingleRecipientNotificationBuilder builder = new SingleRecipientNotificationBuilder(context, notificationPrivacy); + List notifications = notificationState.getNotifications(); + Recipient recipient = notifications.get(0).getRecipient(); int notificationId; if (Build.VERSION.SDK_INT >= 23) { @@ -371,7 +373,10 @@ public class DefaultMessageNotifier implements MessageNotifier { boolean isSingleNotificationContactJoined = notifications.size() == 1 && notifications.get(0).isJoin(); - if (!KeyCachingService.isLocked(context) && RecipientUtil.isMessageRequestAccepted(context, recipient.resolve())) { + if (notificationPrivacy.isDisplayMessage() && + !KeyCachingService.isLocked(context) && + RecipientUtil.isMessageRequestAccepted(context, recipient.resolve())) + { ReplyMethod replyMethod = ReplyMethod.forRecipient(context, recipient); builder.addActions(notificationState.getMarkAsReadIntent(context, notificationId), @@ -422,8 +427,9 @@ public class DefaultMessageNotifier implements MessageNotifier { return; } - MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context)); - List notifications = notificationState.getNotifications(); + NotificationPrivacyPreference notificationPrivacy = TextSecurePreferences.getNotificationPrivacy(context); + MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, notificationPrivacy); + List notifications = notificationState.getNotifications(); builder.setMessageCount(notificationState.getMessageCount(), notificationState.getThreadCount()); builder.setMostRecentSender(notifications.get(0).getIndividualRecipient()); @@ -438,7 +444,9 @@ public class DefaultMessageNotifier implements MessageNotifier { long timestamp = notifications.get(0).getTimestamp(); if (timestamp != 0) builder.setWhen(timestamp); - builder.addActions(notificationState.getMarkAsReadIntent(context, NotificationIds.MESSAGE_SUMMARY)); + if (notificationPrivacy.isDisplayMessage()) { + builder.addActions(notificationState.getMarkAsReadIntent(context, NotificationIds.MESSAGE_SUMMARY)); + } ListIterator iterator = notifications.listIterator(notifications.size());