[Android] Fix the video player lock control and title overlapping the cutout / system gestures
Nicolas Pomepuy
git at videolan.org
Tue Feb 14 12:53:20 UTC 2023
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Feb 14 13:24:24 2023 +0100| [73c32ec71cd2edec91e801f4d43482c840c895a3] | committer: Nicolas Pomepuy
Fix the video player lock control and title overlapping the cutout / system gestures
Fixes #2855
> https://code.videolan.org/videolan/vlc-android/commit/73c32ec71cd2edec91e801f4d43482c840c895a3
---
.../videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index b65d6c5e99..9d6e59c556 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -34,6 +34,7 @@ import android.os.Build
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
+import android.view.WindowInsets
import android.view.WindowManager
import android.view.accessibility.AccessibilityEvent
import android.view.animation.AnimationUtils
@@ -48,6 +49,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.content.ContextCompat
import androidx.core.net.toUri
+import androidx.core.view.WindowInsetsCompat
import androidx.core.view.children
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
@@ -922,6 +924,15 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
hudBinding.playlistNext.isEnabled = false
hudBinding.playlistPrevious.isEnabled = false
hudBinding.swipeToUnlock.setVisible()
+ //make sure the title and unlock views are not conflicting with the cutout / gestures
+ (playerUiContainer.layoutParams as? FrameLayout.LayoutParams)?.let {
+ it.topMargin =
+ player.window.decorView.rootWindowInsets.displayCutout?.safeInsetTop ?: 0
+ it.bottomMargin =
+ (player.window.decorView.rootWindowInsets.displayCutout?.safeInsetBottom
+ ?: 0) + 24.dp
+ }
+
}
hideOverlay(true)
player.lockBackButton = true
@@ -932,6 +943,10 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
* Remove player lock
*/
fun unlockScreen() {
+ (playerUiContainer.layoutParams as? FrameLayout.LayoutParams)?.let {
+ it.topMargin = 0
+ it.bottomMargin = 0
+ }
player.orientationMode.locked = orientationLockedBeforeLock
player.requestedOrientation = player.getScreenOrientation(player.orientationMode)
if (isHudBindingInitialized()) {
More information about the Android
mailing list