diff --git a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt index 6962caf0c..f188293a0 100644 --- a/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt +++ b/app/src/main/java/com/github/libretube/constants/PreferenceKeys.kt @@ -85,7 +85,6 @@ object PreferenceKeys { const val USE_HLS_OVER_DASH = "use_hls" const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos" const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls" - const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness" const val PLAYER_PINCH_CONTROL = "player_pinch_control" const val CAPTIONS_SIZE = "captions_size" const val DOUBLE_TAP_TO_SEEK = "double_tap_seek" diff --git a/app/src/main/java/com/github/libretube/helpers/BrightnessHelper.kt b/app/src/main/java/com/github/libretube/helpers/BrightnessHelper.kt index da5dfa1f2..fef5d83cd 100644 --- a/app/src/main/java/com/github/libretube/helpers/BrightnessHelper.kt +++ b/app/src/main/java/com/github/libretube/helpers/BrightnessHelper.kt @@ -2,11 +2,9 @@ package com.github.libretube.helpers import android.app.Activity import android.view.WindowManager -import com.github.libretube.constants.PreferenceKeys import com.github.libretube.extensions.normalize -class BrightnessHelper(private val activity: Activity) { - +class BrightnessHelper(activity: Activity) { private val window = activity.window private val minBrightness = 0.0f private val maxBrightness = 1.0f @@ -17,17 +15,16 @@ class BrightnessHelper(private val activity: Activity) { private var brightness: Float get() = window.attributes.screenBrightness set(value) { - val lp = window.attributes - lp.screenBrightness = value - window.attributes = lp + window.attributes = window.attributes.apply { + screenBrightness = value + } } /** - * Wrapper for the brightness persisted in the shared preferences. + * Wrapper for the brightness saved per session, set to the current screen brightness of the + * beginning of each session / player creation. */ - private var savedBrightness: Float - get() = PreferenceHelper.getFloat(PreferenceKeys.PLAYER_SCREEN_BRIGHTNESS, brightness) - set(value) = PreferenceHelper.putFloat(PreferenceKeys.PLAYER_SCREEN_BRIGHTNESS, value) + private var savedBrightness = window.attributes.screenBrightness /** * Restore screen brightness to device system brightness. @@ -64,7 +61,7 @@ class BrightnessHelper(private val activity: Activity) { /** * Get scaled brightness with given range. if [saved] is - * ture value will be retrived from shared preferences. + * true value will be restored from the session (per played queue) */ fun getBrightnessWithScale( maxValue: Float,