fix #98, properly set some date/time related exif values when appropriate

This commit is contained in:
tibbi 2018-06-11 12:32:52 +02:00
parent 368a9c109d
commit d8f68fe643
2 changed files with 13 additions and 3 deletions

View File

@ -45,7 +45,7 @@ ext {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:4.1.4' implementation 'com.simplemobiletools:commons:4.1.5'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"

View File

@ -17,6 +17,8 @@ import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.OutputStream import java.io.OutputStream
import java.text.SimpleDateFormat
import java.util.*
class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOrientation: Int, val previewRotation: Int, val isUsingFrontCamera: Boolean) : class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOrientation: Int, val previewRotation: Int, val isUsingFrontCamera: Boolean) :
AsyncTask<ByteArray, Void, String>() { AsyncTask<ByteArray, Void, String>() {
@ -105,8 +107,16 @@ class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOr
} }
if (activity.config.savePhotoMetadata) { if (activity.config.savePhotoMetadata) {
val fileExif = ExifInterface(path) val dateTimeFormat = SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.getDefault())
tempExif.copyTo(fileExif) val formatted = dateTimeFormat.format(Date())
ExifInterface(path).apply {
setAttribute(ExifInterface.TAG_DATETIME, formatted)
setAttribute(ExifInterface.TAG_DATETIME_DIGITIZED, formatted)
setAttribute(ExifInterface.TAG_DATETIME_ORIGINAL, formatted)
saveAttributes()
tempExif.copyTo(this)
}
} }
return photoFile.absolutePath return photoFile.absolutePath