android: show PM file state and identify messages by author and sequence
This commit is contained in:
1 parent
1bd0bea2b4
commit
75998f1606
3 files changed
+35
-9
No files matched your search
@@ -16,7 +16,8 @@ data class Channel(val id: String, val name: String, val lastMsgAt: Long = 0, va
|
||||
val peersOnline: Int = 0, val lastMsgEncrypted: Boolean = false)
|
||||
|
||||
data class DmConversation(val convId: String, val peerNodeId: Long = 0, val peerName: String = "",
|
||||
val lastTs: Long = 0, val online: Boolean = false, val generation: Long = 1) {
|
||||
val lastTs: Long = 0, val online: Boolean = false, val generation: Long = 1,
|
||||
val mode: Int = 0, val closed: Boolean = false) {
|
||||
val displayName: String get() = peerName.ifBlank { "0x%016x".format(peerNodeId) }
|
||||
}
|
||||
data class Message(val id: Long, val author: String, val text: String, val ts: Long,
|
||||
@@ -562,9 +563,9 @@ class ChatRepository(private val reportFailure: (String) -> Unit = { LogManager.
|
||||
|
||||
/* ── DM (личные сообщения) ── */
|
||||
|
||||
/** ID принятого запроса, привязанный к instance; null — отказ. Возврат ещё не подтверждает commit: нужен DM_CONV_UPDATED. */
|
||||
fun dmStart(nodeId: Long, sourceChId: String, peerName: String): String? =
|
||||
NativeLib.dmStart(nodeId, sourceChId, peerName)
|
||||
/** ID зафиксированной ядром беседы, null — отказ. Режим не выводится из node ID. */
|
||||
fun dmStart(nodeId: Long, sourceChId: String, peerName: String, groups: Boolean = false): String? =
|
||||
NativeLib.dmStart(nodeId, sourceChId, peerName, groups)
|
||||
|
||||
fun dmSend(convId: String, text: String, generation: Long, requestId: Long): Boolean =
|
||||
NativeLib.dmSend(convId, text, generation, requestId)
|
||||
@@ -579,7 +580,8 @@ class ChatRepository(private val reportFailure: (String) -> Unit = { LogManager.
|
||||
convId = obj.getString("conv_id"),
|
||||
peerNodeId = obj.optLong("peer_node_id", 0),
|
||||
peerName = obj.optString("peer_name", ""),
|
||||
lastTs = obj.optLong("last_ts", 0), generation = obj.getLong("generation")
|
||||
lastTs = obj.optLong("last_ts", 0), generation = obj.getLong("generation"),
|
||||
mode = obj.optInt("mode"), closed = obj.optBoolean("closed")
|
||||
))
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
@@ -602,15 +604,17 @@ class ChatRepository(private val reportFailure: (String) -> Unit = { LogManager.
|
||||
val delivery = if (file) when {
|
||||
status == "delivered" -> R.string.delivery_delivered
|
||||
status == "expired" -> R.string.delivery_expired
|
||||
outgoing -> R.string.delivery_pending
|
||||
path.isNotEmpty() -> R.string.delivery_received
|
||||
else -> R.string.delivery_loading
|
||||
} else if (outgoing) {
|
||||
status == "downloading" -> R.string.delivery_loading
|
||||
status == "unavailable" -> R.string.dm_file_unavailable
|
||||
else -> R.string.dm_download
|
||||
} else if (obj.optBoolean("source")) {
|
||||
if (obj.optBoolean("pending")) R.string.delivery_pending else R.string.delivery_delivered
|
||||
} else 0
|
||||
val author = peerName.ifBlank { "0x%016x".format(obj.optLong("author", 0)) }
|
||||
list.add(Message(
|
||||
id = obj.optLong("seq", 0),
|
||||
messageId = "${obj.optString("author")}:${obj.optLong("seq")}",
|
||||
author = author,
|
||||
authorNodeId = obj.optLong("author", 0),
|
||||
text = obj.optString("data", ""),
|
||||
@@ -627,7 +631,11 @@ class ChatRepository(private val reportFailure: (String) -> Unit = { LogManager.
|
||||
videoHeight = obj.optInt("height"),
|
||||
imageWidth = obj.optInt("width"),
|
||||
imageHeight = obj.optInt("height"),
|
||||
downloadState = if (!file) "" else if (path.isNotEmpty()) "downloaded" else if (status == "expired") "error" else "downloading",
|
||||
downloadState = if (!file) "" else if (path.isNotEmpty()) "downloaded" else when (status) {
|
||||
"downloading" -> "downloading"
|
||||
"expired", "unavailable" -> "error"
|
||||
else -> ""
|
||||
},
|
||||
deliveryStatusRes = delivery
|
||||
))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="dm_mode_title">Устройства для этой беседы</string>
|
||||
<string name="dm_mode_groups">С подгруппами устройств</string>
|
||||
<string name="dm_mode_device">Только эти устройства</string>
|
||||
<string name="dm_download">Скачать</string>
|
||||
<string name="dm_file_unavailable">Файл недоступен</string>
|
||||
<string name="dm_archived">Вы вышли из подгруппы. Сохранённая история остаётся доступной.</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="dm_mode_title">Devices for this conversation</string>
|
||||
<string name="dm_mode_groups">With device groups</string>
|
||||
<string name="dm_mode_device">Only these devices</string>
|
||||
<string name="dm_download">Download</string>
|
||||
<string name="dm_file_unavailable">File unavailable</string>
|
||||
<string name="dm_archived">You left the device group. Saved history is still available.</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user