mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
Fix pip mode brightness issue
Check if activity is in pip mode then use system brightness. Don't force to store brightness while returning from pip mode. Since it contains system brightness.
This commit is contained in:
parent
92cc7a9cf3
commit
612a23c1dc
@ -445,7 +445,7 @@ internal class CustomExoPlayerView(
|
|||||||
if (PlayerHelper.swipeGestureEnabled) {
|
if (PlayerHelper.swipeGestureEnabled) {
|
||||||
when (newConfig?.orientation) {
|
when (newConfig?.orientation) {
|
||||||
Configuration.ORIENTATION_LANDSCAPE -> brightnessHelper.restoreSavedBrightness()
|
Configuration.ORIENTATION_LANDSCAPE -> brightnessHelper.restoreSavedBrightness()
|
||||||
else -> brightnessHelper.resetToSystemBrightness(true)
|
else -> brightnessHelper.resetToSystemBrightness(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.github.libretube.util
|
package com.github.libretube.util
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.os.Build
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
import com.github.libretube.extensions.normalize
|
import com.github.libretube.extensions.normalize
|
||||||
|
|
||||||
class BrightnessHelper(activity: Activity) {
|
class BrightnessHelper(private val activity: Activity) {
|
||||||
|
|
||||||
private val window = activity.window
|
private val window = activity.window
|
||||||
private val minBrightness = 0.0f
|
private val minBrightness = 0.0f
|
||||||
@ -31,15 +32,13 @@ class BrightnessHelper(activity: Activity) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore screen brightness to device system brightness.
|
* Restore screen brightness to device system brightness.
|
||||||
* [saveOldValue] determines whether the old value should be persisted or not.
|
* if [forced] is false then value will be stored only if it's not
|
||||||
|
* [WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE] value.
|
||||||
*/
|
*/
|
||||||
fun resetToSystemBrightness(saveOldValue: Boolean = false) {
|
fun resetToSystemBrightness(forced: Boolean = true) {
|
||||||
savedBrightness = if (saveOldValue) {
|
if (forced || brightness != WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE) {
|
||||||
brightness
|
savedBrightness = brightness
|
||||||
} else {
|
|
||||||
WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
brightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +46,9 @@ class BrightnessHelper(activity: Activity) {
|
|||||||
* Set current screen brightness to saved brightness value.
|
* Set current screen brightness to saved brightness value.
|
||||||
*/
|
*/
|
||||||
fun restoreSavedBrightness() {
|
fun restoreSavedBrightness() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && activity.isInPictureInPictureMode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
brightness = savedBrightness
|
brightness = savedBrightness
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user