diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt index f7592b94..29173d97 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/activities/ContactActivity.kt @@ -312,7 +312,7 @@ class ContactActivity : SimpleActivity() { } private fun shareContact() { - shareContact(contact!!) + shareContacts(arrayListOf(contact!!)) } private fun showPhotoPlaceholder() { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt index 6154ac39..5f176f22 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/adapters/ContactsAdapter.kt @@ -19,6 +19,7 @@ import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.activities.SimpleActivity import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.extensions.openContact +import com.simplemobiletools.contacts.extensions.shareContacts import com.simplemobiletools.contacts.helpers.ContactsHelper import com.simplemobiletools.contacts.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.models.Contact @@ -62,9 +63,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList editContact() R.id.cab_select_all -> selectAll() - R.id.cab_delete -> askConfirmDelete() R.id.cab_add_to_favorites -> addToFavorites() + R.id.cab_share -> shareContacts() R.id.cab_remove -> removeFavorites() + R.id.cab_delete -> askConfirmDelete() } } @@ -161,6 +163,19 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList() + selectedPositions.forEach { + contacts.add(contactItems[it]) + } + + activity.shareContacts(contacts) + } + override fun onViewRecycled(holder: ViewHolder?) { super.onViewRecycled(holder) if (!activity.isActivityDestroyed()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt index ff191b4f..0f1eeb83 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/extensions/Activity.kt @@ -68,14 +68,14 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new } } -fun BaseSimpleActivity.shareContact(contact: Contact) { +fun BaseSimpleActivity.shareContacts(contacts: ArrayList) { val file = getTempFile() if (file == null) { toast(R.string.unknown_error_occurred) return } - VcfExporter().exportContacts(this, file, arrayListOf(contact)) { + VcfExporter().exportContacts(this, file, contacts) { if (it == VcfExporter.ExportResult.EXPORT_OK) { val uri = getFilePublicUri(file, BuildConfig.APPLICATION_ID) shareUri(uri, BuildConfig.APPLICATION_ID) diff --git a/app/src/main/res/menu/cab.xml b/app/src/main/res/menu/cab.xml index 50c583c0..c727d9bd 100644 --- a/app/src/main/res/menu/cab.xml +++ b/app/src/main/res/menu/cab.xml @@ -16,6 +16,11 @@ android:icon="@drawable/ic_star_on" android:title="@string/add_to_favorites" app:showAsAction="ifRoom"/> +