From 6a0553bf5f1e88d3e6ba35023c37c33badd48cd0 Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 31 Aug 2022 23:57:01 +0530 Subject: [PATCH] Also add name prefix and suffix --- .../smsmessenger/helpers/VCardParser.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/VCardParser.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/VCardParser.kt index 91299e9e..ffab98e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/VCardParser.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/VCardParser.kt @@ -18,14 +18,14 @@ fun VCard?.parseNameFromVCard(): String? { if (this == null) return null var fullName = formattedName?.value if (fullName.isNullOrEmpty()) { - val structured = structuredName - val given = structured?.given - val family = structured.family - fullName = if (family != null) { - given?.plus(" ")?.plus(family) - } else { - given + val structured = structuredName ?: return null + val nameComponents = arrayListOf().apply { + addAll(structured.prefixes) + add(structured.given) + add(structured.family) + addAll(structured.suffixes) } + fullName = nameComponents.filter { !it.isNullOrEmpty() }.joinToString(separator = " ") } return fullName }