mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
remove exif info after image capture if user config.savePhotoMetadata == false
This commit is contained in:
@ -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.interfaces.MyPreview
|
||||||
import com.simplemobiletools.camera.models.MediaOutput
|
import com.simplemobiletools.camera.models.MediaOutput
|
||||||
import com.simplemobiletools.commons.extensions.toast
|
import com.simplemobiletools.commons.extensions.toast
|
||||||
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@ -58,6 +59,7 @@ class CameraXPreview(
|
|||||||
private val windowMetricsCalculator = WindowMetricsCalculator.getOrCreate()
|
private val windowMetricsCalculator = WindowMetricsCalculator.getOrCreate()
|
||||||
private val videoQualityManager = VideoQualityManager(config)
|
private val videoQualityManager = VideoQualityManager(config)
|
||||||
private val imageQualityManager = ImageQualityManager(activity)
|
private val imageQualityManager = ImageQualityManager(activity)
|
||||||
|
private val exifRemover = ExifRemover(contentResolver)
|
||||||
|
|
||||||
private val orientationEventListener = object : OrientationEventListener(activity, SensorManager.SENSOR_DELAY_NORMAL) {
|
private val orientationEventListener = object : OrientationEventListener(activity, SensorManager.SENSOR_DELAY_NORMAL) {
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
@ -368,8 +370,17 @@ class CameraXPreview(
|
|||||||
|
|
||||||
imageCapture.takePicture(outputOptions, mainExecutor, object : OnImageSavedCallback {
|
imageCapture.takePicture(outputOptions, mainExecutor, object : OnImageSavedCallback {
|
||||||
override fun onImageSaved(outputFileResults: OutputFileResults) {
|
override fun onImageSaved(outputFileResults: OutputFileResults) {
|
||||||
|
ensureBackgroundThread {
|
||||||
|
val savedUri = mediaOutput.uri ?: outputFileResults.savedUri!!
|
||||||
|
if (!config.savePhotoMetadata) {
|
||||||
|
exifRemover.removeExif(savedUri)
|
||||||
|
}
|
||||||
|
|
||||||
|
activity.runOnUiThread {
|
||||||
listener.toggleBottomButtons(false)
|
listener.toggleBottomButtons(false)
|
||||||
listener.onMediaSaved(mediaOutput.uri ?: outputFileResults.savedUri!!)
|
listener.onMediaSaved(savedUri)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(exception: ImageCaptureException) {
|
override fun onError(exception: ImageCaptureException) {
|
||||||
|
Reference in New Issue
Block a user