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 95db51b2a..25fc91a82 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -1326,6 +1326,9 @@ class MeshService : Service() { p.data.status = m p.routingError = routingError p.data.relayNode = relayNode + if (isAck) { + p.data.relays += 1 + } packetRepository.get().update(p) } serviceBroadcasts.broadcastMessageStatus(requestId, m) diff --git a/app/src/main/java/com/geeksville/mesh/ui/connections/components/CurrentlyConnectedInfo.kt b/app/src/main/java/com/geeksville/mesh/ui/connections/components/CurrentlyConnectedInfo.kt index 69d56a9c0..595d7994e 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/connections/components/CurrentlyConnectedInfo.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/connections/components/CurrentlyConnectedInfo.kt @@ -64,6 +64,7 @@ import kotlin.time.Duration.Companion.seconds private const val RSSI_DELAY = 10 private const val RSSI_TIMEOUT = 5 +@Suppress("LongMethod", "LoopWithTooManyJumpStatements") @Composable fun CurrentlyConnectedInfo( node: Node, diff --git a/core/database/src/main/kotlin/org/meshtastic/core/database/entity/Packet.kt b/core/database/src/main/kotlin/org/meshtastic/core/database/entity/Packet.kt index 833a0b6a0..27801bf63 100644 --- a/core/database/src/main/kotlin/org/meshtastic/core/database/entity/Packet.kt +++ b/core/database/src/main/kotlin/org/meshtastic/core/database/entity/Packet.kt @@ -54,6 +54,7 @@ data class PacketEntity( replyId = data.replyId, viaMqtt = node.viaMqtt, relayNode = data.relayNode, + relays = data.relays, ) } } diff --git a/core/database/src/main/kotlin/org/meshtastic/core/database/model/Message.kt b/core/database/src/main/kotlin/org/meshtastic/core/database/model/Message.kt index 888f60096..0d5610fd7 100644 --- a/core/database/src/main/kotlin/org/meshtastic/core/database/model/Message.kt +++ b/core/database/src/main/kotlin/org/meshtastic/core/database/model/Message.kt @@ -87,6 +87,7 @@ data class Message( val originalMessage: Message? = null, val viaMqtt: Boolean = false, val relayNode: Int? = null, + val relays: Int = 0, ) { fun getStatusStringRes(): Pair { val title = if (routingError > 0) Res.string.error else Res.string.message_delivery_status diff --git a/core/model/src/main/kotlin/org/meshtastic/core/model/DataPacket.kt b/core/model/src/main/kotlin/org/meshtastic/core/model/DataPacket.kt index 8d3626a3b..a9b0743b1 100644 --- a/core/model/src/main/kotlin/org/meshtastic/core/model/DataPacket.kt +++ b/core/model/src/main/kotlin/org/meshtastic/core/model/DataPacket.kt @@ -62,6 +62,7 @@ data class DataPacket( var rssi: Int = 0, var replyId: Int? = null, // If this is a reply to a previous message, this is the ID of that message var relayNode: Int? = null, + var relays: Int = 0, ) : Parcelable { /** If there was an error with this message, this string describes what was wrong. */ diff --git a/core/strings/src/commonMain/composeResources/values/strings.xml b/core/strings/src/commonMain/composeResources/values/strings.xml index e0737f6d3..f181a67f0 100644 --- a/core/strings/src/commonMain/composeResources/values/strings.xml +++ b/core/strings/src/commonMain/composeResources/values/strings.xml @@ -954,6 +954,10 @@ " https://meshtastic.org/docs/legal/privacy/" Unset - 0 Relayed by: %1$s + + Heard %1$d Relay + Heard %1$d Relays + Preserve Favorites? USB Devices diff --git a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/DeliveryInfoDialog.kt b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/DeliveryInfoDialog.kt index 6e7f703a4..83d1da2a0 100644 --- a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/DeliveryInfoDialog.kt +++ b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/DeliveryInfoDialog.kt @@ -30,18 +30,21 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.StringResource +import org.jetbrains.compose.resources.pluralStringResource import org.jetbrains.compose.resources.stringResource import org.meshtastic.core.strings.Res import org.meshtastic.core.strings.close -import org.meshtastic.core.strings.relayed_by +import org.meshtastic.core.strings.relays import org.meshtastic.core.strings.resend +@Suppress("UnusedParameter") @Composable fun DeliveryInfo( title: StringResource, resendOption: Boolean, text: StringResource? = null, relayNodeName: String? = null, + relays: Int = 0, onConfirm: (() -> Unit) = {}, onDismiss: () -> Unit = {}, ) = AlertDialog( @@ -75,9 +78,9 @@ fun DeliveryInfo( style = MaterialTheme.typography.bodyMedium, ) } - relayNodeName?.let { + if (relays != 0) { Text( - text = stringResource(Res.string.relayed_by, it), + text = pluralStringResource(Res.plurals.relays, relays, relays), modifier = Modifier.padding(top = 8.dp), textAlign = TextAlign.Center, style = MaterialTheme.typography.bodyMedium, diff --git a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt index 77af3ba1f..d1c05cf7a 100644 --- a/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt +++ b/feature/messaging/src/main/kotlin/org/meshtastic/feature/messaging/MessageListPaged.kt @@ -397,6 +397,7 @@ internal fun MessageStatusDialog( resendOption = resendOption, text = text, relayNodeName = relayNodeName, + relays = message.relays, onConfirm = onResend, onDismiss = onDismiss, )