Only show extra padding when there's a notch

This commit is contained in:
Bnyro 2023-01-20 19:00:49 +01:00
parent fbf9c30e9a
commit c1c0e5f6f1
2 changed files with 11 additions and 0 deletions

View File

@ -568,6 +568,9 @@ internal class CustomExoPlayerView(
it.layoutParams = params 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 // add a margin to the top and the bottom bar in landscape mode for notches
val newMargin = when (newConfig?.orientation) { val newMargin = when (newConfig?.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> LANDSCAPE_MARGIN_HORIZONTAL Configuration.ORIENTATION_LANDSCAPE -> LANDSCAPE_MARGIN_HORIZONTAL

View File

@ -54,4 +54,12 @@ class WindowHelper(private val activity: BaseActivity) {
fun showStatusBar() = activity.apply { fun showStatusBar() = activity.apply {
WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.statusBars()) 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
}
}
} }