is_fl_on -> is_frontlight_on outside of powerd

Matches the reader setting we're reading/writing at that point,
and avoids confusion related to scoping because it doesn't necessarily
match powerd.is_fl_on at that point.

Well, at least I had to wrap my mind around it ^^
pull/1863/head
NiLuJe 8 years ago
parent 45bb1ef79e
commit a82fe3ac44

@ -64,23 +64,23 @@ function UIManager:init()
local kobo_light_on_start = tonumber(KOBO_LIGHT_ON_START)
if kobo_light_on_start then
local new_intensity
local is_fl_on
local is_frontlight_on
if kobo_light_on_start > 0 then
new_intensity = math.min(kobo_light_on_start, 100)
is_fl_on = true
is_frontlight_on = true
elseif kobo_light_on_start == 0 then
is_fl_on = false
is_frontlight_on = false
elseif kobo_light_on_start == -2 then
local NickelConf = require("device/kobo/nickel_conf")
new_intensity = NickelConf.frontLightLevel.get()
is_fl_on = NickelConf.frontLightState:get()
if is_fl_on == nil then
is_frontlight_on = NickelConf.frontLightState:get()
if is_frontlight_on == nil then
-- this device does not support frontlight toggle,
-- we set the value based on frontlight intensity.
if new_intensity > 0 then
is_fl_on = true
is_frontlight_on = true
else
is_fl_on = false
is_frontlight_on = false
end
end
end
@ -90,7 +90,7 @@ function UIManager:init()
G_reader_settings:saveSetting("frontlight_intensity",
new_intensity)
end
G_reader_settings:saveSetting("is_frontlight_on", is_fl_on)
G_reader_settings:saveSetting("is_frontlight_on", is_frontlight_on)
end
elseif Device:isKindle() then
self.event_handlers["IntoSS"] = function()

@ -120,11 +120,12 @@ end
if Device:isKobo() then
local powerd = Device:getPowerDevice()
if powerd and powerd.restore_settings then
-- UIManager:init() should have sanely set up the frontlight_stuff by this point
local intensity = G_reader_settings:readSetting("frontlight_intensity")
powerd.fl_intensity = intensity or powerd.fl_intensity
local is_fl_on = G_reader_settings:readSetting("is_frontlight_on")
if is_fl_on then
-- default is_fl_on is false, turn it on
local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on")
if is_frontlight_on then
-- default powerd.is_fl_on is false, turn it on
powerd:toggleFrontlight()
else
-- the light can still be turned on manually outside of koreader

Loading…
Cancel
Save