Skip to content

Commit

Permalink
fix(player): unlock brightness control after disposing player screen …
Browse files Browse the repository at this point in the history
…[attempt 1]
  • Loading branch information
rhenwinch committed Feb 10, 2025
1 parent 46e0d19 commit 49d83e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,12 @@ internal fun PlayerScreen(
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
context.toggleSystemBars(isVisible = false)

// Initialize brightness
val userDefaultBrightnessLevel = brightnessManager.currentBrightness

onDispose {
// Lock the screen to landscape only if we're just changing
// episodes. This is really bad code bruh.
if (!isChangingEpisode) {
context.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
brightnessManager.setBrightness(userDefaultBrightnessLevel)
brightnessManager.unlockBrightnessControl()
context.toggleSystemBars(isVisible = true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ internal class BrightnessManager(private val activity: Activity) {
layoutParams.screenBrightness = currentBrightness
activity.window.attributes = layoutParams
}
}

fun unlockBrightnessControl() {
val layoutParams = activity.window.attributes
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
activity.window.attributes = layoutParams
}
}

0 comments on commit 49d83e5

Please sign in to comment.