mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
improve address parsing at importing in some cases
This commit is contained in:
parent
19119b51c9
commit
eb8c667bc2
@ -3,6 +3,7 @@ package com.simplemobiletools.contacts.helpers
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.provider.ContactsContract.CommonDataKinds
|
import android.provider.ContactsContract.CommonDataKinds
|
||||||
|
import android.text.TextUtils
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||||
@ -190,12 +191,18 @@ class VcfImporter(val activity: SimpleActivity) {
|
|||||||
if (rawType.contains('=')) {
|
if (rawType.contains('=')) {
|
||||||
rawType = rawType.split('=').last()
|
rawType = rawType.split('=').last()
|
||||||
}
|
}
|
||||||
|
|
||||||
val type = getAddressTypeId(rawType.toUpperCase())
|
val type = getAddressTypeId(rawType.toUpperCase())
|
||||||
val addresses = addressParts[1].split(";")
|
val addresses = addressParts[1].split(";")
|
||||||
if (addresses.size == 7) {
|
if (addresses.size == 7) {
|
||||||
|
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))
|
curAddresses.add(Address(addresses[2].replace("\\n", "\n"), type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getAddressTypeId(type: String) = when (type) {
|
private fun getAddressTypeId(type: String) = when (type) {
|
||||||
HOME -> CommonDataKinds.Email.TYPE_HOME
|
HOME -> CommonDataKinds.Email.TYPE_HOME
|
||||||
|
Loading…
x
Reference in New Issue
Block a user