From 00d978109b2171d44b96bebb7870ca572e281bf4 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Mon, 9 Sep 2019 17:18:59 +0200 Subject: [PATCH] Improve push notification display fallback. Fixes #1222 --- Habitica/res/values/strings.xml | 1 + .../ReceivedPrivateMessageLocalNotification.kt | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Habitica/res/values/strings.xml b/Habitica/res/values/strings.xml index 689c799cf..efbff46ee 100644 --- a/Habitica/res/values/strings.xml +++ b/Habitica/res/values/strings.xml @@ -805,6 +805,7 @@ App Theme You sent a %s You received %d messages from %s + You received %d messages Remove Transfer Ownership Remove Member diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ReceivedPrivateMessageLocalNotification.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ReceivedPrivateMessageLocalNotification.kt index 7c6479690..f62447497 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ReceivedPrivateMessageLocalNotification.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/helpers/notifications/ReceivedPrivateMessageLocalNotification.kt @@ -13,9 +13,6 @@ import com.habitrpg.android.habitica.receivers.LocalNotificationActionReceiver import net.pherth.android.emoji_library.EmojiParser -/** - * Created by keithholliday on 7/1/16. - */ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: String) : HabiticaLocalNotification(context, identifier) { override fun configureNotificationBuilder(data: MutableMap): NotificationCompat.Builder { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager @@ -33,8 +30,13 @@ class ReceivedPrivateMessageLocalNotification(context: Context, identifier: Stri var notification = super.configureNotificationBuilder(data) .setExtras(bundleOf(Pair("messages", oldMessages))) if (oldMessages.size > 1) { + val notificationTitle = if (data["senderName"] != null) { + context.getString(R.string.inbox_messages_title, oldMessages.size, data["senderName"]) + } else { + context.getString(R.string.inbox_messages_title_nosender, oldMessages.size) + } notification = notification - .setContentTitle(context.getString(R.string.inbox_messages_title, oldMessages.size, data["senderName"])) + .setContentTitle(notificationTitle) .setStyle(style) title = null }