mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: add dialog for message status information
This commit is contained in:
parent
056f6b28cf
commit
a075dfbd3a
16 changed files with 803 additions and 103 deletions
52
app/src/main/java/com/geeksville/mesh/model/Message.kt
Normal file
52
app/src/main/java/com/geeksville/mesh/model/Message.kt
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package com.geeksville.mesh.model
|
||||
|
||||
import com.geeksville.mesh.MeshProtos.Routing
|
||||
import com.geeksville.mesh.MeshUser
|
||||
import com.geeksville.mesh.MessageStatus
|
||||
import com.geeksville.mesh.R
|
||||
|
||||
val Routing.Error.stringRes: Int
|
||||
get() = when (this) {
|
||||
Routing.Error.NONE -> R.string.routing_error_none
|
||||
Routing.Error.NO_ROUTE -> R.string.routing_error_no_route
|
||||
Routing.Error.GOT_NAK -> R.string.routing_error_got_nak
|
||||
Routing.Error.TIMEOUT -> R.string.routing_error_timeout
|
||||
Routing.Error.NO_INTERFACE -> R.string.routing_error_no_interface
|
||||
Routing.Error.MAX_RETRANSMIT -> R.string.routing_error_max_retransmit
|
||||
Routing.Error.NO_CHANNEL -> R.string.routing_error_no_channel
|
||||
Routing.Error.TOO_LARGE -> R.string.routing_error_too_large
|
||||
Routing.Error.NO_RESPONSE -> R.string.routing_error_no_response
|
||||
Routing.Error.DUTY_CYCLE_LIMIT -> R.string.routing_error_duty_cycle_limit
|
||||
Routing.Error.BAD_REQUEST -> R.string.routing_error_bad_request
|
||||
Routing.Error.NOT_AUTHORIZED -> R.string.routing_error_not_authorized
|
||||
Routing.Error.PKI_FAILED -> R.string.routing_error_pki_failed
|
||||
Routing.Error.PKI_UNKNOWN_PUBKEY -> R.string.routing_error_pki_unknown_pubkey
|
||||
else -> R.string.unrecognized
|
||||
}
|
||||
|
||||
data class Message(
|
||||
val uuid: Long,
|
||||
val receivedTime: Long,
|
||||
val user: MeshUser,
|
||||
val text: String,
|
||||
val time: Long,
|
||||
val read: Boolean,
|
||||
val status: MessageStatus?,
|
||||
val routingError: Int,
|
||||
) {
|
||||
private fun getStatusStringRes(value: Int): Int {
|
||||
val error = Routing.Error.forNumber(value) ?: Routing.Error.UNRECOGNIZED
|
||||
return error.stringRes
|
||||
}
|
||||
|
||||
fun getStatusStringRes(): Pair<Int, Int> {
|
||||
val title = if (routingError > 0) R.string.error else R.string.message_delivery_status
|
||||
val text = when (status) {
|
||||
MessageStatus.RECEIVED -> R.string.delivery_confirmed
|
||||
MessageStatus.QUEUED -> R.string.message_status_queued
|
||||
MessageStatus.ENROUTE -> R.string.message_status_enroute
|
||||
else -> getStatusStringRes(routingError)
|
||||
}
|
||||
return title to text
|
||||
}
|
||||
}
|
||||
|
|
@ -463,7 +463,7 @@ class RadioConfigViewModel @Inject constructor(
|
|||
val parsed = MeshProtos.Routing.parseFrom(data.payload)
|
||||
debug(debugMsg.format(parsed.errorReason.name))
|
||||
if (parsed.errorReason != MeshProtos.Routing.Error.NONE) {
|
||||
setResponseStateError(parsed.errorReason.name)
|
||||
setResponseStateError(app.getString(parsed.errorReason.stringRes))
|
||||
} else if (packet.from == destNum && route.isEmpty()) {
|
||||
requestIds.update { it.apply { remove(data.requestId) } }
|
||||
if (requestIds.value.isEmpty()) setResponseStateSuccess()
|
||||
|
|
|
|||
|
|
@ -130,16 +130,6 @@ data class Contact(
|
|||
val isMuted: Boolean,
|
||||
)
|
||||
|
||||
data class Message(
|
||||
val uuid: Long,
|
||||
val receivedTime: Long,
|
||||
val user: MeshUser,
|
||||
val text: String,
|
||||
val time: Long,
|
||||
val read: Boolean,
|
||||
val status: MessageStatus?,
|
||||
)
|
||||
|
||||
// return time if within 24 hours, otherwise date
|
||||
internal fun getShortDateTime(time: Long): String? {
|
||||
val date = if (time != 0L) Date(time) else return null
|
||||
|
|
@ -181,7 +171,6 @@ class UIViewModel @Inject constructor(
|
|||
|
||||
private val _channels = MutableStateFlow(channelSet {})
|
||||
val channels: StateFlow<AppOnlyProtos.ChannelSet> get() = _channels
|
||||
val channelSet get() = channels.value
|
||||
|
||||
private val _quickChatActions = MutableStateFlow<List<QuickChatAction>>(emptyList())
|
||||
val quickChatActions: StateFlow<List<QuickChatAction>> = _quickChatActions
|
||||
|
|
@ -339,6 +328,7 @@ class UIViewModel @Inject constructor(
|
|||
time = it.data.time,
|
||||
read = it.read,
|
||||
status = it.data.status,
|
||||
routingError = it.routingError,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue