mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 13:48:52 +01:00
In case different contacts share the same phone number, the displayed photo got mixed-up. This bug was due to the fact that the contact's first phone number was always used. This commit makes sure we keep using the right combination of phone/contact.
This commit is contained in:
committed by
Moez Bhatti
parent
16409db689
commit
d707cb30b5
@@ -89,10 +89,14 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the [recipient] has a contact: use the contact's avatar, but keep the address.
|
||||||
|
* Use the recipient address otherwise.
|
||||||
|
*/
|
||||||
fun setContact(recipient: Recipient?) {
|
fun setContact(recipient: Recipient?) {
|
||||||
// If the recipient has a contact, just use that and return
|
// If the recipient has a contact, just use that and return
|
||||||
recipient?.contact?.let { contact ->
|
recipient?.contact?.let { contact ->
|
||||||
setContact(contact)
|
setContact(contact, recipient.address)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,10 +106,15 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setContact(contact: Contact?) {
|
/**
|
||||||
|
* Use the [contact] information to display the avatar.
|
||||||
|
* A specific [contactAddress] can be specified (useful when the contact has several addresses).
|
||||||
|
*/
|
||||||
|
fun setContact(contact: Contact?, contactAddress: String? = null) {
|
||||||
lookupKey = contact?.lookupKey
|
lookupKey = contact?.lookupKey
|
||||||
name = contact?.name
|
name = contact?.name
|
||||||
address = contact?.numbers?.firstOrNull()?.address
|
// If a contactAddress has been given, we use it. Use the contact address otherwise.
|
||||||
|
address = contactAddress ?: contact?.numbers?.firstOrNull()?.address
|
||||||
updateView()
|
updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user