From 77ab6178d022e8989fa464195ec5d98e12c0008e Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 7 Mar 2017 18:55:42 +0100 Subject: [PATCH] fix some file uri issues on android versions below 7 --- .../com/simplemobiletools/gallery/extensions/activity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 dbbe3e847..9c3904756 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/extensions/activity.kt @@ -109,7 +109,13 @@ fun Activity.openEditor(file: File) { } } -fun Activity.getFileUri(file: File) = FileProvider.getUriForFile(this, "$packageName.provider", file) +fun Activity.getFileUri(file: File): Uri { + val isNougat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N + return if (isNougat) + FileProvider.getUriForFile(this, "$packageName.provider", file) + else + Uri.fromFile(file) +} fun Activity.hasNavBar(): Boolean { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {