diff --git a/app/build.gradle b/app/build.gradle index 7dda3beb3..7e2290627 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -81,7 +81,7 @@ dependencies { implementation 'org.apache.sanselan:sanselan:0.97-incubator' implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.caverock:androidsvg-aar:1.3' - implementation 'com.github.tibbi:gestureviews:8dccb8450b' + implementation 'com.github.tibbi:gestureviews:512f929d82' implementation 'com.github.tibbi:subsampling-scale-image-view:d404e74e39' kapt 'com.github.bumptech.glide:compiler:4.10.0' 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 e0ad02923..c6662e523 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 @@ -39,6 +39,7 @@ import java.io.FileInputStream class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener { private val PROGRESS = "progress" + private val DOUBLE_TAP_SKIP_MS = 10000 private var mIsFullscreen = false private var mWasFragmentInit = false @@ -86,6 +87,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S video_duration.setOnClickListener { skip(true) } video_holder.setOnClickListener { toggleFullscreen() } video_preview.setOnClickListener { toggleFullscreen() } + video_surface_frame.controller.settings.swallowDoubleTaps = true video_play_outline.setOnClickListener { if (mConfig.openVideosOnSeparateScreen) { @@ -129,6 +131,19 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } return true } + + override fun onDoubleTap(e: MotionEvent?): Boolean { + val viewWidth = width + val instantWidth = viewWidth / 7 + val clickedX = e?.rawX ?: 0f + when { + clickedX <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_MS, false) + clickedX >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_MS, true) + else -> togglePlayPause() + } + + return true + } }) if (mConfig.allowDownGesture) { @@ -521,9 +536,13 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } mPositionAtPause = 0L - val curr = mExoPlayer!!.currentPosition val twoPercents = Math.max((mExoPlayer!!.duration / 50).toInt(), MIN_SKIP_LENGTH) - val newProgress = if (forward) curr + twoPercents else curr - twoPercents + doSkip(twoPercents, forward) + } + + private fun doSkip(millis: Int, forward: Boolean) { + val curr = mExoPlayer!!.currentPosition + val newProgress = if (forward) curr + millis else curr - millis val roundProgress = Math.round(newProgress / 1000f) val limitedProgress = Math.max(Math.min(mExoPlayer!!.duration.toInt(), roundProgress), 0) setPosition(limitedProgress)