Also add name prefix and suffix

This commit is contained in:
Naveen
2022-08-31 23:57:01 +05:30
parent 8dc4687328
commit 6a0553bf5f

View File

@@ -18,14 +18,14 @@ fun VCard?.parseNameFromVCard(): String? {
if (this == null) return null if (this == null) return null
var fullName = formattedName?.value var fullName = formattedName?.value
if (fullName.isNullOrEmpty()) { if (fullName.isNullOrEmpty()) {
val structured = structuredName val structured = structuredName ?: return null
val given = structured?.given val nameComponents = arrayListOf<String?>().apply {
val family = structured.family addAll(structured.prefixes)
fullName = if (family != null) { add(structured.given)
given?.plus(" ")?.plus(family) add(structured.family)
} else { addAll(structured.suffixes)
given
} }
fullName = nameComponents.filter { !it.isNullOrEmpty() }.joinToString(separator = " ")
} }
return fullName return fullName
} }