show battery icon in crereader page header

This commit is contained in:
chrox
2014-01-04 22:30:36 +08:00
parent 4d1df962f5
commit a6e885e77d
3 changed files with 19 additions and 1 deletions

View File

@@ -204,10 +204,12 @@ end
function ReaderRolling:onPosUpdate(new_pos)
self.current_pos = new_pos
self:updateBatteryState()
end
function ReaderRolling:onPageUpdate(new_page)
self.current_page = new_page
self:updateBatteryState()
end
function ReaderRolling:onGotoPercent(percent)
@@ -345,4 +347,15 @@ function ReaderRolling:onGotoPage(number)
return true
end
function ReaderRolling:updateBatteryState()
DEBUG("update battery state")
if self.view.view_mode == "page" then
local powerd = Device:getPowerDevice()
local state = powerd:isCharging() and -1 or powerd:getCapacity()
if state then
self.ui.document:setBatteryState(state)
end
end
end
return ReaderRolling