set -1f as default (auto-brightness)
need to override -1f in fun restore(), because in some cases the brightness is not restored after force closing app
This commit is contained in:
MarcaDian 2024-04-12 18:20:37 +03:00
parent 2a1916bf6e
commit 765ec07b0d
No known key found for this signature in database
GPG Key ID: 904EF10755E7C016
3 changed files with 5 additions and 8 deletions

View File

@ -244,7 +244,7 @@ public class Settings extends BaseSettings {
public static final LongSetting SWIPE_OVERLAY_TIMEOUT = new LongSetting("revanced_swipe_overlay_timeout", 500L, true,
parentsAny(SWIPE_BRIGHTNESS, SWIPE_VOLUME));
public static final BooleanSetting SWIPE_SAVE_AND_RESTORE_BRIGHTNESS = new BooleanSetting("revanced_swipe_save_and_restore_brightness", TRUE, true, parent(SWIPE_BRIGHTNESS));
public static final FloatSetting SWIPE_BRIGHTNESS_VALUE = new FloatSetting("revanced_swipe_brightness_value", 0.5f);
public static final FloatSetting SWIPE_BRIGHTNESS_VALUE = new FloatSetting("revanced_swipe_brightness_value", -1f);
public static final BooleanSetting SWIPE_ENABLE_LOWEST_VALUE_AUTO_BRIGHTNESS = new BooleanSetting("revanced_swipe_enable_lowest_value_auto_brightness", TRUE, true, parent(SWIPE_BRIGHTNESS));
// Debugging
/**

View File

@ -176,7 +176,6 @@ class SwipeControlsHostActivity : Activity() {
when (type) {
PlayerType.WATCH_WHILE_FULLSCREEN -> screen?.restore()
else -> {
screen?.restore()
screen?.save()
screen?.restoreDefaultBrightness()
}

View File

@ -2,6 +2,7 @@ package app.revanced.integrations.youtube.swipecontrols.controller
import android.app.Activity
import android.view.WindowManager
import app.revanced.integrations.shared.Utils
import app.revanced.integrations.youtube.swipecontrols.SwipeControlsConfigurationProvider
import app.revanced.integrations.youtube.swipecontrols.misc.clamp
@ -37,9 +38,6 @@ class ScreenBrightnessController(
val isDefaultBrightness
get() = (rawScreenBrightness == WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE)
/**
* save the current screen brightness into settings, to be brought back using [restore]
*/
fun save() {
if (config.savedScreenBrightnessValue == -1f) {
config.savedScreenBrightnessValue = rawScreenBrightness
@ -50,12 +48,12 @@ class ScreenBrightnessController(
* restore the screen brightness from settings saved using [save]
*/
fun restore() {
// after force close app, 'savedScreenBrightnessValue' resets to default from settings ('0.5f').
// so default value in settings should not be '-1f'
// `-1f` means auto-brightness activated
if (config.savedScreenBrightnessValue != -1f) {
rawScreenBrightness = config.savedScreenBrightnessValue
config.savedScreenBrightnessValue = -1f
} else {
// here need to override -1f, because in some cases the brightness is not restored after force closing app
config.savedScreenBrightnessValue = -1f
}
}