Added battery info to mini bar

pull/699/head
WS64 10 years ago
parent 1c1adb83cd
commit af400bbe1e

@ -44,6 +44,9 @@ function ReaderFooter:init()
if DMINIBAR_NEXT_CHAPTER then if DMINIBAR_NEXT_CHAPTER then
progress_text_default = progress_text_default .. " | => 000" progress_text_default = progress_text_default .. " | => 000"
end end
if DMINIBAR_BATTERY then
progress_text_default = progress_text_default .. " | B:100%"
end
progress_text_default = string.sub(progress_text_default,4) progress_text_default = string.sub(progress_text_default,4)
else else
progress_text_default = "0000 / 0000" progress_text_default = "0000 / 0000"
@ -117,10 +120,18 @@ function ReaderFooter:fillToc()
end end
function ReaderFooter:updateFooterPage() function ReaderFooter:updateFooterPage()
local powerd
local state
if type(self.pageno) ~= "number" then return end if type(self.pageno) ~= "number" then return end
self.progress_bar.percentage = self.pageno / self.pages self.progress_bar.percentage = self.pageno / self.pages
if DMINIBAR_ALL_AT_ONCE then if DMINIBAR_ALL_AT_ONCE then
self.progress_text.text = "" self.progress_text.text = ""
if DMINIBAR_NEXT_CHAPTER then
powerd = Device:getPowerDevice()
state = powerd:isCharging() and -1 or powerd:getCapacity()
self.progress_text.text = self.progress_text.text .. " | B:" .. powerd:getCapacity() .. "%"
end
if DMINIBAR_TIME then if DMINIBAR_TIME then
self.progress_text.text = self.progress_text.text .. " | " .. os.date("%H:%M") self.progress_text.text = self.progress_text.text .. " | " .. os.date("%H:%M")
end end
@ -138,8 +149,13 @@ function ReaderFooter:updateFooterPage()
self.progress_text.text = os.date("%H:%M") self.progress_text.text = os.date("%H:%M")
elseif self.mode == 3 then elseif self.mode == 3 then
self.progress_text.text = "=> " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages) self.progress_text.text = "=> " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages)
elseif self.mode == 4 then
powerd = Device:getPowerDevice()
state = powerd:isCharging() and -1 or powerd:getCapacity()
self.progress_text.text = "B:" .. powerd:getCapacity() .. "%"
end end
end end
end end
function ReaderFooter:updateFooterPos() function ReaderFooter:updateFooterPos()
@ -172,6 +188,7 @@ function ReaderFooter:applyFooterMode(mode)
-- 1 for footer page info -- 1 for footer page info
-- 2 for footer time info -- 2 for footer time info
-- 3 for footer next_chapter info -- 3 for footer next_chapter info
-- 4 for battery status
if mode ~= nil then self.mode = mode end if mode ~= nil then self.mode = mode end
if self.mode == 0 then if self.mode == 0 then
self.view.footer_visible = false self.view.footer_visible = false
@ -199,7 +216,7 @@ function ReaderFooter:onTapFooter(arg, ges)
self.ui:handleEvent(Event:new("GotoPercentage", percentage)) self.ui:handleEvent(Event:new("GotoPercentage", percentage))
end end
else else
self.mode = (self.mode + 1) % 4 self.mode = (self.mode + 1) % 5
if DMINIBAR_ALL_AT_ONCE and (self.mode > 1) then if DMINIBAR_ALL_AT_ONCE and (self.mode > 1) then
self.mode = 0 self.mode = 0
end end
@ -210,6 +227,9 @@ function ReaderFooter:onTapFooter(arg, ges)
self.mode = 3 self.mode = 3
end end
if (self.mode == 3) and not DMINIBAR_NEXT_CHAPTER then if (self.mode == 3) and not DMINIBAR_NEXT_CHAPTER then
self.mode = 4
end
if (self.mode == 4) and not DMINIBAR_BATTERY then
self.mode = 0 self.mode = 0
end end
self:applyFooterMode() self:applyFooterMode()

Loading…
Cancel
Save