display only the wanted extended details fields
This commit is contained in:
parent
3f008960de
commit
d78068d697
|
@ -25,7 +25,9 @@ import com.bumptech.glide.request.RequestOptions
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
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.R
|
||||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
|
@ -271,20 +273,10 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
|
|
||||||
private fun checkExtendedDetails() {
|
private fun checkExtendedDetails() {
|
||||||
if (context.config.showExtendedDetails) {
|
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 {
|
view.photo_details.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
setTextColor(context.config.textColor)
|
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()
|
(layoutParams as RelativeLayout.LayoutParams).bottomMargin = (resources.getDimension(R.dimen.small_margin) + context.navigationBarHeight).toInt()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import com.simplemobiletools.gallery.extensions.navigationBarHeight
|
||||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import kotlinx.android.synthetic.main.pager_video_item.view.*
|
import kotlinx.android.synthetic.main.pager_video_item.view.*
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSeekBarChangeListener {
|
class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSeekBarChangeListener {
|
||||||
|
@ -505,23 +504,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
|
|
||||||
private fun checkExtendedDetails() {
|
private fun checkExtendedDetails() {
|
||||||
if (context.config.showExtendedDetails) {
|
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 {
|
mView.video_details.apply {
|
||||||
beVisible()
|
beVisible()
|
||||||
setTextColor(context.config.textColor)
|
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 {
|
} else {
|
||||||
mView.video_details.beGone()
|
mView.video_details.beGone()
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package com.simplemobiletools.gallery.fragments
|
package com.simplemobiletools.gallery.fragments
|
||||||
|
|
||||||
import android.support.v4.app.Fragment
|
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() {
|
abstract class ViewPagerFragment : Fragment() {
|
||||||
var listener: FragmentListener? = null
|
var listener: FragmentListener? = null
|
||||||
|
@ -12,4 +17,44 @@ abstract class ViewPagerFragment : Fragment() {
|
||||||
|
|
||||||
fun videoEnded(): Boolean
|
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)
|
if (shouldStop)
|
||||||
break
|
break
|
||||||
|
|
||||||
val path = cur.getStringValue(MediaStore.Images.Media.DATA)
|
val path = cur.getStringValue(MediaStore.Images.Media.DATA).trim()
|
||||||
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME) ?: ""
|
var filename = cur.getStringValue(MediaStore.Images.Media.DISPLAY_NAME)?.trim() ?: ""
|
||||||
if (filename.isEmpty())
|
if (filename.isEmpty())
|
||||||
filename = path.getFilenameFromPath()
|
filename = path.getFilenameFromPath()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue