allow sharing multiple handpicked contacts at once
This commit is contained in:
parent
dc308a94dc
commit
13f5fbc859
|
@ -312,7 +312,7 @@ class ContactActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
private fun shareContact() {
|
||||
shareContact(contact!!)
|
||||
shareContacts(arrayListOf(contact!!))
|
||||
}
|
||||
|
||||
private fun showPhotoPlaceholder() {
|
||||
|
|
|
@ -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<Co
|
|||
when (id) {
|
||||
R.id.cab_edit -> 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<Co
|
|||
finishActMode()
|
||||
}
|
||||
|
||||
private fun shareContacts() {
|
||||
if (selectedPositions.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val contacts = ArrayList<Contact>()
|
||||
selectedPositions.forEach {
|
||||
contacts.add(contactItems[it])
|
||||
}
|
||||
|
||||
activity.shareContacts(contacts)
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder?) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isActivityDestroyed()) {
|
||||
|
|
|
@ -68,14 +68,14 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
|
|||
}
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.shareContact(contact: Contact) {
|
||||
fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
|
||||
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)
|
||||
|
|
|
@ -16,6 +16,11 @@
|
|||
android:icon="@drawable/ic_star_on"
|
||||
android:title="@string/add_to_favorites"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/cab_share"
|
||||
android:icon="@drawable/ic_share"
|
||||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
|
|
Loading…
Reference in New Issue