From a370f086c0dcbd93b4c89abc410fb9f4708e2945 Mon Sep 17 00:00:00 2001 From: FeuRenard Date: Mon, 1 Aug 2016 00:15:49 +0200 Subject: [PATCH] Respect privacy settings on ticker content for Android <5 Fixes #5517 Closes #5592 // FREEBIE --- res/values/strings.xml | 3 +++ .../notifications/AbstractNotificationBuilder.java | 11 +++++++++++ .../securesms/notifications/MessageNotifier.java | 3 ++- .../SingleRecipientNotificationBuilder.java | 10 ---------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index fd5d26b20d..3ca3ab0073 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -6,6 +6,9 @@ Delete Please wait... + + New message + Currently: %s You haven\'t set a passphrase yet! diff --git a/src/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java index 28f255020f..1bd3c1558d 100644 --- a/src/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java @@ -10,6 +10,7 @@ import android.support.v4.app.NotificationCompat; import android.text.SpannableStringBuilder; import android.text.TextUtils; +import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.database.RecipientPreferenceDatabase; import org.thoughtcrime.securesms.preferences.NotificationPrivacyPreference; import org.thoughtcrime.securesms.recipients.Recipient; @@ -61,6 +62,16 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui } } + public void setTicker(@NonNull Recipient recipient, @Nullable CharSequence message) { + if (privacy.isDisplayMessage()) { + setTicker(getStyledMessage(recipient, message)); + } else if (privacy.isDisplayContact()) { + setTicker(getStyledMessage(recipient, context.getString(R.string.AbstractNotificationBuilder_new_message))); + } else { + setTicker(context.getString(R.string.AbstractNotificationBuilder_new_message)); + } + } + private String[] parseBlinkPattern(String blinkPattern, String blinkPatternCustom) { if (blinkPattern.equals("custom")) blinkPattern = blinkPatternCustom; diff --git a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java index 6f6ba38b32..7c0a349b41 100644 --- a/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java +++ b/src/org/thoughtcrime/securesms/notifications/MessageNotifier.java @@ -278,7 +278,8 @@ public class MessageNotifier { if (signal) { builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate()); - builder.setTicker(notifications.get(0).getText()); + builder.setTicker(notifications.get(0).getIndividualRecipient(), + notifications.get(0).getText()); } ((NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE)) diff --git a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java index 169028e1b0..093269eb0a 100644 --- a/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java +++ b/src/org/thoughtcrime/securesms/notifications/SingleRecipientNotificationBuilder.java @@ -150,16 +150,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil } } - public void setTicker(@NonNull Recipient recipient, @Nullable CharSequence message) { - if (privacy.isDisplayMessage()) { - setTicker(getStyledMessage(recipient, message)); - } else if (privacy.isDisplayContact()) { - setTicker(getStyledMessage(recipient, context.getString(R.string.SingleRecipientNotificationBuilder_new_message))); - } else { - setTicker(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)); - } - } - @Override public Notification build() { if (privacy.isDisplayMessage()) {