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:
James Rich
2026-02-14 10:30:06 -06:00
committed by GitHub
parent 0f03492ac6
commit 4fb5546699

View File

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