From 57a280c96e27644dbb62f4ba993da14b74caad7a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 8 Jan 2019 13:33:44 +0100 Subject: [PATCH] fix #1181, properly retrieve exif data at editing, when overwriting a file --- .../gallery/pro/activities/EditActivity.kt | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index 8ee45eacb..3d71b443b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -77,6 +77,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private var currAspectRatio = ASPECT_RATIO_FREE private var isCropIntent = false private var isEditingWithThirdParty = false + private var oldExif: ExifInterface? = null private var initialBitmap: Bitmap? = null @@ -222,7 +223,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } } + @TargetApi(Build.VERSION_CODES.N) private fun saveImage() { + var inputStream: InputStream? = null + try { + if (isNougatPlus()) { + inputStream = contentResolver.openInputStream(uri) + oldExif = ExifInterface(inputStream) + } + } catch (e: Exception) { + } finally { + inputStream?.close() + } + if (crop_image_view.isVisible()) { crop_image_view.getCroppedImageAsync() } else { @@ -593,17 +606,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out) } - var inputStream: InputStream? = null try { if (isNougatPlus()) { - inputStream = contentResolver.openInputStream(uri) - val oldExif = ExifInterface(inputStream) val newExif = ExifInterface(file.absolutePath) - oldExif.copyTo(newExif, false) + oldExif?.copyTo(newExif, false) } } catch (e: Exception) { - } finally { - inputStream?.close() } setResult(Activity.RESULT_OK, intent)