mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 20:48:00 +01:00
show extended details at photos/videos if appropriate
This commit is contained in:
parent
90e3d6c6f5
commit
2e339f08e4
5 changed files with 102 additions and 23 deletions
|
@ -37,7 +37,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.29.18'
|
||||
compile 'com.simplemobiletools:commons:2.29.20'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RelativeLayout
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.Priority
|
||||
import com.bumptech.glide.load.DataSource
|
||||
|
@ -24,15 +25,10 @@ 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.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisible
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.getFileSignature
|
||||
import com.simplemobiletools.gallery.extensions.getRealPathFromURI
|
||||
import com.simplemobiletools.gallery.extensions.portrait
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.helpers.GlideRotateTransformation
|
||||
import com.simplemobiletools.gallery.helpers.MEDIUM
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
@ -101,6 +97,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
}
|
||||
loadImage()
|
||||
checkExtendedDetails()
|
||||
|
||||
wasInit = true
|
||||
|
||||
|
@ -258,6 +255,29 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
loadBitmap(degrees)
|
||||
}
|
||||
|
||||
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"
|
||||
(layoutParams as RelativeLayout.LayoutParams).bottomMargin = (resources.getDimension(R.dimen.small_margin) + context.navigationBarHeight).toInt()
|
||||
}
|
||||
} else {
|
||||
view.photo_details.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !activity.isDestroyed) {
|
||||
|
@ -268,6 +288,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
loadImage()
|
||||
checkExtendedDetails()
|
||||
}
|
||||
|
||||
private fun photoClicked() {
|
||||
|
|
|
@ -14,16 +14,17 @@ import android.view.*
|
|||
import android.view.animation.AnimationUtils
|
||||
import android.widget.SeekBar
|
||||
import android.widget.TextView
|
||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getFormattedDuration
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.gallery.R
|
||||
import com.simplemobiletools.gallery.activities.ViewPagerActivity
|
||||
import com.simplemobiletools.gallery.extensions.*
|
||||
import com.simplemobiletools.gallery.extensions.audioManager
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.hasNavBar
|
||||
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 {
|
||||
|
@ -36,7 +37,6 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
private var mCurrTimeView: TextView? = null
|
||||
private var mTimerHandler: Handler? = null
|
||||
private var mSeekBar: SeekBar? = null
|
||||
private var mTimeHolder: View? = null
|
||||
|
||||
private var mIsPlaying = false
|
||||
private var mIsDragged = false
|
||||
|
@ -59,6 +59,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
lateinit var mView: View
|
||||
lateinit var medium: Medium
|
||||
lateinit var mTimeHolder: View
|
||||
|
||||
companion object {
|
||||
private val TAG = VideoFragment::class.java.simpleName
|
||||
|
@ -67,9 +68,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
mView = inflater.inflate(R.layout.pager_video_item, container, false)
|
||||
setupPlayer()
|
||||
|
||||
mTimeHolder = mView.video_time_holder
|
||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||
|
||||
setupPlayer()
|
||||
if (savedInstanceState != null) {
|
||||
mCurrTime = savedInstanceState.getInt(PROGRESS)
|
||||
}
|
||||
|
@ -109,6 +111,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
initTimeHolder()
|
||||
checkExtendedDetails()
|
||||
}
|
||||
|
||||
override fun setMenuVisibility(menuVisible: Boolean) {
|
||||
|
@ -131,6 +134,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
super.onConfigurationChanged(newConfig)
|
||||
setVideoSize()
|
||||
initTimeHolder()
|
||||
checkExtendedDetails()
|
||||
}
|
||||
|
||||
private fun toggleFullscreen() {
|
||||
|
@ -261,11 +265,10 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
}
|
||||
|
||||
private fun initTimeHolder() {
|
||||
mTimeHolder = mView.video_time_holder
|
||||
val res = resources
|
||||
val height = res.getNavBarHeight()
|
||||
val left = mTimeHolder!!.paddingLeft
|
||||
val top = mTimeHolder!!.paddingTop
|
||||
val height = context.navigationBarHeight
|
||||
val left = mTimeHolder.paddingLeft
|
||||
val top = mTimeHolder.paddingTop
|
||||
var right = res.getDimension(R.dimen.timer_padding).toInt()
|
||||
var bottom = 0
|
||||
|
||||
|
@ -276,7 +279,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
right += height
|
||||
bottom += context.navigationBarHeight
|
||||
}
|
||||
mTimeHolder!!.setPadding(left, top, right, bottom)
|
||||
mTimeHolder.setPadding(left, top, right, bottom)
|
||||
}
|
||||
|
||||
mCurrTimeView = mView.video_curr_time
|
||||
|
@ -284,7 +287,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
mSeekBar!!.setOnSeekBarChangeListener(this)
|
||||
|
||||
if (mIsFullscreen)
|
||||
mTimeHolder!!.visibility = View.INVISIBLE
|
||||
mTimeHolder.beInvisible()
|
||||
}
|
||||
|
||||
private fun setupTimeHolder() {
|
||||
|
@ -328,7 +331,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
|||
AnimationUtils.loadAnimation(activity, anim).apply {
|
||||
duration = 150
|
||||
fillAfter = true
|
||||
mTimeHolder!!.startAnimation(this)
|
||||
mTimeHolder.startAnimation(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,6 +497,31 @@ 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"
|
||||
}
|
||||
} else {
|
||||
mView.video_details.beGone()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
if (mMediaPlayer != null && fromUser) {
|
||||
setProgress(progress)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/photo_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -16,4 +17,18 @@
|
|||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/photo_details"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@color/gradient_grey_start"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:textSize="@dimen/smaller_text_size"
|
||||
android:visibility="gone"
|
||||
tools:text="My image\nAnother line"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/video_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
@ -50,6 +51,20 @@
|
|||
android:textColor="@android:color/white"
|
||||
android:textSize="@dimen/extra_big_text_size"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/video_details"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/video_time_holder"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginLeft="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@color/gradient_grey_start"
|
||||
android:padding="@dimen/small_margin"
|
||||
android:textSize="@dimen/smaller_text_size"
|
||||
android:visibility="gone"
|
||||
tools:text="My video\nAnother line"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/video_time_holder"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
Loading…
Reference in a new issue