From 6eeece124a62bddb1aae4644e833b4e0b0acbb8a Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 22 Mar 2018 15:43:27 +0100 Subject: [PATCH] couple edits to URI obtaining at Edit activity --- .../gallery/activities/EditActivity.kt | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 37a17ae93..6f6338795 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -63,15 +63,20 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener return } - saveUri = when { - intent.extras?.containsKey(REAL_FILE_PATH) == true -> { - val realPath = intent.extras.getString(REAL_FILE_PATH) - if (realPath.startsWith(OTG_PATH)) { - Uri.parse(realPath) - } else { - Uri.fromFile(File(realPath)) - } + if (intent.extras?.containsKey(REAL_FILE_PATH) == true) { + val realPath = intent.extras.getString(REAL_FILE_PATH) + uri = when { + realPath.startsWith(OTG_PATH) -> Uri.parse(realPath) + realPath.startsWith("file:/") -> Uri.parse(realPath) + else -> Uri.fromFile(File(realPath)) } + } else { + (getRealPathFromURI(uri))?.apply { + uri = Uri.fromFile(File(this)) + } + } + + saveUri = when { intent.extras?.containsKey(MediaStore.EXTRA_OUTPUT) == true -> intent.extras!!.get(MediaStore.EXTRA_OUTPUT) as Uri else -> uri }