create a shareUris extension for sharing multiple media

This commit is contained in:
tibbi 2017-10-29 18:37:38 +01:00
parent 02dfcd63c0
commit 437390cfa3
1 changed files with 11 additions and 8 deletions

View File

@ -41,15 +41,8 @@ fun Activity.shareUri(uri: Uri) {
} }
} }
fun Activity.shareMedium(medium: Medium) { fun Activity.shareUris(uris: ArrayList<Uri>) {
val file = File(medium.path)
shareUri(Uri.fromFile(file))
}
fun Activity.shareMedia(media: List<Medium>) {
val shareTitle = resources.getString(R.string.share_via) val shareTitle = resources.getString(R.string.share_via)
val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList
Intent().apply { Intent().apply {
action = Intent.ACTION_SEND_MULTIPLE action = Intent.ACTION_SEND_MULTIPLE
type = uris.getMimeType() type = uris.getMimeType()
@ -63,6 +56,16 @@ fun Activity.shareMedia(media: List<Medium>) {
} }
} }
fun Activity.shareMedium(medium: Medium) {
val file = File(medium.path)
shareUri(Uri.fromFile(file))
}
fun Activity.shareMedia(media: List<Medium>) {
val uris = media.map { getFilePublicUri(File(it.path), BuildConfig.APPLICATION_ID) } as ArrayList
shareUris(uris)
}
fun Activity.setAs(uri: Uri) { fun Activity.setAs(uri: Uri) {
val newUri = ensurePublicUri(uri, BuildConfig.APPLICATION_ID) val newUri = ensurePublicUri(uri, BuildConfig.APPLICATION_ID)
Intent().apply { Intent().apply {