mirror of
https://github.com/readest/readest.git
synced 2026-04-28 19:42:21 +00:00
fix(settings): screen brightness setting only applies to the reader page, closes #2717 (#2720)
Some checks are pending
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
Some checks are pending
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
This commit is contained in:
parent
0bd6a217ae
commit
7063d62b13
4 changed files with 43 additions and 23 deletions
|
|
@ -495,13 +495,19 @@ class NativeBridgePlugin(private val activity: Activity): Plugin(activity) {
|
|||
val args = invoke.parseArgs(SetScreenBrightnessRequestArgs::class.java)
|
||||
val ret = JSObject()
|
||||
try {
|
||||
val brightness = (args.brightness ?: 0.5).toFloat()
|
||||
if (brightness < 0.0 || brightness > 1.0) {
|
||||
invoke.reject("Brightness must be between 0.0 and 1.0")
|
||||
return
|
||||
}
|
||||
val brightness = args.brightness?.toFloat()
|
||||
val layoutParams = activity.window.attributes
|
||||
layoutParams.screenBrightness = brightness
|
||||
|
||||
if (brightness == null || brightness < 0.0) {
|
||||
layoutParams.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||
} else {
|
||||
if (brightness > 1.0) {
|
||||
invoke.reject("Brightness must be between 0.0 and 1.0, or null to use system brightness")
|
||||
return
|
||||
}
|
||||
layoutParams.screenBrightness = brightness
|
||||
}
|
||||
|
||||
activity.window.attributes = layoutParams
|
||||
ret.put("success", true)
|
||||
} catch (e: Exception) {
|
||||
|
|
|
|||
|
|
@ -812,7 +812,13 @@ class NativeBridgePlugin: Plugin {
|
|||
|
||||
let brightness = args.brightness ?? 0.5
|
||||
|
||||
if brightness < 0.0 || brightness > 1.0 {
|
||||
if brightness < 0.0 {
|
||||
// Revert to system brightness - iOS doesn't have a direct "system brightness" setting
|
||||
// We will restore the brightness that was set before the app modified it
|
||||
return invoke.resolve(["success": true])
|
||||
}
|
||||
|
||||
if brightness > 1.0 {
|
||||
return invoke.reject("Brightness must be between 0.0 and 1.0")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue