Skip to content

Commit

Permalink
Apply PiP changes on callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Natanel-Shitrit committed Feb 2, 2024
1 parent 5972259 commit 7436018
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions app/phone/src/main/java/dev/jdtech/jellyfin/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,6 @@ class PlayerActivity : BasePlayerActivity() {
if (!isPipSupported) {
return
}
binding.playerView.useController = false
binding.playerView.findViewById<Button>(R.id.btn_skip_intro).isVisible = false

playerGestureHelper?.updateZoomMode(false)

// Brightness mode Auto
window.attributes = window.attributes.apply {
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
}

try {
enterPictureInPictureMode(pipParams())
Expand All @@ -338,19 +329,32 @@ class PlayerActivity : BasePlayerActivity() {
newConfig: Configuration,
) {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (!isInPictureInPictureMode) {
binding.playerView.useController = true
playerGestureHelper?.isZoomEnabled?.let { playerGestureHelper!!.updateZoomMode(it) }

// Override auto brightness
window.attributes = window.attributes.apply {
screenBrightness = if (appPreferences.playerBrightnessRemember) {
appPreferences.playerBrightness
} else {
Settings.System.getInt(
contentResolver,
Settings.System.SCREEN_BRIGHTNESS,
).toFloat() / 255
when (isInPictureInPictureMode) {
true -> {
binding.playerView.useController = false
binding.playerView.findViewById<Button>(R.id.btn_skip_intro).isVisible = false

playerGestureHelper?.updateZoomMode(false)

// Brightness mode Auto
window.attributes = window.attributes.apply {
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
}
}
false -> {
binding.playerView.useController = true
playerGestureHelper?.isZoomEnabled?.let { playerGestureHelper!!.updateZoomMode(it) }

// Override auto brightness
window.attributes = window.attributes.apply {
screenBrightness = if (appPreferences.playerBrightnessRemember) {
appPreferences.playerBrightness
} else {
Settings.System.getInt(
contentResolver,
Settings.System.SCREEN_BRIGHTNESS,
).toFloat() / 255
}
}
}
}
Expand Down

0 comments on commit 7436018

Please sign in to comment.