mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
Merge pull request #211 from KryptKode/fix/wrong-sender-name
fix wrong sender name from private contacts
This commit is contained in:
@@ -221,8 +221,8 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
if (privateContacts.isNotEmpty()) {
|
if (privateContacts.isNotEmpty()) {
|
||||||
val senderNumbersToReplace = HashMap<String, String>()
|
val senderNumbersToReplace = HashMap<String, String>()
|
||||||
participants.filter { it.doesContainPhoneNumber(it.name) }.forEach { participant ->
|
participants.filter { it.doesHavePhoneNumber(it.name) }.forEach { participant ->
|
||||||
privateContacts.firstOrNull { it.doesContainPhoneNumber(participant.phoneNumbers.first()) }?.apply {
|
privateContacts.firstOrNull { it.doesHavePhoneNumber(participant.phoneNumbers.first()) }?.apply {
|
||||||
senderNumbersToReplace[participant.phoneNumbers.first()] = name
|
senderNumbersToReplace[participant.phoneNumbers.first()] = name
|
||||||
participant.name = name
|
participant.name = name
|
||||||
participant.photoUri = photoUri
|
participant.photoUri = photoUri
|
||||||
|
@@ -415,7 +415,7 @@ fun Context.getThreadContactNames(phoneNumbers: List<String>, privateContacts: A
|
|||||||
if (name != number) {
|
if (name != number) {
|
||||||
names.add(name)
|
names.add(name)
|
||||||
} else {
|
} else {
|
||||||
val privateContact = privateContacts.firstOrNull { it.doesContainPhoneNumber(number) }
|
val privateContact = privateContacts.firstOrNull { it.doesHavePhoneNumber(number) }
|
||||||
if (privateContact == null) {
|
if (privateContact == null) {
|
||||||
names.add(name)
|
names.add(name)
|
||||||
} else {
|
} else {
|
||||||
@@ -682,7 +682,7 @@ fun Context.getNameFromAddress(address: String, privateCursor: Cursor?): String
|
|||||||
var sender = getNameAndPhotoFromPhoneNumber(address).name
|
var sender = getNameAndPhotoFromPhoneNumber(address).name
|
||||||
if (address == sender) {
|
if (address == sender) {
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
sender = privateContacts.firstOrNull { it.doesContainPhoneNumber(address) }?.name ?: address
|
sender = privateContacts.firstOrNull { it.doesHavePhoneNumber(address) }?.name ?: address
|
||||||
}
|
}
|
||||||
return sender
|
return sender
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user