mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-16 11:20:55 +01:00
remove exif info after image capture if user config.savePhotoMetadata == false
This commit is contained in:
parent
e1f292692a
commit
d3d67ec4a4
@ -0,0 +1,26 @@
|
||||
package com.simplemobiletools.camera.helpers
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.exifinterface.media.ExifInterface
|
||||
import com.simplemobiletools.commons.extensions.removeValues
|
||||
import java.io.IOException
|
||||
|
||||
class ExifRemover(private val contentResolver: ContentResolver) {
|
||||
companion object {
|
||||
private const val MODE = "rw"
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun removeExif(uri: Uri) {
|
||||
try {
|
||||
val fileDescriptor = contentResolver.openFileDescriptor(uri, MODE)
|
||||
if (fileDescriptor != null) {
|
||||
val exifInterface = ExifInterface(fileDescriptor.fileDescriptor)
|
||||
exifInterface.removeValues()
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import com.simplemobiletools.camera.helpers.*
|
||||
import com.simplemobiletools.camera.interfaces.MyPreview
|
||||
import com.simplemobiletools.camera.models.MediaOutput
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
@ -58,6 +59,7 @@ class CameraXPreview(
|
||||
private val windowMetricsCalculator = WindowMetricsCalculator.getOrCreate()
|
||||
private val videoQualityManager = VideoQualityManager(config)
|
||||
private val imageQualityManager = ImageQualityManager(activity)
|
||||
private val exifRemover = ExifRemover(contentResolver)
|
||||
|
||||
private val orientationEventListener = object : OrientationEventListener(activity, SensorManager.SENSOR_DELAY_NORMAL) {
|
||||
@SuppressLint("RestrictedApi")
|
||||
@ -368,8 +370,17 @@ class CameraXPreview(
|
||||
|
||||
imageCapture.takePicture(outputOptions, mainExecutor, object : OnImageSavedCallback {
|
||||
override fun onImageSaved(outputFileResults: OutputFileResults) {
|
||||
listener.toggleBottomButtons(false)
|
||||
listener.onMediaSaved(mediaOutput.uri ?: outputFileResults.savedUri!!)
|
||||
ensureBackgroundThread {
|
||||
val savedUri = mediaOutput.uri ?: outputFileResults.savedUri!!
|
||||
if (!config.savePhotoMetadata) {
|
||||
exifRemover.removeExif(savedUri)
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
listener.toggleBottomButtons(false)
|
||||
listener.onMediaSaved(savedUri)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(exception: ImageCaptureException) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user