fix system bars not appearing properly (#879)

This commit is contained in:
IndusAryan 2024-01-14 03:15:30 +05:30 committed by GitHub
parent 723c653b07
commit 93dce8682e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 18 deletions

View File

@ -1482,7 +1482,6 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
playerGoBack.setOnClickListener { playerGoBack.setOnClickListener {
activity?.popCurrentPage() activity?.popCurrentPage()
activity?.showSystemUI()
} }
playerSourcesBtt.setOnClickListener { playerSourcesBtt.setOnClickListener {

View File

@ -35,7 +35,9 @@ import androidx.core.graphics.blue
import androidx.core.graphics.drawable.toBitmapOrNull import androidx.core.graphics.drawable.toBitmapOrNull
import androidx.core.graphics.green import androidx.core.graphics.green
import androidx.core.graphics.red import androidx.core.graphics.red
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.marginBottom import androidx.core.view.marginBottom
import androidx.core.view.marginLeft import androidx.core.view.marginLeft
import androidx.core.view.marginRight import androidx.core.view.marginRight
@ -57,6 +59,7 @@ import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable import com.google.android.material.chip.ChipDrawable
import com.google.android.material.chip.ChipGroup import com.google.android.material.chip.ChipGroup
import com.lagradost.cloudstream3.CommonActivity.activity import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.result.UiImage import com.lagradost.cloudstream3.ui.result.UiImage
@ -402,17 +405,16 @@ object UIHelper {
// Enables regular immersive mode. // Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE. // For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY // Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { /** BUGGED AF **/
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (window.insetsController != null) { WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, View(this)).let { controller ->
window!!.insetsController?.hide(WindowInsetsCompat.Type.systemBars()) controller.hide(WindowInsetsCompat.Type.systemBars())
window!!.insetsController?.systemBarsBehavior = controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} }
} }*/
else {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
window.decorView.systemUiVisibility = ( window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
@ -425,7 +427,7 @@ object UIHelper {
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_FULLSCREEN
) )
} //}
} }
fun FragmentActivity.popCurrentPage() { fun FragmentActivity.popCurrentPage() {
@ -496,13 +498,13 @@ object UIHelper {
} }
fun Activity.changeStatusBarState(hide: Boolean): Int { fun Activity.changeStatusBarState(hide: Boolean): Int {
@Suppress("DEPRECATION")
return if (hide) { return if (hide) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.statusBars()) window.insetsController?.hide(WindowInsets.Type.statusBars())
} else { } else {
@Suppress("DEPRECATION")
window.setFlags( window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN WindowManager.LayoutParams.FLAG_FULLSCREEN
@ -525,17 +527,16 @@ object UIHelper {
// except for the ones that make the content appear under the system bars. // except for the ones that make the content appear under the system bars.
fun Activity.showSystemUI() { fun Activity.showSystemUI() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (window.insetsController != null) { WindowCompat.setDecorFitsSystemWindows(window, true)
window!!.insetsController?.show(WindowInsetsCompat.Type.systemBars()) WindowInsetsControllerCompat(window, View(this)).show(WindowInsetsCompat.Type.systemBars())
}
} else { } else {*/ /** WINDOW COMPAT IS BUGGY DUE TO FU*KED UP PLAYER AND TRAILERS **/
@Suppress("DEPRECATION") Suppress("DEPRECATION")
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
} //}
changeStatusBarState(isEmulatorSettings()) changeStatusBarState(isEmulatorSettings())
} }