mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
lets check those private contacts only if we actually have any
This commit is contained in:
@ -151,9 +151,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
// check if no message came from a privately stored contact in Simple Contacts
|
// check if no message came from a privately stored contact in Simple Contacts
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
|
if (privateContacts.isNotEmpty()) {
|
||||||
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
|
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
|
||||||
conversation.title = name
|
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
|
||||||
|
conversation.title = name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,19 +95,21 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
messages.first().participants
|
messages.first().participants
|
||||||
}
|
}
|
||||||
|
|
||||||
val senderNumbersToReplace = HashMap<String, String>()
|
|
||||||
// check if no participant came from a privately stored contact in Simple Contacts
|
// check if no participant came from a privately stored contact in Simple Contacts
|
||||||
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
val privateContacts = MyContactsContentProvider.getSimpleContacts(this, privateCursor)
|
||||||
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
|
if (privateContacts.isNotEmpty()) {
|
||||||
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
|
val senderNumbersToReplace = HashMap<String, String>()
|
||||||
senderNumbersToReplace[participant.phoneNumber] = name
|
participants.filter { it.name == it.phoneNumber }.forEach { participant ->
|
||||||
participant.name = name
|
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
|
||||||
|
senderNumbersToReplace[participant.phoneNumber] = name
|
||||||
|
participant.name = name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
messages.forEach { message ->
|
messages.forEach { message ->
|
||||||
if (senderNumbersToReplace.keys.contains(message.senderName)) {
|
if (senderNumbersToReplace.keys.contains(message.senderName)) {
|
||||||
message.senderName = senderNumbersToReplace[message.senderName]!!
|
message.senderName = senderNumbersToReplace[message.senderName]!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user