diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index 01daa6fbc..6b08ef6c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -174,12 +174,8 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen val gestureDetector = GestureDetector(this, object : GestureDetector.SimpleOnGestureListener() { override fun onDoubleTap(e: MotionEvent?): Boolean { - val instantWidth = mScreenWidth / 7 - val clickedX = e?.rawX ?: 0f - when { - clickedX <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) - clickedX >= mScreenWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) - else -> togglePlayPause() + if (e != null) { + handleDoubleTap(e.rawX) } return true @@ -198,10 +194,14 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen if (config.allowVideoGestures) { video_brightness_controller.initialize(this, slide_info, true, video_player_holder, singleTap = { x, y -> toggleFullscreen() + }, doubleTap = {x, y -> + doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) }) video_volume_controller.initialize(this, slide_info, false, video_player_holder, singleTap = { x, y -> toggleFullscreen() + }, doubleTap = {x, y -> + doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) }) } else { video_brightness_controller.beGone() @@ -304,6 +304,15 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen } } + private fun handleDoubleTap(x: Float) { + val instantWidth = mScreenWidth / 7 + when { + x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) + x >= mScreenWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + else -> togglePlayPause() + } + } + private fun resumeVideo() { video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline) if (mExoPlayer == null) { 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 63fb3688f..8d7557fd3 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 @@ -132,13 +132,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } 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_VIDEO_MS, false) - clickedX >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) - else -> togglePlayPause() + if (e != null) { + handleDoubleTap(e.rawX) } return true @@ -211,6 +206,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } else { toggleFullscreen() } + }, doubleTap = {x, y -> + doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) }) mVolumeSideScroll.initialize(activity!!, slide_info, false, container, singleTap = { x, y -> @@ -219,6 +216,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S } else { toggleFullscreen() } + }, doubleTap = {x, y -> + doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) }) video_surface.onGlobalLayout { @@ -428,6 +427,16 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S listener?.fragmentClicked() } + private fun handleDoubleTap(x: Float) { + val viewWidth = mView.width + val instantWidth = viewWidth / 7 + when { + x <= instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, false) + x >= viewWidth - instantWidth -> doSkip(DOUBLE_TAP_SKIP_VIDEO_MS, true) + else -> togglePlayPause() + } + } + private fun checkExtendedDetails() { if (mConfig.showExtendedDetails) { mView.video_details.apply {