From 51173b0375d64f9c54d69b74fb72c17acbfffe0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6nnies=2C=20Peter?= Date: Tue, 3 Feb 2026 22:28:53 +0100 Subject: [PATCH 1/2] Fix: Import FN field from vCard 4.0 when N field is missing - Remove incorrect logic that treated FN as organization name - Use FN field directly as contact name when N field is absent - Fixes #465 --- .../fossify/contacts/helpers/VcfImporter.kt | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt b/app/src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt index d966813d9..680145b2d 100644 --- a/app/src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt @@ -55,9 +55,18 @@ class VcfImporter(val activity: SimpleActivity) { for (ezContact in ezContacts) { val structuredName = ezContact.structuredName val prefix = structuredName?.prefixes?.firstOrNull() ?: "" - val firstName = structuredName?.given ?: "" - val middleName = structuredName?.additionalNames?.firstOrNull() ?: "" - val surname = structuredName?.family ?: "" + var firstName = structuredName?.given ?: "" + var middleName = structuredName?.additionalNames?.firstOrNull() ?: "" + var surname = structuredName?.family ?: "" + + if (structuredName == null && ezContact.formattedName?.value?.isNotBlank() == true) { + val fn = ezContact.formattedName.value.trim() + val parts = fn.split("\\s+".toRegex(), limit = 2) + + firstName = parts.getOrNull(0) ?: "" + surname = parts.getOrNull(1) ?: "" + } + val suffix = structuredName?.suffixes?.firstOrNull() ?: "" val nickname = ezContact.nickname?.values?.firstOrNull() ?: "" var photoUri = "" @@ -268,16 +277,6 @@ class VcfImporter(val activity: SimpleActivity) { ringtone = ringtone ) - // if there is no N and ORG fields at the given contact, only FN, treat it as an organization - if ( - contact.getNameToDisplay().isEmpty() - && contact.organization.isEmpty() - && ezContact.formattedName?.value?.isNotEmpty() == true - ) { - contact.organization.company = ezContact.formattedName.value - contact.mimetype = CommonDataKinds.Organization.CONTENT_ITEM_TYPE - } - if (contact.isABusinessContact()) { contact.mimetype = CommonDataKinds.Organization.CONTENT_ITEM_TYPE } From 35fa7dee844a0b012d6238da5dc9164e21314d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6nnies=2C=20Peter?= Date: Tue, 3 Feb 2026 22:38:38 +0100 Subject: [PATCH 2/2] Update CHANGELOG for vCard FN field fix --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9a92d320..d3676186a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Fixed import of vCard 4.0 contacts with only FN field ([#465]) ## [1.6.0] - 2026-01-30 ### Added