mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
AutoWarmth: force setWarmth after resume (#9289)
This commit is contained in:
@@ -201,9 +201,9 @@ function BasePowerD:fromNativeWarmth(nat_warmth)
|
||||
end
|
||||
|
||||
--- @note: Takes a warmth in the *KOReader* scale (i.e., [0, 100], *sic*)
|
||||
function BasePowerD:setWarmth(warmth)
|
||||
function BasePowerD:setWarmth(warmth, force_setting)
|
||||
if not self.device:hasNaturalLight() then return false end
|
||||
if warmth == self:frontlightWarmth() then return false end
|
||||
if not force_setting and warmth == self:frontlightWarmth() then return false end
|
||||
-- Which means that fl_warmth is *also* in the KOReader scale (unlike fl_intensity)
|
||||
self.fl_warmth = self:normalizeWarmth(warmth)
|
||||
local nat_warmth = self:toNativeWarmth(self.fl_warmth)
|
||||
|
||||
@@ -136,7 +136,7 @@ end
|
||||
AutoWarmth.onLeaveStandby = AutoWarmth.onResume
|
||||
|
||||
-- wrapper for unscheduling, so that only our setWarmth gets unscheduled
|
||||
function AutoWarmth.setWarmth(val)
|
||||
function AutoWarmth.setWarmth(val, force)
|
||||
if val then
|
||||
if val > 100 then
|
||||
DeviceListener:onSetNightMode(true)
|
||||
@@ -145,7 +145,7 @@ function AutoWarmth.setWarmth(val)
|
||||
end
|
||||
if Device:hasNaturalLight() then
|
||||
val = math.min(val, 100)
|
||||
Device.powerd:setWarmth(val)
|
||||
Device.powerd:setWarmth(val, force)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -300,7 +300,7 @@ function AutoWarmth:scheduleWarmthChanges(time)
|
||||
-- schedule setting of another valid warmth (=`next_warmth`) again (one time).
|
||||
-- On sane devices this schedule does no harm.
|
||||
-- see https://github.com/koreader/koreader/issues/8363
|
||||
UIManager:scheduleIn(delay_time, self.setWarmth, next_warmth)
|
||||
UIManager:scheduleIn(delay_time, self.setWarmth, next_warmth, true)
|
||||
end
|
||||
|
||||
function AutoWarmth:hoursToClock(hours)
|
||||
|
||||
Reference in New Issue
Block a user