show file extended details when expected
This commit is contained in:
parent
f2895845ee
commit
772880aa77
1 changed files with 23 additions and 1 deletions
|
@ -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 -> {
|
||||
|
|
Loading…
Reference in a new issue