Skip to content

Commit

Permalink
Fix default not being used for View mode and Progress bar
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
poire-z committed Oct 14, 2018
1 parent 0b46c58 commit a200b19
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
10 changes: 7 additions & 3 deletions frontend/apps/reader/modules/readercoptlistener.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
Expand Down
15 changes: 13 additions & 2 deletions frontend/apps/reader/modules/readerfooter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions frontend/apps/reader/modules/readerrolling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/unit/readerfooter_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a200b19

Please sign in to comment.