mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
ReaderFooter: fix minor issues with pages left & chapter progress
When using Reference page numbers, "Pages left" was showing the same info as "Current page", because Reference pages, being strings, couldn't be used for arithmetics. But we can just count the number of items left in the Reference pages array of strings. Also fix edge case with "page progress" with hidden flow when we are before the first chapter with a hidden flow before.
This commit is contained in:
@@ -265,9 +265,12 @@ local footerTextGeneratorMap = {
|
||||
if footer.pageno then
|
||||
if footer.ui.pagemap and footer.ui.pagemap:wantsPageLabels() then
|
||||
-- (Page labels might not be numbers)
|
||||
return ("%s %s / %s"):format(prefix,
|
||||
footer.ui.pagemap:getCurrentPageLabel(true),
|
||||
footer.ui.pagemap:getLastPageLabel(true))
|
||||
local label, idx, count = footer.ui.pagemap:getCurrentPageLabel(false) -- luacheck: no unused
|
||||
local remaining = count - idx
|
||||
if footer.settings.pages_left_includes_current_page then
|
||||
remaining = remaining + 1
|
||||
end
|
||||
return ("%s %s / %s"):format(prefix, remaining, footer.ui.pagemap:getLastPageLabel(true))
|
||||
end
|
||||
if footer.ui.document:hasHiddenFlows() then
|
||||
-- i.e., if we are hiding non-linear fragments and there's anything to hide,
|
||||
@@ -2488,6 +2491,9 @@ function ReaderFooter:getChapterProgress(get_percentage, pageno)
|
||||
current = current + 1
|
||||
else
|
||||
current = pageno
|
||||
if self.ui.document:hasHiddenFlows() then
|
||||
current = self.ui.document:getPageNumberInFlow(pageno)
|
||||
end
|
||||
end
|
||||
local total = self.ui.toc:getChapterPageCount(pageno) or self.pages
|
||||
if get_percentage then
|
||||
|
||||
Reference in New Issue
Block a user