Also add name prefix and suffix
This commit is contained in:
parent
8dc4687328
commit
6a0553bf5f
1 changed files with 7 additions and 7 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue