Skip to content

Commit

Permalink
fix system bars not appearing properly (recloudstream#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndusAryan authored Jan 13, 2024
1 parent 723c653 commit 93dce86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,6 @@ open class FullScreenPlayer : AbstractPlayerFragment() {

playerGoBack.setOnClickListener {
activity?.popCurrentPage()
activity?.showSystemUI()
}

playerSourcesBtt.setOnClickListener {
Expand Down
35 changes: 18 additions & 17 deletions app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import androidx.core.graphics.blue
import androidx.core.graphics.drawable.toBitmapOrNull
import androidx.core.graphics.green
import androidx.core.graphics.red
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.marginBottom
import androidx.core.view.marginLeft
import androidx.core.view.marginRight
Expand All @@ -57,6 +59,7 @@ import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipDrawable
import com.google.android.material.chip.ChipGroup
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.result.UiImage
Expand Down Expand Up @@ -402,17 +405,16 @@ object UIHelper {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// 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) {

window!!.insetsController?.hide(WindowInsetsCompat.Type.systemBars())
window!!.insetsController?.systemBarsBehavior =
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
WindowCompat.setDecorFitsSystemWindows(window, false)
WindowInsetsControllerCompat(window, View(this)).let { controller ->
controller.hide(WindowInsetsCompat.Type.systemBars())
controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
}
}*/

else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
Expand All @@ -425,7 +427,7 @@ object UIHelper {
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN
)
}
//}
}

fun FragmentActivity.popCurrentPage() {
Expand Down Expand Up @@ -496,13 +498,13 @@ object UIHelper {
}

fun Activity.changeStatusBarState(hide: Boolean): Int {
@Suppress("DEPRECATION")
return if (hide) {

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
Expand All @@ -525,17 +527,16 @@ object UIHelper {
// except for the ones that make the content appear under the system bars.
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) {
window!!.insetsController?.show(WindowInsetsCompat.Type.systemBars())
}
WindowCompat.setDecorFitsSystemWindows(window, true)
WindowInsetsControllerCompat(window, View(this)).show(WindowInsetsCompat.Type.systemBars())
} else {
@Suppress("DEPRECATION")
} else {*/ /** WINDOW COMPAT IS BUGGY DUE TO FU*KED UP PLAYER AND TRAILERS **/
Suppress("DEPRECATION")
window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
}
//}

changeStatusBarState(isEmulatorSettings())
}
Expand Down

0 comments on commit 93dce86

Please sign in to comment.