diff --git a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt index b592b9574..027f537a5 100644 --- a/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt +++ b/app/src/main/java/com/github/libretube/ui/views/CustomExoPlayerView.kt @@ -568,6 +568,9 @@ internal class CustomExoPlayerView( it.layoutParams = params } + // don't add extra padding if there's no cutout + if ((context as? MainActivity)?.windowHelper?.hasCutout() == false) return + // add a margin to the top and the bottom bar in landscape mode for notches val newMargin = when (newConfig?.orientation) { Configuration.ORIENTATION_LANDSCAPE -> LANDSCAPE_MARGIN_HORIZONTAL diff --git a/app/src/main/java/com/github/libretube/util/WindowHelper.kt b/app/src/main/java/com/github/libretube/util/WindowHelper.kt index 7f669d25f..3c6e501f1 100644 --- a/app/src/main/java/com/github/libretube/util/WindowHelper.kt +++ b/app/src/main/java/com/github/libretube/util/WindowHelper.kt @@ -54,4 +54,12 @@ class WindowHelper(private val activity: BaseActivity) { fun showStatusBar() = activity.apply { WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.statusBars()) } + + fun hasCutout(): Boolean { + return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + activity.window.decorView.rootWindowInsets.displayCutout != null + } else { + return false + } + } }