show the Remove EXIF button only at some image extensions

This commit is contained in:
tibbi 2022-03-20 20:25:46 +01:00
parent ae2488ff25
commit a42e990ca4
3 changed files with 7 additions and 3 deletions

View file

@ -53,7 +53,7 @@ class PropertiesDialog() {
val builder = AlertDialog.Builder(mActivity)
.setPositiveButton(R.string.ok, null)
if (!path.startsWith("content://")) {
if (!path.startsWith("content://") && path.canModifyEXIF()) {
builder.setNeutralButton(R.string.remove_exif, null)
}
@ -243,7 +243,7 @@ class PropertiesDialog() {
val builder = AlertDialog.Builder(mActivity)
.setPositiveButton(R.string.ok, null)
if (!paths.any { it.startsWith("content://") }) {
if (!paths.any { it.startsWith("content://") } && paths.any { it.canModifyEXIF() }) {
builder.setNeutralButton(R.string.remove_exif, null)
}
@ -307,7 +307,7 @@ class PropertiesDialog() {
private fun removeEXIFFromPaths(paths: List<String>) {
ConfirmationDialog(mActivity, "", R.string.remove_exif_confirmation) {
try {
paths.forEach {
paths.filter { it.canModifyEXIF() }.forEach {
ExifInterface(it).removeValues()
}
mActivity.toast(R.string.exif_removed)

View file

@ -103,6 +103,8 @@ fun String.isImageSlow() = isImageFast() || getMimeType().startsWith("image") ||
fun String.isVideoSlow() = isVideoFast() || getMimeType().startsWith("video") || startsWith(MediaStore.Video.Media.EXTERNAL_CONTENT_URI.toString())
fun String.isAudioSlow() = isAudioFast() || getMimeType().startsWith("audio") || startsWith(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI.toString())
fun String.canModifyEXIF() = extensionsSupportingEXIF.any { endsWith(it, true) }
fun String.getCompressionFormat() = when (getFilenameExtension().toLowerCase()) {
"png" -> Bitmap.CompressFormat.PNG
"webp" -> Bitmap.CompressFormat.WEBP

View file

@ -304,6 +304,8 @@ val videoExtensions: Array<String> get() = arrayOf(".mp4", ".mkv", ".webm", ".av
val audioExtensions: Array<String> get() = arrayOf(".mp3", ".wav", ".wma", ".ogg", ".m4a", ".opus", ".flac", ".aac")
val rawExtensions: Array<String> get() = arrayOf(".dng", ".orf", ".nef", ".arw", ".rw2", ".cr2", ".cr3")
val extensionsSupportingEXIF: Array<String> get() = arrayOf(".jpg", ".jpeg", ".png", ".webp", ".dng")
const val DATE_FORMAT_ONE = "dd.MM.yyyy"
const val DATE_FORMAT_TWO = "dd/MM/yyyy"
const val DATE_FORMAT_THREE = "MM/dd/yyyy"