Skip to content

Commit 91b13e4

Browse files
authored
Merge pull request #22 from crazo7924/fix-auto-brightness
NewPlayerUIState: correctly handle auto brightness
2 parents 681c88e + 3c998b5 commit 91b13e4

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

new-player/src/main/java/net/newpipe/newplayer/ui/NewPlayerUI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fun NewPlayerUI(
149149
val defaultBrightness = getDefaultBrightness(activity)
150150

151151
setScreenBrightness(
152-
uiState.brightness ?: defaultBrightness, activity
152+
if (uiState.brightness < 0) defaultBrightness else uiState.brightness, activity
153153
)
154154
}
155155

new-player/src/main/java/net/newpipe/newplayer/ui/common/utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal fun LockScreenOrientation(orientation: Int) {
7272
internal fun getDefaultBrightness(activity: Activity): Float {
7373
val window = activity.window
7474
val layout = window.attributes as WindowManager.LayoutParams
75-
return if (layout.screenBrightness < 0) 0.5f else layout.screenBrightness
75+
return if (layout.screenBrightness < 0) -1f else layout.screenBrightness
7676
}
7777

7878
@SuppressLint("NewApi")

new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerUIState.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ data class NewPlayerUIState(
103103
val soundVolume: Float,
104104

105105
/**
106-
* The brightness volume. Might be null if the system is in control of the brightness.
106+
* The brightness volume. Might be negative if the system is in control of the brightness.
107107
*/
108-
val brightness: Float?,
108+
val brightness: Float,
109109

110110
/**
111111
* This is used to restore several values when switching back from a fullscreen view to an
@@ -214,7 +214,7 @@ data class NewPlayerUIState(
214214
playbackPositionInMs = 0,
215215
fastSeekSeconds = 0,
216216
soundVolume = 0f,
217-
brightness = null,
217+
brightness = -1f,
218218
embeddedUiConfig = null,
219219
playList = emptyList(),
220220
chapters = emptyList(),

0 commit comments

Comments
 (0)