create a shareUris extension for sharing multiple media
This commit is contained in:
parent
02dfcd63c0
commit
437390cfa3
1 changed files with 11 additions and 8 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue