From ec16a3f745681b883570a39c1faa6792cade5289 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 07:06:43 +0200 Subject: [PATCH 1/8] Update readerfooter.lua Add "pages left to next chapter" to minibar --- frontend/apps/reader/modules/readerfooter.lua | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index a32214fcd..d1ddd6774 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -15,18 +15,19 @@ local Event = require("ui/event") local Font = require("ui/font") local DEBUG = require("dbg") + local ReaderFooter = InputContainer:new{ mode = 1, visible = true, pageno = nil, pages = nil, progress_percentage = 0.0, - progress_text = "0000 / 0000", - show_time = false, + progress_text = "WW:WW | 0000 / 0000 Next: 000", +-- show_time = true, text_font_face = "ffont", text_font_size = 14, height = Screen:scaleByDPI(19), - padding = Screen:scaleByDPI(10), + padding = Screen:scaleByDPI(10) } function ReaderFooter:init() @@ -93,28 +94,34 @@ function ReaderFooter:init() self:applyFooterMode() end + +function ReaderFooter:fillToc() + self.toc = self.ui.document:getToc() +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") - else - self.progress_text.text = string.format("%d / %d", self.pageno, self.pages) - end +-- 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 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 + function ReaderFooter:onPageUpdate(pageno) self.pageno = pageno self.pages = self.view.document.info.number_of_pages @@ -131,18 +138,18 @@ function ReaderFooter:applyFooterMode(mode) -- three modes switcher for reader footer -- 0 for footer off -- 1 for footer page info - -- 2 for footer time info + -- 2 for footer time info (WS64: unused!) 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 +-- if self.mode == 1 then +-- self.show_time = false +-- elseif self.mode == 2 then +-- self.show_time = true +-- end end function ReaderFooter:onEnterFlippingMode() @@ -164,7 +171,7 @@ function ReaderFooter:onTapFooter(arg, ges) self.ui:handleEvent(Event:new("GotoPercentage", percentage)) end else - self.mode = (self.mode + 1) % 3 + self.mode = 1 - self.mode self:applyFooterMode() end if self.pageno then From dee04099d146cdeadc721186577b80182839b0d4 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 07:07:18 +0200 Subject: [PATCH 2/8] Update readertoc.lua Add "pages left to next chapter" to minibar --- frontend/apps/reader/modules/readertoc.lua | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index 41aafe45a..e33b14a2f 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -98,6 +98,35 @@ function ReaderToc:getTocTitleOfCurrentPage() return self:getTocTitleByPage(self.pageno) end +function ReaderToc:_getChapterPagesLeft(pageno,pages) + if not self.toc then + -- build toc when needed. + self:fillToc() + end + + -- no table of content + if #self.toc == 0 then + return "" + end + + j=0 + if #self.toc > 0 then + for i=1, #self.toc do + v = self.toc[i] + if v.page > pageno then + j = v.page + break + end + end + end + if j==0 then + return pages-pageno + else + return j-pageno-1 + end +end + + function ReaderToc:onShowToc() if not self.toc then self:fillToc() From ddf90f2391bc5a9f5820cc5543fdf6a45bd2a126 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 10:30:22 +0200 Subject: [PATCH 3/8] Update defaults.lua --- defaults.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/defaults.lua b/defaults.lua index b8f4bff0b..6572e18c8 100644 --- a/defaults.lua +++ b/defaults.lua @@ -110,6 +110,13 @@ DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {20, 20, 20, 20} -- 1 for bottom "mini" progress bar DCREREADER_PROGRESS_BAR = 1 +-- configure "mini" progress bar +DMINIBAR_ALL_AT_ONCE = true +DMINIBAR_TIME = true +DMINIBAR_PAGES = true +DMINIBAR_NEXT_CHAPTER = true + + -- gesture detector defaults DGESDETECT_DISABLE_DOUBLE_TAP = true From c50a0f701bc052c2a55b3fe5b264c3f3d9cc2c72 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 10:32:17 +0200 Subject: [PATCH 4/8] 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 From 00c050f279d31158732a494e8df6bcacd8cf2682 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 10:43:24 +0200 Subject: [PATCH 5/8] Update readerfooter.lua --- frontend/apps/reader/modules/readerfooter.lua | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index c7df9997b..e46698181 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -17,16 +17,16 @@ 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) + 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 @@ -115,27 +115,27 @@ end function ReaderFooter:updateFooterPage() if type(self.pageno) ~= "number" then return end self.progress_bar.percentage = self.pageno / self.pages - 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 + 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() @@ -197,16 +197,16 @@ function ReaderFooter:onTapFooter(arg, ges) else self.mode = (self.mode + 1) % 4 if DMINIBAR_ALL_AT_ONCE and (self.mode > 1) then - self.mode = 0 + self.mode = 0 end if (self.mode == 1) and not DMINIBAR_PAGES then - self.mode = 2 + self.mode = 2 end if (self.mode == 2) and not DMINIBAR_TIME then - self.mode = 3 + self.mode = 3 end if (self.mode == 3) and not DMINIBAR_NEXT_CHAPTER then - self.mode = 0 + self.mode = 0 end self:applyFooterMode() end From dc78dd9fdaf393fc8795f416efb2e7e1023922b2 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 10:46:26 +0200 Subject: [PATCH 6/8] Update readertoc.lua --- frontend/apps/reader/modules/readertoc.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index e33b14a2f..fb368843b 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -109,21 +109,21 @@ function ReaderToc:_getChapterPagesLeft(pageno,pages) return "" end - j=0 + j=0 if #self.toc > 0 then for i=1, #self.toc do v = self.toc[i] if v.page > pageno then - j = v.page + j = v.page break end end end if j==0 then return pages-pageno - else - return j-pageno-1 - end + else + return j-pageno-1 + end end From 0429325c5f2065e1ba703f73a71787be4b31e91e Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 14:46:23 +0200 Subject: [PATCH 7/8] removed "next chapter" for PDFs Should actually also be done for EPUBs without TOC, but somehow I can't get it to work --- frontend/apps/reader/modules/readerfooter.lua | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index e46698181..7a71fc782 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -15,29 +15,13 @@ 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, visible = true, pageno = nil, pages = nil, progress_percentage = 0.0, - progress_text = progress_text_default, + progress_text = nil, text_font_face = "ffont", text_font_size = 14, height = Screen:scaleByDPI(19), @@ -45,8 +29,28 @@ local ReaderFooter = InputContainer:new{ } function ReaderFooter:init() + if self.ui.document.info.has_pages then + DMINIBAR_NEXT_CHAPTER = false + end + + 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 + self.progress_text = TextWidget:new{ - text = self.progress_text, + text = progress_text_default, face = Font:getFace(self.text_font_face, self.text_font_size), } local text_width = self.progress_text:getSize().w From c32af1585405d26cf015ca8e36d67ac876d98f35 Mon Sep 17 00:00:00 2001 From: WS64 Date: Wed, 2 Jul 2014 14:47:07 +0200 Subject: [PATCH 8/8] set DMINIBAR_ALL_AT_ONCE = false --- defaults.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults.lua b/defaults.lua index 6572e18c8..c63ebdd73 100644 --- a/defaults.lua +++ b/defaults.lua @@ -111,7 +111,7 @@ DCREREADER_CONFIG_MARGIN_SIZES_LARGE = {20, 20, 20, 20} DCREREADER_PROGRESS_BAR = 1 -- configure "mini" progress bar -DMINIBAR_ALL_AT_ONCE = true +DMINIBAR_ALL_AT_ONCE = false DMINIBAR_TIME = true DMINIBAR_PAGES = true DMINIBAR_NEXT_CHAPTER = true