mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
kobo: build fl_state based on fl_intensity if model does not support toggle
This commit is contained in:
@@ -68,12 +68,8 @@ function NickelConf.frontLightState.get()
|
||||
if new_state then
|
||||
new_state = (new_state == "true") or false
|
||||
end
|
||||
|
||||
if new_state == nil then
|
||||
assert(NickelConf.frontLightState.set(false))
|
||||
return false
|
||||
end
|
||||
|
||||
-- for devices that do not have toggle button, the entry will be missing
|
||||
-- and we return nil in this case.
|
||||
return new_state
|
||||
end
|
||||
|
||||
|
||||
@@ -74,12 +74,21 @@ function UIManager:init()
|
||||
local NickelConf = require("device/kobo/nickel_conf")
|
||||
new_intensity = NickelConf.frontLightLevel.get()
|
||||
new_state = NickelConf.frontLightState:get()
|
||||
if new_state == nil then
|
||||
-- this device does not support frontlight toggle,
|
||||
-- we set the state based on frontlight intensity.
|
||||
if new_intensity > 0 then
|
||||
new_state = true
|
||||
else
|
||||
new_state = false
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Since this kobo-specific, we save all values in settings here
|
||||
-- and let the code (reader.lua) pick it up later during bootstrap.
|
||||
if new_intensity then
|
||||
-- Since this kobo-specific, we save here and let the code pick
|
||||
-- it up later from the reader settings.
|
||||
G_reader_settings:saveSetting(
|
||||
"frontlight_intensity", new_intensity)
|
||||
G_reader_settings:saveSetting("frontlight_intensity",
|
||||
new_intensity)
|
||||
end
|
||||
G_reader_settings:saveSetting("frontlight_state", new_state)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user