From 04ebe8bc12c9bcc681d30a8e3b4e94dc0d0a05a0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 14 Jan 2017 23:38:37 +0100 Subject: [PATCH] display some EXIF info at photo properties --- .../commons/dialogs/PropertiesDialog.kt | 32 +++++++++++++++++++ commons/src/main/res/values-de/strings.xml | 4 +++ commons/src/main/res/values-es/strings.xml | 4 +++ commons/src/main/res/values-fr/strings.xml | 4 +++ .../src/main/res/values-hi-rIN/strings.xml | 4 +++ commons/src/main/res/values-hu/strings.xml | 4 +++ commons/src/main/res/values-it/strings.xml | 4 +++ commons/src/main/res/values-ja/strings.xml | 4 +++ .../src/main/res/values-pt-rPT/strings.xml | 4 +++ commons/src/main/res/values-ru/strings.xml | 4 +++ commons/src/main/res/values-sv/strings.xml | 4 +++ commons/src/main/res/values-tr/strings.xml | 4 +++ .../src/main/res/values-zh-rCN/strings.xml | 4 +++ commons/src/main/res/values/strings.xml | 4 +++ 14 files changed, 84 insertions(+) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PropertiesDialog.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PropertiesDialog.kt index 22ff3879b..fd8c89495 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PropertiesDialog.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/dialogs/PropertiesDialog.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.commons.dialogs import android.app.Activity import android.content.res.Resources +import android.media.ExifInterface import android.support.v7.app.AlertDialog import android.view.LayoutInflater import android.view.ViewGroup @@ -13,6 +14,7 @@ import kotlinx.android.synthetic.main.property_item.view.* import java.io.File import java.util.* + class PropertiesDialog() { lateinit var mInflater: LayoutInflater lateinit var mPropertyView: ViewGroup @@ -64,6 +66,36 @@ class PropertiesDialog() { addProperty(R.string.album, file.getAlbum()) } + val exif = ExifInterface(path) + exif.getAttribute(ExifInterface.TAG_FOCAL_LENGTH).let { + if (it?.isNotEmpty() == true) { + val values = it.split('/') + val focalLength = "${Math.round(values[0].toDouble() / values[1].toDouble())}mm ($it)" + addProperty(R.string.focal_length, focalLength) + } + } + + exif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME).let { + if (it?.isNotEmpty() == true) { + val exposureSec = (1 / it.toFloat()).toInt() + val exposureTime = "1/$exposureSec (${it}s)" + addProperty(R.string.exposure_time, exposureTime) + } + } + + exif.getAttribute(ExifInterface.TAG_ISO_SPEED_RATINGS).let { + if (it?.isNotEmpty() == true) { + addProperty(R.string.iso_speed, it) + } + } + + exif.getAttribute(ExifInterface.TAG_F_NUMBER).let { + if (it?.isNotEmpty() == true) { + val fNumber = "f/$it" + addProperty(R.string.focal_length, fNumber) + } + } + AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) .create().apply { diff --git a/commons/src/main/res/values-de/strings.xml b/commons/src/main/res/values-de/strings.xml index f03e22ff3..1d0c6064a 100644 --- a/commons/src/main/res/values-de/strings.xml +++ b/commons/src/main/res/values-de/strings.xml @@ -67,6 +67,10 @@ Dauer Künstler Album + Focal length + Exposure time + ISO speed + F-number Hintergrundfarbe diff --git a/commons/src/main/res/values-es/strings.xml b/commons/src/main/res/values-es/strings.xml index a89b3b9c5..bb7b617bc 100644 --- a/commons/src/main/res/values-es/strings.xml +++ b/commons/src/main/res/values-es/strings.xml @@ -68,6 +68,10 @@ Duración Artista Álbum + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-fr/strings.xml b/commons/src/main/res/values-fr/strings.xml index a503ab577..8c543fc7c 100644 --- a/commons/src/main/res/values-fr/strings.xml +++ b/commons/src/main/res/values-fr/strings.xml @@ -68,6 +68,10 @@ Durée Artiste Album + Focal length + Exposure time + ISO speed + F-number Couleur d\'arrière-plan diff --git a/commons/src/main/res/values-hi-rIN/strings.xml b/commons/src/main/res/values-hi-rIN/strings.xml index 338450fc5..545d1e23c 100644 --- a/commons/src/main/res/values-hi-rIN/strings.xml +++ b/commons/src/main/res/values-hi-rIN/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-hu/strings.xml b/commons/src/main/res/values-hu/strings.xml index 9b26a7afe..bb2d64ffc 100644 --- a/commons/src/main/res/values-hu/strings.xml +++ b/commons/src/main/res/values-hu/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-it/strings.xml b/commons/src/main/res/values-it/strings.xml index 1902dc74a..77c3ae505 100644 --- a/commons/src/main/res/values-it/strings.xml +++ b/commons/src/main/res/values-it/strings.xml @@ -68,6 +68,10 @@ Durata Artista Album + Focal length + Exposure time + ISO speed + F-number Colore di sfondo diff --git a/commons/src/main/res/values-ja/strings.xml b/commons/src/main/res/values-ja/strings.xml index 6b2149d22..5ab607088 100644 --- a/commons/src/main/res/values-ja/strings.xml +++ b/commons/src/main/res/values-ja/strings.xml @@ -68,6 +68,10 @@ 期間 アーティスト アルバム + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-pt-rPT/strings.xml b/commons/src/main/res/values-pt-rPT/strings.xml index d5ff4fe7a..7937d24e9 100644 --- a/commons/src/main/res/values-pt-rPT/strings.xml +++ b/commons/src/main/res/values-pt-rPT/strings.xml @@ -68,6 +68,10 @@ Duração Artista Álbum + Focal length + Exposure time + ISO speed + F-number Cor de fundo diff --git a/commons/src/main/res/values-ru/strings.xml b/commons/src/main/res/values-ru/strings.xml index cc9bbfdbf..b12f2b5a7 100644 --- a/commons/src/main/res/values-ru/strings.xml +++ b/commons/src/main/res/values-ru/strings.xml @@ -68,6 +68,10 @@ Длительность Исполнитель Альбом + Focal length + Exposure time + ISO speed + F-number Цвет фона diff --git a/commons/src/main/res/values-sv/strings.xml b/commons/src/main/res/values-sv/strings.xml index 4e490afa1..20d848fb1 100644 --- a/commons/src/main/res/values-sv/strings.xml +++ b/commons/src/main/res/values-sv/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-tr/strings.xml b/commons/src/main/res/values-tr/strings.xml index 622b08be1..7db956f8b 100644 --- a/commons/src/main/res/values-tr/strings.xml +++ b/commons/src/main/res/values-tr/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values-zh-rCN/strings.xml b/commons/src/main/res/values-zh-rCN/strings.xml index 50f3dcb1d..7cde38865 100644 --- a/commons/src/main/res/values-zh-rCN/strings.xml +++ b/commons/src/main/res/values-zh-rCN/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color diff --git a/commons/src/main/res/values/strings.xml b/commons/src/main/res/values/strings.xml index 622b08be1..7db956f8b 100644 --- a/commons/src/main/res/values/strings.xml +++ b/commons/src/main/res/values/strings.xml @@ -68,6 +68,10 @@ Duration Artist Album + Focal length + Exposure time + ISO speed + F-number Background color