mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-23 04:57:59 +01:00
keep exif data at editing images from Android 7+
This commit is contained in:
parent
ee9749ba3b
commit
5b22d06ff9
1 changed files with 16 additions and 0 deletions
|
@ -1,12 +1,15 @@
|
||||||
package com.simplemobiletools.gallery.pro.activities
|
package com.simplemobiletools.gallery.pro.activities
|
||||||
|
|
||||||
|
import android.annotation.TargetApi
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Bitmap.CompressFormat
|
import android.graphics.Bitmap.CompressFormat
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Point
|
import android.graphics.Point
|
||||||
|
import android.media.ExifInterface
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
@ -24,6 +27,7 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE
|
||||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||||
|
import com.simplemobiletools.commons.helpers.isNougatPlus
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
|
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
|
||||||
|
@ -576,6 +580,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) {
|
private fun saveBitmap(file: File, bitmap: Bitmap, out: OutputStream, showSavingToast: Boolean) {
|
||||||
if (showSavingToast) {
|
if (showSavingToast) {
|
||||||
toast(R.string.saving)
|
toast(R.string.saving)
|
||||||
|
@ -587,6 +592,17 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
} else {
|
} else {
|
||||||
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
|
bitmap.compress(file.absolutePath.getCompressionFormat(), 90, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isNougatPlus()) {
|
||||||
|
val inputStream = contentResolver.openInputStream(uri)
|
||||||
|
val oldExif = ExifInterface(inputStream)
|
||||||
|
val newExif = ExifInterface(file.absolutePath)
|
||||||
|
oldExif.copyTo(newExif, false)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
|
||||||
setResult(Activity.RESULT_OK, intent)
|
setResult(Activity.RESULT_OK, intent)
|
||||||
scanFinalPath(file.absolutePath)
|
scanFinalPath(file.absolutePath)
|
||||||
out.close()
|
out.close()
|
||||||
|
|
Loading…
Reference in a new issue