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

View file

@ -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<Medium>) {
fun Activity.shareUris(uris: ArrayList<Uri>) {
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<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) {
val newUri = ensurePublicUri(uri, BuildConfig.APPLICATION_ID)
Intent().apply {