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.
pull/4273/head
poire-z 6 years ago
parent 1b3d974bec
commit fa0117bb2a

@ -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)

@ -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

@ -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

@ -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)

Loading…
Cancel
Save