feat: show unique messaging notifications per contact (#1381)

* Show unique notifications per contact

Instead of a single notification for all messages, each contact now has its own, unique notification. This uses the `NotificationCompat.MessagingStyle` and the contact's name to create distinct notifications, enhancing message organization.

* feat: Add notification tap action to open contacts tab

This is done by:
- Adding an intent extra to the notification with the contact key for future use to navigate to the message thread.
- Adding a new action to the MainActivity to handle the intent.
- Updating the message notification to include the intent.

* Open message notification to the correct conversation

Adds an extra to the message notification intent to open the correct conversation. This ensures that when a user taps on a message notification, they are taken to the conversation with the sender of that message.
This commit is contained in:
James Rich 2024-11-04 16:05:39 -06:00 committed by GitHub
parent eea62e6533
commit 80e915a36c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 14 deletions

View file

@ -247,7 +247,7 @@ class MeshService : Service(), Logging {
startPacketQueue()
}
private fun updateMessageNotification(dataPacket: DataPacket) {
private fun updateMessageNotification(contactKey: String, dataPacket: DataPacket) {
val message: String = when (dataPacket.dataType) {
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> dataPacket.text!!
Portnums.PortNum.WAYPOINT_APP_VALUE -> {
@ -256,7 +256,7 @@ class MeshService : Service(), Logging {
else -> return
}
serviceNotifications.updateMessageNotification(getSenderName(dataPacket), message)
serviceNotifications.updateMessageNotification(contactKey, getSenderName(dataPacket), message)
}
override fun onCreate() {
@ -627,7 +627,7 @@ class MeshService : Service(), Logging {
packetRepository.get().apply {
insert(packetToSave)
val isMuted = getContactSettings(contactKey).isMuted
if (updateNotification && !isMuted) updateMessageNotification(dataPacket)
if (updateNotification && !isMuted) updateMessageNotification(contactKey, dataPacket)
}
}
}