Merge pull request #995 from Merkost/contacts_sharing_fix
Contacts sharing fix
This commit is contained in:
commit
3b6baab1a0
|
@ -16,6 +16,7 @@ import com.simplemobiletools.contacts.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.contacts.pro.activities.ViewContactActivity
|
import com.simplemobiletools.contacts.pro.activities.ViewContactActivity
|
||||||
import com.simplemobiletools.contacts.pro.helpers.DEFAULT_FILE_NAME
|
import com.simplemobiletools.contacts.pro.helpers.DEFAULT_FILE_NAME
|
||||||
import com.simplemobiletools.contacts.pro.helpers.VcfExporter
|
import com.simplemobiletools.contacts.pro.helpers.VcfExporter
|
||||||
|
import ezvcard.VCardVersion
|
||||||
|
|
||||||
fun SimpleActivity.startCallIntent(recipient: String) {
|
fun SimpleActivity.startCallIntent(recipient: String) {
|
||||||
handlePermission(PERMISSION_CALL_PHONE) {
|
handlePermission(PERMISSION_CALL_PHONE) {
|
||||||
|
@ -63,7 +64,9 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
getFileOutputStream(file.toFileDirItem(this), true) {
|
getFileOutputStream(file.toFileDirItem(this), true) {
|
||||||
VcfExporter().exportContacts(this, it, contacts, false) {
|
|
||||||
|
// 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) {
|
if (it == VcfExporter.ExportResult.EXPORT_OK) {
|
||||||
sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID)
|
sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,6 +36,7 @@ class VcfExporter {
|
||||||
outputStream: OutputStream?,
|
outputStream: OutputStream?,
|
||||||
contacts: ArrayList<Contact>,
|
contacts: ArrayList<Contact>,
|
||||||
showExportingToast: Boolean,
|
showExportingToast: Boolean,
|
||||||
|
version: VCardVersion = VCardVersion.V4_0,
|
||||||
callback: (result: ExportResult) -> Unit
|
callback: (result: ExportResult) -> Unit
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
@ -164,7 +165,7 @@ class VcfExporter {
|
||||||
contactsExported++
|
contactsExported++
|
||||||
}
|
}
|
||||||
|
|
||||||
Ezvcard.write(cards).version(VCardVersion.V4_0).go(outputStream)
|
Ezvcard.write(cards).version(version).go(outputStream)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
activity.showErrorToast(e)
|
activity.showErrorToast(e)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue