From 9f0e736ec3200608de74639a83c1753f7bb50231 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 7 Feb 2022 12:25:48 +0100 Subject: [PATCH] fix #769, import whole address from .vcf files --- .../contacts/pro/helpers/VcfImporter.kt | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt index a1cbc02b..c23c1738 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfImporter.kt @@ -83,7 +83,7 @@ class VcfImporter(val activity: SimpleActivity) { val addresses = ArrayList
() ezContact.addresses.forEach { - val address = it.streetAddress + var address = it.streetAddress ?: "" val type = getAddressTypeId(it.types.firstOrNull()?.value ?: HOME) val label = if (type == StructuredPostal.TYPE_CUSTOM) { it.types.firstOrNull()?.value ?: "" @@ -91,7 +91,28 @@ class VcfImporter(val activity: SimpleActivity) { "" } - if (address?.isNotEmpty() == true) { + if (it.locality?.isNotEmpty() == true) { + address += " ${it.locality} " + } + + if (it.region?.isNotEmpty() == true) { + if (address.isNotEmpty()) { + address = "${address.trim()}, " + } + address += "${it.region} " + } + + if (it.postalCode?.isNotEmpty() == true) { + address += "${it.postalCode} " + } + + if (it.country?.isNotEmpty() == true) { + address += "${it.country} " + } + + address = address.trim() + + if (address.isNotEmpty()) { addresses.add(Address(address, type, label)) } }