From ca453ff04d7b16400e2280767f973815749118aa Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 27 Oct 2018 17:20:35 +0200 Subject: [PATCH] properly compare contacts that have no name or organization, just email --- .../simplemobiletools/contacts/models/Contact.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt index ae9318d3..29f73546 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt @@ -37,12 +37,20 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m } } - if (firstString.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty() && organization.company.isNotEmpty()) { - firstString = organization.company.normalizeString() + if (firstString.isEmpty() && firstName.isEmpty() && middleName.isEmpty() && surname.isEmpty()) { + if (organization.company.isNotEmpty()) { + firstString = organization.company.normalizeString() + } else if (emails.isNotEmpty()) { + firstString = emails.first().value + } } - if (secondString.isEmpty() && other.firstName.isEmpty() && other.middleName.isEmpty() && other.surname.isEmpty() && other.organization.company.isNotEmpty()) { - secondString = other.organization.company.normalizeString() + if (secondString.isEmpty() && other.firstName.isEmpty() && other.middleName.isEmpty() && other.surname.isEmpty()) { + if (other.organization.company.isNotEmpty()) { + secondString = other.organization.company.normalizeString() + } else if (other.emails.isNotEmpty()) { + secondString = other.emails.first().value + } } var result = if (firstString.firstOrNull()?.isLetter() == true && secondString.firstOrNull()?.isLetter() == false) {