From 31f3cb3391505d9774a6ae1a4cb71d77b323805b Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 19 Jan 2023 09:21:19 +0100 Subject: [PATCH] Fixed chat message replies in notification --- .../notifications/NotificationsManager.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index 803db3cef..ab0367863 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -675,7 +675,7 @@ class NotificationsManager(private val context: Context) { for (message in messages) { if (message.isRead || message.isOutgoing) continue val friend = coreContext.contactsManager.findContactByAddress(message.fromAddress) - val notifiableMessage = getNotifiableMessage(message, friend, notifiable) + val notifiableMessage = getNotifiableMessage(message, friend) notifiable.messages.add(notifiableMessage) } @@ -703,7 +703,7 @@ class NotificationsManager(private val context: Context) { return notifiable } - private fun getNotifiableMessage(message: ChatMessage, friend: Friend?, notifiable: Notifiable): NotifiableMessage { + private fun getNotifiableMessage(message: ChatMessage, friend: Friend?): NotifiableMessage { val roundPicture = ImageUtils.getRoundBitmapFromUri(context, friend?.getThumbnailUri()) val displayName = friend?.name ?: LinphoneUtils.getDisplayName(message.fromAddress) var text = "" @@ -825,10 +825,7 @@ class NotificationsManager(private val context: Context) { var lastPerson: Person? = null for (message in notifiable.messages) { val friend = message.friend - val person = if (message.isOutgoing) - me - else - getPerson(friend, message.sender, message.senderAvatar) + val person = getPerson(friend, message.sender, message.senderAvatar) if (!message.isOutgoing) { // We don't want to see our own avatar @@ -840,15 +837,19 @@ class NotificationsManager(private val context: Context) { } } + val senderPerson = if (message.isOutgoing) null else person // Use null for ourselves val msg = if (corePreferences.hideChatMessageContentInNotification) { - NotificationCompat.MessagingStyle.Message(AppUtils.getString(R.string.chat_message_notification_hidden_content), message.time, person) + NotificationCompat.MessagingStyle.Message(AppUtils.getString(R.string.chat_message_notification_hidden_content), message.time, senderPerson) } else { - val tmp = NotificationCompat.MessagingStyle.Message(message.message, message.time, person) + val tmp = NotificationCompat.MessagingStyle.Message(message.message, message.time, senderPerson) if (message.filePath != null) tmp.setData(message.fileMime, message.filePath) tmp } style.addMessage(msg) + if (message.isOutgoing) { + style.addHistoricMessage(msg) + } } style.conversationTitle = if (notifiable.isGroup) notifiable.groupTitle else lastPerson?.name