mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
refactor out flush settings when device goes into screensaver
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
local Event = require("ui/event")
|
||||
local util = require("ffi/util")
|
||||
local DEBUG = require("dbg")
|
||||
|
||||
@@ -69,10 +70,12 @@ function Device:getPowerDevice()
|
||||
end
|
||||
|
||||
function Device:intoScreenSaver()
|
||||
local UIManager = require("ui/uimanager")
|
||||
if self.charging_mode == false and self.screen_saver_mode == false then
|
||||
self.screen:saveCurrentBB()
|
||||
self.screen_saver_mode = true
|
||||
end
|
||||
UIManager:sendEvent(Event:new("FlushSettings"))
|
||||
end
|
||||
|
||||
function Device:outofScreenSaver()
|
||||
@@ -97,6 +100,7 @@ function Device:onPowerEvent(ev)
|
||||
self.screen:setRotationMode(0)
|
||||
Screensaver:show()
|
||||
self:prepareSuspend()
|
||||
UIManager:sendEvent(Event:new("FlushSettings"))
|
||||
UIManager:scheduleIn(10, self.Suspend)
|
||||
elseif (ev == "Power" or ev == "Resume") and self.screen_saver_mode then
|
||||
DEBUG("Resuming...")
|
||||
|
||||
@@ -39,7 +39,6 @@ function UIManager:init()
|
||||
}
|
||||
if Device:isKobo() then
|
||||
self.event_handlers["Suspend"] = function(input_event)
|
||||
self:sendEvent(Event:new("FlushSettings"))
|
||||
Device:onPowerEvent(input_event)
|
||||
end
|
||||
self.event_handlers["Resume"] = function(input_event)
|
||||
@@ -64,7 +63,6 @@ function UIManager:init()
|
||||
end
|
||||
elseif Device:isKindle() then
|
||||
self.event_handlers["IntoSS"] = function()
|
||||
self:sendEvent(Event:new("FlushSettings"))
|
||||
Device:intoScreenSaver()
|
||||
end
|
||||
self.event_handlers["OutOfSS"] = function()
|
||||
|
||||
Reference in New Issue
Block a user