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 a7cb97cd9..137d5e7cd 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 @@ -26,6 +26,7 @@ import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.isPiePlus import com.simplemobiletools.gallery.pro.R import com.simplemobiletools.gallery.pro.extensions.* +import com.simplemobiletools.gallery.pro.helpers.CLICK_MAX_DURATION import com.simplemobiletools.gallery.pro.helpers.DRAG_THRESHOLD import com.simplemobiletools.gallery.pro.helpers.MIN_SKIP_LENGTH import kotlinx.android.synthetic.main.activity_video_player.* @@ -51,6 +52,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private var mTouchDownX = 0f private var mTouchDownY = 0f + private var mTouchDownTime = 0L private var mProgressAtDown = 0L private var mCloseDownThreshold = 100f private var mIgnoreCloseDown = false @@ -144,32 +146,22 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen fullscreenToggled(isFullscreen) } - // adding an empty click listener just to avoid ripple animation at toggling fullscreen - video_seekbar.setOnClickListener { } video_curr_time.setOnClickListener { skip(false) } video_duration.setOnClickListener { skip(true) } video_toggle_play_pause.setOnClickListener { togglePlayPause() } - video_player_holder.setOnClickListener { - fullscreenToggled(!mIsFullscreen) + + video_player_holder.setOnTouchListener { view, event -> + handleEvent(event) + true } - if (config.allowDownGesture) { - video_player_holder.setOnTouchListener { v, event -> - handleEvent(event) - false - } - - video_surface.setOnTouchListener { v, event -> - handleEvent(event) - false - } + video_surface.setOnTouchListener { view, event -> + handleEvent(event) + true } initExoPlayer() video_surface.surfaceTextureListener = this - video_surface.setOnClickListener { - fullscreenToggled(!mIsFullscreen) - } if (config.allowVideoGestures) { video_brightness_controller.initialize(this, slide_info, true, video_player_holder) { x, y -> @@ -470,6 +462,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen MotionEvent.ACTION_DOWN -> { mTouchDownX = event.x mTouchDownY = event.y + mTouchDownTime = System.currentTimeMillis() mProgressAtDown = mExoPlayer!!.currentPosition } MotionEvent.ACTION_POINTER_DOWN -> mIgnoreCloseDown = true @@ -500,9 +493,10 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen val diffX = mTouchDownX - event.x val diffY = mTouchDownY - event.y - if (!mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold) { + if (config.allowDownGesture && !mIgnoreCloseDown && Math.abs(diffY) > Math.abs(diffX) && diffY < -mCloseDownThreshold) { supportFinishAfterTransition() } + mIgnoreCloseDown = false if (mIsDragged) { if (mIsFullscreen) { @@ -514,6 +508,10 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen if (!mIsPlaying) { togglePlayPause() } + } else { + if (System.currentTimeMillis() - mTouchDownTime < CLICK_MAX_DURATION) { + fullscreenToggled(!mIsFullscreen) + } } mIsDragged = false }