Implements#4054 - Add channel name to channel message notification (#4069)

This commit is contained in:
Camerin Figueroa 2025-12-27 08:02:16 -05:00 committed by GitHub
parent 55754b1612
commit 250caa7c99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 4 deletions

View file

@ -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
},
)
}

View file

@ -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)

View file

@ -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)