diff --git a/app/build.gradle b/app/build.gradle index 25b89ecc..e1d218b3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:4.3.29' + implementation 'com.simplemobiletools:commons:4.4.24' implementation 'joda-time:joda-time:2.9.9' implementation 'com.facebook.stetho:stetho:1.5.0' diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt index 5409d2dd..a2239943 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/Constants.kt @@ -46,10 +46,10 @@ const val ANNIVERSARY = "ANNIVERSARY:" const val PHOTO = "PHOTO" const val EMAIL = "EMAIL" const val ADR = "ADR" -const val NOTE = "NOTE:" -const val ORG = "ORG:" -const val TITLE = "TITLE:" -const val URL = "URL:" +const val NOTE = "NOTE" +const val ORG = "ORG" +const val TITLE = "TITLE" +const val URL = "URL" const val ENCODING = "ENCODING" const val BASE64 = "BASE64" const val JPEG = "JPEG" diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt index 88f077f3..e53cecd4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt @@ -65,16 +65,16 @@ class VcfExporter { } if (contact.notes.isNotEmpty()) { - out.writeLn("$NOTE${contact.notes.replace("\n", "\\n")}") + out.writeLn("$NOTE:${contact.notes.replace("\n", "\\n")}") } if (!contact.organization.isEmpty()) { - out.writeLn("$ORG${contact.organization.company.replace("\n", "\\n")}") - out.writeLn("$TITLE${contact.organization.jobPosition.replace("\n", "\\n")}") + out.writeLn("$ORG:${contact.organization.company.replace("\n", "\\n")}") + out.writeLn("$TITLE:${contact.organization.jobPosition.replace("\n", "\\n")}") } contact.websites.forEach { - out.writeLn("$URL$it") + out.writeLn("$URL:$it") } if (contact.thumbnailUri.isNotEmpty()) { 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 44c3106d..f8c9ec67 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfImporter.kt @@ -59,7 +59,8 @@ class VcfImporter(val activity: SimpleActivity) { inputStream.bufferedReader().use { while (true) { - val line = it.readLine() ?: break + var line = it.readLine() ?: break + line = line.trim() if (line.trim().isEmpty()) { if (isGettingPhoto) { savePhoto() @@ -128,6 +129,7 @@ class VcfImporter(val activity: SimpleActivity) { val nameParts = currentNameString.split(";") curSurname = if (currentNameIsANSI) QuotedPrintable.decode(nameParts[0]) else nameParts[0] curFirstName = if (currentNameIsANSI) QuotedPrintable.decode(nameParts[1]) else nameParts[1] + if (nameParts.size > 2) { curMiddleName = if (currentNameIsANSI) QuotedPrintable.decode(nameParts[2]) else nameParts[2] curPrefix = if (currentNameIsANSI) QuotedPrintable.decode(nameParts[3]) else nameParts[3] @@ -244,26 +246,43 @@ class VcfImporter(val activity: SimpleActivity) { } private fun addNotes(notes: String) { - currentNotesSB.append(notes) + if (notes.startsWith(";CHARSET", true)) { + currentNotesSB.append(notes.substringAfter(":")) + } else { + currentNotesSB.append(notes.substring(1)) + } isGettingNotes = true } private fun addCompany(company: String) { - curCompany = company + curCompany = if (company.startsWith(";")) { + company.substringAfter(":").trim(';') + } else { + company + } } private fun addJobPosition(jobPosition: String) { - curJobPosition = jobPosition + curJobPosition = if (jobPosition.startsWith(";")) { + jobPosition.substringAfter(":") + } else { + jobPosition + } } private fun addWebsite(website: String) { - curWebsites.add(website) + if (website.startsWith(";")) { + curWebsites.add(website.substringAfter(":")) + } else { + curWebsites.add(website) + } } private fun saveContact(source: String) { val organization = Organization(curCompany, curJobPosition) val contact = Contact(0, curPrefix, curFirstName, curMiddleName, curSurname, curSuffix, curPhotoUri, curPhoneNumbers, curEmails, curAddresses, curEvents, source, 0, 0, "", null, curNotes, curGroups, organization, curWebsites) + if (ContactsHelper(activity).insertContact(contact)) { contactsImported++ }