mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-27 06:57:59 +01:00
try sticking the damn read_uri_permission to every intent
This commit is contained in:
parent
1050a20e84
commit
f1d5baa8a8
1 changed files with 6 additions and 0 deletions
|
@ -28,6 +28,7 @@ fun Activity.shareUri(medium: Medium, uri: Uri) {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
putExtra(Intent.EXTRA_STREAM, uri)
|
putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
type = medium.getMimeType()
|
type = medium.getMimeType()
|
||||||
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
startActivity(Intent.createChooser(this, shareTitle))
|
startActivity(Intent.createChooser(this, shareTitle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +41,7 @@ fun Activity.shareMedium(medium: Medium) {
|
||||||
action = Intent.ACTION_SEND
|
action = Intent.ACTION_SEND
|
||||||
putExtra(Intent.EXTRA_STREAM, uri)
|
putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
type = medium.getMimeType()
|
type = medium.getMimeType()
|
||||||
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
startActivity(Intent.createChooser(this, shareTitle))
|
startActivity(Intent.createChooser(this, shareTitle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +52,7 @@ fun Activity.shareMedia(media: List<Medium>) {
|
||||||
action = Intent.ACTION_SEND_MULTIPLE
|
action = Intent.ACTION_SEND_MULTIPLE
|
||||||
type = "image/* video/*"
|
type = "image/* video/*"
|
||||||
val uris = ArrayList<Uri>(media.size)
|
val uris = ArrayList<Uri>(media.size)
|
||||||
|
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
media.map { File(it.path) }
|
media.map { File(it.path) }
|
||||||
.mapTo(uris) { Uri.fromFile(it) }
|
.mapTo(uris) { Uri.fromFile(it) }
|
||||||
|
|
||||||
|
@ -62,6 +65,7 @@ fun Activity.setAsWallpaper(file: File) {
|
||||||
val intent = Intent(Intent.ACTION_ATTACH_DATA)
|
val intent = Intent(Intent.ACTION_ATTACH_DATA)
|
||||||
val uri = Uri.fromFile(file)
|
val uri = Uri.fromFile(file)
|
||||||
intent.setDataAndType(uri, file.getMimeType("image/*"))
|
intent.setDataAndType(uri, file.getMimeType("image/*"))
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
val chooser = Intent.createChooser(intent, getString(R.string.set_as_wallpaper_with))
|
val chooser = Intent.createChooser(intent, getString(R.string.set_as_wallpaper_with))
|
||||||
|
|
||||||
if (intent.resolveActivity(packageManager) != null) {
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
|
@ -75,6 +79,7 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) {
|
||||||
val intent = Intent(Intent.ACTION_VIEW)
|
val intent = Intent(Intent.ACTION_VIEW)
|
||||||
val uri = Uri.fromFile(file)
|
val uri = Uri.fromFile(file)
|
||||||
intent.setDataAndType(uri, file.getMimeType("image/jpeg"))
|
intent.setDataAndType(uri, file.getMimeType("image/jpeg"))
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
val chooser = Intent.createChooser(intent, getString(R.string.open_with))
|
val chooser = Intent.createChooser(intent, getString(R.string.open_with))
|
||||||
|
|
||||||
if (intent.resolveActivity(packageManager) != null) {
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
|
@ -87,6 +92,7 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) {
|
||||||
fun Activity.openEditor(file: File) {
|
fun Activity.openEditor(file: File) {
|
||||||
val intent = Intent(Intent.ACTION_EDIT)
|
val intent = Intent(Intent.ACTION_EDIT)
|
||||||
intent.setDataAndType(Uri.fromFile(file), "image/*")
|
intent.setDataAndType(Uri.fromFile(file), "image/*")
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
|
||||||
if (intent.resolveActivity(packageManager) != null) {
|
if (intent.resolveActivity(packageManager) != null) {
|
||||||
startActivityForResult(intent, REQUEST_EDIT_IMAGE)
|
startActivityForResult(intent, REQUEST_EDIT_IMAGE)
|
||||||
|
|
Loading…
Reference in a new issue