From c50a0f701bc052c2a55b3fe5b264c3f3d9cc2c72 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 10:32:17 +0200 Subject: [PATCH] Update readerfooter.lua --- frontend/apps/reader/modules/readerfooter.lua | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index d1ddd6774..c7df9997b 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -15,6 +15,21 @@ local Event = require("ui/event") local Font = require("ui/font") local DEBUG = require("dbg") +progress_text_default = "" +if DMINIBAR_ALL_AT_ONCE then + if DMINIBAR_TIME then + progress_text_default = progress_text_default .. " | WW:WW" + end + if DMINIBAR_PAGES then + progress_text_default = progress_text_default .. " | 0000 / 0000" + end + if DMINIBAR_NEXT_CHAPTER then + progress_text_default = progress_text_default .. " | => 000" + end + progress_text_default = string.sub(progress_text_default,4) +else + progress_text_default = "0000 / 0000" +end local ReaderFooter = InputContainer:new{ mode = 1, @@ -22,12 +37,11 @@ local ReaderFooter = InputContainer:new{ pageno = nil, pages = nil, progress_percentage = 0.0, - progress_text = "WW:WW | 0000 / 0000 Next: 000", --- show_time = true, + progress_text = progress_text_default, text_font_face = "ffont", text_font_size = 14, height = Screen:scaleByDPI(19), - padding = Screen:scaleByDPI(10) + padding = Screen:scaleByDPI(10), } function ReaderFooter:init() @@ -94,7 +108,6 @@ function ReaderFooter:init() self:applyFooterMode() end - function ReaderFooter:fillToc() self.toc = self.ui.document:getToc() end @@ -102,23 +115,38 @@ end function ReaderFooter:updateFooterPage() if type(self.pageno) ~= "number" then return end self.progress_bar.percentage = self.pageno / self.pages - --- if self.show_time then - self.progress_text.text = os.date("%H:%M") .. " | " .. string.format("%d / %d", self.pageno, self.pages) .. " Next: " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages) --- else --- self.progress_text.text = string.format("%d / %d", self.pageno, self.pages) --- end + if DMINIBAR_ALL_AT_ONCE then + self.progress_text.text = "" + if DMINIBAR_TIME then + self.progress_text.text = self.progress_text.text .. " | " .. os.date("%H:%M") + end + if DMINIBAR_PAGES then + self.progress_text.text = self.progress_text.text .. " | " .. string.format("%d / %d", self.pageno, self.pages) + end + if DMINIBAR_NEXT_CHAPTER then + self.progress_text.text = self.progress_text.text .. " | => " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages) + end + self.progress_text.text = string.sub(self.progress_text.text,4) + else + if self.mode == 1 then + self.progress_text.text = string.format("%d / %d", self.pageno, self.pages) + end if self.mode == 2 then + self.progress_text.text = os.date("%H:%M") + end if self.mode == 3 then + self.progress_text.text = "=> " .. self.ui.toc:_getChapterPagesLeft(self.pageno,self.pages) + end + end end function ReaderFooter:updateFooterPos() if type(self.position) ~= "number" then return end self.progress_bar.percentage = self.position / self.doc_height --- if self.show_time then + if self.show_time then self.progress_text.text = os.date("%H:%M") --- else --- self.progress_text.text = string.format("%1.f", self.progress_bar.percentage*100).."%" --- end + else + self.progress_text.text = string.format("%1.f", self.progress_bar.percentage*100).."%" + end end @@ -138,18 +166,14 @@ function ReaderFooter:applyFooterMode(mode) -- three modes switcher for reader footer -- 0 for footer off -- 1 for footer page info - -- 2 for footer time info (WS64: unused!) + -- 2 for footer time info + -- 3 for footer next_chapter info if mode ~= nil then self.mode = mode end if self.mode == 0 then self.view.footer_visible = false else self.view.footer_visible = true end --- if self.mode == 1 then --- self.show_time = false --- elseif self.mode == 2 then --- self.show_time = true --- end end function ReaderFooter:onEnterFlippingMode() @@ -171,7 +195,19 @@ function ReaderFooter:onTapFooter(arg, ges) self.ui:handleEvent(Event:new("GotoPercentage", percentage)) end else - self.mode = 1 - self.mode + self.mode = (self.mode + 1) % 4 + if DMINIBAR_ALL_AT_ONCE and (self.mode > 1) then + self.mode = 0 + end + if (self.mode == 1) and not DMINIBAR_PAGES then + self.mode = 2 + end + if (self.mode == 2) and not DMINIBAR_TIME then + self.mode = 3 + end + if (self.mode == 3) and not DMINIBAR_NEXT_CHAPTER then + self.mode = 0 + end self:applyFooterMode() end if self.pageno then