Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show utf-8 length in bytes of text messages #160

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading