From f6347db55dc8a778b4c39be2beb07604bdaa39e3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 27 Oct 2018 17:12:30 +0200 Subject: [PATCH] show contact email as its name, if real name and oganization are empty --- .../com/simplemobiletools/contacts/models/Contact.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 c710d572..6aa539fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Contact.kt @@ -86,9 +86,13 @@ data class Contact(val id: Int, var prefix: String, var firstName: String, var m val suffixComma = if (suffix.isEmpty()) "" else ", $suffix" val fullName = "$prefix $firstPart $lastPart$suffixComma".trim() return if (fullName.isEmpty()) { - var fullOrganization = if (organization.jobPosition.isEmpty()) "" else "${organization.jobPosition}, " - fullOrganization += organization.company - fullOrganization.trim().trimEnd(',') + if (organization.isEmpty()) { + emails.firstOrNull()?.value ?: "" + } else { + var fullOrganization = if (organization.jobPosition.isEmpty()) "" else "${organization.jobPosition}, " + fullOrganization += organization.company + fullOrganization.trim().trimEnd(',') + } } else { fullName }