improve the contact number fetching at the dialpad

This commit is contained in:
tibbi 2018-09-25 14:42:08 +02:00
parent 04a7cfc9a5
commit 04ce30cdbd
1 changed files with 4 additions and 3 deletions

View File

@ -262,12 +262,13 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
contact_name.setPadding(if (showContactThumbnails) smallPadding else bigPadding, smallPadding, smallPadding, 0)
if (contact_number != null) {
val numberText = if (textToHighlight.isEmpty()) {
contact.phoneNumbers.firstOrNull()?.value ?: ""
val phoneNumberToUse = if (textToHighlight.isEmpty()) {
contact.phoneNumbers.firstOrNull()
} else {
contact.phoneNumbers.firstOrNull { it.value.contains(textToHighlight) }?.value ?: ""
contact.phoneNumbers.firstOrNull { it.value.contains(textToHighlight) } ?: contact.phoneNumbers.firstOrNull()
}
val numberText = phoneNumberToUse?.value ?: ""
contact_number.text = if (textToHighlight.isEmpty()) numberText else numberText.highlightTextPart(textToHighlight, adjustedPrimaryColor)
contact_number.setTextColor(textColor)
contact_number.setPadding(if (showContactThumbnails) smallPadding else bigPadding, 0, smallPadding, 0)