update battery state on device resume

pull/456/head
Qingping Hou 10 years ago
parent f7b47a3634
commit 21af7b6a9f

@ -216,6 +216,14 @@ function ReaderRolling:onPageUpdate(new_page)
self:updateBatteryState() self:updateBatteryState()
end end
function ReaderRolling:onResume()
self:updateBatteryState()
end
function ReaderRolling:onNotCharging()
self:updateBatteryState()
end
function ReaderRolling:onGotoPercent(percent) function ReaderRolling:onGotoPercent(percent)
DEBUG("goto document offset in percent:", percent) DEBUG("goto document offset in percent:", percent)
self:gotoPercent(percent) self:gotoPercent(percent)

@ -287,10 +287,11 @@ function UIManager:run()
Device:usbPlugIn() Device:usbPlugIn()
elseif input_event == "NotCharging" then elseif input_event == "NotCharging" then
Device:usbPlugOut() Device:usbPlugOut()
self:sendEvent(Event:new("NotCharging"))
elseif input_event == "Light" then elseif input_event == "Light" then
Device:getPowerDevice():toggleFrontlight() Device:getPowerDevice():toggleFrontlight()
elseif (input_event == "Power" and not Device.screen_saver_mode) or elseif (input_event == "Power" and not Device.screen_saver_mode)
input_event == "Suspend" then or input_event == "Suspend" then
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
self:show(InfoMessage:new{ self:show(InfoMessage:new{
text = _("Standby"), text = _("Standby"),
@ -298,9 +299,10 @@ function UIManager:run()
}) })
Device:prepareSuspend() Device:prepareSuspend()
self:scheduleIn(0.5, function() Device:Suspend() end) self:scheduleIn(0.5, function() Device:Suspend() end)
elseif (input_event == "Power" and Device.screen_saver_mode) or elseif (input_event == "Power" and Device.screen_saver_mode)
input_event == "Resume" then or input_event == "Resume" then
Device:Resume() Device:Resume()
self:sendEvent(Event:new("Resume"))
else else
self:sendEvent(input_event) self:sendEvent(input_event)
end end

Loading…
Cancel
Save