Use structured name when formatted name is empty

This commit is contained in:
Naveen 2022-08-31 17:34:51 +05:30
parent d95985841a
commit 8dc4687328
3 changed files with 19 additions and 16 deletions

View file

@ -13,3 +13,19 @@ fun parseVCardFromUri(context: Context, uri: Uri, callback: (vCards: List<VCard>
callback(vCards)
}
}
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
}
}
return fullName
}