get the Photo Uri of private contacts too

This commit is contained in:
tibbi 2020-05-20 16:52:43 +02:00
parent 81e5905bf7
commit 1c1a2d2855
3 changed files with 4 additions and 1 deletions

View File

@ -155,6 +155,7 @@ class MainActivity : SimpleActivity() {
conversations.filter { it.title == it.phoneNumber }.forEach { conversation ->
privateContacts.firstOrNull { it.phoneNumber == conversation.phoneNumber }?.apply {
conversation.title = name
conversation.photoUri = photoUri
}
}
}

View File

@ -104,6 +104,7 @@ class ThreadActivity : SimpleActivity() {
privateContacts.firstOrNull { it.phoneNumber == participant.phoneNumber }?.apply {
senderNumbersToReplace[participant.phoneNumber] = name
participant.name = name
participant.photoUri = photoUri
}
}

View File

@ -383,6 +383,7 @@ fun Context.getSuggestedContacts(privateContacts: ArrayList<SimpleContact>): Arr
val senderNumber = cursor.getStringValue(Sms.ADDRESS) ?: return@queryCursor
val namePhoto = getNameAndPhotoFromPhoneNumber(senderNumber)
var senderName = namePhoto?.name ?: ""
var photoUri = namePhoto?.photoUri ?: ""
if (namePhoto == null || isNumberBlocked(senderNumber)) {
return@queryCursor
} else if (namePhoto.name == senderNumber) {
@ -390,6 +391,7 @@ fun Context.getSuggestedContacts(privateContacts: ArrayList<SimpleContact>): Arr
val privateContact = privateContacts.firstOrNull { it.phoneNumber == senderNumber }
if (privateContact != null) {
senderName = privateContact.name
photoUri = privateContact.photoUri
} else {
return@queryCursor
}
@ -398,7 +400,6 @@ fun Context.getSuggestedContacts(privateContacts: ArrayList<SimpleContact>): Arr
}
}
val photoUri = namePhoto.photoUri ?: ""
val contact = SimpleContact(0, 0, senderName, photoUri, senderNumber)
if (!contacts.map { it.phoneNumber.trimToComparableNumber() }.contains(senderNumber.trimToComparableNumber())) {
contacts.add(contact)