From 0f79cf9b8eae40c5eacdbaba981f305082eb5c9e Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 9 Jan 2019 23:50:57 +0100 Subject: [PATCH] adding some play/pause improvements --- .../pro/activities/ViewPagerActivity.kt | 3 +++ .../gallery/pro/fragments/VideoFragment.kt | 20 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 6edf32c38..cda0390d8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -41,6 +41,7 @@ import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog import com.simplemobiletools.gallery.pro.dialogs.SlideshowDialog import com.simplemobiletools.gallery.pro.extensions.* import com.simplemobiletools.gallery.pro.fragments.PhotoFragment +import com.simplemobiletools.gallery.pro.fragments.VideoFragment import com.simplemobiletools.gallery.pro.fragments.ViewPagerFragment import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.models.Medium @@ -492,6 +493,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View swipeToNextMedium() } }, mSlideshowInterval * 1000L) + } else { + (getCurrentFragment() as? VideoFragment)!!.playVideo() } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt index 2e921f978..2e33786b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/fragments/VideoFragment.kt @@ -9,6 +9,7 @@ import android.os.Bundle import android.os.Handler import android.util.DisplayMetrics import android.view.* +import android.widget.ImageView import android.widget.RelativeLayout import android.widget.SeekBar import android.widget.TextView @@ -52,6 +53,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S private var mTextureView: TextureView? = null private var mCurrTimeView: TextView? = null + private var mPlayPauseButton: ImageView? = null private var mSeekBar: SeekBar? = null private var mExoPlayer: SimpleExoPlayer? = null private var mVideoSize = Point(0, 0) @@ -89,6 +91,11 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } } + mPlayPauseButton = video_toggle_play_pause + mPlayPauseButton!!.setOnClickListener { + togglePlayPause() + } + mSeekBar = video_seekbar mSeekBar!!.setOnSeekBarChangeListener(this@VideoFragment) // adding an empty click listener just to avoid ripple animation at toggling fullscreen @@ -433,6 +440,10 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } mSeekBar!!.setOnSeekBarChangeListener(if (mIsFullscreen) null else this) + arrayOf(mView.video_curr_time, mView.video_duration).forEach { + it.isClickable = !mIsFullscreen + } + mTimeHolder.animate().alpha(newAlpha).start() mView.video_details.apply { if (mStoredShowExtendedDetails && isVisible()) { @@ -539,7 +550,12 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } if (!wasEnded || context?.config?.loopVideos == false) { - mView.video_play_outline.setImageResource(R.drawable.ic_pause) + mPlayPauseButton?.setImageResource(R.drawable.ic_pause_outline) + } + + if (!mWasVideoStarted) { + mView.video_play_outline.beGone() + mPlayPauseButton?.beVisible() } mWasVideoStarted = true @@ -563,7 +579,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S mExoPlayer?.playWhenReady = false } - mView.video_play_outline?.setImageResource(R.drawable.ic_play) + mPlayPauseButton?.setImageResource(R.drawable.ic_play_outline) activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) }