fix: missing horizontal player spacing with display cutout

This commit is contained in:
Bnyro 2024-05-01 14:42:20 +02:00
parent 4649b084e2
commit e57a55a769
2 changed files with 8 additions and 4 deletions

View File

@ -31,9 +31,7 @@ open class BaseActivity : AppCompatActivity() {
/**
* Whether the phone of the user has a cutout like a notch or not
*/
val hasCutout by lazy {
WindowHelper.hasCutout(window.decorView.rootView)
}
var hasCutout: Boolean = false
override fun onCreate(savedInstanceState: Bundle?) {
// set the app theme (e.g. Material You)
@ -49,6 +47,12 @@ open class BaseActivity : AppCompatActivity() {
requestOrientationChange()
// wait for the window decor view to be drawn before detecting display cutouts
window.decorView.setOnApplyWindowInsetsListener { view, insets ->
hasCutout = WindowHelper.hasCutout(view)
insets
}
super.onCreate(savedInstanceState)
}

View File

@ -637,7 +637,7 @@ abstract class CustomExoPlayerView(
updateTopBarMargin()
// don't add extra padding if there's no cutout and no margin set that would need to be undone
if (!(context as BaseActivity).hasCutout && binding.topBar.marginStart == LANDSCAPE_MARGIN_HORIZONTAL_NONE) return
if (!activity.hasCutout && binding.topBar.marginStart == LANDSCAPE_MARGIN_HORIZONTAL_NONE) return
// add a margin to the top and the bottom bar in landscape mode for notches
val isForcedPortrait = activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT