From 30927ac6db6caeb206850934bbaa9a08203e28de Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 20 Mar 2024 16:56:52 +0100 Subject: [PATCH] Should prevent going to the wrong conversation when multiple message notifications are still visible --- .../notifications/NotificationsManager.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt index d33424833..988120b86 100644 --- a/app/src/main/java/org/linphone/notifications/NotificationsManager.kt +++ b/app/src/main/java/org/linphone/notifications/NotificationsManager.kt @@ -249,7 +249,10 @@ class NotificationsManager @MainThread constructor(private val context: Context) "$TAG After removing original reaction notification there is still messages, updating notification" ) val me = coreContext.contactsManager.getMePerson(chatRoom.localAddress) - val pendingIntent = getChatRoomPendingIntent(chatRoom) + val pendingIntent = getChatRoomPendingIntent( + chatRoom, + notifiable.notificationId + ) val notification = createMessageNotification( notifiable, pendingIntent, @@ -599,7 +602,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) if (notifiable.messages.isNotEmpty()) { val me = coreContext.contactsManager.getMePerson(chatRoom.localAddress) - val pendingIntent = getChatRoomPendingIntent(chatRoom) + val pendingIntent = getChatRoomPendingIntent(chatRoom, notifiable.notificationId) val notification = createMessageNotification( notifiable, pendingIntent, @@ -664,7 +667,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) if (notifiable.messages.isNotEmpty()) { val me = coreContext.contactsManager.getMePerson(chatRoom.localAddress) - val pendingIntent = getChatRoomPendingIntent(chatRoom) + val pendingIntent = getChatRoomPendingIntent(chatRoom, notifiable.notificationId) val notification = createMessageNotification( notifiable, pendingIntent, @@ -1053,7 +1056,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) notifiable.messages.add(reply) val chatRoom = message.chatRoom - val pendingIntent = getChatRoomPendingIntent(chatRoom) + val pendingIntent = getChatRoomPendingIntent(chatRoom, notifiable.notificationId) val me = coreContext.contactsManager.getMePerson(chatRoom.localAddress) val notification = createMessageNotification( notifiable, @@ -1216,7 +1219,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) } @WorkerThread - private fun getChatRoomPendingIntent(chatRoom: ChatRoom): PendingIntent { + private fun getChatRoomPendingIntent(chatRoom: ChatRoom, notificationId: Int): PendingIntent { val args = Bundle() args.putBoolean("Chat", true) args.putString("RemoteSipUri", chatRoom.peerAddress.asStringUriOnly()) @@ -1230,7 +1233,7 @@ class NotificationsManager @MainThread constructor(private val context: Context) } ) getPendingIntent( - 0, + notificationId, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, args // Need to pass args here too for Remote & Local SIP URIs )!!