mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #729 from WS64/master
Added DCREREADER_TWO_PAGE_THRESHOLD and changed behaviour of next/previous chapter
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user