From 4cc35c6676365a5988fbca99bad8e18f495ad98d Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 29 Jun 2023 22:28:44 +1000 Subject: [PATCH 1/3] Enables vcf contact file sharing to WhatsApp --- .../com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt index d586a0df..c71ff289 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt @@ -164,7 +164,8 @@ class VcfExporter { contactsExported++ } - Ezvcard.write(cards).version(VCardVersion.V4_0).go(outputStream) + // whatsapp does not support version 4.0 yet + Ezvcard.write(cards).version(VCardVersion.V3_0).go(outputStream) } catch (e: Exception) { activity.showErrorToast(e) } From 8a96e7b9339db363e36851eb282edf6f9c7578c5 Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 29 Jun 2023 22:37:54 +1000 Subject: [PATCH 2/3] Using VCF version 3.0 only while sharing --- .../com/simplemobiletools/contacts/pro/extensions/Activity.kt | 3 ++- .../com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt index d90281c4..9fcac817 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.ViewContactActivity import com.simplemobiletools.contacts.pro.helpers.DEFAULT_FILE_NAME import com.simplemobiletools.contacts.pro.helpers.VcfExporter +import ezvcard.VCardVersion fun SimpleActivity.startCallIntent(recipient: String) { handlePermission(PERMISSION_CALL_PHONE) { @@ -63,7 +64,7 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList) { } getFileOutputStream(file.toFileDirItem(this), true) { - VcfExporter().exportContacts(this, it, contacts, false) { + VcfExporter().exportContacts(this, it, contacts, false, version = VCardVersion.V3_0) { if (it == VcfExporter.ExportResult.EXPORT_OK) { sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID) } else { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt index c71ff289..10bccdf6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt @@ -36,6 +36,7 @@ class VcfExporter { outputStream: OutputStream?, contacts: ArrayList, showExportingToast: Boolean, + version: VCardVersion = VCardVersion.V4_0, callback: (result: ExportResult) -> Unit ) { try { @@ -165,7 +166,7 @@ class VcfExporter { } // whatsapp does not support version 4.0 yet - Ezvcard.write(cards).version(VCardVersion.V3_0).go(outputStream) + Ezvcard.write(cards).version(version).go(outputStream) } catch (e: Exception) { activity.showErrorToast(e) } From 55b7fad3faf98d4cabf80796d8e715efaf464723 Mon Sep 17 00:00:00 2001 From: merkost Date: Thu, 29 Jun 2023 22:54:29 +1000 Subject: [PATCH 3/3] Commentary moved --- .../com/simplemobiletools/contacts/pro/extensions/Activity.kt | 2 ++ .../com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt index 9fcac817..6b68e2fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt @@ -64,6 +64,8 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList) { } getFileOutputStream(file.toFileDirItem(this), true) { + + // whatsApp does not support vCard version 4.0 yet VcfExporter().exportContacts(this, it, contacts, false, version = VCardVersion.V3_0) { if (it == VcfExporter.ExportResult.EXPORT_OK) { sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt index 10bccdf6..f7ba012d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt @@ -165,7 +165,6 @@ class VcfExporter { contactsExported++ } - // whatsapp does not support version 4.0 yet Ezvcard.write(cards).version(version).go(outputStream) } catch (e: Exception) { activity.showErrorToast(e)