From 6b68fa71f6600688c7753730ecaa5f671eb80b62 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 22 Dec 2022 10:40:46 +0100 Subject: [PATCH 1/2] Ignore touches to the top of the player --- .../java/com/github/libretube/util/PlayerGestureController.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt index fe6b74d5b..7e7355077 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt @@ -55,6 +55,9 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play listener.onSwipeEnd() } + // ignore touches to the top of the player + if (event.y < height * 0.1) return false + // Event can be already consumed by some view which may lead to NPE. try { scaleGestureDetector.onTouchEvent(event) From 6bd64dde38359f030156a3597c8a028b05ce059d Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 22 Dec 2022 10:44:58 +0100 Subject: [PATCH 2/2] only ignore touches at top of player when in landscape --- .../com/github/libretube/util/PlayerGestureController.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt index 7e7355077..a74d9e8c3 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt @@ -1,6 +1,7 @@ package com.github.libretube.util import android.annotation.SuppressLint +import android.content.res.Configuration import android.content.res.Resources import android.os.Handler import android.os.Looper @@ -22,6 +23,7 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play // size changes. private val width get() = Resources.getSystem().displayMetrics.widthPixels private val height get() = Resources.getSystem().displayMetrics.heightPixels + private val orientation get() = Resources.getSystem().configuration.orientation private val elapsedTime get() = SystemClock.elapsedRealtime() private val playerViewModel: PlayerViewModel by activity.viewModels() @@ -55,8 +57,8 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play listener.onSwipeEnd() } - // ignore touches to the top of the player - if (event.y < height * 0.1) return false + // ignore touches to the top of the player when in landscape mode + if (event.y < height * 0.1 && orientation == Configuration.ORIENTATION_LANDSCAPE) return false // Event can be already consumed by some view which may lead to NPE. try {