From 250caa7c99f7a19cc128762846799fb6744a2c3f Mon Sep 17 00:00:00 2001 From: Camerin Figueroa Date: Sat, 27 Dec 2025 08:02:16 -0500 Subject: [PATCH] Implements#4054 - Add channel name to channel message notification (#4069) --- .../com/geeksville/mesh/service/MeshService.kt | 7 +++++++ .../service/MeshServiceNotificationsImpl.kt | 17 ++++++++++++++--- .../core/service/MeshServiceNotifications.kt | 8 +++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index f533104b5..0e14bf926 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -374,11 +374,18 @@ class MeshService : Service() { else -> return } + serviceNotifications.updateMessageNotification( contactKey, getSenderName(dataPacket), message, isBroadcast = dataPacket.to == DataPacket.ID_BROADCAST, + channelName = + if (dataPacket.to == DataPacket.ID_BROADCAST) { + channelSet.settingsList[dataPacket.channel].name + } else { + null + }, ) } diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotificationsImpl.kt b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotificationsImpl.kt index 336e463da..b56fc0791 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotificationsImpl.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshServiceNotificationsImpl.kt @@ -271,8 +271,14 @@ class MeshServiceNotificationsImpl @Inject constructor(@ApplicationContext priva return notification } - override fun updateMessageNotification(contactKey: String, name: String, message: String, isBroadcast: Boolean) { - val notification = createMessageNotification(contactKey, name, message, isBroadcast) + override fun updateMessageNotification( + contactKey: String, + name: String, + message: String, + isBroadcast: Boolean, + channelName: String?, + ) { + val notification = createMessageNotification(contactKey, name, message, isBroadcast, channelName) // Use a consistent, unique ID for each message conversation. notificationManager.notify(contactKey.hashCode(), notification) } @@ -339,12 +345,17 @@ class MeshServiceNotificationsImpl @Inject constructor(@ApplicationContext priva name: String, message: String, isBroadcast: Boolean, + channelName: String? = null, ): Notification { val type = if (isBroadcast) NotificationType.BroadcastMessage else NotificationType.DirectMessage val builder = commonBuilder(type, createOpenMessageIntent(contactKey)) val person = Person.Builder().setName(name).build() - val style = NotificationCompat.MessagingStyle(person).addMessage(message, System.currentTimeMillis(), person) + val style = + NotificationCompat.MessagingStyle(person) + .setGroupConversation(channelName != null) + .setConversationTitle(channelName) + .addMessage(message, System.currentTimeMillis(), person) builder .setCategory(Notification.CATEGORY_MESSAGE) diff --git a/core/service/src/main/kotlin/org/meshtastic/core/service/MeshServiceNotifications.kt b/core/service/src/main/kotlin/org/meshtastic/core/service/MeshServiceNotifications.kt index 4d4c346f3..14dc2e17d 100644 --- a/core/service/src/main/kotlin/org/meshtastic/core/service/MeshServiceNotifications.kt +++ b/core/service/src/main/kotlin/org/meshtastic/core/service/MeshServiceNotifications.kt @@ -31,7 +31,13 @@ interface MeshServiceNotifications { fun updateServiceStateNotification(summaryString: String?, telemetry: TelemetryProtos.Telemetry?): Notification - fun updateMessageNotification(contactKey: String, name: String, message: String, isBroadcast: Boolean) + fun updateMessageNotification( + contactKey: String, + name: String, + message: String, + isBroadcast: Boolean, + channelName: String?, + ) fun showAlertNotification(contactKey: String, name: String, alert: String)