mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Implements#4054 - Add channel name to channel message notification (#4069)
This commit is contained in:
parent
55754b1612
commit
250caa7c99
3 changed files with 28 additions and 4 deletions
|
|
@ -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
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue