kobo: build fl_state based on fl_intensity if model does not support toggle

This commit is contained in:
Qingping Hou
2016-03-01 22:30:29 -08:00
committed by NiLuJe
parent 9afae91b13
commit cf3b97537b
2 changed files with 15 additions and 10 deletions

View File

@@ -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

View File

@@ -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