From c1b29646d39ac65a43a29a304980d86b523a19a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Mon, 10 Jul 2023 16:59:36 +0200 Subject: [PATCH] Show SIM in details only if multiple are present --- .../dialogs/MessageDetailsDialog.kt | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt index e57d2903..83061563 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt @@ -20,13 +20,17 @@ class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Messag @SuppressLint("SetTextI18n") val view = activity.layoutInflater.inflate(R.layout.dialog_message_details, null).apply { - dialog_message_details_text_value.text = """ - ${activity.getString(R.string.message_details_type)}: ${message.getMessageType()} - ${message.getReceiverOrSenderLabel()}: ${message.getReceiverOrSenderPhoneNumbers()} - SIM: ${message.getSIM(availableSIMs)} - ${activity.getString(R.string.message_details_sent_at)}: ${message.getSentAt()} - ${message.getReceivedAtLine()} - """.trimIndent().trimEnd() + dialog_message_details_text_value.text = mutableListOf().apply { + add("${activity.getString(R.string.message_details_type)}: ${message.getMessageType()}") + add("${message.getReceiverOrSenderLabel()}: ${message.getReceiverOrSenderPhoneNumbers()}") + if (availableSIMs.count() > 1) { + add("SIM: ${message.getSIM(availableSIMs)}") + } + add("${activity.getString(R.string.message_details_sent_at)}: ${message.getSentAt()}") + if (message.isReceivedMessage()) { + add("${activity.getString(R.string.message_details_received_at)}: ${message.getReceivedAt()}") + } + }.joinToString(separator = System.lineSeparator()) } activity.getAlertDialogBuilder() @@ -60,14 +64,6 @@ class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Messag return DateTime(dateSent * 1000L).toString(activity.config.dateFormat + " " + activity.getTimeFormat()) } - private fun Message.getReceivedAtLine(): String { - return if (isReceivedMessage()) { - "${activity.getString(R.string.message_details_received_at)}: ${getReceivedAt()}" - } else { - "" - } - } - private fun Message.getReceivedAt(): String { return DateTime(date * 1000L).toString("${activity.config.dateFormat} ${activity.getTimeFormat()}") }