From 91d81e3bd87386a50e292a2ff64d45843b68fef1 Mon Sep 17 00:00:00 2001 From: darthpaul Date: Fri, 24 Sep 2021 13:57:15 +0100 Subject: [PATCH] fix wrong sender name from private contacts - use SimpleContact.doesHavePhoneNumber to perform comparision between a sender and private contact. SimpleContact.doesHavePhoneNumber does equality check. --- .../smsmessenger/activities/ThreadActivity.kt | 4 ++-- .../com/simplemobiletools/smsmessenger/extensions/Context.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index 28c5b7ef..4216b2c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -218,8 +218,8 @@ class ThreadActivity : SimpleActivity() { privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor) if (privateContacts.isNotEmpty()) { val senderNumbersToReplace = HashMap() - participants.filter { it.doesContainPhoneNumber(it.name) }.forEach { participant -> - privateContacts.firstOrNull { it.doesContainPhoneNumber(participant.phoneNumbers.first()) }?.apply { + participants.filter { it.doesHavePhoneNumber(it.name) }.forEach { participant -> + privateContacts.firstOrNull { it.doesHavePhoneNumber(participant.phoneNumbers.first()) }?.apply { senderNumbersToReplace[participant.phoneNumbers.first()] = name participant.name = name participant.photoUri = photoUri diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt index 4ff626ce..d9e7b93e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt @@ -401,7 +401,7 @@ fun Context.getThreadContactNames(phoneNumbers: List, privateContacts: A if (name != number) { names.add(name) } else { - val privateContact = privateContacts.firstOrNull { it.doesContainPhoneNumber(number) } + val privateContact = privateContacts.firstOrNull { it.doesHavePhoneNumber(number) } if (privateContact == null) { names.add(name) } else {