display some EXIF info at photo properties

This commit is contained in:
tibbi 2017-01-14 23:38:37 +01:00
parent 584b09f602
commit 04ebe8bc12
14 changed files with 84 additions and 0 deletions

View file

@ -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 {

View file

@ -67,6 +67,10 @@
<string name="duration">Dauer</string>
<string name="artist">Künstler</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Hintergrundfarbe</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duración</string>
<string name="artist">Artista</string>
<string name="album">Álbum</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Durée</string>
<string name="artist">Artiste</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Couleur d\'arrière-plan</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Durata</string>
<string name="artist">Artista</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Colore di sfondo</string>

View file

@ -68,6 +68,10 @@
<string name="duration">期間</string>
<string name="artist">アーティスト</string>
<string name="album">アルバム</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duração</string>
<string name="artist">Artista</string>
<string name="album">Álbum</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Cor de fundo</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Длительность</string>
<string name="artist">Исполнитель</string>
<string name="album">Альбом</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Цвет фона</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>

View file

@ -68,6 +68,10 @@
<string name="duration">Duration</string>
<string name="artist">Artist</string>
<string name="album">Album</string>
<string name="focal_length">Focal length</string>
<string name="exposure_time">Exposure time</string>
<string name="iso_speed">ISO speed</string>
<string name="f_number">F-number</string>
<!-- Color customization -->
<string name="background_color">Background color</string>