From eb8c667bc282217a43cb420d82ced4ceda57cabf Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 16 Jul 2018 22:55:47 +0200 Subject: [PATCH] improve address parsing at importing in some cases --- .../simplemobiletools/contacts/helpers/VcfImporter.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt index f8c9ec67..b7d98142 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.contacts.helpers import android.graphics.Bitmap import android.graphics.BitmapFactory import android.provider.ContactsContract.CommonDataKinds +import android.text.TextUtils import android.util.Base64 import android.widget.Toast import com.simplemobiletools.commons.extensions.showErrorToast @@ -190,10 +191,16 @@ class VcfImporter(val activity: SimpleActivity) { if (rawType.contains('=')) { rawType = rawType.split('=').last() } + val type = getAddressTypeId(rawType.toUpperCase()) val addresses = addressParts[1].split(";") if (addresses.size == 7) { - curAddresses.add(Address(addresses[2].replace("\\n", "\n"), type)) + if (address.contains(";CHARSET=UTF-8:")) { + val fullAddress = TextUtils.join(", ", addresses.filter { it.trim().isNotEmpty() }) + curAddresses.add(Address(fullAddress, type)) + } else { + curAddresses.add(Address(addresses[2].replace("\\n", "\n"), type)) + } } }