diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bbd6f1d93..8dfd17b86 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -158,5 +158,15 @@
+
+
+
+
diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
index 3fc11f4aa..48f818bcd 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt
@@ -5,7 +5,6 @@ import android.app.WallpaperManager
import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
-import android.os.Build
import android.os.Bundle
import android.support.v7.widget.GridLayoutManager
import android.util.Log
@@ -333,8 +332,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
} else {
val file = File(path)
val isVideo = file.isVideoFast()
- val isNougat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
- if (isVideo && !isNougat) {
+ if (isVideo) {
openWith(file, false)
} else {
Intent(this, ViewPagerActivity::class.java).apply {
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 5f9aab147..2e37a0d6e 100644
--- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt
@@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
+import android.support.v4.content.FileProvider
import android.support.v7.app.AppCompatActivity
import android.util.DisplayMetrics
import android.view.KeyCharacterMap
@@ -36,7 +37,7 @@ fun Activity.shareUri(medium: Medium, uri: Uri) {
fun Activity.shareMedium(medium: Medium) {
val shareTitle = resources.getString(R.string.share_via)
val file = File(medium.path)
- val uri = Uri.fromFile(file)
+ val uri = FileProvider.getUriForFile(this, "$packageName.provider", file)
Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, uri)
@@ -54,7 +55,7 @@ fun Activity.shareMedia(media: List) {
type = "image/* video/*"
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
media.map { File(it.path) }
- .mapTo(uris) { Uri.fromFile(it) }
+ .mapTo(uris) { FileProvider.getUriForFile(this@shareMedia, "$packageName.provider", it) }
putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris)
startActivity(Intent.createChooser(this, shareTitle))
@@ -62,7 +63,7 @@ fun Activity.shareMedia(media: List) {
}
fun Activity.setAsWallpaper(file: File) {
- val uri = Uri.fromFile(file)
+ val uri = FileProvider.getUriForFile(this, "$packageName.provider", file)
Intent().apply {
action = Intent.ACTION_ATTACH_DATA
setDataAndType(uri, file.getMimeType("image/*"))
@@ -78,7 +79,7 @@ fun Activity.setAsWallpaper(file: File) {
}
fun Activity.openWith(file: File, forceChooser: Boolean = true) {
- val uri = Uri.fromFile(file)
+ val uri = FileProvider.getUriForFile(this, "$packageName.provider", file)
Intent().apply {
action = Intent.ACTION_VIEW
setDataAndType(uri, file.getMimeType("image/jpeg"))
@@ -94,9 +95,10 @@ fun Activity.openWith(file: File, forceChooser: Boolean = true) {
}
fun Activity.openEditor(file: File) {
+ val uri = FileProvider.getUriForFile(this, "$packageName.provider", file)
Intent().apply {
action = Intent.ACTION_EDIT
- setDataAndType(Uri.fromFile(file), "image/*")
+ setDataAndType(uri, "image/*")
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
if (resolveActivity(packageManager) != null) {
diff --git a/app/src/main/res/xml/provider_paths.xml b/app/src/main/res/xml/provider_paths.xml
new file mode 100644
index 000000000..8d13fa177
--- /dev/null
+++ b/app/src/main/res/xml/provider_paths.xml
@@ -0,0 +1,4 @@
+
+
+
+