This commit is contained in:
oSumAtrIX 2024-04-21 01:47:16 +02:00
parent 7c0b506b90
commit cef6012d8a
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
5 changed files with 17 additions and 19 deletions

View File

@ -251,7 +251,7 @@ public class Settings extends BaseSettings {
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", -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));
public static final BooleanSetting SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS = new BooleanSetting("revanced_swipe_lowest_value_enable_auto_brightness", FALSE, true, parent(SWIPE_BRIGHTNESS));
// Debugging
/**
* When enabled, share the debug logs with care.

View File

@ -105,10 +105,10 @@ class SwipeControlsConfigurationProvider(
get() = Settings.SWIPE_SAVE_AND_RESTORE_BRIGHTNESS.get()
/**
* should the auto-brightness be enabled at the lowest value of the brightness gesture
* should auto-brightness be enabled at the lowest value of the brightness gesture
*/
val shouldEnableLowestValueAutoBrightness: Boolean
get() = Settings.SWIPE_ENABLE_LOWEST_VALUE_AUTO_BRIGHTNESS.get()
val shouldLowestValueEnableAutoBrightness: Boolean
get() = Settings.SWIPE_LOWEST_VALUE_ENABLE_AUTO_BRIGHTNESS.get()
/**
* variable that stores the brightness gesture value in the settings
@ -117,4 +117,4 @@ class SwipeControlsConfigurationProvider(
get() = Settings.SWIPE_BRIGHTNESS_VALUE.get()
set(value) = Settings.SWIPE_BRIGHTNESS_VALUE.save(value)
//endregion
}
}

View File

@ -1,18 +1,16 @@
package app.revanced.integrations.youtube.swipecontrols.controller
import android.app.Activity
import android.view.WindowManager
import app.revanced.integrations.youtube.swipecontrols.SwipeControlsConfigurationProvider
import app.revanced.integrations.youtube.swipecontrols.SwipeControlsHostActivity
import app.revanced.integrations.youtube.swipecontrols.misc.clamp
/**
* controller to adjust the screen brightness level
*
* @param host the host activity of which the brightness is adjusted
* @param host the host activity of which the brightness is adjusted, the main controller instance
*/
class ScreenBrightnessController(
private val host: Activity,
val config: SwipeControlsConfigurationProvider = SwipeControlsConfigurationProvider(host),
val host: SwipeControlsHostActivity,
) {
/**
@ -46,7 +44,7 @@ class ScreenBrightnessController(
fun save() {
if (isBrightnessRestored) {
// Saves the current screen brightness value into settings
config.savedScreenBrightnessValue = rawScreenBrightness
host.config.savedScreenBrightnessValue = rawScreenBrightness
// Reset the flag
isBrightnessRestored = false
}
@ -57,7 +55,7 @@ class ScreenBrightnessController(
*/
fun restore() {
// Restores the screen brightness value from the saved settings
rawScreenBrightness = config.savedScreenBrightnessValue
rawScreenBrightness = host.config.savedScreenBrightnessValue
// Mark that brightness has been restored
isBrightnessRestored = true
}
@ -72,4 +70,4 @@ class ScreenBrightnessController(
attr.screenBrightness = value
host.window.attributes = attr
}
}
}

View File

@ -77,7 +77,7 @@ class VolumeAndBrightnessScrollerImpl(
),
) { _, _, direction ->
screenController?.run {
val shouldAdjustBrightness = if (config.shouldEnableLowestValueAutoBrightness) {
val shouldAdjustBrightness = if (host.config.shouldLowestValueEnableAutoBrightness) {
screenBrightness > 0 || direction > 0
} else {
screenBrightness >= 0 || direction >= 0
@ -99,4 +99,4 @@ class VolumeAndBrightnessScrollerImpl(
volumeScroller.reset()
brightnessScroller.reset()
}
}
}

View File

@ -123,10 +123,10 @@ class SwipeControlsOverlayLayout(
}
override fun onBrightnessChanged(brightness: Double) {
if (config.shouldEnableLowestValueAutoBrightness && brightness <= 0) {
if (config.shouldLowestValueEnableAutoBrightness && brightness <= 0) {
showFeedbackView(
str("revanced_swipe_enable_lowest_value_auto_brightness_overlay_text"),
autoBrightnessIcon
str("revanced_swipe_lowest_value_enable_auto_brightness_overlay_text"),
autoBrightnessIcon,
)
} else if (brightness >= 0) {
showFeedbackView("${round(brightness).toInt()}%", manualBrightnessIcon)
@ -142,4 +142,4 @@ class SwipeControlsOverlayLayout(
)
}
}
}
}