show battery icon in crereader page header

pull/433/head
chrox 10 years ago
parent 4d1df962f5
commit a6e885e77d

@ -297,6 +297,11 @@ function CreDocument:setVisiblePageCount(new_count)
self._document:setVisiblePageCount(new_count)
end
function CreDocument:setBatteryState(state)
DEBUG("CreDocument: set battery state", state)
self._document:setBatteryState(state)
end
function CreDocument:register(registry)
registry:addProvider("txt", "application/txt", self)
registry:addProvider("epub", "application/epub", self)

@ -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

@ -1 +1 @@
Subproject commit bf3ef2a6c9002a665b8c224632eba744e6147fe0
Subproject commit 5c2afc4f9f40b51ebe0ee86c9ba200859559e5f9
Loading…
Cancel
Save