2019-12-06 21:55:39 +00:00
|
|
|
|
local BD = require("ui/bidi")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local BottomContainer = require("ui/widget/container/bottomcontainer")
|
2019-08-11 17:58:39 +00:00
|
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local Device = require("device")
|
|
|
|
|
local Event = require("ui/event")
|
|
|
|
|
local Font = require("ui/font")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local Geom = require("ui/geometry")
|
2013-12-15 12:19:06 +00:00
|
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
2016-03-12 08:59:15 +00:00
|
|
|
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
2019-08-11 17:58:39 +00:00
|
|
|
|
local LeftContainer = require("ui/widget/container/leftcontainer")
|
2019-09-05 11:58:34 +00:00
|
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local ProgressWidget = require("ui/widget/progresswidget")
|
|
|
|
|
local RightContainer = require("ui/widget/container/rightcontainer")
|
2019-09-05 11:58:34 +00:00
|
|
|
|
local Size = require("ui/size")
|
2013-10-18 20:38:07 +00:00
|
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
2013-12-15 12:19:06 +00:00
|
|
|
|
local UIManager = require("ui/uimanager")
|
2019-09-05 11:58:34 +00:00
|
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
|
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
2020-09-13 17:00:03 +00:00
|
|
|
|
local logger = require("logger")
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local util = require("util")
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local T = require("ffi/util").template
|
2015-03-12 06:35:43 +00:00
|
|
|
|
local _ = require("gettext")
|
2019-12-06 21:55:39 +00:00
|
|
|
|
local C_ = _.pgettext
|
2017-04-02 10:42:25 +00:00
|
|
|
|
local Screen = Device.screen
|
2013-02-23 18:25:57 +00:00
|
|
|
|
|
2016-04-28 07:02:15 +00:00
|
|
|
|
local MODE = {
|
|
|
|
|
off = 0,
|
|
|
|
|
page_progress = 1,
|
2020-12-31 22:48:16 +00:00
|
|
|
|
pages_left_book = 2,
|
|
|
|
|
time = 3,
|
|
|
|
|
pages_left = 4,
|
|
|
|
|
battery = 5,
|
|
|
|
|
percentage = 6,
|
|
|
|
|
book_time_to_read = 7,
|
|
|
|
|
chapter_time_to_read = 8,
|
|
|
|
|
frontlight = 9,
|
|
|
|
|
mem_usage = 10,
|
|
|
|
|
wifi_status = 11,
|
|
|
|
|
book_title = 12,
|
|
|
|
|
book_chapter = 13,
|
|
|
|
|
bookmark_count = 14,
|
2021-06-05 18:19:01 +00:00
|
|
|
|
chapter_progress = 15,
|
2016-04-28 07:02:15 +00:00
|
|
|
|
}
|
2016-11-02 08:38:52 +00:00
|
|
|
|
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local symbol_prefix = {
|
|
|
|
|
letters = {
|
|
|
|
|
time = nil,
|
2021-06-05 16:13:57 +00:00
|
|
|
|
pages_left_book = "->",
|
2019-08-16 21:22:58 +00:00
|
|
|
|
pages_left = "=>",
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for battery % remaining.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
battery = C_("FooterLetterPrefix", "B:"),
|
2020-09-05 12:54:53 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for the number of bookmarks (bookmark count).
|
|
|
|
|
bookmark_count = C_("FooterLetterPrefix", "BM:"),
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for percentage read.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
percentage = C_("FooterLetterPrefix", "R:"),
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for book time to read.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
book_time_to_read = C_("FooterLetterPrefix", "TB:"),
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for chapter time to read.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
chapter_time_to_read = C_("FooterLetterPrefix", "TC:"),
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for frontlight level.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
frontlight = C_("FooterLetterPrefix", "L:"),
|
2019-12-10 22:00:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for memory usage.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
mem_usage = C_("FooterLetterPrefix", "M:"),
|
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
2020-07-27 01:39:06 +00:00
|
|
|
|
-- @translators This is the footer letter prefix for Wi-Fi status.
|
2019-12-06 21:55:39 +00:00
|
|
|
|
wifi_status = C_("FooterLetterPrefix", "W:"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
},
|
|
|
|
|
icons = {
|
|
|
|
|
time = "⌚",
|
2021-06-05 16:13:57 +00:00
|
|
|
|
pages_left_book = BD.mirroredUILayout() and "↢" or "↣",
|
2019-12-06 21:55:39 +00:00
|
|
|
|
pages_left = BD.mirroredUILayout() and "⇐" or "⇒",
|
2019-11-15 18:06:35 +00:00
|
|
|
|
battery = "",
|
2020-09-05 12:54:53 +00:00
|
|
|
|
bookmark_count = "☆",
|
2019-12-06 21:55:39 +00:00
|
|
|
|
percentage = BD.mirroredUILayout() and "⤟" or "⤠",
|
2019-08-16 21:22:58 +00:00
|
|
|
|
book_time_to_read = "⏳",
|
2019-12-06 21:55:39 +00:00
|
|
|
|
chapter_time_to_read = BD.mirroredUILayout() and "⥖" or "⤻",
|
2019-08-16 21:22:58 +00:00
|
|
|
|
frontlight = "☼",
|
2019-11-15 18:06:35 +00:00
|
|
|
|
mem_usage = "",
|
|
|
|
|
wifi_status = "",
|
2020-09-28 23:06:41 +00:00
|
|
|
|
wifi_status_off = "",
|
2021-01-12 01:04:15 +00:00
|
|
|
|
},
|
|
|
|
|
compact_items = {
|
|
|
|
|
time = nil,
|
2021-06-21 16:48:33 +00:00
|
|
|
|
pages_left_book = BD.mirroredUILayout() and "‹" or "›",
|
2021-06-05 16:13:57 +00:00
|
|
|
|
pages_left = BD.mirroredUILayout() and "‹" or "›",
|
2021-01-12 01:04:15 +00:00
|
|
|
|
battery = "",
|
|
|
|
|
-- @translators This is the footer compact item prefix for the number of bookmarks (bookmark count).
|
|
|
|
|
bookmark_count = C_("FooterCompactItemsPrefix", "BM"),
|
|
|
|
|
percentage = nil,
|
|
|
|
|
book_time_to_read = nil,
|
2021-06-05 16:13:57 +00:00
|
|
|
|
chapter_time_to_read = BD.mirroredUILayout() and "«" or "»",
|
2021-01-12 01:04:15 +00:00
|
|
|
|
frontlight = "*",
|
|
|
|
|
-- @translators This is the footer compact item prefix for memory usage.
|
|
|
|
|
mem_usage = C_("FooterCompactItemsPrefix", "M"),
|
|
|
|
|
wifi_status = "",
|
|
|
|
|
wifi_status_off = "",
|
2019-08-16 21:22:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-06 21:55:39 +00:00
|
|
|
|
if BD.mirroredUILayout() then
|
|
|
|
|
-- We need to RTL-wrap these letters and symbols for proper layout
|
|
|
|
|
for k, v in pairs(symbol_prefix.letters) do
|
|
|
|
|
local colon = v:find(":")
|
|
|
|
|
local wrapped
|
|
|
|
|
if colon then
|
|
|
|
|
local pre = v:sub(1, colon-1)
|
|
|
|
|
local post = v:sub(colon)
|
|
|
|
|
wrapped = BD.wrap(pre) .. BD.wrap(post)
|
|
|
|
|
else
|
|
|
|
|
wrapped = BD.wrap(v)
|
|
|
|
|
end
|
|
|
|
|
symbol_prefix.letters[k] = wrapped
|
|
|
|
|
end
|
|
|
|
|
for k, v in pairs(symbol_prefix.icons) do
|
|
|
|
|
symbol_prefix.icons[k] = BD.wrap(v)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-10-10 15:02:28 +00:00
|
|
|
|
local PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT = 7
|
|
|
|
|
local PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT = 3
|
2019-08-16 21:22:58 +00:00
|
|
|
|
|
2020-06-11 14:44:24 +00:00
|
|
|
|
-- android: guidelines for rounded corner margins
|
|
|
|
|
local material_pixels = 16 * math.floor(Screen:getDPI() / 160)
|
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- functions that generates footer text for each mode
|
|
|
|
|
local footerTextGeneratorMap = {
|
|
|
|
|
empty = function() return "" end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
frontlight = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].frontlight
|
2016-11-02 08:38:52 +00:00
|
|
|
|
local powerd = Device:getPowerDevice()
|
2017-06-14 17:32:16 +00:00
|
|
|
|
if powerd:isFrontlightOn() then
|
2018-10-31 22:48:36 +00:00
|
|
|
|
if Device:isCervantes() or Device:isKobo() then
|
2019-08-16 21:22:58 +00:00
|
|
|
|
return (prefix .. " %d%%"):format(powerd:frontlightIntensity())
|
2017-09-02 16:33:40 +00:00
|
|
|
|
else
|
2019-08-16 21:22:58 +00:00
|
|
|
|
return (prefix .. " %d"):format(powerd:frontlightIntensity())
|
2017-09-02 16:33:40 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
else
|
2021-04-26 15:40:06 +00:00
|
|
|
|
if footer.settings.all_at_once and footer.settings.hide_empty_generators then
|
2020-10-06 03:25:37 +00:00
|
|
|
|
return ""
|
|
|
|
|
else
|
|
|
|
|
return T(_("%1 Off"), prefix)
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
battery = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].battery
|
2016-11-02 08:38:52 +00:00
|
|
|
|
local powerd = Device:getPowerDevice()
|
2019-10-27 04:22:17 +00:00
|
|
|
|
local batt_lvl = powerd:getCapacity()
|
2021-06-22 17:03:05 +00:00
|
|
|
|
if footer.settings.all_at_once and batt_lvl > footer.settings.battery_hide_threshold then
|
|
|
|
|
return ""
|
|
|
|
|
end
|
2019-10-27 04:22:17 +00:00
|
|
|
|
-- If we're using icons, use fancy variable icons
|
2021-01-12 01:04:15 +00:00
|
|
|
|
if symbol_type == "icons" or symbol_type == "compact_items" then
|
2019-10-27 04:22:17 +00:00
|
|
|
|
if powerd:isCharging() then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
else
|
|
|
|
|
if batt_lvl >= 100 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 90 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 80 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 70 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 60 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 50 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 40 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 30 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 20 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
elseif batt_lvl >= 10 then
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
else
|
2019-11-15 18:06:35 +00:00
|
|
|
|
prefix = ""
|
2019-10-27 04:22:17 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-01-16 14:30:43 +00:00
|
|
|
|
if symbol_type == "compact_items" then
|
|
|
|
|
return BD.wrap(prefix)
|
|
|
|
|
else
|
|
|
|
|
return BD.wrap(prefix) .. batt_lvl .. "%"
|
|
|
|
|
end
|
2019-10-27 18:10:25 +00:00
|
|
|
|
else
|
2019-12-06 21:55:39 +00:00
|
|
|
|
return BD.wrap(prefix) .. " " .. (powerd:isCharging() and "+" or "") .. batt_lvl .. "%"
|
2019-10-27 04:22:17 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
2020-09-05 12:54:53 +00:00
|
|
|
|
bookmark_count = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2020-09-05 12:54:53 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].bookmark_count
|
|
|
|
|
local bookmark_count = footer.ui.bookmark:getNumberOfBookmarks()
|
2021-04-26 15:40:06 +00:00
|
|
|
|
if footer.settings.all_at_once and footer.settings.hide_empty_generators and bookmark_count == 0 then
|
2020-09-05 12:54:53 +00:00
|
|
|
|
return ""
|
|
|
|
|
end
|
|
|
|
|
return prefix .. " " .. tostring(bookmark_count)
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
time = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].time
|
ReaderFooter: Don't duplicate a 12h clock time format option (#6973)
* ReaderFooter:
* Honor the global twelve_hour_clock setting, instead of
duplicating a local one.
(Re #6969)
* os.date is a thin wrapper around strftime, so we might be able to get
away with some not-quite-standard extensions...
These are *definitely* supported on Linux, but are *NOT* the glibc
extension (that'd be e.g., %-I), so, hopefully, they're somewhat
portable...
They are also supported on BSD/macOS.
They are *not* supported by the MS UCRT. That means MinGW-w64, too.
This *appears* to be supported on current Bionic (it might even support
said glibc format altering extensions).
* And of course, Windows is terrible, so, make this terribly ugly to not
break it there...
* Turns out BSD also supports the dash trim format extension, so, leave
the trimming to the libc, and handle the special-casing in a way that
doesn't create stupid locals.
* Random unrelated cleanup ^^.
(https://gitter.im/koreader/koreader?at=5fd24be492aa1c4ef5d11f31)
* Update the testsuite
(Because the default used to be 24h clock).
Changed the default to 24h clock ;p.
* Explain why we don't try to fix it in Lua
2020-12-12 09:44:35 +00:00
|
|
|
|
local clock = util.secondsToHour(os.time(), G_reader_settings:isTrue("twelve_hour_clock"))
|
2019-08-16 21:22:58 +00:00
|
|
|
|
if not prefix then
|
|
|
|
|
return clock
|
|
|
|
|
else
|
|
|
|
|
return prefix .. " " .. clock
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
|
|
|
|
page_progress = function(footer)
|
|
|
|
|
if footer.pageno then
|
2020-03-26 13:04:59 +00:00
|
|
|
|
if footer.ui.pagemap and footer.ui.pagemap:wantsPageLabels() then
|
|
|
|
|
-- (Page labels might not be numbers)
|
|
|
|
|
return ("%s / %s"):format(footer.ui.pagemap:getCurrentPageLabel(true),
|
|
|
|
|
footer.ui.pagemap:getLastPageLabel(true))
|
|
|
|
|
end
|
2020-10-31 09:40:36 +00:00
|
|
|
|
if footer.ui.document:hasHiddenFlows() then
|
|
|
|
|
-- i.e., if we are hiding non-linear fragments and there's anything to hide,
|
|
|
|
|
local flow = footer.ui.document:getPageFlow(footer.pageno)
|
|
|
|
|
local page = footer.ui.document:getPageNumberInFlow(footer.pageno)
|
|
|
|
|
local pages = footer.ui.document:getTotalPagesInFlow(flow)
|
|
|
|
|
if flow == 0 then
|
|
|
|
|
return ("%d // %d"):format(page, pages)
|
|
|
|
|
else
|
|
|
|
|
return ("[%d / %d]%d"):format(page, pages, flow)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return ("%d / %d"):format(footer.pageno, footer.pages)
|
|
|
|
|
end
|
2019-08-16 21:22:58 +00:00
|
|
|
|
elseif footer.position then
|
2017-04-11 09:44:58 +00:00
|
|
|
|
return ("%d / %d"):format(footer.position, footer.doc_height)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
2020-12-31 22:48:16 +00:00
|
|
|
|
pages_left_book = function(footer)
|
2021-06-05 16:13:57 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
|
|
|
|
local prefix = symbol_prefix[symbol_type].pages_left_book
|
2020-12-31 22:48:16 +00:00
|
|
|
|
if footer.pageno then
|
|
|
|
|
if footer.ui.pagemap and footer.ui.pagemap:wantsPageLabels() then
|
|
|
|
|
-- (Page labels might not be numbers)
|
2021-06-05 16:13:57 +00:00
|
|
|
|
return ("%s %s / %s"):format(prefix,
|
|
|
|
|
footer.ui.pagemap:getCurrentPageLabel(true),
|
2020-12-31 22:48:16 +00:00
|
|
|
|
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,
|
|
|
|
|
local flow = footer.ui.document:getPageFlow(footer.pageno)
|
|
|
|
|
local page = footer.ui.document:getPageNumberInFlow(footer.pageno)
|
|
|
|
|
local pages = footer.ui.document:getTotalPagesInFlow(flow)
|
|
|
|
|
local remaining = pages - page;
|
|
|
|
|
if flow == 0 then
|
2021-06-05 16:13:57 +00:00
|
|
|
|
return ("%s %d // %d"):format(prefix, remaining, pages)
|
2020-12-31 22:48:16 +00:00
|
|
|
|
else
|
2021-06-05 16:13:57 +00:00
|
|
|
|
return ("%s [%d / %d]%d"):format(prefix, remaining, pages, flow)
|
2020-12-31 22:48:16 +00:00
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
local remaining = footer.pages - footer.pageno
|
2021-06-05 16:13:57 +00:00
|
|
|
|
return ("%s %d / %d"):format(prefix, remaining, footer.pages)
|
2020-12-31 22:48:16 +00:00
|
|
|
|
end
|
|
|
|
|
elseif footer.position then
|
2021-06-05 16:13:57 +00:00
|
|
|
|
return ("%s %d / %d"):format(prefix, footer.doc_height - footer.position, footer.doc_height)
|
2020-12-31 22:48:16 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
2016-11-02 08:38:52 +00:00
|
|
|
|
pages_left = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].pages_left
|
2021-06-05 18:19:01 +00:00
|
|
|
|
local left = footer.ui.toc:getChapterPagesLeft(footer.pageno) or footer.ui.document:getTotalPagesLeft(footer.pageno)
|
|
|
|
|
return prefix .. " " .. left
|
|
|
|
|
end,
|
|
|
|
|
chapter_progress = function(footer)
|
|
|
|
|
local current = footer.ui.toc:getChapterPagesDone(footer.pageno)
|
|
|
|
|
-- We want a page number, not a page read count
|
|
|
|
|
if current then
|
|
|
|
|
current = current + 1
|
|
|
|
|
else
|
|
|
|
|
current = footer.pageno
|
|
|
|
|
end
|
|
|
|
|
local total = footer.ui.toc:getChapterPageCount(footer.pageno) or footer.pages
|
|
|
|
|
return current .. " ⁄⁄ " .. total
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
|
|
|
|
percentage = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].percentage
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local digits = footer.settings.progress_pct_format
|
2020-10-31 09:40:36 +00:00
|
|
|
|
local string_percentage = "%." .. digits .. "f%%"
|
|
|
|
|
if footer.ui.document:hasHiddenFlows() then
|
|
|
|
|
local flow = footer.ui.document:getPageFlow(footer.pageno)
|
|
|
|
|
if flow ~= 0 then
|
|
|
|
|
string_percentage = "[" .. string_percentage .. "]"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if prefix then
|
|
|
|
|
string_percentage = prefix .. " " .. string_percentage
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end
|
|
|
|
|
return string_percentage:format(footer.progress_bar.percentage * 100)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
|
|
|
|
book_time_to_read = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].book_time_to_read
|
2020-10-31 09:40:36 +00:00
|
|
|
|
local left = footer.ui.document:getTotalPagesLeft(footer.pageno)
|
2021-06-05 18:19:01 +00:00
|
|
|
|
return footer:getDataFromStatistics(prefix and (prefix .. " ") or "", left)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
|
|
|
|
chapter_time_to_read = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].chapter_time_to_read
|
2021-06-05 18:19:01 +00:00
|
|
|
|
local left = footer.ui.toc:getChapterPagesLeft(footer.pageno) or footer.ui.document:getTotalPagesLeft(footer.pageno)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
return footer:getDataFromStatistics(
|
2021-06-05 18:19:01 +00:00
|
|
|
|
prefix .. " ", left)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
2017-03-11 12:22:44 +00:00
|
|
|
|
mem_usage = function(footer)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].mem_usage
|
2017-03-11 12:22:44 +00:00
|
|
|
|
local statm = io.open("/proc/self/statm", "r")
|
|
|
|
|
if statm then
|
2021-01-16 03:41:46 +00:00
|
|
|
|
local dummy, rss = statm:read("*number", "*number")
|
2017-03-11 12:22:44 +00:00
|
|
|
|
statm:close()
|
|
|
|
|
-- we got the nb of 4Kb-pages used, that we convert to Mb
|
2021-01-16 03:41:46 +00:00
|
|
|
|
rss = math.floor(rss * 4096 / 1024 / 1024)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
return (prefix .. " %d"):format(rss)
|
2017-03-11 12:22:44 +00:00
|
|
|
|
end
|
|
|
|
|
return ""
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
wifi_status = function(footer)
|
2020-09-28 23:06:41 +00:00
|
|
|
|
-- NOTE: This one deviates a bit from the mold because, in icons mode, we simply use two different icons and no text.
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = footer.settings.item_prefix
|
2017-10-28 15:51:34 +00:00
|
|
|
|
local NetworkMgr = require("ui/network/manager")
|
2021-01-12 01:04:15 +00:00
|
|
|
|
if symbol_type == "icons" or symbol_type == "compact_items" then
|
2020-09-28 23:06:41 +00:00
|
|
|
|
if NetworkMgr:isWifiOn() then
|
|
|
|
|
return symbol_prefix.icons.wifi_status
|
|
|
|
|
else
|
2021-04-26 15:40:06 +00:00
|
|
|
|
if footer.settings.all_at_once and footer.settings.hide_empty_generators then
|
2020-10-06 03:25:37 +00:00
|
|
|
|
return ""
|
|
|
|
|
else
|
|
|
|
|
return symbol_prefix.icons.wifi_status_off
|
|
|
|
|
end
|
2020-09-28 23:06:41 +00:00
|
|
|
|
end
|
2017-10-28 15:51:34 +00:00
|
|
|
|
else
|
2020-09-28 23:06:41 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].wifi_status
|
|
|
|
|
if NetworkMgr:isWifiOn() then
|
|
|
|
|
return T(_("%1 On"), prefix)
|
|
|
|
|
else
|
2021-04-26 15:40:06 +00:00
|
|
|
|
if footer.settings.all_at_once and footer.settings.hide_empty_generators then
|
2020-10-06 03:25:37 +00:00
|
|
|
|
return ""
|
|
|
|
|
else
|
|
|
|
|
return T(_("%1 Off"), prefix)
|
|
|
|
|
end
|
2020-09-28 23:06:41 +00:00
|
|
|
|
end
|
2017-10-28 15:51:34 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
book_title = function(footer)
|
|
|
|
|
local doc_info = footer.ui.document:getProps()
|
|
|
|
|
if doc_info and doc_info.title then
|
2021-01-12 01:04:15 +00:00
|
|
|
|
local title = doc_info.title:gsub(" ", "\xC2\xA0") -- replace space with no-break-space
|
2020-01-23 20:28:37 +00:00
|
|
|
|
local title_widget = TextWidget:new{
|
2021-01-12 01:04:15 +00:00
|
|
|
|
text = title,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
max_width = footer._saved_screen_width * footer.settings.book_title_max_width_pct / 100,
|
|
|
|
|
face = Font:getFace(footer.text_font_face, footer.settings.text_font_size),
|
2020-02-12 16:51:08 +00:00
|
|
|
|
bold = footer.settings.text_font_bold,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
}
|
|
|
|
|
local fitted_title_text, add_ellipsis = title_widget:getFittedText()
|
|
|
|
|
title_widget:free()
|
|
|
|
|
if add_ellipsis then
|
|
|
|
|
fitted_title_text = fitted_title_text .. "…"
|
|
|
|
|
end
|
|
|
|
|
return BD.auto(fitted_title_text)
|
|
|
|
|
else
|
2020-10-06 03:25:37 +00:00
|
|
|
|
return ""
|
2020-01-23 20:28:37 +00:00
|
|
|
|
end
|
|
|
|
|
end,
|
|
|
|
|
book_chapter = function(footer)
|
|
|
|
|
local chapter_title = footer.ui.toc:getTocTitleByPage(footer.pageno)
|
|
|
|
|
if chapter_title and chapter_title ~= "" then
|
2021-01-12 01:04:15 +00:00
|
|
|
|
chapter_title = chapter_title:gsub(" ", "\xC2\xA0") -- replace space with no-break-space
|
2020-01-23 20:28:37 +00:00
|
|
|
|
local chapter_widget = TextWidget:new{
|
|
|
|
|
text = chapter_title,
|
|
|
|
|
max_width = footer._saved_screen_width * footer.settings.book_chapter_max_width_pct / 100,
|
|
|
|
|
face = Font:getFace(footer.text_font_face, footer.settings.text_font_size),
|
2020-02-12 16:51:08 +00:00
|
|
|
|
bold = footer.settings.text_font_bold,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
}
|
|
|
|
|
local fitted_chapter_text, add_ellipsis = chapter_widget:getFittedText()
|
|
|
|
|
chapter_widget:free()
|
|
|
|
|
if add_ellipsis then
|
|
|
|
|
fitted_chapter_text = fitted_chapter_text .. "…"
|
|
|
|
|
end
|
|
|
|
|
return BD.auto(fitted_chapter_text)
|
|
|
|
|
else
|
2020-10-06 03:25:37 +00:00
|
|
|
|
return ""
|
2020-01-23 20:28:37 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-25 20:13:30 +00:00
|
|
|
|
local ReaderFooter = WidgetContainer:extend{
|
2016-04-28 07:02:15 +00:00
|
|
|
|
mode = MODE.page_progress,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
pageno = nil,
|
|
|
|
|
pages = nil,
|
|
|
|
|
progress_percentage = 0.0,
|
2016-11-02 08:38:52 +00:00
|
|
|
|
footer_text = nil,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
text_font_face = "ffont",
|
2014-11-20 22:07:39 +00:00
|
|
|
|
height = Screen:scaleBySize(DMINIBAR_CONTAINER_HEIGHT),
|
2020-06-11 16:49:51 +00:00
|
|
|
|
horizontal_margin = Size.span.horizontal_default,
|
|
|
|
|
bottom_padding = Size.padding.tiny,
|
2015-03-12 06:35:43 +00:00
|
|
|
|
settings = {},
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- added to expose them to unit tests
|
|
|
|
|
textGeneratorMap = footerTextGeneratorMap,
|
2013-02-23 18:25:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-18 02:44:39 +00:00
|
|
|
|
-- 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(),
|
2021-06-22 17:03:05 +00:00
|
|
|
|
battery_hide_threshold = 100,
|
2021-05-18 02:44:39 +00:00
|
|
|
|
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,
|
2021-05-18 03:46:05 +00:00
|
|
|
|
bookmark_count = false,
|
2021-06-05 18:19:01 +00:00
|
|
|
|
chapter_progress = false,
|
2021-05-18 02:44:39 +00:00
|
|
|
|
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",
|
|
|
|
|
progress_margin = false,
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 07:25:08 +00:00
|
|
|
|
function ReaderFooter:init()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
self.settings = G_reader_settings:readSetting("footer", self.default_settings)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
|
2020-05-30 20:10:32 +00:00
|
|
|
|
-- Remove items not supported by the current device
|
2020-09-28 23:06:41 +00:00
|
|
|
|
if not Device:hasFastWifiStatusQuery() then
|
2020-01-23 20:28:37 +00:00
|
|
|
|
MODE.wifi_status = nil
|
|
|
|
|
end
|
|
|
|
|
if not Device:hasFrontlight() then
|
|
|
|
|
MODE.frontlight = nil
|
|
|
|
|
end
|
2020-07-20 22:52:50 +00:00
|
|
|
|
if not Device:hasBattery() then
|
2020-04-11 15:45:37 +00:00
|
|
|
|
MODE.battery = nil
|
|
|
|
|
end
|
2020-05-30 20:10:32 +00:00
|
|
|
|
|
|
|
|
|
-- self.mode_index will be an array of MODE names, with an additional element
|
|
|
|
|
-- with key 0 for "off", which feels a bit strange but seems to work...
|
|
|
|
|
-- (The same is true for self.settings.order which is saved in settings.)
|
|
|
|
|
self.mode_index = {}
|
|
|
|
|
self.mode_nb = 0
|
|
|
|
|
|
|
|
|
|
local handled_modes = {}
|
|
|
|
|
if self.settings.order then
|
|
|
|
|
-- Start filling self.mode_index from what's been ordered by the user and saved
|
|
|
|
|
for i=0, #self.settings.order do
|
|
|
|
|
local name = self.settings.order[i]
|
|
|
|
|
-- (if name has been removed from our supported MODEs: ignore it)
|
|
|
|
|
if MODE[name] then -- this mode still exists
|
|
|
|
|
self.mode_index[self.mode_nb] = name
|
|
|
|
|
self.mode_nb = self.mode_nb + 1
|
|
|
|
|
handled_modes[name] = true
|
|
|
|
|
end
|
2019-09-17 12:50:03 +00:00
|
|
|
|
end
|
2020-05-30 20:10:32 +00:00
|
|
|
|
-- go on completing it with remaining new modes in MODE
|
2020-01-23 20:28:37 +00:00
|
|
|
|
end
|
2020-05-30 20:10:32 +00:00
|
|
|
|
-- If no previous self.settings.order, fill mode_index with what's in MODE
|
|
|
|
|
-- in the original indices order
|
|
|
|
|
local orig_indexes = {}
|
|
|
|
|
local orig_indexes_to_name = {}
|
|
|
|
|
for name, orig_index in pairs(MODE) do
|
|
|
|
|
if not handled_modes[name] then
|
|
|
|
|
table.insert(orig_indexes, orig_index)
|
|
|
|
|
orig_indexes_to_name[orig_index] = name
|
2019-09-17 12:50:03 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-30 20:10:32 +00:00
|
|
|
|
table.sort(orig_indexes)
|
|
|
|
|
for i = 1, #orig_indexes do
|
|
|
|
|
self.mode_index[self.mode_nb] = orig_indexes_to_name[orig_indexes[i]]
|
|
|
|
|
self.mode_nb = self.mode_nb + 1
|
|
|
|
|
end
|
|
|
|
|
-- require("logger").dbg(self.mode_nb, self.mode_index)
|
2020-01-23 20:28:37 +00:00
|
|
|
|
|
2020-06-11 16:49:51 +00:00
|
|
|
|
-- Container settings
|
|
|
|
|
self.height = Screen:scaleBySize(self.settings.container_height)
|
|
|
|
|
self.bottom_padding = Screen:scaleBySize(self.settings.container_bottom_padding)
|
|
|
|
|
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.mode_list = {}
|
|
|
|
|
for i = 0, #self.mode_index do
|
|
|
|
|
self.mode_list[self.mode_index[i]] = i
|
|
|
|
|
end
|
2016-03-12 21:59:49 +00:00
|
|
|
|
if self.settings.disabled then
|
2019-10-15 19:57:51 +00:00
|
|
|
|
-- footer feature is completely disabled, stop initialization now
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self:disableFooter()
|
2016-03-12 21:59:49 +00:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2017-04-11 09:44:58 +00:00
|
|
|
|
self.pageno = self.view.state.page
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.has_no_mode = true
|
2021-05-18 02:44:39 +00:00
|
|
|
|
self.reclaim_height = self.settings.reclaim_height
|
2019-09-17 12:50:03 +00:00
|
|
|
|
for _, m in ipairs(self.mode_index) do
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if self.settings[m] then
|
|
|
|
|
self.has_no_mode = false
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.footer_text = TextWidget:new{
|
2016-03-12 08:59:15 +00:00
|
|
|
|
text = '',
|
2020-01-04 23:09:27 +00:00
|
|
|
|
face = Font:getFace(self.text_font_face, self.settings.text_font_size),
|
2020-02-12 16:51:08 +00:00
|
|
|
|
bold = self.settings.text_font_bold,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- all width related values will be initialized in self:resetLayout()
|
|
|
|
|
self.text_width = 0
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
self.footer_text.height = 0
|
2014-06-05 04:48:48 +00:00
|
|
|
|
self.progress_bar = ProgressWidget:new{
|
2016-11-02 08:38:52 +00:00
|
|
|
|
width = nil,
|
2019-10-10 15:02:28 +00:00
|
|
|
|
height = nil,
|
2014-06-05 04:48:48 +00:00
|
|
|
|
percentage = self.progress_percentage,
|
2019-12-30 15:20:31 +00:00
|
|
|
|
tick_width = Screen:scaleBySize(self.settings.toc_markers_width),
|
2016-03-19 06:22:17 +00:00
|
|
|
|
ticks = nil, -- ticks will be populated in self:updateFooterText
|
|
|
|
|
last = nil, -- last will be initialized in self:updateFooterText
|
2014-06-05 04:48:48 +00:00
|
|
|
|
}
|
2019-10-10 15:02:28 +00:00
|
|
|
|
|
|
|
|
|
if self.settings.progress_style_thin then
|
|
|
|
|
self.progress_bar:updateStyle(false, nil)
|
|
|
|
|
end
|
|
|
|
|
|
2016-03-12 08:59:15 +00:00
|
|
|
|
self.text_container = RightContainer:new{
|
2016-12-04 06:57:57 +00:00
|
|
|
|
dimen = Geom:new{ w = 0, h = self.height },
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.footer_text,
|
2014-03-13 13:52:43 +00:00
|
|
|
|
}
|
2019-08-11 17:58:39 +00:00
|
|
|
|
self:updateFooterContainer()
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.mode = G_reader_settings:readSetting("reader_footer_mode") or self.mode
|
2019-03-02 14:06:26 +00:00
|
|
|
|
if self.has_no_mode and self.settings.disable_progress_bar then
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.mode = self.mode_list.off
|
2017-08-08 17:06:11 +00:00
|
|
|
|
self.view.footer_visible = false
|
|
|
|
|
self:resetLayout()
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.footer_text.height = 0
|
2017-08-08 17:06:11 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if self.settings.all_at_once then
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.view.footer_visible = (self.mode ~= self.mode_list.off)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self:updateFooterTextGenerator()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
if self.settings.progress_bar_position ~= "alongside" and self.has_no_mode then
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.footer_text.height = 0
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
else
|
|
|
|
|
self:applyFooterMode()
|
|
|
|
|
end
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
|
|
|
|
|
self.visibility_change = nil
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
|
|
|
|
|
2019-08-11 17:58:39 +00:00
|
|
|
|
function ReaderFooter:updateFooterContainer()
|
2019-09-20 07:33:29 +00:00
|
|
|
|
local margin_span = HorizontalSpan:new{ width = self.horizontal_margin }
|
|
|
|
|
self.vertical_frame = VerticalGroup:new{}
|
|
|
|
|
if self.settings.bottom_horizontal_separator then
|
|
|
|
|
self.separator_line = LineWidget:new{
|
|
|
|
|
dimen = Geom:new{
|
|
|
|
|
w = 0,
|
|
|
|
|
h = Size.line.medium,
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-11 16:49:51 +00:00
|
|
|
|
local vertical_span = VerticalSpan:new{width = Size.span.vertical_default}
|
2019-09-20 07:33:29 +00:00
|
|
|
|
table.insert(self.vertical_frame, self.separator_line)
|
|
|
|
|
table.insert(self.vertical_frame, vertical_span)
|
|
|
|
|
end
|
2021-05-18 02:44:39 +00:00
|
|
|
|
if self.settings.progress_bar_position ~= "alongside" and not self.settings.disable_progress_bar then
|
2019-09-20 07:33:29 +00:00
|
|
|
|
self.horizontal_group = HorizontalGroup:new{
|
|
|
|
|
margin_span,
|
|
|
|
|
self.text_container,
|
|
|
|
|
margin_span,
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
self.horizontal_group = HorizontalGroup:new{
|
|
|
|
|
margin_span,
|
|
|
|
|
self.progress_bar,
|
|
|
|
|
self.text_container,
|
|
|
|
|
margin_span,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2019-08-11 17:58:39 +00:00
|
|
|
|
if self.settings.align == "left" then
|
|
|
|
|
self.footer_container = LeftContainer:new{
|
|
|
|
|
dimen = Geom:new{ w = 0, h = self.height },
|
2019-09-05 11:58:34 +00:00
|
|
|
|
self.horizontal_group
|
2019-08-11 17:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
elseif self.settings.align == "right" then
|
|
|
|
|
self.footer_container = RightContainer:new{
|
|
|
|
|
dimen = Geom:new{ w = 0, h = self.height },
|
2019-09-05 11:58:34 +00:00
|
|
|
|
self.horizontal_group
|
2019-08-11 17:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
self.footer_container = CenterContainer:new{
|
|
|
|
|
dimen = Geom:new{ w = 0, h = self.height },
|
2019-09-05 11:58:34 +00:00
|
|
|
|
self.horizontal_group
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-11 16:49:51 +00:00
|
|
|
|
local vertical_span = VerticalSpan:new{width = Size.span.vertical_default}
|
2019-09-05 11:58:34 +00:00
|
|
|
|
|
2019-10-10 15:02:28 +00:00
|
|
|
|
if self.settings.progress_bar_position == "above" and not self.settings.disable_progress_bar then
|
|
|
|
|
table.insert(self.vertical_frame, self.progress_bar)
|
|
|
|
|
table.insert(self.vertical_frame, vertical_span)
|
|
|
|
|
table.insert(self.vertical_frame, self.footer_container)
|
|
|
|
|
elseif self.settings.progress_bar_position == "below" and not self.settings.disable_progress_bar then
|
|
|
|
|
table.insert(self.vertical_frame, self.footer_container)
|
|
|
|
|
table.insert(self.vertical_frame, vertical_span)
|
|
|
|
|
table.insert(self.vertical_frame, self.progress_bar)
|
|
|
|
|
else
|
|
|
|
|
table.insert(self.vertical_frame, self.footer_container)
|
|
|
|
|
end
|
2019-09-05 11:58:34 +00:00
|
|
|
|
self.footer_content = FrameContainer:new{
|
|
|
|
|
self.vertical_frame,
|
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
|
|
|
|
bordersize = 0,
|
|
|
|
|
padding = 0,
|
|
|
|
|
padding_bottom = self.bottom_padding,
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-11 17:58:39 +00:00
|
|
|
|
self.footer_positioner = BottomContainer:new{
|
|
|
|
|
dimen = Geom:new{},
|
2019-09-05 11:58:34 +00:00
|
|
|
|
self.footer_content,
|
2019-08-11 17:58:39 +00:00
|
|
|
|
}
|
|
|
|
|
self[1] = self.footer_positioner
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-30 19:54:44 +00:00
|
|
|
|
function ReaderFooter:unscheduleFooterAutoRefresh()
|
|
|
|
|
if not self.autoRefreshFooter then return end -- not yet set up
|
|
|
|
|
UIManager:unschedule(self.autoRefreshFooter)
|
|
|
|
|
logger.dbg("ReaderFooter.autoRefreshFooter unscheduled")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:rescheduleFooterAutoRefreshIfNeeded()
|
|
|
|
|
if not self.autoRefreshFooter then
|
|
|
|
|
-- Create this function the first time we're called
|
|
|
|
|
self.autoRefreshFooter = function()
|
2020-09-13 17:00:03 +00:00
|
|
|
|
-- Only actually repaint the footer if nothing's being shown over ReaderUI (#6616)
|
2021-01-30 19:54:44 +00:00
|
|
|
|
-- (We want to avoid the footer to be painted over a widget covering it - we would
|
|
|
|
|
-- be fine refreshing it if the widget is not covering it, but this is hard to
|
|
|
|
|
-- guess from here.)
|
2020-09-13 17:00:03 +00:00
|
|
|
|
if UIManager:getTopWidget() == "ReaderUI" then
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:onUpdateFooter(self.view.footer_visible)
|
2020-09-13 17:00:03 +00:00
|
|
|
|
else
|
|
|
|
|
logger.dbg("Skipping ReaderFooter repaint, because ReaderUI is not the top-level widget")
|
|
|
|
|
-- NOTE: We *do* keep its content up-to-date, though
|
|
|
|
|
self:onUpdateFooter()
|
|
|
|
|
end
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded() -- schedule (or not) next refresh
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
local unscheduled = UIManager:unschedule(self.autoRefreshFooter) -- unschedule if already scheduled
|
|
|
|
|
-- Only schedule an update if the footer has items that may change
|
|
|
|
|
-- As self.view.footer_visible may be temporarily toggled off by other modules,
|
|
|
|
|
-- we can't trust it for not scheduling auto refresh
|
|
|
|
|
local schedule = false
|
|
|
|
|
if self.settings.auto_refresh_time then
|
|
|
|
|
if self.settings.all_at_once then
|
|
|
|
|
if self.settings.time or self.settings.battery or self.settings.wifi_status or self.settings.mem_usage then
|
|
|
|
|
schedule = true
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if self.mode == self.mode_list.time or self.mode == self.mode_list.battery
|
|
|
|
|
or self.mode == self.mode_list.wifi_status or self.mode == self.mode_list.mem_usage then
|
|
|
|
|
schedule = true
|
|
|
|
|
end
|
2016-03-08 06:42:46 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2021-01-30 19:54:44 +00:00
|
|
|
|
if schedule then
|
|
|
|
|
UIManager:scheduleIn(61 - tonumber(os.date("%S")), self.autoRefreshFooter)
|
|
|
|
|
if not unscheduled then
|
|
|
|
|
logger.dbg("ReaderFooter.autoRefreshFooter scheduled")
|
|
|
|
|
else
|
|
|
|
|
logger.dbg("ReaderFooter.autoRefreshFooter rescheduled")
|
|
|
|
|
end
|
|
|
|
|
elseif unscheduled then
|
|
|
|
|
logger.dbg("ReaderFooter.autoRefreshFooter unscheduled")
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2016-03-08 06:42:46 +00:00
|
|
|
|
end
|
|
|
|
|
|
2016-12-04 06:57:57 +00:00
|
|
|
|
function ReaderFooter:setupTouchZones()
|
|
|
|
|
if not Device:isTouchDevice() then return end
|
|
|
|
|
local footer_screen_zone = {
|
|
|
|
|
ratio_x = DTAP_ZONE_MINIBAR.x, ratio_y = DTAP_ZONE_MINIBAR.y,
|
|
|
|
|
ratio_w = DTAP_ZONE_MINIBAR.w, ratio_h = DTAP_ZONE_MINIBAR.h,
|
|
|
|
|
}
|
|
|
|
|
self.ui:registerTouchZones({
|
|
|
|
|
{
|
2016-12-19 04:27:56 +00:00
|
|
|
|
id = "readerfooter_tap",
|
2016-12-04 06:57:57 +00:00
|
|
|
|
ges = "tap",
|
|
|
|
|
screen_zone = footer_screen_zone,
|
2017-04-02 10:42:25 +00:00
|
|
|
|
handler = function(ges) return self:onTapFooter(ges) end,
|
2016-12-19 04:27:56 +00:00
|
|
|
|
overrides = {
|
2020-12-03 16:33:54 +00:00
|
|
|
|
"readerconfigmenu_ext_tap",
|
|
|
|
|
"readerconfigmenu_tap",
|
2019-03-30 20:05:44 +00:00
|
|
|
|
"tap_forward",
|
|
|
|
|
"tap_backward",
|
2016-12-19 04:27:56 +00:00
|
|
|
|
},
|
2020-01-24 19:05:21 +00:00
|
|
|
|
-- (Low priority: tap on existing highlights
|
|
|
|
|
-- or links have priority)
|
2016-12-04 06:57:57 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
2016-12-19 04:27:56 +00:00
|
|
|
|
id = "readerfooter_hold",
|
2016-12-04 06:57:57 +00:00
|
|
|
|
ges = "hold",
|
|
|
|
|
screen_zone = footer_screen_zone,
|
2021-05-17 21:40:24 +00:00
|
|
|
|
handler = function(ges) return self:onHoldFooter(ges) end,
|
|
|
|
|
overrides = {
|
|
|
|
|
"readerhighlight_hold",
|
|
|
|
|
},
|
|
|
|
|
-- (High priority: it's a fallthrough if we held outside the footer)
|
2016-12-04 06:57:57 +00:00
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- call this method whenever the screen size changes
|
2019-08-11 17:58:39 +00:00
|
|
|
|
function ReaderFooter:resetLayout(force_reset)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
local new_screen_width = Screen:getWidth()
|
|
|
|
|
local new_screen_height = Screen:getHeight()
|
2018-03-20 20:41:53 +00:00
|
|
|
|
if new_screen_width == self._saved_screen_width
|
2019-08-11 17:58:39 +00:00
|
|
|
|
and new_screen_height == self._saved_screen_height and not force_reset then return end
|
2016-03-12 08:59:15 +00:00
|
|
|
|
|
2017-04-11 09:44:58 +00:00
|
|
|
|
if self.settings.disable_progress_bar then
|
|
|
|
|
self.progress_bar.width = 0
|
2021-05-18 02:44:39 +00:00
|
|
|
|
elseif self.settings.progress_bar_position ~= "alongside" then
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self.progress_bar.width = math.floor(new_screen_width - 2 * self.settings.progress_margin_width)
|
2017-04-11 09:44:58 +00:00
|
|
|
|
else
|
|
|
|
|
self.progress_bar.width = math.floor(
|
2021-03-06 18:23:12 +00:00
|
|
|
|
new_screen_width - 2 * self.settings.progress_margin_width - self.text_width)
|
2017-04-11 09:44:58 +00:00
|
|
|
|
end
|
2019-09-19 09:51:55 +00:00
|
|
|
|
if self.separator_line then
|
|
|
|
|
self.separator_line.dimen.w = new_screen_width - 2 * self.horizontal_margin
|
|
|
|
|
end
|
2020-11-22 03:52:03 +00:00
|
|
|
|
if self.settings.disable_progress_bar then
|
|
|
|
|
self.progress_bar.height = 0
|
2019-10-10 15:02:28 +00:00
|
|
|
|
else
|
2020-11-22 03:52:03 +00:00
|
|
|
|
local bar_height
|
|
|
|
|
if self.settings.progress_style_thin then
|
2021-05-18 02:44:39 +00:00
|
|
|
|
bar_height = self.settings.progress_style_thin_height
|
2020-11-22 03:52:03 +00:00
|
|
|
|
else
|
2021-05-18 02:44:39 +00:00
|
|
|
|
bar_height = self.settings.progress_style_thick_height
|
2020-11-22 03:52:03 +00:00
|
|
|
|
end
|
|
|
|
|
self.progress_bar:setHeight(bar_height)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
|
|
|
|
|
2016-03-08 06:42:46 +00:00
|
|
|
|
self.horizontal_group:resetLayout()
|
2016-12-04 06:57:57 +00:00
|
|
|
|
self.footer_positioner.dimen.w = new_screen_width
|
|
|
|
|
self.footer_positioner.dimen.h = new_screen_height
|
|
|
|
|
self.footer_container.dimen.w = new_screen_width
|
|
|
|
|
self.dimen = self.footer_positioner:getSize()
|
2016-03-08 06:42:46 +00:00
|
|
|
|
|
2016-03-12 08:59:15 +00:00
|
|
|
|
self._saved_screen_width = new_screen_width
|
2018-03-20 20:41:53 +00:00
|
|
|
|
self._saved_screen_height = new_screen_height
|
2013-02-23 18:25:57 +00:00
|
|
|
|
end
|
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
|
function ReaderFooter:getHeight()
|
2019-07-22 18:42:36 +00:00
|
|
|
|
if self.footer_content then
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- NOTE: self.footer_content is self.vertical_frame + self.bottom_padding,
|
|
|
|
|
-- self.vertical_frame includes self.text_container (which includes self.footer_text)
|
2019-07-22 18:42:36 +00:00
|
|
|
|
return self.footer_content:getSize().h
|
|
|
|
|
else
|
|
|
|
|
return 0
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:disableFooter()
|
|
|
|
|
self.onReaderReady = function() end
|
|
|
|
|
self.resetLayout = function() end
|
2019-10-15 19:57:51 +00:00
|
|
|
|
self.updateFooterPage = function() end
|
|
|
|
|
self.updateFooterPos = function() end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.onUpdatePos = function() end
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.mode = self.mode_list.off
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.view.footer_visible = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:updateFooterTextGenerator()
|
|
|
|
|
local footerTextGenerators = {}
|
2019-09-17 12:50:03 +00:00
|
|
|
|
for i, m in pairs(self.mode_index) do
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if self.settings[m] then
|
|
|
|
|
table.insert(footerTextGenerators,
|
|
|
|
|
footerTextGeneratorMap[m])
|
|
|
|
|
if not self.settings.all_at_once then
|
|
|
|
|
-- if not show all at once, then one is enough
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.mode = i
|
2016-11-02 08:38:52 +00:00
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if #footerTextGenerators == 0 then
|
|
|
|
|
-- all modes are disabled
|
|
|
|
|
self.genFooterText = footerTextGeneratorMap.empty
|
|
|
|
|
elseif #footerTextGenerators == 1 then
|
|
|
|
|
-- there is only one mode enabled, simplify the generator
|
|
|
|
|
-- function to that one
|
|
|
|
|
self.genFooterText = footerTextGenerators[1]
|
|
|
|
|
else
|
|
|
|
|
self.genFooterText = self.genAllFooterText
|
|
|
|
|
end
|
2020-08-25 14:47:32 +00:00
|
|
|
|
|
|
|
|
|
-- Even if there's no or a single mode enabled, all_at_once requires this to be set
|
|
|
|
|
self.footerTextGenerators = footerTextGenerators
|
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- notify caller that UI needs update
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
|
2019-08-16 21:22:58 +00:00
|
|
|
|
function ReaderFooter:progressPercentage(digits)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol_type = self.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local prefix = symbol_prefix[symbol_type].percentage
|
|
|
|
|
|
|
|
|
|
local string_percentage
|
|
|
|
|
if not prefix then
|
|
|
|
|
string_percentage = "%." .. digits .. "f%%"
|
|
|
|
|
else
|
|
|
|
|
string_percentage = prefix .. " %." .. digits .. "f%%"
|
|
|
|
|
end
|
|
|
|
|
return string_percentage:format(self.progress_bar.percentage * 100)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:textOptionTitles(option)
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local symbol = self.settings.item_prefix
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local option_titles = {
|
|
|
|
|
all_at_once = _("Show all at once"),
|
|
|
|
|
reclaim_height = _("Reclaim bar height from bottom margin"),
|
2020-09-21 18:52:40 +00:00
|
|
|
|
bookmark_count = T(_("Bookmark count (%1)"), symbol_prefix[symbol].bookmark_count),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
page_progress = T(_("Current page (%1)"), "/"),
|
2021-06-05 16:13:57 +00:00
|
|
|
|
pages_left_book = T(_("Pages left in book (%1)"), symbol_prefix[symbol].pages_left_book),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
time = symbol_prefix[symbol].time
|
|
|
|
|
and T(_("Current time (%1)"), symbol_prefix[symbol].time) or _("Current time"),
|
2021-06-05 18:19:01 +00:00
|
|
|
|
chapter_progress = T(_("Current page in chapter (%1)"), " ⁄⁄ "),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
pages_left = T(_("Pages left in chapter (%1)"), symbol_prefix[symbol].pages_left),
|
|
|
|
|
battery = T(_("Battery status (%1)"), symbol_prefix[symbol].battery),
|
|
|
|
|
percentage = symbol_prefix[symbol].percentage
|
2021-01-10 18:37:51 +00:00
|
|
|
|
and T(_("Progress percentage (%1)"), symbol_prefix[symbol].percentage) or _("Progress percentage"),
|
2021-01-19 20:07:56 +00:00
|
|
|
|
book_time_to_read = symbol_prefix[symbol].book_time_to_read
|
|
|
|
|
and T(_("Book time to read (%1)"),symbol_prefix[symbol].book_time_to_read) or _("Book time to read"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
chapter_time_to_read = T(_("Chapter time to read (%1)"), symbol_prefix[symbol].chapter_time_to_read),
|
|
|
|
|
frontlight = T(_("Frontlight level (%1)"), symbol_prefix[symbol].frontlight),
|
|
|
|
|
mem_usage = T(_("KOReader memory usage (%1)"), symbol_prefix[symbol].mem_usage),
|
|
|
|
|
wifi_status = T(_("Wi-Fi status (%1)"), symbol_prefix[symbol].wifi_status),
|
2020-01-23 20:28:37 +00:00
|
|
|
|
book_title = _("Book title"),
|
|
|
|
|
book_chapter = _("Current chapter"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
}
|
|
|
|
|
return option_titles[option]
|
|
|
|
|
end
|
2015-03-12 06:35:43 +00:00
|
|
|
|
|
2017-03-03 15:03:12 +00:00
|
|
|
|
function ReaderFooter:addToMainMenu(menu_items)
|
2016-04-26 02:45:55 +00:00
|
|
|
|
local sub_items = {}
|
2017-03-03 15:03:12 +00:00
|
|
|
|
menu_items.status_bar = {
|
2016-11-02 08:38:52 +00:00
|
|
|
|
text = _("Status bar"),
|
|
|
|
|
sub_item_table = sub_items,
|
2017-02-28 21:46:32 +00:00
|
|
|
|
}
|
2016-11-02 08:38:52 +00:00
|
|
|
|
|
|
|
|
|
-- menu item to fake footer tapping when touch area is disabled
|
2021-06-22 17:03:05 +00:00
|
|
|
|
local settings_submenu_num = 1
|
2016-04-26 02:45:55 +00:00
|
|
|
|
if Geom:new{
|
|
|
|
|
x = DTAP_ZONE_MINIBAR.x,
|
|
|
|
|
y = DTAP_ZONE_MINIBAR.y,
|
|
|
|
|
w = DTAP_ZONE_MINIBAR.w,
|
|
|
|
|
h = DTAP_ZONE_MINIBAR.h
|
2016-12-04 23:13:49 +00:00
|
|
|
|
}:area() == 0 then
|
2016-04-26 02:45:55 +00:00
|
|
|
|
table.insert(sub_items, {
|
2016-11-02 08:38:52 +00:00
|
|
|
|
text = _("Toggle mode"),
|
2016-04-26 02:45:55 +00:00
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.view.flipping_visible
|
|
|
|
|
end,
|
2020-06-04 13:56:37 +00:00
|
|
|
|
callback = function() self:onTapFooter(true) end,
|
2016-04-26 02:45:55 +00:00
|
|
|
|
})
|
2021-06-22 17:03:05 +00:00
|
|
|
|
settings_submenu_num = 2
|
2016-04-26 02:45:55 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
|
|
|
|
|
local getMinibarOption = function(option, callback)
|
|
|
|
|
return {
|
2019-08-16 21:22:58 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
return self:textOptionTitles(option)
|
|
|
|
|
end,
|
2016-11-02 08:38:52 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings[option] == true
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings[option] = not self.settings[option]
|
2019-10-15 19:57:51 +00:00
|
|
|
|
-- We only need to send a SetPageBottomMargin event when we truly affect the margin
|
|
|
|
|
local should_signal = false
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- only case that we don't need a UI update is enable/disable
|
|
|
|
|
-- non-current mode when all_at_once is disabled.
|
|
|
|
|
local should_update = false
|
|
|
|
|
local first_enabled_mode_num
|
|
|
|
|
local prev_has_no_mode = self.has_no_mode
|
2019-05-01 00:09:01 +00:00
|
|
|
|
local prev_reclaim_height = self.reclaim_height
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.has_no_mode = true
|
2019-09-17 12:50:03 +00:00
|
|
|
|
for mode_num, m in pairs(self.mode_index) do
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if self.settings[m] then
|
|
|
|
|
first_enabled_mode_num = mode_num
|
|
|
|
|
self.has_no_mode = false
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-05-18 02:44:39 +00:00
|
|
|
|
self.reclaim_height = self.settings.reclaim_height
|
2017-08-08 17:06:11 +00:00
|
|
|
|
-- refresh margins position
|
|
|
|
|
if self.has_no_mode then
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.footer_text.height = 0
|
2019-10-15 19:57:51 +00:00
|
|
|
|
should_signal = true
|
2017-08-08 17:06:11 +00:00
|
|
|
|
self.genFooterText = footerTextGeneratorMap.empty
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.mode = self.mode_list.off
|
2017-08-08 17:06:11 +00:00
|
|
|
|
elseif prev_has_no_mode then
|
2019-10-13 12:47:06 +00:00
|
|
|
|
if self.settings.all_at_once then
|
|
|
|
|
self.mode = self.mode_list.page_progress
|
|
|
|
|
self:applyFooterMode()
|
2021-01-06 17:25:13 +00:00
|
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
|
|
|
|
else
|
|
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", first_enabled_mode_num)
|
2019-10-13 12:47:06 +00:00
|
|
|
|
end
|
2019-10-15 19:57:51 +00:00
|
|
|
|
should_signal = true
|
2019-05-01 00:09:01 +00:00
|
|
|
|
elseif self.reclaim_height ~= prev_reclaim_height then
|
2019-10-15 19:57:51 +00:00
|
|
|
|
should_signal = true
|
2019-05-01 00:09:01 +00:00
|
|
|
|
should_update = true
|
2017-08-08 17:06:11 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if callback then
|
|
|
|
|
should_update = callback(self)
|
|
|
|
|
elseif self.settings.all_at_once then
|
|
|
|
|
should_update = self:updateFooterTextGenerator()
|
2019-09-17 12:50:03 +00:00
|
|
|
|
elseif (self.mode_list[option] == self.mode and self.settings[option] == false)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
or (prev_has_no_mode ~= self.has_no_mode) then
|
|
|
|
|
-- current mode got disabled, redraw footer with other
|
|
|
|
|
-- enabled modes. if all modes are disabled, then only show
|
|
|
|
|
-- progress bar
|
|
|
|
|
if not self.has_no_mode then
|
|
|
|
|
self.mode = first_enabled_mode_num
|
2019-10-15 19:57:51 +00:00
|
|
|
|
else
|
|
|
|
|
-- If we've just disabled our last mode, first_enabled_mode_num is nil
|
|
|
|
|
-- If the progress bar is enabled,
|
|
|
|
|
-- fake an innocuous mode so that we switch to showing the progress bar alone, instead of nothing,
|
|
|
|
|
-- This is exactly what the "Show progress bar" toggle does.
|
|
|
|
|
self.mode = self.settings.disable_progress_bar and self.mode_list.off or self.mode_list.page_progress
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
|
|
|
|
should_update = true
|
|
|
|
|
self:applyFooterMode()
|
2021-01-06 17:25:13 +00:00
|
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2019-10-15 19:57:51 +00:00
|
|
|
|
if should_update or should_signal then
|
|
|
|
|
self:refreshFooter(should_update, should_signal)
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2021-01-30 19:54:44 +00:00
|
|
|
|
-- The absence or presence of some items may change whether auto-refresh should be ensured
|
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end,
|
|
|
|
|
}
|
2016-10-16 17:22:26 +00:00
|
|
|
|
end
|
2019-08-16 21:22:58 +00:00
|
|
|
|
table.insert(sub_items, {
|
|
|
|
|
text = _("Settings"),
|
|
|
|
|
sub_item_table = {
|
2019-09-17 12:50:03 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Sort items"),
|
2021-06-22 17:03:05 +00:00
|
|
|
|
separator = true,
|
2019-09-17 12:50:03 +00:00
|
|
|
|
callback = function()
|
|
|
|
|
local item_table = {}
|
|
|
|
|
for i=1, #self.mode_index do
|
|
|
|
|
table.insert(item_table, {text = self:textOptionTitles(self.mode_index[i]), label = self.mode_index[i]})
|
|
|
|
|
end
|
|
|
|
|
local SortWidget = require("ui/widget/sortwidget")
|
|
|
|
|
local sort_item
|
|
|
|
|
sort_item = SortWidget:new{
|
|
|
|
|
title = _("Sort footer items"),
|
|
|
|
|
item_table = item_table,
|
|
|
|
|
callback = function()
|
|
|
|
|
for i=1, #sort_item.item_table do
|
|
|
|
|
self.mode_index[i] = sort_item.item_table[i].label
|
|
|
|
|
end
|
|
|
|
|
self.settings.order = self.mode_index
|
|
|
|
|
self:updateFooterTextGenerator()
|
2020-07-12 18:47:49 +00:00
|
|
|
|
self:onUpdateFooter()
|
2019-09-17 12:50:03 +00:00
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(sort_item)
|
|
|
|
|
end,
|
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
|
getMinibarOption("all_at_once", self.updateFooterTextGenerator),
|
2021-04-26 15:40:06 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Hide empty items"),
|
|
|
|
|
help_text = _([[This will hide values like 0 or off.]]),
|
|
|
|
|
enabled_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.all_at_once == true
|
2021-04-26 15:40:06 +00:00
|
|
|
|
end,
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.hide_empty_generators == true
|
2021-04-26 15:40:06 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.hide_empty_generators = not self.settings.hide_empty_generators
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
|
getMinibarOption("reclaim_height"),
|
|
|
|
|
{
|
2021-01-30 19:54:44 +00:00
|
|
|
|
text = _("Auto refresh"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.auto_refresh_time == true
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.auto_refresh_time = not self.settings.auto_refresh_time
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end
|
|
|
|
|
},
|
2019-09-05 11:58:34 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Show footer separator"),
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.bottom_horizontal_separator == true
|
2019-09-05 11:58:34 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.bottom_horizontal_separator = not self.settings.bottom_horizontal_separator
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:refreshFooter(true, true)
|
2019-09-05 11:58:34 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
2020-04-26 08:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Lock status bar"),
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.lock_tap == true
|
2020-04-26 08:35:48 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.lock_tap = not self.settings.lock_tap
|
|
|
|
|
end,
|
|
|
|
|
},
|
2020-11-09 19:16:53 +00:00
|
|
|
|
{
|
2020-11-09 21:45:27 +00:00
|
|
|
|
text = _("Hold footer to skim"),
|
2020-11-09 19:16:53 +00:00
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.skim_widget_on_hold == true
|
2020-11-09 19:16:53 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.skim_widget_on_hold = not self.settings.skim_widget_on_hold
|
|
|
|
|
end,
|
|
|
|
|
},
|
2020-01-04 23:09:27 +00:00
|
|
|
|
{
|
2020-02-12 16:51:08 +00:00
|
|
|
|
text = _("Font"),
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Font size (%1)"), self.settings.text_font_size)
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local font_size = self.settings.text_font_size
|
|
|
|
|
local items_font = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-02-12 16:51:08 +00:00
|
|
|
|
value = font_size,
|
|
|
|
|
value_min = 8,
|
|
|
|
|
value_max = 36,
|
|
|
|
|
default_value = 14,
|
|
|
|
|
ok_text = _("Set size"),
|
|
|
|
|
title_text = _("Footer font size"),
|
2020-05-09 11:16:09 +00:00
|
|
|
|
keep_shown_on_apply = true,
|
2020-02-12 16:51:08 +00:00
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.text_font_size = spin.value
|
|
|
|
|
self.footer_text:free()
|
|
|
|
|
self.footer_text = TextWidget:new{
|
|
|
|
|
text = self.footer_text.text,
|
|
|
|
|
face = Font:getFace(self.text_font_face, self.settings.text_font_size),
|
|
|
|
|
bold = self.settings.text_font_bold,
|
|
|
|
|
}
|
|
|
|
|
self.text_container[1] = self.footer_text
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end,
|
2020-01-04 23:09:27 +00:00
|
|
|
|
}
|
2020-02-12 16:51:08 +00:00
|
|
|
|
UIManager:show(items_font)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Use bold font"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.text_font_bold == true
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
self.settings.text_font_bold = not self.settings.text_font_bold
|
|
|
|
|
self.footer_text:free()
|
|
|
|
|
self.footer_text = TextWidget:new{
|
|
|
|
|
text = self.footer_text.text,
|
|
|
|
|
face = Font:getFace(self.text_font_face, self.settings.text_font_size),
|
|
|
|
|
bold = self.settings.text_font_bold,
|
2020-01-04 23:09:27 +00:00
|
|
|
|
}
|
2020-02-12 16:51:08 +00:00
|
|
|
|
self.text_container[1] = self.footer_text
|
2020-01-04 23:09:27 +00:00
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end,
|
2020-02-12 16:51:08 +00:00
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
|
|
|
|
}
|
2020-01-04 23:09:27 +00:00
|
|
|
|
},
|
2020-06-11 16:49:51 +00:00
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Container height (%1)"), self.settings.container_height)
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local container_height = self.settings.container_height
|
|
|
|
|
local items_font = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-06-11 16:49:51 +00:00
|
|
|
|
value = container_height,
|
|
|
|
|
value_min = 7,
|
|
|
|
|
value_max = 98,
|
|
|
|
|
default_value = DMINIBAR_CONTAINER_HEIGHT,
|
|
|
|
|
ok_text = _("Set height"),
|
|
|
|
|
title_text = _("Container height"),
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.container_height = spin.value
|
|
|
|
|
self.height = Screen:scaleBySize(self.settings.container_height)
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items_font)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Container bottom margin (%1)"), self.settings.container_bottom_padding)
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local container_bottom_padding = self.settings.container_bottom_padding
|
|
|
|
|
local items_font = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-06-11 16:49:51 +00:00
|
|
|
|
value = container_bottom_padding,
|
|
|
|
|
value_min = 0,
|
|
|
|
|
value_max = 49,
|
|
|
|
|
default_value = 1,
|
|
|
|
|
ok_text = _("Set margin"),
|
|
|
|
|
title_text = _("Container bottom margin"),
|
|
|
|
|
keep_shown_on_apply = true,
|
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.container_bottom_padding = spin.value
|
|
|
|
|
self.bottom_padding = Screen:scaleBySize(self.settings.container_bottom_padding)
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items_font)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
2020-01-23 20:28:37 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Maximum width of items"),
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Book title (%1%)"), self.settings.book_title_max_width_pct)
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local items = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-01-23 20:28:37 +00:00
|
|
|
|
value = self.settings.book_title_max_width_pct,
|
|
|
|
|
value_min = 10,
|
|
|
|
|
value_step = 5,
|
|
|
|
|
value_hold_step = 20,
|
|
|
|
|
value_max = 100,
|
|
|
|
|
title_text = _("Maximum width"),
|
2020-05-09 11:16:09 +00:00
|
|
|
|
info_text = _("Maximum book title width in percentage of screen width"),
|
|
|
|
|
keep_shown_on_apply = true,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.book_title_max_width_pct = spin.value
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Current chapter (%1%)"), self.settings.book_chapter_max_width_pct)
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local items = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-01-23 20:28:37 +00:00
|
|
|
|
value = self.settings.book_chapter_max_width_pct,
|
|
|
|
|
value_min = 10,
|
|
|
|
|
value_step = 5,
|
|
|
|
|
value_hold_step = 20,
|
|
|
|
|
value_max = 100,
|
|
|
|
|
title_text = _("Maximum width"),
|
2020-05-09 11:16:09 +00:00
|
|
|
|
info_text = _("Maximum chapter width in percentage of screen width"),
|
|
|
|
|
keep_shown_on_apply = true,
|
2020-01-23 20:28:37 +00:00
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.book_chapter_max_width_pct = spin.value
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
text = _("Alignment"),
|
2020-06-11 16:49:51 +00:00
|
|
|
|
separator = true,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
enabled_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.disable_progress_bar or self.settings.progress_bar_position ~= "alongside"
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text = _("Center"),
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.align == "center"
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.align = "center"
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Left"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.align == "left"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.align = "left"
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Right"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.align == "right"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.align = "right"
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Prefix"),
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
local sym_tbl = {}
|
|
|
|
|
for _, letter in pairs(symbol_prefix.icons) do
|
|
|
|
|
table.insert(sym_tbl, letter)
|
|
|
|
|
end
|
|
|
|
|
return T(_("Icons (%1)"), table.concat(sym_tbl, " "))
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.item_prefix == "icons"
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.item_prefix = "icons"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
2021-01-12 01:04:15 +00:00
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
local sym_tbl = {}
|
|
|
|
|
for _, letter in pairs(symbol_prefix.compact_items) do
|
|
|
|
|
table.insert(sym_tbl, letter)
|
|
|
|
|
end
|
|
|
|
|
return T(_("Compact Items (%1)"), table.concat(sym_tbl, " "))
|
|
|
|
|
end,
|
|
|
|
|
checked_func = function()
|
2021-01-19 20:07:56 +00:00
|
|
|
|
return self.settings.item_prefix == "compact_items"
|
2021-01-12 01:04:15 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.item_prefix = "compact_items"
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
local sym_tbl = {}
|
|
|
|
|
for _, letter in pairs(symbol_prefix.letters) do
|
|
|
|
|
table.insert(sym_tbl, letter)
|
|
|
|
|
end
|
|
|
|
|
return T(_("Letters (%1)"), table.concat(sym_tbl, " "))
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.item_prefix == "letters"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.item_prefix = "letters"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-09-05 11:58:34 +00:00
|
|
|
|
text = _("Item separator"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
2019-08-24 07:25:38 +00:00
|
|
|
|
text = _("Vertical line (|)"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.items_separator == "bar"
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.items_separator = "bar"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-08-24 07:25:38 +00:00
|
|
|
|
text = _("Bullet (•)"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.items_separator == "bullet"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.items_separator = "bullet"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("No separator"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.items_separator == "none"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.items_separator = "none"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Progress percentage format"),
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("No decimal point (%1)"), self:progressPercentage(0))
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.progress_pct_format == "0"
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_pct_format = "0"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("1 digit after decimal point (%1)"), self:progressPercentage(1))
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_pct_format == "1"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_pct_format = "1"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("2 digits after decimal point (%1)"), self:progressPercentage(2))
|
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_pct_format == "2"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_pct_format = "2"
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-08-16 21:22:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-06-22 17:03:05 +00:00
|
|
|
|
if Device:hasBattery() then
|
|
|
|
|
table.insert(sub_items[settings_submenu_num].sub_item_table, 4, {
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Hide battery status if level higher than (%1%)"), self.settings.battery_hide_threshold)
|
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
|
|
|
|
return self.settings.all_at_once == true
|
|
|
|
|
end,
|
|
|
|
|
separator = true,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local battery_threshold = SpinWidget:new{
|
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
|
|
|
|
value = self.settings.battery_hide_threshold,
|
|
|
|
|
value_min = 0,
|
|
|
|
|
value_max = 100,
|
|
|
|
|
default_value = 100,
|
|
|
|
|
value_hold_step = 10,
|
|
|
|
|
title_text = _("Hide battery threshold"),
|
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.battery_hide_threshold = spin.value
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(battery_threshold)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
})
|
|
|
|
|
end
|
2017-04-11 09:44:58 +00:00
|
|
|
|
table.insert(sub_items, {
|
|
|
|
|
text = _("Progress bar"),
|
2019-08-16 21:22:58 +00:00
|
|
|
|
separator = true,
|
2017-04-11 09:44:58 +00:00
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text = _("Show progress bar"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return not self.settings.disable_progress_bar
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.disable_progress_bar = not self.settings.disable_progress_bar
|
2019-10-13 12:47:06 +00:00
|
|
|
|
if not self.settings.disable_progress_bar then
|
|
|
|
|
self:setTocMarkers()
|
2021-01-06 17:25:13 +00:00
|
|
|
|
end
|
|
|
|
|
-- If the status bar is currently disabled, switch to an innocuous mode to display it
|
|
|
|
|
if not self.view.footer_visible then
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.mode = self.mode_list.page_progress
|
|
|
|
|
self:applyFooterMode()
|
2021-01-06 17:25:13 +00:00
|
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
2019-09-20 07:33:29 +00:00
|
|
|
|
end
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self:refreshFooter(true, true)
|
2017-04-11 09:44:58 +00:00
|
|
|
|
end,
|
|
|
|
|
},
|
2019-09-11 15:56:26 +00:00
|
|
|
|
{
|
2019-10-10 15:02:28 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
local text = _("alongside items")
|
|
|
|
|
if self.settings.progress_bar_position == "above" then
|
|
|
|
|
text = _("above items")
|
|
|
|
|
elseif self.settings.progress_bar_position == "below" then
|
|
|
|
|
text = _("below items")
|
|
|
|
|
end
|
|
|
|
|
return T(_("Position: %1"), text)
|
2019-09-11 15:56:26 +00:00
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.settings.disable_progress_bar
|
|
|
|
|
end,
|
2019-10-10 15:02:28 +00:00
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text = _("Above items"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_bar_position == "above"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_bar_position = "above"
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Below items"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_bar_position == "below"
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_bar_position = "below"
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Alongside items"),
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.progress_bar_position == "alongside"
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
2021-03-06 18:23:12 +00:00
|
|
|
|
-- "Same as book" is disabled in this mode, and we enforce the defaults.
|
2019-10-10 15:02:28 +00:00
|
|
|
|
if self.settings.progress_margin then
|
|
|
|
|
self.settings.progress_margin = false
|
2021-03-06 18:23:12 +00:00
|
|
|
|
self.settings.progress_margin_width = self.horizontal_margin
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
2021-03-06 18:23:12 +00:00
|
|
|
|
-- Text alignment is also disabled
|
|
|
|
|
self.settings.align = "center"
|
|
|
|
|
|
2021-05-18 02:44:39 +00:00
|
|
|
|
self.settings.progress_bar_position = "alongside"
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-09-11 15:56:26 +00:00
|
|
|
|
},
|
2019-09-20 07:33:29 +00:00
|
|
|
|
{
|
2019-10-10 15:02:28 +00:00
|
|
|
|
text_func = function()
|
|
|
|
|
if self.settings.progress_style_thin then
|
|
|
|
|
return _("Style: thin")
|
|
|
|
|
else
|
|
|
|
|
return _("Style: thick")
|
|
|
|
|
end
|
2019-09-20 07:33:29 +00:00
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.settings.disable_progress_bar
|
|
|
|
|
end,
|
2019-10-10 15:02:28 +00:00
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text = _("Thick"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return not self.settings.progress_style_thin
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_style_thin = nil
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local bar_height = self.settings.progress_style_thick_height
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self.progress_bar:updateStyle(true, bar_height)
|
|
|
|
|
self:setTocMarkers()
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Thin"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_style_thin
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_style_thin = true
|
2021-05-18 02:44:39 +00:00
|
|
|
|
local bar_height = self.settings.progress_style_thin_height
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self.progress_bar:updateStyle(false, bar_height)
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Set size"),
|
|
|
|
|
callback = function()
|
|
|
|
|
local value, value_min, value_max, default_value
|
|
|
|
|
if self.settings.progress_style_thin then
|
|
|
|
|
default_value = PROGRESS_BAR_STYLE_THIN_DEFAULT_HEIGHT
|
|
|
|
|
value = self.settings.progress_style_thin_height or default_value
|
|
|
|
|
value_min = 1
|
2020-06-11 16:49:51 +00:00
|
|
|
|
value_max = 12
|
2019-10-10 15:02:28 +00:00
|
|
|
|
else
|
|
|
|
|
default_value = PROGRESS_BAR_STYLE_THICK_DEFAULT_HEIGHT
|
|
|
|
|
value = self.settings.progress_style_thick_height or default_value
|
|
|
|
|
value_min = 5
|
2020-06-11 16:49:51 +00:00
|
|
|
|
value_max = 28
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local items = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2019-10-10 15:02:28 +00:00
|
|
|
|
value = value,
|
|
|
|
|
value_min = value_min,
|
|
|
|
|
value_step = 1,
|
|
|
|
|
value_hold_step = 2,
|
|
|
|
|
value_max = value_max,
|
|
|
|
|
default_value = default_value,
|
|
|
|
|
title_text = _("Progress bar size"),
|
2020-05-09 11:16:09 +00:00
|
|
|
|
keep_shown_on_apply = true,
|
2019-10-10 15:02:28 +00:00
|
|
|
|
callback = function(spin)
|
|
|
|
|
if self.settings.progress_style_thin then
|
|
|
|
|
self.settings.progress_style_thin_height = spin.value
|
|
|
|
|
else
|
|
|
|
|
self.settings.progress_style_thick_height = spin.value
|
|
|
|
|
end
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items)
|
|
|
|
|
end,
|
|
|
|
|
separator = true,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Show chapter markers"),
|
|
|
|
|
checked_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.toc_markers == true
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.settings.progress_style_thin
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.toc_markers = not self.settings.toc_markers
|
|
|
|
|
self:setTocMarkers()
|
2019-12-30 15:20:31 +00:00
|
|
|
|
self:refreshFooter(true)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
|
|
|
|
},
|
2019-12-30 15:20:31 +00:00
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
local markers_width_text = _("thick")
|
|
|
|
|
if self.settings.toc_markers_width == 1 then
|
|
|
|
|
markers_width_text = _("thin")
|
|
|
|
|
elseif self.settings.toc_markers_width == 2 then
|
|
|
|
|
markers_width_text = _("medium")
|
|
|
|
|
end
|
|
|
|
|
return T(_("Chapter marker width (%1)"), markers_width_text)
|
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.settings.progress_style_thin and self.settings.toc_markers
|
|
|
|
|
end,
|
|
|
|
|
sub_item_table = {
|
|
|
|
|
{
|
|
|
|
|
text = _("Thin"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.toc_markers_width == 1
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.toc_markers_width = 1 -- unscaled_size_check: ignore
|
|
|
|
|
self:setTocMarkers()
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Medium"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.toc_markers_width == 2
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.toc_markers_width = 2 -- unscaled_size_check: ignore
|
|
|
|
|
self:setTocMarkers()
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text = _("Thick"),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.toc_markers_width == 3
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.toc_markers_width = 3 -- unscaled_size_check: ignore
|
|
|
|
|
self:setTocMarkers()
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-10-10 15:02:28 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
local text = _("static margins (10)")
|
2020-06-11 14:44:24 +00:00
|
|
|
|
local cur_width = self.settings.progress_margin_width
|
2020-06-11 16:49:51 +00:00
|
|
|
|
if cur_width == 0 then
|
2019-10-10 15:02:28 +00:00
|
|
|
|
text = _("no margins (0)")
|
2020-06-11 14:44:24 +00:00
|
|
|
|
elseif cur_width == Screen:scaleBySize(material_pixels) then
|
|
|
|
|
text = T(_("static margins (%1)"), material_pixels)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
|
|
|
|
if self.settings.progress_margin and not self.ui.document.info.has_pages then
|
|
|
|
|
text = T(_("same as book margins (%1)"), self.book_margins_footer_width)
|
|
|
|
|
end
|
|
|
|
|
return T(_("Margins: %1"), text)
|
2019-09-20 07:33:29 +00:00
|
|
|
|
end,
|
2019-10-10 15:02:28 +00:00
|
|
|
|
enabled_func = function()
|
|
|
|
|
return not self.settings.disable_progress_bar
|
|
|
|
|
end,
|
2020-06-11 14:44:24 +00:00
|
|
|
|
sub_item_table_func = function()
|
|
|
|
|
local common = {
|
|
|
|
|
{
|
|
|
|
|
text = _("No margins (0)"),
|
|
|
|
|
checked_func = function()
|
2020-06-11 16:49:51 +00:00
|
|
|
|
return self.settings.progress_margin_width == 0
|
2020-06-11 14:44:24 +00:00
|
|
|
|
and not self.settings.progress_margin
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self.settings.progress_margin_width = 0
|
2020-06-11 14:44:24 +00:00
|
|
|
|
self.settings.progress_margin = false
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
if self.ui.document.info.has_pages then
|
|
|
|
|
return _("Same as book margins")
|
|
|
|
|
end
|
|
|
|
|
return T(_("Same as book margins (%1)"), self.book_margins_footer_width)
|
|
|
|
|
end,
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_margin and not self.ui.document.info.has_pages
|
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return not self.ui.document.info.has_pages and self.settings.progress_bar_position ~= "alongside"
|
2020-06-11 14:44:24 +00:00
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_margin = true
|
|
|
|
|
self.settings.progress_margin_width = Screen:scaleBySize(self.book_margins_footer_width)
|
|
|
|
|
self:refreshFooter(true)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
2020-06-11 14:44:24 +00:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
local function customMargin(px)
|
|
|
|
|
return {
|
|
|
|
|
text = T(_("Static margins (%1)"), px),
|
|
|
|
|
checked_func = function()
|
|
|
|
|
return self.settings.progress_margin_width == Screen:scaleBySize(px)
|
|
|
|
|
and not self.settings.progress_margin
|
|
|
|
|
-- if same as book margins is selected in document with pages (pdf) we enforce static margins
|
|
|
|
|
or (self.ui.document.info.has_pages and self.settings.progress_margin)
|
|
|
|
|
end,
|
|
|
|
|
callback = function()
|
|
|
|
|
self.settings.progress_margin_width = Screen:scaleBySize(px)
|
|
|
|
|
self.settings.progress_margin = false
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
local device_defaults
|
|
|
|
|
if Device:isAndroid() then
|
|
|
|
|
device_defaults = customMargin(material_pixels)
|
|
|
|
|
else
|
|
|
|
|
device_defaults = customMargin(10)
|
|
|
|
|
end
|
|
|
|
|
table.insert(common, 2, device_defaults)
|
|
|
|
|
return common
|
|
|
|
|
end,
|
2019-09-20 07:33:29 +00:00
|
|
|
|
},
|
2020-01-12 19:19:10 +00:00
|
|
|
|
{
|
|
|
|
|
text_func = function()
|
|
|
|
|
return T(_("Minimal width (%1%)"), self.settings.progress_bar_min_width_pct)
|
|
|
|
|
end,
|
|
|
|
|
enabled_func = function()
|
2021-05-18 02:44:39 +00:00
|
|
|
|
return self.settings.progress_bar_position == "alongside" and not self.settings.disable_progress_bar
|
2020-01-12 19:19:10 +00:00
|
|
|
|
and self.settings.all_at_once
|
|
|
|
|
end,
|
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
|
local items = SpinWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
|
width = math.floor(Screen:getWidth() * 0.6),
|
2020-01-12 19:19:10 +00:00
|
|
|
|
value = self.settings.progress_bar_min_width_pct,
|
2020-01-23 20:41:06 +00:00
|
|
|
|
value_min = 5,
|
2020-01-12 19:19:10 +00:00
|
|
|
|
value_step = 5,
|
|
|
|
|
value_hold_step = 20,
|
|
|
|
|
value_max = 50,
|
|
|
|
|
title_text = _("Minimal width"),
|
|
|
|
|
text = _("Minimal progress bar width in percentage of screen width"),
|
2020-05-09 11:16:09 +00:00
|
|
|
|
keep_shown_on_apply = true,
|
2020-01-12 19:19:10 +00:00
|
|
|
|
callback = function(spin)
|
|
|
|
|
self.settings.progress_bar_min_width_pct = spin.value
|
|
|
|
|
self:refreshFooter(true, true)
|
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
UIManager:show(items)
|
|
|
|
|
end,
|
|
|
|
|
keep_menu_open = true,
|
|
|
|
|
}
|
2017-04-11 09:44:58 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
2016-11-02 08:38:52 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("page_progress"))
|
2020-12-31 22:48:16 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("pages_left_book"))
|
2016-11-02 08:38:52 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("time"))
|
2021-06-05 18:19:01 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("chapter_progress"))
|
2016-11-02 08:38:52 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("pages_left"))
|
2020-07-20 22:52:50 +00:00
|
|
|
|
if Device:hasBattery() then
|
2020-06-01 06:07:42 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("battery"))
|
|
|
|
|
end
|
2020-09-05 12:54:53 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("bookmark_count"))
|
2016-11-02 08:38:52 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("percentage"))
|
|
|
|
|
table.insert(sub_items, getMinibarOption("book_time_to_read"))
|
|
|
|
|
table.insert(sub_items, getMinibarOption("chapter_time_to_read"))
|
2017-04-13 16:54:30 +00:00
|
|
|
|
if Device:hasFrontlight() then
|
|
|
|
|
table.insert(sub_items, getMinibarOption("frontlight"))
|
|
|
|
|
end
|
2017-03-11 12:22:44 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("mem_usage"))
|
2020-09-28 23:06:41 +00:00
|
|
|
|
if Device:hasFastWifiStatusQuery() then
|
2017-10-28 15:51:34 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("wifi_status"))
|
|
|
|
|
end
|
2020-01-23 20:28:37 +00:00
|
|
|
|
table.insert(sub_items, getMinibarOption("book_title"))
|
|
|
|
|
table.insert(sub_items, getMinibarOption("book_chapter"))
|
2021-01-07 20:22:40 +00:00
|
|
|
|
|
2021-06-29 12:10:21 +00:00
|
|
|
|
-- Settings menu: keep the same parent page for going up from submenu
|
|
|
|
|
for i = 1, #sub_items[settings_submenu_num].sub_item_table do
|
|
|
|
|
sub_items[settings_submenu_num].sub_item_table[i].menu_item_id = i
|
|
|
|
|
end
|
|
|
|
|
|
2021-01-07 20:22:40 +00:00
|
|
|
|
-- If using crengine, add Alt status bar items at top
|
|
|
|
|
if self.ui.crelistener then
|
|
|
|
|
table.insert(sub_items, 1, self.ui.crelistener:getAltStatusBarMenu())
|
|
|
|
|
end
|
2014-10-07 09:09:37 +00:00
|
|
|
|
end
|
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
|
-- this method will be updated at runtime based on user setting
|
|
|
|
|
function ReaderFooter:genFooterText() end
|
2014-10-07 09:09:37 +00:00
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
|
function ReaderFooter:genAllFooterText()
|
|
|
|
|
local info = {}
|
2019-08-16 21:22:58 +00:00
|
|
|
|
local separator = " "
|
2021-01-16 14:30:43 +00:00
|
|
|
|
if self.settings.item_prefix == "compact_items" then
|
|
|
|
|
separator = " "
|
|
|
|
|
end
|
2021-05-18 02:44:39 +00:00
|
|
|
|
if self.settings.items_separator == "bar" then
|
2019-08-16 21:22:58 +00:00
|
|
|
|
separator = " | "
|
|
|
|
|
elseif self.settings.items_separator == "bullet" then
|
|
|
|
|
separator = " • "
|
|
|
|
|
end
|
2019-12-06 21:55:39 +00:00
|
|
|
|
-- We need to BD.wrap() all items and separators, so we're
|
|
|
|
|
-- sure they are laid out in our order (reversed in RTL),
|
|
|
|
|
-- without ordering by the RTL Bidi algorithm.
|
2016-11-02 08:38:52 +00:00
|
|
|
|
for _, gen in ipairs(self.footerTextGenerators) do
|
2020-10-05 14:18:31 +00:00
|
|
|
|
-- Skip empty generators, so they don't generate bogus separators
|
|
|
|
|
local text = gen(self)
|
|
|
|
|
if text and text ~= "" then
|
2021-01-12 01:04:15 +00:00
|
|
|
|
if self.settings.item_prefix == "compact_items" then
|
|
|
|
|
-- remove whitespace from footer items if symbol_type is compact_items
|
|
|
|
|
-- use a hair-space to avoid issues with RTL display
|
|
|
|
|
text = text:gsub("%s", "\xE2\x80\x8A")
|
|
|
|
|
end
|
2020-10-05 14:18:31 +00:00
|
|
|
|
table.insert(info, BD.wrap(text))
|
|
|
|
|
end
|
2016-03-12 08:59:15 +00:00
|
|
|
|
end
|
2019-12-06 21:55:39 +00:00
|
|
|
|
return table.concat(info, BD.wrap(separator))
|
2014-10-07 09:09:37 +00:00
|
|
|
|
end
|
|
|
|
|
|
2018-06-13 22:46:52 +00:00
|
|
|
|
function ReaderFooter:setTocMarkers(reset)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
if self.settings.disable_progress_bar or self.settings.progress_style_thin then return end
|
2018-06-13 22:46:52 +00:00
|
|
|
|
if reset then
|
|
|
|
|
self.progress_bar.ticks = nil
|
2020-10-31 09:40:36 +00:00
|
|
|
|
self.pages = self.ui.document:getPageCount()
|
2018-06-13 22:46:52 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
if self.settings.toc_markers then
|
2019-12-30 15:20:31 +00:00
|
|
|
|
self.progress_bar.tick_width = Screen:scaleBySize(self.settings.toc_markers_width)
|
2020-06-05 08:09:44 +00:00
|
|
|
|
if self.progress_bar.ticks ~= nil then -- already computed
|
|
|
|
|
return
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2020-10-31 09:40:36 +00:00
|
|
|
|
if self.ui.document:hasHiddenFlows() and self.pageno then
|
|
|
|
|
local flow = self.ui.document:getPageFlow(self.pageno)
|
|
|
|
|
self.progress_bar.ticks = {}
|
|
|
|
|
if self.ui.toc then
|
|
|
|
|
-- filter the ticks to show only those in the current flow
|
|
|
|
|
for n, pageno in ipairs(self.ui.toc:getTocTicksFlattened()) do
|
|
|
|
|
if self.ui.document:getPageFlow(pageno) == flow then
|
|
|
|
|
table.insert(self.progress_bar.ticks, self.ui.document:getPageNumberInFlow(pageno))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self.progress_bar.last = self.ui.document:getTotalPagesInFlow(flow)
|
|
|
|
|
else
|
|
|
|
|
if self.ui.toc then
|
|
|
|
|
self.progress_bar.ticks = self.ui.toc:getTocTicksFlattened()
|
|
|
|
|
end
|
|
|
|
|
if self.view.view_mode == "page" then
|
|
|
|
|
self.progress_bar.last = self.pages or self.ui.document:getPageCount()
|
|
|
|
|
else
|
|
|
|
|
-- in scroll mode, convert pages to positions
|
|
|
|
|
if self.ui.toc then
|
|
|
|
|
self.progress_bar.ticks = {}
|
|
|
|
|
for n, pageno in ipairs(self.ui.toc:getTocTicksFlattened()) do
|
|
|
|
|
local idx = self.ui.toc:getTocIndexByPage(pageno)
|
|
|
|
|
local pos = self.ui.document:getPosFromXPointer(self.ui.toc.toc[idx].xpointer)
|
|
|
|
|
table.insert(self.progress_bar.ticks, pos)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self.progress_bar.last = self.doc_height or self.ui.document.info.doc_height
|
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2015-12-26 04:54:13 +00:00
|
|
|
|
else
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self.progress_bar.ticks = nil
|
2015-12-26 04:54:13 +00:00
|
|
|
|
end
|
2016-11-24 13:44:19 +00:00
|
|
|
|
-- notify caller that UI needs update
|
|
|
|
|
return true
|
2015-11-27 15:13:01 +00:00
|
|
|
|
end
|
|
|
|
|
|
2021-06-29 23:45:34 +00:00
|
|
|
|
-- This is implemented by the Statistics plugin
|
2017-09-16 11:36:54 +00:00
|
|
|
|
function ReaderFooter:getAvgTimePerPage()
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2015-11-27 15:13:01 +00:00
|
|
|
|
function ReaderFooter:getDataFromStatistics(title, pages)
|
2021-03-06 21:44:18 +00:00
|
|
|
|
local sec = _("N/A")
|
2017-09-16 11:36:54 +00:00
|
|
|
|
local average_time_per_page = self:getAvgTimePerPage()
|
2021-06-29 23:45:34 +00:00
|
|
|
|
local user_duration_format = G_reader_settings:readSetting("duration_format", "classic")
|
2017-09-16 11:36:54 +00:00
|
|
|
|
if average_time_per_page then
|
2021-06-29 23:45:34 +00:00
|
|
|
|
sec = util.secondsToClockDuration(user_duration_format, pages * average_time_per_page, true)
|
2015-11-27 15:13:01 +00:00
|
|
|
|
end
|
2015-12-23 06:35:46 +00:00
|
|
|
|
return title .. sec
|
2015-11-27 15:13:01 +00:00
|
|
|
|
end
|
|
|
|
|
|
2020-07-12 18:47:49 +00:00
|
|
|
|
function ReaderFooter:onUpdateFooter(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
if self.pageno then
|
2019-10-15 19:57:51 +00:00
|
|
|
|
self:updateFooterPage(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
else
|
2019-10-15 19:57:51 +00:00
|
|
|
|
self:updateFooterPos(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-10-15 19:57:51 +00:00
|
|
|
|
function ReaderFooter:updateFooterPage(force_repaint, force_recompute)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
if type(self.pageno) ~= "number" then return end
|
2020-10-31 09:40:36 +00:00
|
|
|
|
if self.ui.document:hasHiddenFlows() then
|
|
|
|
|
local flow = self.ui.document:getPageFlow(self.pageno)
|
|
|
|
|
local page = self.ui.document:getPageNumberInFlow(self.pageno)
|
|
|
|
|
local pages = self.ui.document:getTotalPagesInFlow(flow)
|
|
|
|
|
self.progress_bar.percentage = page / pages
|
|
|
|
|
else
|
|
|
|
|
self.progress_bar.percentage = self.pageno / self.pages
|
|
|
|
|
end
|
2019-10-15 19:57:51 +00:00
|
|
|
|
self:updateFooterText(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
end
|
|
|
|
|
|
2019-10-15 19:57:51 +00:00
|
|
|
|
function ReaderFooter:updateFooterPos(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
if type(self.position) ~= "number" then return end
|
|
|
|
|
self.progress_bar.percentage = self.position / self.doc_height
|
2019-10-15 19:57:51 +00:00
|
|
|
|
self:updateFooterText(force_repaint, force_recompute)
|
2016-03-12 08:59:15 +00:00
|
|
|
|
end
|
|
|
|
|
|
2016-06-03 08:31:46 +00:00
|
|
|
|
-- updateFooterText will start as a noop. After onReaderReady event is
|
2016-07-24 00:57:29 +00:00
|
|
|
|
-- received, it will initialized as _updateFooterText below
|
2019-10-15 19:57:51 +00:00
|
|
|
|
function ReaderFooter:updateFooterText(force_repaint, force_recompute)
|
2016-06-03 08:31:46 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- only call this function after document is fully loaded
|
2019-10-15 19:57:51 +00:00
|
|
|
|
function ReaderFooter:_updateFooterText(force_repaint, force_recompute)
|
|
|
|
|
-- footer is invisible, we need neither a repaint nor a recompute, go away.
|
|
|
|
|
if not self.view.footer_visible and not force_repaint and not force_recompute then
|
|
|
|
|
return
|
|
|
|
|
end
|
2019-03-29 19:12:09 +00:00
|
|
|
|
local text = self:genFooterText()
|
2020-01-12 19:19:10 +00:00
|
|
|
|
if not text then text = "" end
|
|
|
|
|
self.footer_text:setText(text)
|
2017-04-11 09:44:58 +00:00
|
|
|
|
if self.settings.disable_progress_bar then
|
2020-01-12 19:19:10 +00:00
|
|
|
|
if self.has_no_mode or text == "" then
|
2017-04-11 09:44:58 +00:00
|
|
|
|
self.text_width = 0
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.footer_text.height = 0
|
2017-04-11 09:44:58 +00:00
|
|
|
|
else
|
2021-03-06 18:23:12 +00:00
|
|
|
|
-- No progress bar, we're only constrained to fit inside self.footer_container
|
|
|
|
|
self.footer_text:setMaxWidth(math.floor(self._saved_screen_width - 2 * self.horizontal_margin))
|
2017-04-11 09:44:58 +00:00
|
|
|
|
self.text_width = self.footer_text:getSize().w
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
self.footer_text.height = self.footer_text:getSize().h
|
2017-04-11 09:44:58 +00:00
|
|
|
|
end
|
2020-11-22 03:52:03 +00:00
|
|
|
|
self.progress_bar.height = 0
|
2017-04-11 09:44:58 +00:00
|
|
|
|
self.progress_bar.width = 0
|
2021-05-18 02:44:39 +00:00
|
|
|
|
elseif self.settings.progress_bar_position ~= "alongside" then
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
if self.has_no_mode or text == "" then
|
|
|
|
|
self.text_width = 0
|
2019-10-13 12:47:06 +00:00
|
|
|
|
self.footer_text.height = 0
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
else
|
2021-03-06 18:23:12 +00:00
|
|
|
|
-- With a progress bar above or below us, we want to align ourselves to the bar's margins... iff text is centered.
|
|
|
|
|
if self.settings.align == "center" then
|
|
|
|
|
self.footer_text:setMaxWidth(math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width))
|
|
|
|
|
else
|
|
|
|
|
-- Otherwise, we have to constrain ourselves to the container, or weird shit happens.
|
|
|
|
|
self.footer_text:setMaxWidth(math.floor(self._saved_screen_width - 2 * self.horizontal_margin))
|
|
|
|
|
end
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
self.text_width = self.footer_text:getSize().w
|
|
|
|
|
self.footer_text.height = self.footer_text:getSize().h
|
2019-10-13 12:47:06 +00:00
|
|
|
|
end
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self.progress_bar.width = math.floor(self._saved_screen_width - 2 * self.settings.progress_margin_width)
|
2014-07-02 08:43:24 +00:00
|
|
|
|
else
|
2020-01-12 19:19:10 +00:00
|
|
|
|
if self.has_no_mode or text == "" then
|
2017-04-11 09:44:58 +00:00
|
|
|
|
self.text_width = 0
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
self.footer_text.height = 0
|
2017-04-11 09:44:58 +00:00
|
|
|
|
else
|
2021-03-06 18:23:12 +00:00
|
|
|
|
-- Alongside a progress bar, it's the bar's width plus whatever's left.
|
2020-01-12 19:19:10 +00:00
|
|
|
|
local text_max_available_ratio = (100 - self.settings.progress_bar_min_width_pct) / 100
|
2021-03-06 18:23:12 +00:00
|
|
|
|
self.footer_text:setMaxWidth(math.floor(text_max_available_ratio * self._saved_screen_width - 2 * self.settings.progress_margin_width - self.horizontal_margin))
|
|
|
|
|
-- Add some spacing between the text and the bar
|
|
|
|
|
self.text_width = self.footer_text:getSize().w + self.horizontal_margin
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
self.footer_text.height = self.footer_text:getSize().h
|
2017-04-11 09:44:58 +00:00
|
|
|
|
end
|
|
|
|
|
self.progress_bar.width = math.floor(
|
2021-03-06 18:23:12 +00:00
|
|
|
|
self._saved_screen_width - 2 * self.settings.progress_margin_width - self.text_width)
|
2014-07-02 08:43:24 +00:00
|
|
|
|
end
|
2019-10-10 15:02:28 +00:00
|
|
|
|
|
2019-09-19 09:51:55 +00:00
|
|
|
|
if self.separator_line then
|
|
|
|
|
self.separator_line.dimen.w = self._saved_screen_width - 2 * self.horizontal_margin
|
|
|
|
|
end
|
2016-03-12 08:59:15 +00:00
|
|
|
|
self.text_container.dimen.w = self.text_width
|
|
|
|
|
self.horizontal_group:resetLayout()
|
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
* FileManager and co. (where appropriate, i.e., when covers are shown)
* Book Status
* Reader, where appropriate:
* CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
* Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
* ScreenSaver
* ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
(The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
either by switching the widget to nil when only a refresh was needed, and not a repaint,
or by passing the appropritate widget to setDirty.
(Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.
PS: (Almost :100: commits! :D)
2019-02-07 00:14:37 +00:00
|
|
|
|
-- NOTE: This is essentially preventing us from truly using "fast" for panning,
|
|
|
|
|
-- since it'll get coalesced in the "fast" panning update, upgrading it to "ui".
|
2019-02-11 02:28:46 +00:00
|
|
|
|
-- NOTE: That's assuming using "fast" for pans was a good idea, which, it turned out, not so much ;).
|
|
|
|
|
-- NOTE: We skip repaints on page turns/pos update, as that's redundant (and slow).
|
|
|
|
|
if force_repaint then
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- If there was a visibility change, notify ReaderView
|
|
|
|
|
if self.visibility_change then
|
|
|
|
|
self.ui:handleEvent(Event:new("ReaderFooterVisibilityChange"))
|
|
|
|
|
self.visibility_change = nil
|
|
|
|
|
end
|
|
|
|
|
|
2020-08-23 01:46:05 +00:00
|
|
|
|
-- NOTE: Getting the dimensions of the widget is impossible without having drawn it first,
|
|
|
|
|
-- so, we'll fudge it if need be...
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- i.e., when it's no longer visible, because there's nothing to draw ;).
|
2020-08-23 01:46:05 +00:00
|
|
|
|
local refresh_dim = self.footer_content.dimen
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- No more content...
|
|
|
|
|
if not self.view.footer_visible and not refresh_dim then
|
|
|
|
|
-- So, instead, rely on self:getHeight to compute self.footer_content's height early...
|
2020-08-23 01:46:05 +00:00
|
|
|
|
refresh_dim = self.dimen
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
refresh_dim.h = self:getHeight()
|
2020-08-23 01:46:05 +00:00
|
|
|
|
refresh_dim.y = self._saved_screen_height - refresh_dim.h
|
|
|
|
|
end
|
|
|
|
|
-- If we're making the footer visible (or it already is), we don't need to repaint ReaderUI behind it
|
|
|
|
|
if self.view.footer_visible then
|
|
|
|
|
-- Unfortunately, it's not a modal (we never show() it), so it's not in the window stack,
|
|
|
|
|
-- instead, it's baked inside ReaderUI, so it gets slightly trickier...
|
|
|
|
|
-- NOTE: self.view.footer -> self ;).
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
|
2020-09-13 17:00:03 +00:00
|
|
|
|
-- c.f., ReaderView:paintTo()
|
|
|
|
|
UIManager:widgetRepaint(self.view.footer, 0, 0)
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- We've painted it first to ensure self.footer_content.dimen is sane
|
|
|
|
|
UIManager:setDirty(self.view.footer, function()
|
2021-05-19 20:57:54 +00:00
|
|
|
|
return self.view.currently_scrolling and "fast" or "ui", self.footer_content.dimen
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
end)
|
2020-08-23 01:46:05 +00:00
|
|
|
|
else
|
|
|
|
|
UIManager:setDirty(self.view.dialog, function()
|
2021-05-19 20:57:54 +00:00
|
|
|
|
return self.view.currently_scrolling and "fast" or "ui", refresh_dim
|
2020-08-23 01:46:05 +00:00
|
|
|
|
end)
|
|
|
|
|
end
|
2019-02-11 02:28:46 +00:00
|
|
|
|
end
|
2014-02-12 07:26:56 +00:00
|
|
|
|
end
|
|
|
|
|
|
2020-10-31 09:40:36 +00:00
|
|
|
|
function ReaderFooter:onTocReset()
|
|
|
|
|
self:setTocMarkers(true)
|
|
|
|
|
if self.view.view_mode == "page" then
|
|
|
|
|
self:updateFooterPage()
|
|
|
|
|
else
|
|
|
|
|
self:updateFooterPos()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2013-02-24 07:25:08 +00:00
|
|
|
|
function ReaderFooter:onPageUpdate(pageno)
|
2020-10-31 09:40:36 +00:00
|
|
|
|
local toc_markers_update = false
|
|
|
|
|
if self.ui.document:hasHiddenFlows() then
|
|
|
|
|
local flow = self.pageno and self.ui.document:getPageFlow(self.pageno)
|
|
|
|
|
local new_flow = pageno and self.ui.document:getPageFlow(pageno)
|
|
|
|
|
if pageno and new_flow ~= flow then
|
|
|
|
|
toc_markers_update = true
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.pageno = pageno
|
2020-10-31 09:40:36 +00:00
|
|
|
|
self.pages = self.ui.document:getPageCount()
|
|
|
|
|
if toc_markers_update then
|
|
|
|
|
self:setTocMarkers(true)
|
|
|
|
|
end
|
2017-07-01 09:41:27 +00:00
|
|
|
|
self.ui.doc_settings:saveSetting("doc_pages", self.pages) -- for Book information
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self:updateFooterPage()
|
2014-02-12 07:26:56 +00:00
|
|
|
|
end
|
|
|
|
|
|
2017-10-05 19:49:59 +00:00
|
|
|
|
function ReaderFooter:onPosUpdate(pos, pageno)
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self.position = pos
|
2020-10-31 09:40:36 +00:00
|
|
|
|
self.doc_height = self.ui.document.info.doc_height
|
2017-10-05 19:49:59 +00:00
|
|
|
|
if pageno then
|
|
|
|
|
self.pageno = pageno
|
2020-10-31 09:40:36 +00:00
|
|
|
|
self.pages = self.ui.document:getPageCount()
|
2017-10-05 19:49:59 +00:00
|
|
|
|
self.ui.doc_settings:saveSetting("doc_pages", self.pages) -- for Book information
|
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
self:updateFooterPos()
|
2013-02-23 18:25:57 +00:00
|
|
|
|
end
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
2014-07-22 13:52:41 +00:00
|
|
|
|
-- recalculate footer sizes when document page count is updated
|
2016-03-12 08:59:15 +00:00
|
|
|
|
-- see documentation for more info about this event.
|
2020-07-19 04:56:39 +00:00
|
|
|
|
ReaderFooter.onUpdatePos = ReaderFooter.onUpdateFooter
|
2014-07-22 13:52:41 +00:00
|
|
|
|
|
2016-06-03 08:31:46 +00:00
|
|
|
|
function ReaderFooter:onReaderReady()
|
2016-12-25 20:13:30 +00:00
|
|
|
|
self.ui.menu:registerToMainMenu(self)
|
2016-12-04 06:57:57 +00:00
|
|
|
|
self:setupTouchZones()
|
2019-10-10 15:02:28 +00:00
|
|
|
|
-- if same as book margins is selected in document with pages (pdf) we enforce static margins
|
|
|
|
|
if self.ui.document.info.has_pages and self.settings.progress_margin then
|
2020-06-11 16:49:51 +00:00
|
|
|
|
self.settings.progress_margin_width = Size.span.horizontal_default
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
-- set progress bar margins for current book
|
|
|
|
|
elseif self.settings.progress_margin then
|
|
|
|
|
local margins = self.ui.document:getPageMargins()
|
|
|
|
|
self.settings.progress_margin_width = math.floor((margins.left + margins.right)/2)
|
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
end
|
|
|
|
|
self:resetLayout(self.settings.progress_margin_width) -- set widget dimen
|
2016-11-02 08:38:52 +00:00
|
|
|
|
self:setTocMarkers()
|
2016-06-03 08:31:46 +00:00
|
|
|
|
self.updateFooterText = self._updateFooterText
|
2020-07-12 18:47:49 +00:00
|
|
|
|
self:onUpdateFooter()
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2016-06-03 08:31:46 +00:00
|
|
|
|
end
|
2016-03-19 06:22:17 +00:00
|
|
|
|
|
2019-10-10 15:02:28 +00:00
|
|
|
|
function ReaderFooter:onReadSettings(config)
|
|
|
|
|
if not self.ui.document.info.has_pages then
|
2021-03-06 21:44:18 +00:00
|
|
|
|
local h_margins = config:readSetting("copt_h_page_margins")
|
|
|
|
|
or G_reader_settings:readSetting("copt_h_page_margins")
|
|
|
|
|
or DCREREADER_CONFIG_H_MARGIN_SIZES_MEDIUM
|
2019-10-10 15:02:28 +00:00
|
|
|
|
self.book_margins_footer_width = math.floor((h_margins[1] + h_margins[2])/2)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-19 06:23:31 +00:00
|
|
|
|
function ReaderFooter:applyFooterMode(mode)
|
|
|
|
|
if mode ~= nil then self.mode = mode end
|
2020-06-11 16:49:51 +00:00
|
|
|
|
local prev_visible_state = self.view.footer_visible
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self.view.footer_visible = (self.mode ~= self.mode_list.off)
|
2019-03-29 19:12:09 +00:00
|
|
|
|
|
2020-06-11 16:49:51 +00:00
|
|
|
|
-- NOTE: _updateFooterText won't actually run the text generator(s) when hidden ;).
|
|
|
|
|
|
|
|
|
|
-- We're hidden, disable text generation entirely
|
2019-03-29 19:12:09 +00:00
|
|
|
|
if not self.view.footer_visible then
|
|
|
|
|
self.genFooterText = footerTextGeneratorMap.empty
|
2020-06-11 16:49:51 +00:00
|
|
|
|
else
|
|
|
|
|
if self.settings.all_at_once then
|
|
|
|
|
-- If all-at-once is enabled, we only have toggle from empty to All.
|
|
|
|
|
self.genFooterText = self.genAllFooterText
|
|
|
|
|
else
|
|
|
|
|
-- Otherwise, switch to the right text generator for the new mode
|
|
|
|
|
local mode_name = self.mode_index[self.mode]
|
|
|
|
|
if not self.settings[mode_name] or self.has_no_mode then
|
|
|
|
|
-- all modes disabled, only show progress bar
|
|
|
|
|
mode_name = "empty"
|
|
|
|
|
end
|
|
|
|
|
self.genFooterText = footerTextGeneratorMap[mode_name]
|
|
|
|
|
end
|
2019-03-29 19:12:09 +00:00
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
|
2020-06-11 16:49:51 +00:00
|
|
|
|
-- If we changed visibility state at runtime (as opposed to during init), better make sure the layout has been reset...
|
|
|
|
|
if prev_visible_state ~= nil and self.view.footer_visible ~= prev_visible_state then
|
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
-- NOTE: _updateFooterText does a resetLayout, but not a forced one!
|
|
|
|
|
self:resetLayout(true)
|
Another round of ReaderFooter fixes (#6830)
* When auto_refresh_time is enabled, don't actually refresh anything when the footer is hidden.
* Fix a bunch of state tracking related to height computations, meaning `getHeight()` is now actually accurate, always, and we don't need shitty workarounds anymore.
* `footer_container.dimen.h` *includes* the progress bar, so, never reset it to 0 unless the progress bar is disabled (some `settings.progress_bar_position` codepaths were mistakenly doing just that).
* More aggressively set/reset `footer_text.height` (not sure this one makes much of a difference, and/or if it's actually useful at all, but, the tracking was already there, but hella inconsistent, so, just fix it).
* Honor `settings.reclaim_height` in other bits of code that were only checking `footer_visible` to figure out the visible page area.
* Ask ReaderView to update the `visible_area` *now* when toggling the footer's visibility (for ReaderPaging).
2020-10-27 15:48:34 +00:00
|
|
|
|
-- Flag _updateFooterText to notify ReaderView to recalculate the visible_area!
|
|
|
|
|
self.visibility_change = true
|
2016-11-02 08:38:52 +00:00
|
|
|
|
end
|
2014-04-04 13:20:26 +00:00
|
|
|
|
end
|
|
|
|
|
|
2014-05-19 06:23:31 +00:00
|
|
|
|
function ReaderFooter:onEnterFlippingMode()
|
|
|
|
|
self.orig_mode = self.mode
|
2019-09-17 12:50:03 +00:00
|
|
|
|
self:applyFooterMode(self.mode_list.page_progress)
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2014-05-19 06:23:31 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onExitFlippingMode()
|
|
|
|
|
self:applyFooterMode(self.orig_mode)
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2014-05-19 06:23:31 +00:00
|
|
|
|
end
|
|
|
|
|
|
2017-04-02 10:42:25 +00:00
|
|
|
|
function ReaderFooter:onTapFooter(ges)
|
2020-06-04 13:56:37 +00:00
|
|
|
|
local ignore_lock = false
|
|
|
|
|
if ges == true then
|
|
|
|
|
ignore_lock = true
|
|
|
|
|
ges = nil
|
2017-08-08 17:06:11 +00:00
|
|
|
|
end
|
2020-06-04 13:56:37 +00:00
|
|
|
|
if self.view.flipping_visible and ges then
|
2014-03-13 13:52:43 +00:00
|
|
|
|
local pos = ges.pos
|
|
|
|
|
local dimen = self.progress_bar.dimen
|
2014-05-19 06:23:31 +00:00
|
|
|
|
-- if reader footer is not drawn before the dimen value should be nil
|
|
|
|
|
if dimen then
|
|
|
|
|
local percentage = (pos.x - dimen.x)/dimen.w
|
|
|
|
|
self.ui:handleEvent(Event:new("GotoPercentage", percentage))
|
|
|
|
|
end
|
2020-07-12 18:47:49 +00:00
|
|
|
|
self:onUpdateFooter(true)
|
2020-06-04 13:56:37 +00:00
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
if self.has_no_mode or (self.settings.lock_tap and not ignore_lock) then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if self.settings.all_at_once or self.has_no_mode then
|
|
|
|
|
if self.mode >= 1 then
|
|
|
|
|
self.mode = self.mode_list.off
|
2016-04-28 07:02:15 +00:00
|
|
|
|
else
|
2020-06-04 13:56:37 +00:00
|
|
|
|
self.mode = self.mode_list.page_progress
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
self.mode = (self.mode + 1) % self.mode_nb
|
|
|
|
|
for i, m in ipairs(self.mode_index) do
|
|
|
|
|
if self.mode == self.mode_list.off then break end
|
|
|
|
|
if self.mode == i then
|
|
|
|
|
if self.settings[m] then
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
self.mode = (self.mode + 1) % self.mode_nb
|
2016-04-28 07:02:15 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
2014-07-02 08:32:17 +00:00
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
|
end
|
2020-06-04 13:56:37 +00:00
|
|
|
|
self:applyFooterMode()
|
|
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
2020-07-12 18:47:49 +00:00
|
|
|
|
self:onUpdateFooter(true)
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2014-04-04 13:20:26 +00:00
|
|
|
|
return true
|
2013-12-15 12:19:06 +00:00
|
|
|
|
end
|
|
|
|
|
|
2021-05-17 21:40:24 +00:00
|
|
|
|
function ReaderFooter:onHoldFooter(ges)
|
|
|
|
|
-- We're higher priority than readerhighlight_hold, so, make sure we fall through properly...
|
|
|
|
|
if not self.settings.skim_widget_on_hold then
|
|
|
|
|
return
|
2020-11-09 19:16:53 +00:00
|
|
|
|
end
|
2021-05-17 21:40:24 +00:00
|
|
|
|
if not self.view.footer_visible then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
if not self.footer_content.dimen or not self.footer_content.dimen:contains(ges.pos) then
|
|
|
|
|
-- We held outside the footer: meep!
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- We're good, make sure we stop the event from going to readerhighlight_hold
|
|
|
|
|
self.ui:handleEvent(Event:new("ShowSkimtoDialog"))
|
|
|
|
|
return true
|
2014-02-12 12:41:16 +00:00
|
|
|
|
end
|
|
|
|
|
|
2019-10-10 15:02:28 +00:00
|
|
|
|
function ReaderFooter:refreshFooter(refresh, signal)
|
2019-09-20 07:33:29 +00:00
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
self:resetLayout(true)
|
2019-10-15 19:57:51 +00:00
|
|
|
|
-- If we signal, the event we send will trigger a full repaint anyway, so we should be able to skip this one.
|
|
|
|
|
-- We *do* need to ensure we at least re-compute the footer layout, though, especially when going from visible to invisible...
|
2020-07-12 18:47:49 +00:00
|
|
|
|
self:onUpdateFooter(refresh and not signal, refresh and signal)
|
2019-10-10 15:02:28 +00:00
|
|
|
|
if signal then
|
2020-11-22 03:52:03 +00:00
|
|
|
|
if self.ui.document.provider == "crengine" then
|
|
|
|
|
-- This will ultimately trigger an UpdatePos, hence a ReaderUI repaint.
|
|
|
|
|
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.ui.document.configurable.b_page_margin))
|
|
|
|
|
else
|
|
|
|
|
-- No fancy chain of events outside of CRe, just ask for a ReaderUI repaint ourselves ;).
|
|
|
|
|
UIManager:setDirty(self.view.dialog, "partial")
|
|
|
|
|
end
|
2019-10-10 15:02:28 +00:00
|
|
|
|
end
|
2019-09-20 07:33:29 +00:00
|
|
|
|
end
|
|
|
|
|
|
2017-03-24 17:57:07 +00:00
|
|
|
|
function ReaderFooter:onResume()
|
2021-02-23 23:36:05 +00:00
|
|
|
|
-- Don't repaint the footer until OutOfScreenSaver if screensaver_delay is enabled...
|
|
|
|
|
local screensaver_delay = G_reader_settings:readSetting("screensaver_delay")
|
|
|
|
|
if screensaver_delay and screensaver_delay ~= "disable" then
|
|
|
|
|
self._delayed_screensaver = true
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Force a footer repaint on resume if it was visible
|
|
|
|
|
self:onUpdateFooter(self.view.footer_visible)
|
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onOutOfScreenSaver()
|
|
|
|
|
if not self._delayed_screensaver then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self._delayed_screensaver = nil
|
Tame some ButtonTable users into re-using Buttontable instances if possible (#7166)
* QuickDictLookup, ImageViewer, NumberPicker: Smarter `update` that will re-use most of the widget's layout instead of re-instantiating all the things.
* SpinWidget/DoubleSpinWidget: The NumberPicker change above renders a hack to preserve alpha on these widgets almost unnecessary. Also fixed said hack to also apply to the center, value button.
* Button: Don't re-instantiate the frame in setText/setIcon when unnecessary (e.g., no change at all, or no layout change).
* Button: Add a refresh method that repaints and refreshes a *specific* Button (provided it's been painted once) all on its lonesome.
* ConfigDialog: Free everything that's going to be re-instatiated on update
* A few more post #7118 fixes:
* SkimTo: Always flag the chapter nav buttons as vsync
* Button: Fix the highlight on rounded buttons when vsync is enabled (e.g., it's now entirely visible, instead of showing a weird inverted corner glitch).
* Some more heuristic tweaks in Menu/TouchMenu/Button/IconButton
* ButtonTable: fix the annoying rounding issue I'd noticed in #7054 ;).
* Enable dithering in TextBoxWidget (e.g., in the Wikipedia full view). This involved moving the HW dithering align fixup to base, where it always ought to have been ;).
* Switch a few widgets that were using "partial" on close to "ui", or, more rarely, "flashui". The intent being to limit "partial" purely to the Reader, because it has a latency cost when mixed with other refreshes, which happens often enough in UI ;).
* Minor documentation tweaks around UIManager's `setDirty` to reflect that change.
* ReaderFooter: Force a footer repaint on resume if it is visible (otherwise, just update it).
* ReaderBookmark: In the same vein, don't repaint an invisible footer on bookmark count changes.
2021-01-28 23:20:15 +00:00
|
|
|
|
-- Force a footer repaint on resume if it was visible
|
|
|
|
|
self:onUpdateFooter(self.view.footer_visible)
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:rescheduleFooterAutoRefreshIfNeeded()
|
2017-04-04 18:24:06 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onSuspend()
|
2021-01-30 19:54:44 +00:00
|
|
|
|
self:unscheduleFooterAutoRefresh()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onCloseDocument()
|
|
|
|
|
self:unscheduleFooterAutoRefresh()
|
2017-03-24 17:57:07 +00:00
|
|
|
|
end
|
|
|
|
|
|
2021-04-16 21:05:06 +00:00
|
|
|
|
-- Used by event handlers that can trip without direct UI interaction...
|
|
|
|
|
function ReaderFooter:maybeUpdateFooter()
|
|
|
|
|
-- ...so we need to avoid stomping over unsuspecting widgets (usually, ScreenSaver).
|
|
|
|
|
if UIManager:getTopWidget() == "ReaderUI" then
|
|
|
|
|
self:onUpdateFooter(self.view.footer_visible)
|
|
|
|
|
else
|
|
|
|
|
self:onUpdateFooter()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2017-06-20 02:00:36 +00:00
|
|
|
|
function ReaderFooter:onFrontlightStateChanged()
|
|
|
|
|
if self.settings.frontlight then
|
2021-04-16 21:05:06 +00:00
|
|
|
|
self:maybeUpdateFooter()
|
2017-06-20 02:00:36 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-28 23:06:41 +00:00
|
|
|
|
function ReaderFooter:onNetworkConnected()
|
|
|
|
|
if self.settings.wifi_status then
|
2021-04-16 21:05:06 +00:00
|
|
|
|
self:maybeUpdateFooter()
|
2020-09-28 23:06:41 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onNetworkDisconnected()
|
|
|
|
|
if self.settings.wifi_status then
|
2021-04-16 21:05:06 +00:00
|
|
|
|
self:maybeUpdateFooter()
|
2020-09-28 23:06:41 +00:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-04-16 21:05:06 +00:00
|
|
|
|
function ReaderFooter:onCharging()
|
|
|
|
|
self:maybeUpdateFooter()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ReaderFooter:onNotCharging()
|
|
|
|
|
self:maybeUpdateFooter()
|
|
|
|
|
end
|
|
|
|
|
|
2020-07-01 20:17:41 +00:00
|
|
|
|
function ReaderFooter:onSetRotationMode()
|
2019-09-18 09:13:51 +00:00
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
self:resetLayout(true)
|
|
|
|
|
end
|
|
|
|
|
|
2019-10-10 15:02:28 +00:00
|
|
|
|
function ReaderFooter:onSetPageHorizMargins(h_margins)
|
|
|
|
|
self.book_margins_footer_width = math.floor((h_margins[1] + h_margins[2])/2)
|
|
|
|
|
if self.settings.progress_margin then
|
|
|
|
|
self.settings.progress_margin_width = Screen:scaleBySize(self.book_margins_footer_width)
|
|
|
|
|
self:refreshFooter(true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-09-30 18:05:29 +00:00
|
|
|
|
function ReaderFooter:onScreenResize()
|
|
|
|
|
self:updateFooterContainer()
|
|
|
|
|
self:resetLayout(true)
|
|
|
|
|
end
|
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
|
return ReaderFooter
|