From fe09961c618575d122e715669bc0d2514720d9d1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 31 Aug 2017 09:35:18 +0200 Subject: [PATCH] simplify the uri getter at sharing media --- .../com/simplemobiletools/gallery/extensions/activity.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 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 ddb92198c..d66248274 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -48,6 +48,7 @@ fun Activity.shareMedium(medium: Medium) { val shareTitle = resources.getString(R.string.share_via) val file = File(medium.path) val uri = Uri.fromFile(file) + Intent().apply { action = Intent.ACTION_SEND putExtra(Intent.EXTRA_STREAM, uri) @@ -59,14 +60,12 @@ fun Activity.shareMedium(medium: Medium) { fun Activity.shareMedia(media: List) { val shareTitle = resources.getString(R.string.share_via) - val uris = ArrayList(media.size) + val uris = media.map { Uri.fromFile(File(it.path)) } as ArrayList + Intent().apply { action = Intent.ACTION_SEND_MULTIPLE type = "image/* video/*" addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) - media.map { File(it.path) } - .mapTo(uris) { Uri.fromFile(it) } - putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris) startActivity(Intent.createChooser(this, shareTitle)) }