Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 12 additions & 13 deletions app/src/main/kotlin/org/fossify/contacts/helpers/VcfImporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down Expand Up @@ -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
}
Expand Down
Loading