AltStatusBar/Footer: add the read timer value (#12002)

Closes #11950
This commit is contained in:
zwim
2024-07-19 22:55:31 +02:00
committed by GitHub
parent ce8e27a67c
commit df48d51eca
4 changed files with 245 additions and 31 deletions

View File

@@ -341,10 +341,10 @@ local footerTextGeneratorMap = {
prefix .. " ", left)
end,
mem_usage = function(footer)
local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].mem_usage
local statm = io.open("/proc/self/statm", "r")
if statm then
local symbol_type = footer.settings.item_prefix
local prefix = symbol_prefix[symbol_type].mem_usage
local dummy, rss = statm:read("*number", "*number")
statm:close()
-- we got the nb of 4Kb-pages used, that we convert to MiB
@@ -516,6 +516,8 @@ ReaderFooter.default_settings = {
function ReaderFooter:init()
self.settings = G_reader_settings:readSetting("footer", self.default_settings)
self.additional_footer_content = {} -- place, where additional header content can be inserted.
-- Remove items not supported by the current device
if not Device:hasFastWifiStatusQuery() then
MODE.wifi_status = nil
@@ -1981,6 +1983,19 @@ function ReaderFooter:genAlignmentMenuItems(value)
}
end
function ReaderFooter:addAdditionalFooterContent(content_func)
table.insert(self.additional_footer_content, content_func)
end
function ReaderFooter:removeAdditionalFooterContent(content_func)
for i, v in ipairs(self.additional_footer_content) do
if v == content_func then
table.remove(self.additional_footer_content, i)
return true
end
end
end
-- this method will be updated at runtime based on user setting
function ReaderFooter:genFooterText() end
@@ -2153,6 +2168,13 @@ function ReaderFooter:_updateFooterText(force_repaint, full_repaint)
return
end
local text = self:genFooterText()
for dummy, v in ipairs(self.additional_footer_content) do
local value = v()
if value and value ~= "" then
text = value .. " " .. self:get_separator_symbol() .. " " .. text
end
end
if not text then text = "" end
self.footer_text:setText(text)
if self.settings.disable_progress_bar then