mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #5948 from Bnyro/master
fix: missing horizontal player spacing with display cutout
This commit is contained in:
commit
8fe9d5c6ac
@ -31,9 +31,7 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
/**
|
/**
|
||||||
* Whether the phone of the user has a cutout like a notch or not
|
* Whether the phone of the user has a cutout like a notch or not
|
||||||
*/
|
*/
|
||||||
val hasCutout by lazy {
|
var hasCutout: Boolean = false
|
||||||
WindowHelper.hasCutout(window.decorView.rootView)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// set the app theme (e.g. Material You)
|
// set the app theme (e.g. Material You)
|
||||||
@ -49,6 +47,12 @@ open class BaseActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
requestOrientationChange()
|
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)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ abstract class CustomExoPlayerView(
|
|||||||
updateTopBarMargin()
|
updateTopBarMargin()
|
||||||
|
|
||||||
// don't add extra padding if there's no cutout and no margin set that would need to be undone
|
// 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
|
// add a margin to the top and the bottom bar in landscape mode for notches
|
||||||
val isForcedPortrait = activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
val isForcedPortrait = activity.requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||||
|
Loading…
Reference in New Issue
Block a user