File tree Expand file tree Collapse file tree
app/src/main/java/com/bnyro/contacts/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ object VcardHelper {
103103 }
104104 ContactData (
105105 displayName = it.formattedName?.value,
106- firstName = it.structuredName?.given,
106+ // we currently don't support prefixes, suffixes and middle names
107+ // so we merge all of them into the first name to not lose that information
108+ firstName = it.structuredName?.allExceptFamilyName(),
107109 surName = it.structuredName?.family,
108110 nickName = it.nickname?.values?.firstOrNull(),
109111 organization = it.organization?.values?.firstOrNull(),
@@ -165,4 +167,10 @@ object VcardHelper {
165167 )
166168 }
167169 }
170+
171+ fun StructuredName.allExceptFamilyName (): String {
172+ return (prefixes + listOf (given) + additionalNames + suffixes)
173+ .filterNotNull()
174+ .joinToString(" " )
175+ }
168176}
You can’t perform that action at this time.
0 commit comments