From 437390cfa3c603d538c6384e865c8d15b4f0f606 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 29 Oct 2017 18:37:38 +0100 Subject: [PATCH] create a shareUris extension for sharing multiple media --- .../gallery/extensions/activity.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt index d38c06865..12f3ef851 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -41,15 +41,8 @@ fun Activity.shareUri(uri: Uri) { } } -fun Activity.shareMedium(medium: Medium) { - val file = File(medium.path) - shareUri(Uri.fromFile(file)) -} - -fun Activity.shareMedia(media: List) { +fun Activity.shareUris(uris: ArrayList) { val shareTitle = resources.getString(R.string.share_via) - val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList - Intent().apply { action = Intent.ACTION_SEND_MULTIPLE type = uris.getMimeType() @@ -63,6 +56,16 @@ fun Activity.shareMedia(media: List) { } } +fun Activity.shareMedium(medium: Medium) { + val file = File(medium.path) + shareUri(Uri.fromFile(file)) +} + +fun Activity.shareMedia(media: List) { + val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList + shareUris(uris) +} + fun Activity.setAs(uri: Uri) { val newUri = ensurePublicUri(uri, BuildConfig.APPLICATION_ID) Intent().apply {