Skip to content

Commit

Permalink
Merge pull request #5948 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: missing horizontal player spacing with display cutout
  • Loading branch information
Bnyro authored May 1, 2024
2 parents de3969a + e57a55a commit 8fe9d5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/src/main/java/com/github/libretube/ui/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fe9d5c

Please sign in to comment.