fix #1181, properly retrieve exif data at editing, when overwriting a file
This commit is contained in:
parent
51cf93001b
commit
57a280c96e
|
@ -77,6 +77,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
private var currAspectRatio = ASPECT_RATIO_FREE
|
private var currAspectRatio = ASPECT_RATIO_FREE
|
||||||
private var isCropIntent = false
|
private var isCropIntent = false
|
||||||
private var isEditingWithThirdParty = false
|
private var isEditingWithThirdParty = false
|
||||||
|
private var oldExif: ExifInterface? = null
|
||||||
|
|
||||||
private var initialBitmap: Bitmap? = null
|
private var initialBitmap: Bitmap? = null
|
||||||
|
|
||||||
|
@ -222,7 +223,19 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
private fun saveImage() {
|
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()) {
|
if (crop_image_view.isVisible()) {
|
||||||
crop_image_view.getCroppedImageAsync()
|
crop_image_view.getCroppedImageAsync()
|
||||||
} else {
|
} else {
|
||||||
|
@ -593,17 +606,12 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
|
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputStream: InputStream? = null
|
|
||||||
try {
|
try {
|
||||||
if (isNougatPlus()) {
|
if (isNougatPlus()) {
|
||||||
inputStream = contentResolver.openInputStream(uri)
|
|
||||||
val oldExif = ExifInterface(inputStream)
|
|
||||||
val newExif = ExifInterface(file.absolutePath)
|
val newExif = ExifInterface(file.absolutePath)
|
||||||
oldExif.copyTo(newExif, false)
|
oldExif?.copyTo(newExif, false)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
} finally {
|
|
||||||
inputStream?.close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setResult(Activity.RESULT_OK, intent)
|
setResult(Activity.RESULT_OK, intent)
|
||||||
|
|
Loading…
Reference in New Issue