From c63a63cb3398be9ea5e94d833d887ae9da113e2a Mon Sep 17 00:00:00 2001 From: Koen <koen@pop-os.localdomain> Date: Wed, 20 Dec 2023 11:06:18 +0100 Subject: [PATCH] Fixed Gesture control distances for portrait full screen. --- .../views/behavior/GestureControlView.kt | 21 +++++++++++++------ app/src/stable/assets/sources/nebula | 2 +- app/src/stable/assets/sources/youtube | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt b/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt index f48cd486..f500a87e 100644 --- a/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt +++ b/app/src/main/java/com/futo/platformplayer/views/behavior/GestureControlView.kt @@ -18,12 +18,20 @@ import android.widget.TextView import androidx.core.animation.doOnEnd import androidx.core.animation.doOnStart import androidx.core.view.GestureDetectorCompat -import com.futo.platformplayer.logging.Logger import com.futo.platformplayer.R import com.futo.platformplayer.constructs.Event0 import com.futo.platformplayer.constructs.Event1 +import com.futo.platformplayer.logging.Logger import com.futo.platformplayer.views.others.CircularProgressBar -import kotlinx.coroutines.* +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.cancel +import kotlinx.coroutines.delay +import kotlinx.coroutines.ensureActive +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch class GestureControlView : LinearLayout { private val _scope = CoroutineScope(Dispatchers.Main); @@ -95,22 +103,23 @@ class GestureControlView : LinearLayout { if(p0 == null) return false; + val minDistance = Math.min(width, height) if (_isFullScreen && _adjustingBrightness) { - val adjustAmount = (distanceY * 2) / height; + val adjustAmount = (distanceY * 2) / minDistance; _brightnessFactor = (_brightnessFactor + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f); _progressBrightness.progress = _brightnessFactor; onBrightnessAdjusted.emit(_brightnessFactor); } else if (_isFullScreen && _adjustingSound) { - val adjustAmount = (distanceY * 2) / height; + val adjustAmount = (distanceY * 2) / minDistance; _soundFactor = (_soundFactor + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f); _progressSound.progress = _soundFactor; onSoundAdjusted.emit(_soundFactor); } else if (_adjustingFullscreenUp) { - val adjustAmount = (distanceY * 2) / height; + val adjustAmount = (distanceY * 2) / minDistance; _fullScreenFactorUp = (_fullScreenFactorUp + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f); _layoutControlsFullscreen.alpha = _fullScreenFactorUp; } else if (_adjustingFullscreenDown) { - val adjustAmount = (-distanceY * 2) / height; + val adjustAmount = (-distanceY * 2) / minDistance; _fullScreenFactorDown = (_fullScreenFactorDown + adjustAmount).coerceAtLeast(0.0f).coerceAtMost(1.0f); _layoutControlsFullscreen.alpha = _fullScreenFactorDown; } else { diff --git a/app/src/stable/assets/sources/nebula b/app/src/stable/assets/sources/nebula index 863d0be1..01270edb 160000 --- a/app/src/stable/assets/sources/nebula +++ b/app/src/stable/assets/sources/nebula @@ -1 +1 @@ -Subproject commit 863d0be1322660c99e4d0cdae0b45d0a5918542d +Subproject commit 01270edbb4b6b4fb004e22fc529bf787c7f5be81 diff --git a/app/src/stable/assets/sources/youtube b/app/src/stable/assets/sources/youtube index d41cc8e8..13551ab6 160000 --- a/app/src/stable/assets/sources/youtube +++ b/app/src/stable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit d41cc8e848891ef8e949e6d49384b754e7c305c7 +Subproject commit 13551ab67fc8fb1899b5bcbfdec750855b154790 -- GitLab