diff --git a/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt b/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt
new file mode 100644
index 0000000000..df927a4ba1
--- /dev/null
+++ b/app/src/main/java/eu/kanade/presentation/reader/BrightnessOverlay.kt
@@ -0,0 +1,26 @@
+package eu.kanade.presentation.reader
+
+import androidx.compose.foundation.Canvas
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.graphicsLayer
+import kotlin.math.abs
+
+@Composable
+fun BrightnessOverlay(
+ value: Int,
+) {
+ if (value >= 0) return
+
+ Canvas(
+ modifier = Modifier
+ .fillMaxSize()
+ .graphicsLayer {
+ alpha = abs(value) / 100f
+ }
+ ) {
+ drawRect(Color.Black)
+ }
+}
diff --git a/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt b/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt
index 1683b20284..55a28e4373 100644
--- a/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt
+++ b/app/src/main/java/eu/kanade/presentation/reader/appbars/ReaderAppBars.kt
@@ -9,10 +9,8 @@ import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
-import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
-import androidx.compose.foundation.layout.systemBars
-import androidx.compose.foundation.layout.windowInsetsPadding
+import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Bookmark
import androidx.compose.material.icons.outlined.BookmarkBorder
@@ -70,7 +68,7 @@ fun ReaderAppBars(
.copy(alpha = if (isSystemInDarkTheme()) 0.9f else 0.95f)
val appBarModifier = if (fullscreen) {
- Modifier.windowInsetsPadding(WindowInsets.systemBars)
+ Modifier.systemBarsPadding()
} else {
Modifier
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
index 6d58736e34..9ac903fc3b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
@@ -42,6 +42,7 @@ import com.google.android.material.elevation.SurfaceColors
import com.google.android.material.transition.platform.MaterialContainerTransform
import dev.chrisbanes.insetter.applyInsetter
import eu.kanade.domain.base.BasePreferences
+import eu.kanade.presentation.reader.BrightnessOverlay
import eu.kanade.presentation.reader.OrientationModeSelectDialog
import eu.kanade.presentation.reader.PageIndicatorText
import eu.kanade.presentation.reader.ReaderPageActionsDialog
@@ -377,6 +378,10 @@ class ReaderActivity : BaseActivity() {
onClickSettings = viewModel::openSettingsDialog,
)
+ BrightnessOverlay(
+ value = state.brightnessOverlayValue,
+ )
+
val onDismissRequest = viewModel::closeDialog
when (state.dialog) {
is ReaderViewModel.Dialog.Loading -> {
@@ -903,17 +908,9 @@ class ReaderActivity : BaseActivity() {
}
else -> WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
}
-
window.attributes = window.attributes.apply { screenBrightness = readerBrightness }
- // Set black overlay visibility.
- if (value < 0) {
- binding.brightnessOverlay.isVisible = true
- val alpha = (abs(value) * 2.56).toInt()
- binding.brightnessOverlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0))
- } else {
- binding.brightnessOverlay.isVisible = false
- }
+ viewModel.setBrightnessOverlayValue(value)
}
/**
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
index c16c5a3626..555bdef3ae 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderViewModel.kt
@@ -736,6 +736,10 @@ class ReaderViewModel @JvmOverloads constructor(
mutableState.update { it.copy(dialog = null) }
}
+ fun setBrightnessOverlayValue(value: Int) {
+ mutableState.update { it.copy(brightnessOverlayValue = value) }
+ }
+
/**
* Saves the image of the selected page on the pictures directory and notifies the UI of the result.
* There's also a notification to allow sharing the image somewhere else or deleting it.
@@ -894,6 +898,7 @@ class ReaderViewModel @JvmOverloads constructor(
val viewer: Viewer? = null,
val dialog: Dialog? = null,
val menuVisible: Boolean = false,
+ val brightnessOverlayValue: Int = 0,
) {
val currentChapter: ReaderChapter?
get() = viewerChapters?.currChapter
diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml
index 2401432ffe..da843c09fd 100644
--- a/app/src/main/res/layout/reader_activity.xml
+++ b/app/src/main/res/layout/reader_activity.xml
@@ -35,12 +35,6 @@
android:focusable="false"
android:visibility="gone" />
-
-