From 83ab2ad56e93cb2239464c96ea87ed2bb94068ae Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 19 Mar 2020 16:37:57 +0100 Subject: [PATCH] properly handle panorama photos without storage access --- .../pro/activities/PanoramaPhotoActivity.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt index cbf066e42..8222b9d52 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaPhotoActivity.kt @@ -4,6 +4,7 @@ import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Color +import android.net.Uri import android.os.Bundle import android.view.View import android.view.Window @@ -14,7 +15,6 @@ import com.simplemobiletools.commons.extensions.beVisible import com.simplemobiletools.commons.extensions.onGlobalLayout import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.toast -import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.* @@ -48,14 +48,7 @@ open class PanoramaPhotoActivity : SimpleActivity() { explore.setImageResource(if (isExploreEnabled) R.drawable.ic_explore_vector else R.drawable.ic_explore_off_vector) } - handlePermission(PERMISSION_WRITE_STORAGE) { - if (it) { - checkIntent() - } else { - toast(R.string.no_storage_permissions) - finish() - } - } + checkIntent() } override fun onResume() { @@ -144,7 +137,12 @@ open class PanoramaPhotoActivity : SimpleActivity() { for (i in 0..10) { try { - bitmap = BitmapFactory.decodeFile(path, options) + bitmap = if (path.startsWith("content://")) { + val inputStream = contentResolver.openInputStream(Uri.parse(path)) + BitmapFactory.decodeStream(inputStream) + } else { + BitmapFactory.decodeFile(path, options) + } break } catch (e: OutOfMemoryError) { options.inSampleSize *= 2