lets check those private contacts only if we actually have any

This commit is contained in:
tibbi 2020-05-18 23:38:56 +02:00
parent 83dcc7423c
commit 422ccf4b6a
2 changed files with 16 additions and 12 deletions

View File

@ -151,9 +151,11 @@ class MainActivity : SimpleActivity() {
// check if no message came from a privately stored contact in Simple Contacts
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
conversation.title = name
if (privateContacts.isNotEmpty()) {
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
conversation.title = name
}
}
}

View File

@ -95,19 +95,21 @@ class ThreadActivity : SimpleActivity() {
messages.first().participants
}
val senderNumbersToReplace = HashMap<String, String>()
// check if no participant came from a privately stored contact in Simple Contacts
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
senderNumbersToReplace[participant.phoneNumber] = name
participant.name = name
if (privateContacts.isNotEmpty()) {
val senderNumbersToReplace = HashMap<String, String>()
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
senderNumbersToReplace[participant.phoneNumber] = name
participant.name = name
}
}
}
messages.forEach { message ->
if (senderNumbersToReplace.keys.contains(message.senderName)) {
message.senderName = senderNumbersToReplace[message.senderName]!!
messages.forEach { message ->
if (senderNumbersToReplace.keys.contains(message.senderName)) {
message.senderName = senderNumbersToReplace[message.senderName]!!
}
}
}