mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-05-13 01:05:55 -04:00
feat(notifications): navigate to node details on tap (#4558)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
@@ -436,7 +436,7 @@ constructor(
|
||||
}
|
||||
|
||||
override fun showNewNodeSeenNotification(node: NodeEntity) {
|
||||
val notification = createNewNodeSeenNotification(node.user.short_name, node.user.long_name)
|
||||
val notification = createNewNodeSeenNotification(node.user.short_name, node.user.long_name, node.num)
|
||||
notificationManager.notify(node.num, notification)
|
||||
}
|
||||
|
||||
@@ -615,10 +615,10 @@ constructor(
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun createNewNodeSeenNotification(name: String, message: String): Notification {
|
||||
private fun createNewNodeSeenNotification(name: String, message: String, nodeNum: Int): Notification {
|
||||
val title = getString(Res.string.new_node_seen).format(name)
|
||||
val builder =
|
||||
commonBuilder(NotificationType.NewNode)
|
||||
commonBuilder(NotificationType.NewNode, createOpenNodeDetailIntent(nodeNum))
|
||||
.setCategory(Notification.CATEGORY_STATUS)
|
||||
.setAutoCancel(true)
|
||||
.setContentTitle(title)
|
||||
@@ -636,7 +636,7 @@ constructor(
|
||||
val batteryLevel = node.deviceTelemetry?.device_metrics?.battery_level ?: 0
|
||||
val message = getString(Res.string.low_battery_message).format(node.longName, batteryLevel)
|
||||
|
||||
return commonBuilder(type)
|
||||
return commonBuilder(type, createOpenNodeDetailIntent(node.num))
|
||||
.setCategory(Notification.CATEGORY_STATUS)
|
||||
.setOngoing(true)
|
||||
.setOnlyAlertOnce(true)
|
||||
@@ -692,6 +692,19 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun createOpenNodeDetailIntent(nodeNum: Int): PendingIntent {
|
||||
val deepLinkUri = "$DEEP_LINK_BASE_URI/node?destNum=$nodeNum".toUri()
|
||||
val deepLinkIntent =
|
||||
Intent(Intent.ACTION_VIEW, deepLinkUri, context, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||||
}
|
||||
|
||||
return TaskStackBuilder.create(context).run {
|
||||
addNextIntentWithParentStack(deepLinkIntent)
|
||||
getPendingIntent(nodeNum, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createReplyAction(contactKey: String): NotificationCompat.Action {
|
||||
val replyLabel = getString(Res.string.reply)
|
||||
val remoteInput = RemoteInput.Builder(KEY_TEXT_REPLY).setLabel(replyLabel).build()
|
||||
|
||||
Reference in New Issue
Block a user