2
0
mirror of https://github.com/koreader/koreader synced 2024-11-16 06:12:56 +00:00

Fix default not being used for View mode and Progress bar

Default setting set by holding on the bottom config buttons
for "View mode" (scroll/page) and "Progress bar" (full/mini)
were not used.

Also, when switching Progress bar from 'full' to 'mini',
show the mini bar again.
This commit is contained in:
poire-z 2018-10-12 17:58:07 +02:00
parent 1b3d974bec
commit fa0117bb2a
4 changed files with 25 additions and 9 deletions

View File

@ -1,9 +1,11 @@
local Event = require("ui/event")
local EventListener = require("ui/widget/eventlistener")
local ReaderCoptListener = EventListener:new{}
function ReaderCoptListener:onReadSettings(config)
local view_mode = config:readSetting("copt_view_mode")
local view_mode = config:readSetting("copt_view_mode") or
G_reader_settings:readSetting("copt_view_mode")
if view_mode == 0 then
self.ui:registerPostReadyCallback(function()
self.view:onSetViewMode("page")
@ -14,8 +16,10 @@ function ReaderCoptListener:onReadSettings(config)
end)
end
local status_line = config:readSetting("copt_status_line") or DCREREADER_PROGRESS_BAR
self.document:setStatusLineProp(status_line)
local status_line = config:readSetting("copt_status_line") or
G_reader_settings:readSetting("copt_status_line") or
DCREREADER_PROGRESS_BAR
self.ui:handleEvent(Event:new("SetStatusLine", status_line, true))
end
function ReaderCoptListener:onSetFontSize(font_size)

View File

@ -692,14 +692,25 @@ function ReaderFooter:onHoldFooter()
return true
end
function ReaderFooter:onSetStatusLine(status_line)
function ReaderFooter:onSetStatusLine(status_line, on_read_settings)
-- Ignore this event when it is first sent by ReaderCoptListener
-- on book loading, so we stay with the saved footer settings
if on_read_settings then
return
end
-- 1 is min progress bar while 0 is full cre header progress bar
if status_line == 1 then
-- If footer was off (if previously with full status bar), make the
-- footer visible, as if we taped on it (and so we don't duplicate
-- this code - not if flipping_visible as in this case, a ges.pos
-- argument to onTapFooter(ges) is required)
if self.mode == MODE.off and not self.view.flipping_visible then
self:onTapFooter()
end
self.view.footer_visible = (self.mode ~= MODE.off)
else
self:applyFooterMode(MODE.off)
end
self.ui.document:setStatusLineProp(status_line)
self.ui:handleEvent(Event:new("UpdatePos"))
end

View File

@ -172,8 +172,6 @@ function ReaderRolling:onReadSettings(config)
self.show_overlap_enable = DSHOWOVERLAP
end
self.inverse_reading_order = config:readSetting("inverse_reading_order") or false
self:onSetStatusLine(config:readSetting("copt_status_line") or DCREREADER_PROGRESS_BAR)
end
-- in scroll mode percent_finished must be save before close document
@ -712,6 +710,9 @@ end
--]]
function ReaderRolling:onSetStatusLine(status_line)
-- in crengine: 0=header enabled, 1=disabled
-- in koreader: 0=top status bar, 1=bottom mini bar
self.ui.document:setStatusLineProp(status_line)
self.cre_top_bar_enabled = status_line == 0
end

View File

@ -626,8 +626,8 @@ describe("Readerfooter module", function()
assert.is.same(0, footer.mode)
assert.falsy(readerui.view.footer_visible)
readerui.view.footer:onSetStatusLine(1)
assert.is.same(0, footer.mode)
assert.falsy(readerui.view.footer_visible)
assert.is.same(1, footer.mode)
assert.truthy(readerui.view.footer_visible)
footer.mode = 1
readerui.view.footer:onSetStatusLine(1)