Hide System UI upon Hiding the Controller

This commit is contained in:
Bnyro 2022-10-18 19:32:46 +02:00
parent 029dd03228
commit 9998cec4c4
2 changed files with 5 additions and 32 deletions

View File

@ -399,7 +399,7 @@ class MainActivity : BaseActivity() {
}
}
private fun setFullscreen() {
fun setFullscreen() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.attributes.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
@ -454,36 +454,6 @@ class MainActivity : BaseActivity() {
}
}
/**
* hide the status bar
*/
fun hideSystemBars() {
if (resources.configuration.orientation != Configuration.ORIENTATION_LANDSCAPE) return
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.statusBars())
} else {
@Suppress("DEPRECATION")
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
}
/**
* show the status bar
*/
private fun showSystemBars() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.show(WindowInsets.Type.statusBars())
} else {
@Suppress("DEPRECATION")
window.clearFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
}
}
override fun onUserLeaveHint() {
super.onUserLeaveHint()
supportFragmentManager.fragments.forEach { fragment ->

View File

@ -119,7 +119,10 @@ internal class CustomExoPlayerView(
}
override fun hideController() {
(context as? MainActivity)?.hideSystemBars()
if (resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
// hide all the navigation bars that potentially could have been reopened manually ba the user
(context as? MainActivity)?.setFullscreen()
}
super.hideController()
}