mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-29 22:24:29 +02:00
restore brightness when leaving app while a video is full screen
Changelog: changed
This commit is contained in:
parent
d10026acd1
commit
1a061268de
@ -455,6 +455,10 @@ class VideoDetailFragment() : MainFragment() {
|
||||
activity?.enterPictureInPictureMode(params);
|
||||
}
|
||||
}
|
||||
|
||||
if (isFullscreen) {
|
||||
viewDetail?.restoreBrightness()
|
||||
}
|
||||
}
|
||||
|
||||
fun forcePictureInPicture() {
|
||||
@ -487,6 +491,10 @@ class VideoDetailFragment() : MainFragment() {
|
||||
_isActive = true;
|
||||
_leavingPiP = false;
|
||||
|
||||
if (isFullscreen) {
|
||||
_viewDetail?.saveBrightness()
|
||||
}
|
||||
|
||||
_viewDetail?.let {
|
||||
Logger.v(TAG, "onResume preventPictureInPicture=false");
|
||||
it.preventPictureInPicture = false;
|
||||
|
@ -2485,6 +2485,13 @@ class VideoDetailView : ConstraintLayout {
|
||||
}
|
||||
}
|
||||
|
||||
fun saveBrightness() {
|
||||
_player.gestureControl.saveBrightness()
|
||||
}
|
||||
fun restoreBrightness() {
|
||||
_player.gestureControl.restoreBrightness()
|
||||
}
|
||||
|
||||
fun setFullscreen(fullscreen : Boolean) {
|
||||
Logger.i(TAG, "setFullscreen(fullscreen=$fullscreen)")
|
||||
_player.setFullScreen(fullscreen)
|
||||
|
@ -735,11 +735,7 @@ class GestureControlView : LinearLayout {
|
||||
_animatorBrightness?.start();
|
||||
}
|
||||
|
||||
fun setFullscreen(isFullScreen: Boolean) {
|
||||
resetZoomPan()
|
||||
|
||||
if (isFullScreen) {
|
||||
if (Settings.instance.gestureControls.useSystemBrightness) {
|
||||
fun saveBrightness() {
|
||||
try {
|
||||
_originalBrightnessMode = android.provider.Settings.System.getInt(context.contentResolver, android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE)
|
||||
|
||||
@ -754,18 +750,7 @@ class GestureControlView : LinearLayout {
|
||||
UIDialogs.toast(context, "useSystemBrightness disabled due to an error")
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.instance.gestureControls.useSystemVolume) {
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
_soundFactor = currentVolume.toFloat() / maxVolume.toFloat()
|
||||
}
|
||||
|
||||
onBrightnessAdjusted.emit(_brightnessFactor);
|
||||
onSoundAdjusted.emit(_soundFactor);
|
||||
} else {
|
||||
if (Settings.instance.gestureControls.useSystemBrightness) {
|
||||
fun restoreBrightness() {
|
||||
if (Settings.instance.gestureControls.restoreSystemBrightness) {
|
||||
onBrightnessAdjusted.emit(_originalBrightnessFactor)
|
||||
|
||||
@ -779,6 +764,28 @@ class GestureControlView : LinearLayout {
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setFullscreen(isFullScreen: Boolean) {
|
||||
resetZoomPan()
|
||||
|
||||
if (isFullScreen) {
|
||||
if (Settings.instance.gestureControls.useSystemBrightness) {
|
||||
saveBrightness()
|
||||
}
|
||||
|
||||
if (Settings.instance.gestureControls.useSystemVolume) {
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
_soundFactor = currentVolume.toFloat() / maxVolume.toFloat()
|
||||
}
|
||||
|
||||
onBrightnessAdjusted.emit(_brightnessFactor);
|
||||
onSoundAdjusted.emit(_soundFactor);
|
||||
} else {
|
||||
if (Settings.instance.gestureControls.useSystemBrightness) {
|
||||
restoreBrightness()
|
||||
} else {
|
||||
onBrightnessAdjusted.emit(1.0f);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user