From 6fef121599ceebc38082ea1a19cd065ffd6914e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 11 Jul 2023 09:55:57 +0200 Subject: [PATCH] Fix formatting of senders and receivers --- .../smsmessenger/dialogs/MessageDetailsDialog.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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 d1f89b22..57390420 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/dialogs/MessageDetailsDialog.kt @@ -45,8 +45,20 @@ class MessageDetailsDialog(val activity: BaseSimpleActivity, val message: Messag } private fun Message.getReceiverOrSenderPhoneNumbers(): String { - return participants.joinToString(", ") { - it.phoneNumbers.first().value + return if (isReceivedMessage()) { + formatContactInfo(senderName, senderPhoneNumber) + } else { + participants.joinToString(", ") { + formatContactInfo(it.name, it.phoneNumbers.first().value) + } + } + } + + private fun formatContactInfo(name: String, phoneNumber: String): String { + return if (name != phoneNumber) { + "$name ($phoneNumber)" + } else { + phoneNumber } }