diff --git a/defaults.lua b/defaults.lua index e38f55137..a42497bc5 100644 --- a/defaults.lua +++ b/defaults.lua @@ -56,6 +56,9 @@ DSHOWFILESIZE = false -- default to true, set to false for counterclockwise rotation DLANDSCAPE_CLOCKWISE_ROTATION = true +-- default minimum screen height for reading with 2 pages in landscape mode +DCREREADER_TWO_PAGE_THRESHOLD = 7 + -- page overlap pixels DOVERLAPPIXELS = 30 diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 68677d8e3..020cbf618 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -246,17 +246,17 @@ function ReaderRolling:onResume() end function ReaderRolling:onDoubleTapForward() - local i = self.ui.toc:_getChapterPagesLeft(self.current_page,-1) + local i = self.ui.toc:_getNextChapter(self.current_page+self.ui.document:getVisiblePageCount()) if i ~= "" then - self:onGotoViewRel(i+1) + self:onGotoPage(i) end return true end function ReaderRolling:onDoubleTapBackward() - local i = self.ui.toc:_getChapterPagesDone(self.current_page) + local i = self.ui.toc:_getPreviousChapter(self.current_page) if i ~= "" then - self:onGotoViewRel(i) + self:onGotoPage(i) end return true end diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index 8d7b36a66..132a45cc7 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -101,6 +101,7 @@ end function ReaderToc:_getChapterPagesLeft(pageno,pages) local i local j = 0 + if not self.toc then -- build toc when needed. self:fillToc() @@ -134,6 +135,7 @@ end function ReaderToc:_getChapterPagesDone(pageno) local i local j = 0 + if not self.toc then -- build toc when needed. self:fillToc() @@ -160,6 +162,66 @@ function ReaderToc:_getChapterPagesDone(pageno) end end +function ReaderToc:_getPreviousChapter(pageno) + local i + local j = 0 + + if not self.toc then + -- build toc when needed. + self:fillToc() + end + + -- no table of content + if #self.toc == 0 then + return "" + end + + if #self.toc > 0 then + for i = 1, #self.toc do + v = self.toc[i] + if v.page >= pageno then + break + end + j = v.page + end + end + if j >= pageno then + return "" + else + return j + end +end + +function ReaderToc:_getNextChapter(pageno) + local i + local j = 0 + + if not self.toc then + -- build toc when needed. + self:fillToc() + end + + -- no table of content + if #self.toc == 0 then + return "" + end + + 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 < pageno then + return "" + else + return j + end +end + function ReaderToc:onShowToc() if not self.toc then diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 0843681a3..55fd0a909 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -121,7 +121,7 @@ function CreDocument:loadDocument() if not self.info.has_pages then self.info.doc_height = self._document:getFullHeight() end - if math.max(Screen:getWidth(), Screen:getHeight())/Screen:getDPI() < 7 then + if math.max(Screen:getWidth(),Screen:getHeight())/Screen:getDPI() < DCREREADER_TWO_PAGE_THRESHOLD then self:setVisiblePageCount(1) end end