Skip to content

Commit

Permalink
Merge pull request #714 from RounakDadsena/jetpack_compose
Browse files Browse the repository at this point in the history
Added Screen off prevention On Full Screen player
  • Loading branch information
maxrave-dev authored Jan 30, 2025
2 parents 8d4408f + 8569808 commit cbb6439
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import android.view.WindowManager
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
Expand Down Expand Up @@ -138,6 +139,9 @@ fun FullscreenPlayer(
val insetsController = WindowCompat.getInsetsController(window, window.decorView)

onDispose {

window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

insetsController.apply {
show(WindowInsetsCompat.Type.systemBars())
systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_DEFAULT
Expand All @@ -152,6 +156,9 @@ fun FullscreenPlayer(
LaunchedEffect(true) {
val activity = context.findActivity()
val window = activity.window

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

val insetsController = WindowCompat.getInsetsController(window, window.decorView)
insetsController.apply {
hide(WindowInsetsCompat.Type.systemBars())
Expand Down

0 comments on commit cbb6439

Please sign in to comment.