Merge pull request #2475 from Bnyro/master

Ignore touches to the top of the player
This commit is contained in:
Bnyro 2022-12-22 10:45:07 +01:00 committed by GitHub
commit b389895c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package com.github.libretube.util package com.github.libretube.util
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.res.Configuration
import android.content.res.Resources import android.content.res.Resources
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
@ -22,6 +23,7 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
// size changes. // size changes.
private val width get() = Resources.getSystem().displayMetrics.widthPixels private val width get() = Resources.getSystem().displayMetrics.widthPixels
private val height get() = Resources.getSystem().displayMetrics.heightPixels private val height get() = Resources.getSystem().displayMetrics.heightPixels
private val orientation get() = Resources.getSystem().configuration.orientation
private val elapsedTime get() = SystemClock.elapsedRealtime() private val elapsedTime get() = SystemClock.elapsedRealtime()
private val playerViewModel: PlayerViewModel by activity.viewModels() private val playerViewModel: PlayerViewModel by activity.viewModels()
@ -55,6 +57,9 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play
listener.onSwipeEnd() listener.onSwipeEnd()
} }
// 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. // Event can be already consumed by some view which may lead to NPE.
try { try {
scaleGestureDetector.onTouchEvent(event) scaleGestureDetector.onTouchEvent(event)