mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
display only the wanted extended details fields
This commit is contained in:
parent
3f008960de
commit
d78068d697
4 changed files with 52 additions and 29 deletions
|
@ -25,7 +25,9 @@ import com.bumptech.glide.request.RequestOptions
|
|||
import com.bumptech.glide.request.target.Target
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisible
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
|
@ -271,20 +273,10 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
private fun checkExtendedDetails() {
|
||||
if (context.config.showExtendedDetails) {
|
||||
val file = File(medium.path)
|
||||
val name = medium.name
|
||||
val path = "${File(medium.path).parent.trimEnd('/')}/"
|
||||
val exif = android.media.ExifInterface(medium.path)
|
||||
val size = file.length().formatSize()
|
||||
val resolution = file.getResolution().formatAsResolution()
|
||||
val lastModified = file.lastModified().formatLastModified()
|
||||
val dateTaken = path.getExifDateTaken(exif)
|
||||
val cameraModel = path.getExifCameraModel(exif)
|
||||
val exifProperties = path.getExifProperties(exif)
|
||||
view.photo_details.apply {
|
||||
beVisible()
|
||||
setTextColor(context.config.textColor)
|
||||
text = "$name\n$path\n$size\n$resolution\n$lastModified\n$dateTaken\n$cameraModel\n$exifProperties"
|
||||
text = getMediumExtendedDetails(medium)
|
||||
(layoutParams as RelativeLayout.LayoutParams).bottomMargin = (resources.getDimension(R.dimen.small_margin) + context.navigationBarHeight).toInt()
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.simplemobiletools.gallery.extensions.navigationBarHeight
|
|||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import kotlinx.android.synthetic.main.pager_video_item.view.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSeekBarChangeListener {
|
||||
|
@ -505,23 +504,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
private fun checkExtendedDetails() {
|
||||
if (context.config.showExtendedDetails) {
|
||||
val file = File(medium.path)
|
||||
val name = medium.name
|
||||
val path = "${File(medium.path).parent.trimEnd('/')}/"
|
||||
val exif = android.media.ExifInterface(medium.path)
|
||||
val size = file.length().formatSize()
|
||||
val resolution = file.getResolution().formatAsResolution()
|
||||
val duration = file.getDuration()
|
||||
val artist = file.getArtist() ?: ""
|
||||
val album = file.getAlbum() ?: ""
|
||||
val lastModified = file.lastModified().formatLastModified()
|
||||
val dateTaken = path.getExifDateTaken(exif)
|
||||
val cameraModel = path.getExifCameraModel(exif)
|
||||
val exifProperties = path.getExifProperties(exif)
|
||||
mView.video_details.apply {
|
||||
beVisible()
|
||||
setTextColor(context.config.textColor)
|
||||
text = "$name\n$path\n$size\n$resolution\n$duration\n$artist\n$album\n$lastModified\n$dateTaken\n$cameraModel\n$exifProperties"
|
||||
text = getMediumExtendedDetails(medium)
|
||||
}
|
||||
} else {
|
||||
mView.video_details.beGone()
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.simplemobiletools.gallery.fragments
|
||||
|
||||
import android.support.v4.app.Fragment
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.*
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
|
||||
abstract class ViewPagerFragment : Fragment() {
|
||||
var listener: FragmentListener? = null
|
||||
|
@ -12,4 +17,44 @@ abstract class ViewPagerFragment : Fragment() {
|
|||
|
||||
fun videoEnded(): Boolean
|
||||
}
|
||||
|
||||
fun getMediumExtendedDetails(medium: Medium): String {
|
||||
val file = File(medium.path)
|
||||
val path = "${file.parent.trimEnd('/')}/"
|
||||
val exif = android.media.ExifInterface(medium.path)
|
||||
val details = StringBuilder()
|
||||
val detailsFlag = context.config.extendedDetails
|
||||
if (detailsFlag and EXT_NAME != 0) {
|
||||
medium.name.let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_PATH != 0) {
|
||||
path.let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_SIZE != 0) {
|
||||
file.length().formatSize().let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_RESOLUTION != 0) {
|
||||
file.getResolution().formatAsResolution().let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_LAST_MODIFIED != 0) {
|
||||
file.lastModified().formatLastModified().let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_DATE_TAKEN != 0) {
|
||||
path.getExifDateTaken(exif).let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_CAMERA_MODEL != 0) {
|
||||
path.getExifCameraModel(exif).let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
|
||||
if (detailsFlag and EXT_EXIF_PROPERTIES != 0) {
|
||||
path.getExifProperties(exif).let { if (it.isNotEmpty()) details.appendln(it) }
|
||||
}
|
||||
return details.toString().trim()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,8 +110,8 @@ class MediaFetcher(val context: Context) {
|
|||
if (shouldStop)
|
||||
break
|
||||
|
||||
val path = cur.getStringValue(MediaStore.Images.Media.DATA)
|
||||
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""
|
||||
val path = cur.getStringValue(MediaStore.Images.Media.DATA).trim()
|
||||
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)?.trim() ?: ""
|
||||
if (filename.isEmpty())
|
||||
filename = path.getFilenameFromPath()
|
||||
|
||||
|
|
Loading…
Reference in a new issue