Skip to content

Commit

Permalink
show utf-8 length in bytes of text messages
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Feb 19, 2024
1 parent 06d6e6e commit 493700f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/com/zoffcc/applications/trifa2/ChatMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,17 @@ inline fun ChatMessage(isMyMessage: Boolean, message: UIMessage, ui_scale: Float
horizontalArrangement = Arrangement.End,
modifier = Modifier.randomDebugBorder().padding(all = 0.dp).align(Alignment.End)
) {
var message_size_in_bytes = 0
try
{
message_size_in_bytes = message.text.toByteArray().size
}
catch(_: Exception)
{
}
Tooltip("Message sent at: " + timeToString(message.sentTimeMs) + "\n" +
"Message rcvd at: " + timeToString(message.recvTimeMs) + "\n" +
"Message size in bytes: " + (if (message_size_in_bytes == 0) "unknown" else message_size_in_bytes) + "\n" +
"The clocks on both sides are not synchronized for security reasons, " + "\n" +
"therfore the timestamps may not be accurate") {
Text(
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/com/zoffcc/applications/trifa2/GroupChatMessage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.zoffcc.applications.trifa.HelperOSFile.show_file_in_explorer_or_open
import com.zoffcc.applications.trifa.TRIFAGlobals
import org.briarproject.briar.desktop.ui.Tooltip
import java.io.File
import java.nio.charset.Charset

@Composable
fun GroupTriangle(risingToTheRight: Boolean, background: Color) {
Expand Down Expand Up @@ -194,9 +195,18 @@ inline fun GroupChatMessage(isMyMessage: Boolean, groupmessage: UIGroupMessage,
)
Spacer(modifier = Modifier.width(10.dp))
}
var message_size_in_bytes = 0
try
{
message_size_in_bytes = groupmessage.text.toByteArray().size
}
catch(_: Exception)
{
}
Tooltip("Message sent at: " + timeToString(groupmessage.timeMs) + "\n" +
"Message ID: " + groupmessage.message_id_tox + "\n" +
"Sender Peer Pubkey: " + groupmessage.toxpk + "\n" +
"Message size in bytes: " + (if (message_size_in_bytes == 0) "unknown" else message_size_in_bytes) + "\n" +
"was synced: " + groupmessage.was_synced.toString()) {
Text(
modifier = Modifier.padding(all = 0.dp),
Expand Down

0 comments on commit 493700f

Please sign in to comment.