ReaderFooter: Get rid of magic nil settings

And go through one-time-migration to ensure the settings are properly
filled.

Also, disable hold-to-skim by default.
reviewable/pr7711/r1
NiLuJe 3 years ago
parent 99ee3763c1
commit 189035cafc

@ -115,8 +115,6 @@ end
local PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT = 7 local PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT = 7
local PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT = 3 local PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT = 3
local DMINIBAR_TOC_MARKER_WIDTH = 2
local DMINIBAR_FONT_SIZE = 14
-- android: guidelines for rounded corner margins -- android: guidelines for rounded corner margins
local material_pixels = 16 * math.floor(Screen:getDPI() / 160) local material_pixels = 16 * math.floor(Screen:getDPI() / 160)
@ -125,7 +123,7 @@ local material_pixels = 16 * math.floor(Screen:getDPI() / 160)
local footerTextGeneratorMap = { local footerTextGeneratorMap = {
empty = function() return "" end, empty = function() return "" end,
frontlight = function(footer) frontlight = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].frontlight local prefix = symbol_prefix[symbol_type].frontlight
local powerd = Device:getPowerDevice() local powerd = Device:getPowerDevice()
if powerd:isFrontlightOn() then if powerd:isFrontlightOn() then
@ -143,7 +141,7 @@ local footerTextGeneratorMap = {
end end
end, end,
battery = function(footer) battery = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].battery local prefix = symbol_prefix[symbol_type].battery
local powerd = Device:getPowerDevice() local powerd = Device:getPowerDevice()
local batt_lvl = powerd:getCapacity() local batt_lvl = powerd:getCapacity()
@ -186,7 +184,7 @@ local footerTextGeneratorMap = {
end end
end, end,
bookmark_count = function(footer) bookmark_count = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].bookmark_count local prefix = symbol_prefix[symbol_type].bookmark_count
local bookmark_count = footer.ui.bookmark:getNumberOfBookmarks() local bookmark_count = footer.ui.bookmark:getNumberOfBookmarks()
if footer.settings.all_at_once and footer.settings.hide_empty_generators and bookmark_count == 0 then if footer.settings.all_at_once and footer.settings.hide_empty_generators and bookmark_count == 0 then
@ -195,7 +193,7 @@ local footerTextGeneratorMap = {
return prefix .. " " .. tostring(bookmark_count) return prefix .. " " .. tostring(bookmark_count)
end, end,
time = function(footer) time = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].time local prefix = symbol_prefix[symbol_type].time
local clock = util.secondsToHour(os.time(), G_reader_settings:isTrue("twelve_hour_clock")) local clock = util.secondsToHour(os.time(), G_reader_settings:isTrue("twelve_hour_clock"))
if not prefix then if not prefix then
@ -255,15 +253,15 @@ local footerTextGeneratorMap = {
end end
end, end,
pages_left = function(footer) pages_left = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].pages_left local prefix = symbol_prefix[symbol_type].pages_left
local left = footer.ui.toc:getChapterPagesLeft(footer.pageno) local left = footer.ui.toc:getChapterPagesLeft(footer.pageno)
return prefix .. " " .. (left or footer.ui.document:getTotalPagesLeft(footer.pageno)) return prefix .. " " .. (left or footer.ui.document:getTotalPagesLeft(footer.pageno))
end, end,
percentage = function(footer) percentage = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].percentage local prefix = symbol_prefix[symbol_type].percentage
local digits = footer.settings.progress_pct_format or "0" local digits = footer.settings.progress_pct_format
local string_percentage = "%." .. digits .. "f%%" local string_percentage = "%." .. digits .. "f%%"
if footer.ui.document:hasHiddenFlows() then if footer.ui.document:hasHiddenFlows() then
local flow = footer.ui.document:getPageFlow(footer.pageno) local flow = footer.ui.document:getPageFlow(footer.pageno)
@ -277,20 +275,20 @@ local footerTextGeneratorMap = {
return string_percentage:format(footer.progress_bar.percentage * 100) return string_percentage:format(footer.progress_bar.percentage * 100)
end, end,
book_time_to_read = function(footer) book_time_to_read = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].book_time_to_read local prefix = symbol_prefix[symbol_type].book_time_to_read
local left = footer.ui.document:getTotalPagesLeft(footer.pageno) local left = footer.ui.document:getTotalPagesLeft(footer.pageno)
return footer:getDataFromStatistics(prefix and (prefix.." ") or "", left) return footer:getDataFromStatistics(prefix and (prefix.." ") or "", left)
end, end,
chapter_time_to_read = function(footer) chapter_time_to_read = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].chapter_time_to_read local prefix = symbol_prefix[symbol_type].chapter_time_to_read
local left = footer.ui.toc:getChapterPagesLeft(footer.pageno) local left = footer.ui.toc:getChapterPagesLeft(footer.pageno)
return footer:getDataFromStatistics( return footer:getDataFromStatistics(
prefix .. " ", (left or footer.ui.document:getTotalPagesLeft(footer.pageno))) prefix .. " ", (left or footer.ui.document:getTotalPagesLeft(footer.pageno)))
end, end,
mem_usage = function(footer) mem_usage = function(footer)
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].mem_usage local prefix = symbol_prefix[symbol_type].mem_usage
local statm = io.open("/proc/self/statm", "r") local statm = io.open("/proc/self/statm", "r")
if statm then if statm then
@ -304,7 +302,7 @@ local footerTextGeneratorMap = {
end, end,
wifi_status = function(footer) wifi_status = function(footer)
-- NOTE: This one deviates a bit from the mold because, in icons mode, we simply use two different icons and no text. -- NOTE: This one deviates a bit from the mold because, in icons mode, we simply use two different icons and no text.
local symbol_type = footer.settings.item_prefix or "icons" local symbol_type = footer.settings.item_prefix
local NetworkMgr = require("ui/network/manager") local NetworkMgr = require("ui/network/manager")
if symbol_type == "icons" or symbol_type == "compact_items" then if symbol_type == "icons" or symbol_type == "compact_items" then
if NetworkMgr:isWifiOn() then if NetworkMgr:isWifiOn() then
@ -386,35 +384,56 @@ local ReaderFooter = WidgetContainer:extend{
textGeneratorMap = footerTextGeneratorMap, textGeneratorMap = footerTextGeneratorMap,
} }
-- NOTE: This is used in a migration script by ui/data/onetime_migration,
-- which is why it's public.
ReaderFooter.default_settings = {
disable_progress_bar = false, -- enable progress bar by default
disabled = false,
all_at_once = false,
reclaim_height = false,
toc_markers = true,
page_progress = true,
pages_left_book = false,
time = true,
pages_left = true,
battery = Device:hasBattery(),
percentage = true,
book_time_to_read = true,
chapter_time_to_read = true,
frontlight = false,
mem_usage = false,
wifi_status = false,
book_title = false,
book_chapter = false,
bookmark_count = true,
item_prefix = "icons",
toc_markers_width = 2, -- unscaled_size_check: ignore
text_font_size = 14, -- unscaled_size_check: ignore
text_font_bold = false,
container_height = DMINIBAR_CONTAINER_HEIGHT,
container_bottom_padding = 1, -- unscaled_size_check: ignore
progress_margin_width = Screen:scaleBySize(Device:isAndroid() and material_pixels or 10), -- default margin (like self.horizontal_margin)
progress_bar_min_width_pct = 20,
book_title_max_width_pct = 30,
book_chapter_max_width_pct = 30,
skim_widget_on_hold = false,
progress_style_thin = false,
progress_bar_position = "alongside",
bottom_horizontal_separator = false,
align = "center",
auto_refresh_time = false,
progress_style_thin_height = PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT,
progress_style_thick_height = PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT,
hide_empty_generators = false,
lock_tap = false,
items_separator = "bar",
progress_pct_format = "0",
duration_format = "modern",
progress_margin = false,
}
function ReaderFooter:init() function ReaderFooter:init()
self.settings = G_reader_settings:readSetting("footer", { self.settings = G_reader_settings:readSetting("footer", self.default_settings)
-- enable progress bar by default
-- disable_progress_bar = true,
disabled = false,
all_at_once = false,
reclaim_height = false,
toc_markers = true,
battery = Device:hasBattery(),
bookmark_count = true,
time = true,
page_progress = true,
pages_left_book = false,
pages_left = true,
percentage = true,
book_time_to_read = true,
chapter_time_to_read = true,
frontlight = false,
mem_usage = false,
wifi_status = false,
book_title = false,
book_chapter = false,
item_prefix = "icons",
toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH,
text_font_size = DMINIBAR_FONT_SIZE,
text_font_bold = false,
container_height = DMINIBAR_CONTAINER_HEIGHT,
container_bottom_padding = 1, -- unscaled_size_check: ignore
})
-- Remove items not supported by the current device -- Remove items not supported by the current device
if not Device:hasFastWifiStatusQuery() then if not Device:hasFastWifiStatusQuery() then
@ -465,35 +484,9 @@ function ReaderFooter:init()
-- require("logger").dbg(self.mode_nb, self.mode_index) -- require("logger").dbg(self.mode_nb, self.mode_index)
-- Container settings -- Container settings
if not self.settings.container_height then
self.settings.container_height = DMINIBAR_CONTAINER_HEIGHT
end
self.height = Screen:scaleBySize(self.settings.container_height) self.height = Screen:scaleBySize(self.settings.container_height)
if not self.settings.container_bottom_padding then
self.settings.container_bottom_padding = 1 -- unscaled_size_check: ignore
end
self.bottom_padding = Screen:scaleBySize(self.settings.container_bottom_padding) self.bottom_padding = Screen:scaleBySize(self.settings.container_bottom_padding)
-- default margin (like self.horizontal_margin)
if not self.settings.progress_margin_width then
local defaults = Device:isAndroid() and material_pixels or 10
self.settings.progress_margin_width = Screen:scaleBySize(defaults)
end
if not self.settings.toc_markers_width then
self.settings.toc_markers_width = DMINIBAR_TOC_MARKER_WIDTH
end
if not self.settings.progress_bar_min_width_pct then
self.settings.progress_bar_min_width_pct = 20
end
if not self.settings.book_title_max_width_pct then
self.settings.book_title_max_width_pct = 30
end
if not self.settings.book_chapter_max_width_pct then
self.settings.book_chapter_max_width_pct = 30
end
if self.settings.skim_widget_on_hold == nil then
self.settings.skim_widget_on_hold = true
end
self.mode_list = {} self.mode_list = {}
for i = 0, #self.mode_index do for i = 0, #self.mode_index do
self.mode_list[self.mode_index[i]] = i self.mode_list[self.mode_index[i]] = i
@ -506,7 +499,7 @@ function ReaderFooter:init()
self.pageno = self.view.state.page self.pageno = self.view.state.page
self.has_no_mode = true self.has_no_mode = true
self.reclaim_height = self.settings.reclaim_height or false self.reclaim_height = self.settings.reclaim_height
for _, m in ipairs(self.mode_index) do for _, m in ipairs(self.mode_index) do
if self.settings[m] then if self.settings[m] then
self.has_no_mode = false self.has_no_mode = false
@ -514,12 +507,6 @@ function ReaderFooter:init()
end end
end end
if not self.settings.text_font_size then
self.settings.text_font_size = DMINIBAR_FONT_SIZE
end
if not self.settings.text_font_bold then
self.settings.text_font_bold = false
end
self.footer_text = TextWidget:new{ self.footer_text = TextWidget:new{
text = '', text = '',
face = Font:getFace(self.text_font_face, self.settings.text_font_size), face = Font:getFace(self.text_font_face, self.settings.text_font_size),
@ -556,7 +543,7 @@ function ReaderFooter:init()
if self.settings.all_at_once then if self.settings.all_at_once then
self.view.footer_visible = (self.mode ~= self.mode_list.off) self.view.footer_visible = (self.mode ~= self.mode_list.off)
self:updateFooterTextGenerator() self:updateFooterTextGenerator()
if self.settings.progress_bar_position and self.has_no_mode then if self.settings.progress_bar_position ~= "alongside" and self.has_no_mode then
self.footer_text.height = 0 self.footer_text.height = 0
end end
else else
@ -580,7 +567,7 @@ function ReaderFooter:updateFooterContainer()
table.insert(self.vertical_frame, self.separator_line) table.insert(self.vertical_frame, self.separator_line)
table.insert(self.vertical_frame, vertical_span) table.insert(self.vertical_frame, vertical_span)
end end
if self.settings.progress_bar_position and not self.settings.disable_progress_bar then if self.settings.progress_bar_position ~= "alongside" and not self.settings.disable_progress_bar then
self.horizontal_group = HorizontalGroup:new{ self.horizontal_group = HorizontalGroup:new{
margin_span, margin_span,
self.text_container, self.text_container,
@ -736,7 +723,7 @@ function ReaderFooter:resetLayout(force_reset)
if self.settings.disable_progress_bar then if self.settings.disable_progress_bar then
self.progress_bar.width = 0 self.progress_bar.width = 0
elseif self.settings.progress_bar_position then elseif self.settings.progress_bar_position ~= "alongside" then
self.progress_bar.width = math.floor(new_screen_width - 2 * self.settings.progress_margin_width) self.progress_bar.width = math.floor(new_screen_width - 2 * self.settings.progress_margin_width)
else else
self.progress_bar.width = math.floor( self.progress_bar.width = math.floor(
@ -750,9 +737,9 @@ function ReaderFooter:resetLayout(force_reset)
else else
local bar_height local bar_height
if self.settings.progress_style_thin then if self.settings.progress_style_thin then
bar_height = self.settings.progress_style_thin_height or PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT bar_height = self.settings.progress_style_thin_height
else else
bar_height = self.settings.progress_style_thick_height or PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT bar_height = self.settings.progress_style_thick_height
end end
self.progress_bar:setHeight(bar_height) self.progress_bar:setHeight(bar_height)
end end
@ -819,7 +806,7 @@ function ReaderFooter:updateFooterTextGenerator()
end end
function ReaderFooter:progressPercentage(digits) function ReaderFooter:progressPercentage(digits)
local symbol_type = self.settings.item_prefix or "icons" local symbol_type = self.settings.item_prefix
local prefix = symbol_prefix[symbol_type].percentage local prefix = symbol_prefix[symbol_type].percentage
local string_percentage local string_percentage
@ -832,7 +819,7 @@ function ReaderFooter:progressPercentage(digits)
end end
function ReaderFooter:textOptionTitles(option) function ReaderFooter:textOptionTitles(option)
local symbol = self.settings.item_prefix or "icons" local symbol = self.settings.item_prefix
local option_titles = { local option_titles = {
all_at_once = _("Show all at once"), all_at_once = _("Show all at once"),
reclaim_height = _("Reclaim bar height from bottom margin"), reclaim_height = _("Reclaim bar height from bottom margin"),
@ -906,7 +893,7 @@ function ReaderFooter:addToMainMenu(menu_items)
break break
end end
end end
self.reclaim_height = self.settings.reclaim_height or false self.reclaim_height = self.settings.reclaim_height
-- refresh margins position -- refresh margins position
if self.has_no_mode then if self.has_no_mode then
self.footer_text.height = 0 self.footer_text.height = 0
@ -989,10 +976,10 @@ function ReaderFooter:addToMainMenu(menu_items)
text = _("Hide empty items"), text = _("Hide empty items"),
help_text = _([[This will hide values like 0 or off.]]), help_text = _([[This will hide values like 0 or off.]]),
enabled_func = function() enabled_func = function()
return self.settings.all_at_once return self.settings.all_at_once == true
end, end,
checked_func = function() checked_func = function()
return self.settings.hide_empty_generators return self.settings.hide_empty_generators == true
end, end,
callback = function() callback = function()
self.settings.hide_empty_generators = not self.settings.hide_empty_generators self.settings.hide_empty_generators = not self.settings.hide_empty_generators
@ -1013,7 +1000,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Show footer separator"), text = _("Show footer separator"),
checked_func = function() checked_func = function()
return self.settings.bottom_horizontal_separator return self.settings.bottom_horizontal_separator == true
end, end,
callback = function() callback = function()
self.settings.bottom_horizontal_separator = not self.settings.bottom_horizontal_separator self.settings.bottom_horizontal_separator = not self.settings.bottom_horizontal_separator
@ -1023,7 +1010,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Lock status bar"), text = _("Lock status bar"),
checked_func = function() checked_func = function()
return self.settings.lock_tap return self.settings.lock_tap == true
end, end,
callback = function() callback = function()
self.settings.lock_tap = not self.settings.lock_tap self.settings.lock_tap = not self.settings.lock_tap
@ -1032,7 +1019,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Hold footer to skim"), text = _("Hold footer to skim"),
checked_func = function() checked_func = function()
return self.settings.skim_widget_on_hold return self.settings.skim_widget_on_hold == true
end, end,
callback = function() callback = function()
self.settings.skim_widget_on_hold = not self.settings.skim_widget_on_hold self.settings.skim_widget_on_hold = not self.settings.skim_widget_on_hold
@ -1211,13 +1198,13 @@ function ReaderFooter:addToMainMenu(menu_items)
text = _("Alignment"), text = _("Alignment"),
separator = true, separator = true,
enabled_func = function() enabled_func = function()
return self.settings.disable_progress_bar or self.settings.progress_bar_position ~= nil return self.settings.disable_progress_bar or self.settings.progress_bar_position ~= "alongside"
end, end,
sub_item_table = { sub_item_table = {
{ {
text = _("Center"), text = _("Center"),
checked_func = function() checked_func = function()
return self.settings.align == "center" or self.settings.align == nil return self.settings.align == "center"
end, end,
callback = function() callback = function()
self.settings.align = "center" self.settings.align = "center"
@ -1258,7 +1245,7 @@ function ReaderFooter:addToMainMenu(menu_items)
return T(_("Icons (%1)"), table.concat(sym_tbl, " ")) return T(_("Icons (%1)"), table.concat(sym_tbl, " "))
end, end,
checked_func = function() checked_func = function()
return self.settings.item_prefix == "icons" or self.settings.item_prefix == nil return self.settings.item_prefix == "icons"
end, end,
callback = function() callback = function()
self.settings.item_prefix = "icons" self.settings.item_prefix = "icons"
@ -1305,7 +1292,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Vertical line (|)"), text = _("Vertical line (|)"),
checked_func = function() checked_func = function()
return self.settings.items_separator == "bar" or self.settings.items_separator == nil return self.settings.items_separator == "bar"
end, end,
callback = function() callback = function()
self.settings.items_separator = "bar" self.settings.items_separator = "bar"
@ -1342,7 +1329,7 @@ function ReaderFooter:addToMainMenu(menu_items)
return T(_("No decimal point (%1)"), self:progressPercentage(0)) return T(_("No decimal point (%1)"), self:progressPercentage(0))
end, end,
checked_func = function() checked_func = function()
return self.settings.progress_pct_format == "0" or self.settings.progress_pct_format == nil return self.settings.progress_pct_format == "0"
end, end,
callback = function() callback = function()
self.settings.progress_pct_format = "0" self.settings.progress_pct_format = "0"
@ -1388,7 +1375,7 @@ function ReaderFooter:addToMainMenu(menu_items)
return T(_("Modern (%1)"), return_text) return T(_("Modern (%1)"), return_text)
end, end,
checked_func = function() checked_func = function()
return self.settings.duration_format == "modern" or self.settings.duration_format == nil return self.settings.duration_format == "modern"
end, end,
callback = function() callback = function()
self.settings.duration_format = "modern" self.settings.duration_format = "modern"
@ -1476,7 +1463,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Alongside items"), text = _("Alongside items"),
checked_func = function() checked_func = function()
return not self.settings.progress_bar_position return self.settings.progress_bar_position == "alongside"
end, end,
callback = function() callback = function()
-- "Same as book" is disabled in this mode, and we enforce the defaults. -- "Same as book" is disabled in this mode, and we enforce the defaults.
@ -1487,7 +1474,7 @@ function ReaderFooter:addToMainMenu(menu_items)
-- Text alignment is also disabled -- Text alignment is also disabled
self.settings.align = "center" self.settings.align = "center"
self.settings.progress_bar_position = nil self.settings.progress_bar_position = "alongside"
self:refreshFooter(true, true) self:refreshFooter(true, true)
end end
}, },
@ -1512,7 +1499,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end, end,
callback = function() callback = function()
self.settings.progress_style_thin = nil self.settings.progress_style_thin = nil
local bar_height = self.settings.progress_style_thick_height or PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT local bar_height = self.settings.progress_style_thick_height
self.progress_bar:updateStyle(true, bar_height) self.progress_bar:updateStyle(true, bar_height)
self:setTocMarkers() self:setTocMarkers()
self:refreshFooter(true, true) self:refreshFooter(true, true)
@ -1525,7 +1512,7 @@ function ReaderFooter:addToMainMenu(menu_items)
end, end,
callback = function() callback = function()
self.settings.progress_style_thin = true self.settings.progress_style_thin = true
local bar_height = self.settings.progress_style_thin_height or PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT local bar_height = self.settings.progress_style_thin_height
self.progress_bar:updateStyle(false, bar_height) self.progress_bar:updateStyle(false, bar_height)
self:refreshFooter(true, true) self:refreshFooter(true, true)
end, end,
@ -1573,7 +1560,7 @@ function ReaderFooter:addToMainMenu(menu_items)
{ {
text = _("Show chapter markers"), text = _("Show chapter markers"),
checked_func = function() checked_func = function()
return self.settings.toc_markers return self.settings.toc_markers == true
end, end,
enabled_func = function() enabled_func = function()
return not self.settings.progress_style_thin return not self.settings.progress_style_thin
@ -1677,7 +1664,7 @@ function ReaderFooter:addToMainMenu(menu_items)
return self.settings.progress_margin and not self.ui.document.info.has_pages return self.settings.progress_margin and not self.ui.document.info.has_pages
end, end,
enabled_func = function() enabled_func = function()
return not self.ui.document.info.has_pages and self.settings.progress_bar_position ~= nil return not self.ui.document.info.has_pages and self.settings.progress_bar_position ~= "alongside"
end, end,
callback = function() callback = function()
self.settings.progress_margin = true self.settings.progress_margin = true
@ -1717,7 +1704,7 @@ function ReaderFooter:addToMainMenu(menu_items)
return T(_("Minimal width (%1%)"), self.settings.progress_bar_min_width_pct) return T(_("Minimal width (%1%)"), self.settings.progress_bar_min_width_pct)
end, end,
enabled_func = function() enabled_func = function()
return not self.settings.progress_bar_position and not self.settings.disable_progress_bar return self.settings.progress_bar_position == "alongside" and not self.settings.disable_progress_bar
and self.settings.all_at_once and self.settings.all_at_once
end, end,
callback = function(touchmenu_instance) callback = function(touchmenu_instance)
@ -1780,7 +1767,7 @@ function ReaderFooter:genAllFooterText()
if self.settings.item_prefix == "compact_items" then if self.settings.item_prefix == "compact_items" then
separator = " " separator = " "
end end
if self.settings.items_separator == "bar" or self.settings.items_separator == nil then if self.settings.items_separator == "bar" then
separator = " | " separator = " | "
elseif self.settings.items_separator == "bullet" then elseif self.settings.items_separator == "bullet" then
separator = "" separator = ""
@ -1922,7 +1909,7 @@ function ReaderFooter:_updateFooterText(force_repaint, force_recompute)
end end
self.progress_bar.height = 0 self.progress_bar.height = 0
self.progress_bar.width = 0 self.progress_bar.width = 0
elseif self.settings.progress_bar_position then elseif self.settings.progress_bar_position ~= "alongside" then
if self.has_no_mode or text == "" then if self.has_no_mode or text == "" then
self.text_width = 0 self.text_width = 0
self.footer_text.height = 0 self.footer_text.height = 0

@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs")
local logger = require("logger") local logger = require("logger")
-- Date at which the last migration snippet was added -- Date at which the last migration snippet was added
local CURRENT_MIGRATION_DATE = 20210508 local CURRENT_MIGRATION_DATE = 20210518
-- Retrieve the date of the previous migration, if any -- Retrieve the date of the previous migration, if any
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0) local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
@ -218,5 +218,21 @@ if last_migration_date < 20210508 then
DocCache:clearDiskCache() DocCache:clearDiskCache()
end end
-- 20210518, ReaderFooter, https://github.com/koreader/koreader/pull/7702
if last_migration_date < 20210518 then
logger.info("Performing one-time migration for 20210518")
local ReaderFooter = require("apps/reader/modules/readerfooter")
local settings = G_reader_settings:readSetting("footer", ReaderFooter.default_settings)
-- Make sure we have a full set, some of these were historically kept as magic nils...
for k, v in pairs(ReaderFooter.default_settings) do
if settings[k] == nil then
settings[k] = v
end
end
G_reader_settings:saveSetting("footer", settings)
end
-- We're done, store the current migration date -- We're done, store the current migration date
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE) G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)

Loading…
Cancel
Save