From 772880aa778cf0228a26e81fc07ab8130f0d1fd6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 8 Jul 2019 22:48:38 +0200 Subject: [PATCH] show file extended details when expected --- .../pro/fragments/ViewPagerFragment.kt | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt index d6df0add0..63feec23f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/ViewPagerFragment.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.gallery.pro.fragments +import android.media.ExifInterface import android.provider.MediaStore import android.view.MotionEvent import androidx.fragment.app.Fragment @@ -39,7 +40,7 @@ abstract class ViewPagerFragment : Fragment() { } val path = "${file.parent.trimEnd('/')}/" - val exif = android.media.ExifInterface(medium.path) + val exif = ExifInterface(medium.path) val details = StringBuilder() val detailsFlag = context!!.config.extendedDetails if (detailsFlag and EXT_NAME != 0) { @@ -73,6 +74,10 @@ abstract class ViewPagerFragment : Fragment() { if (detailsFlag and EXT_EXIF_PROPERTIES != 0) { path.getExifProperties(exif).let { if (it.isNotEmpty()) details.appendln(it) } } + + if (detailsFlag and EXT_GPS != 0) { + getLatLonAltitude(medium.path).let { if (it.isNotEmpty()) details.appendln(it) } + } return details.toString().trim() } @@ -93,6 +98,23 @@ abstract class ViewPagerFragment : Fragment() { return "" } + private fun getLatLonAltitude(path: String): String { + var result = "" + val exif = ExifInterface(path) + val latLon = FloatArray(2) + + if (exif.getLatLong(latLon)) { + result = "${latLon[0]}, ${latLon[1]}" + } + + val altitude = exif.getAltitude(0.0) + if (altitude != 0.0) { + result += ", ${altitude}m" + } + + return result.trimStart(',').trim() + } + protected fun handleEvent(event: MotionEvent) { when (event.actionMasked) { MotionEvent.ACTION_DOWN -> {