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")
|
|
|
|
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")
|
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,
|
|
|
|
time = 2,
|
|
|
|
pages_left = 3,
|
|
|
|
battery = 4,
|
|
|
|
percentage = 5,
|
|
|
|
book_time_to_read = 6,
|
|
|
|
chapter_time_to_read = 7,
|
2016-10-16 17:22:26 +00:00
|
|
|
frontlight = 8,
|
2017-03-11 12:22:44 +00:00
|
|
|
mem_usage = 9,
|
2017-10-28 15:51:34 +00:00
|
|
|
wifi_status = 10,
|
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,
|
|
|
|
pages_left = "=>",
|
|
|
|
battery = "B:",
|
|
|
|
percentage = "R:",
|
|
|
|
book_time_to_read = "TB:",
|
|
|
|
chapter_time_to_read = "TC:",
|
|
|
|
frontlight = "L:",
|
|
|
|
mem_usage = "M:",
|
|
|
|
wifi_status = "W:",
|
|
|
|
},
|
|
|
|
icons = {
|
|
|
|
time = "⌚",
|
|
|
|
pages_left = "⇒",
|
|
|
|
battery = "⚡",
|
|
|
|
percentage = "⤠",
|
|
|
|
book_time_to_read = "⏳",
|
|
|
|
chapter_time_to_read = "⤻",
|
|
|
|
frontlight = "☼",
|
2019-09-01 13:55:41 +00:00
|
|
|
mem_usage = "≡",
|
2019-08-16 21:22:58 +00:00
|
|
|
wifi_status = "⚟",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
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
|
2019-08-16 21:22:58 +00:00
|
|
|
return T(_("%1 Off"), prefix)
|
2016-11-02 08:38:52 +00:00
|
|
|
end
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
battery = function(footer)
|
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].battery
|
2016-11-02 08:38:52 +00:00
|
|
|
local powerd = Device:getPowerDevice()
|
2019-08-16 21:22:58 +00:00
|
|
|
return prefix .. " " .. (powerd:isCharging() and "+" or "") .. powerd:getCapacity() .. "%"
|
2016-11-02 08:38:52 +00:00
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
time = function(footer)
|
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].time
|
|
|
|
local clock
|
|
|
|
if footer.settings.time_format == "12" then
|
|
|
|
clock = os.date("%I:%M%p")
|
|
|
|
else
|
|
|
|
clock = os.date("%H:%M")
|
|
|
|
end
|
|
|
|
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
|
2017-04-11 09:44:58 +00:00
|
|
|
return ("%d / %d"):format(footer.pageno, footer.pages)
|
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,
|
|
|
|
pages_left = function(footer)
|
2019-08-16 21:22:58 +00:00
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].pages_left
|
2016-11-02 08:38:52 +00:00
|
|
|
local left = footer.ui.toc:getChapterPagesLeft(
|
|
|
|
footer.pageno, footer.toc_level)
|
2019-08-16 21:22:58 +00:00
|
|
|
return prefix .. " " .. (left and left or footer.pages - footer.pageno)
|
2016-11-02 08:38:52 +00:00
|
|
|
end,
|
|
|
|
percentage = function(footer)
|
2019-08-16 21:22:58 +00:00
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].percentage
|
|
|
|
local digits = footer.settings.progress_pct_format or "0"
|
|
|
|
local string_percentage
|
|
|
|
if not prefix then
|
|
|
|
string_percentage = "%." .. digits .. "f%%"
|
|
|
|
else
|
|
|
|
string_percentage = prefix .. " %." .. digits .. "f%%"
|
|
|
|
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)
|
2019-08-16 21:22:58 +00:00
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].book_time_to_read
|
2016-11-02 08:38:52 +00:00
|
|
|
local current_page
|
|
|
|
if footer.view.document.info.has_pages then
|
|
|
|
current_page = footer.ui.paging.current_page
|
|
|
|
else
|
|
|
|
current_page = footer.view.document:getCurrentPage()
|
|
|
|
end
|
2019-08-16 21:22:58 +00:00
|
|
|
return footer:getDataFromStatistics(prefix .. " ", footer.pages - current_page)
|
2016-11-02 08:38:52 +00:00
|
|
|
end,
|
|
|
|
chapter_time_to_read = function(footer)
|
2019-08-16 21:22:58 +00:00
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].chapter_time_to_read
|
2016-11-02 08:38:52 +00:00
|
|
|
local left = footer.ui.toc:getChapterPagesLeft(
|
|
|
|
footer.pageno, footer.toc_level)
|
|
|
|
return footer:getDataFromStatistics(
|
2019-08-16 21:22:58 +00:00
|
|
|
prefix .. " ", (left and left or footer.pages - footer.pageno))
|
2016-11-02 08:38:52 +00:00
|
|
|
end,
|
2017-03-11 12:22:44 +00:00
|
|
|
mem_usage = function(footer)
|
2019-08-16 21:22:58 +00:00
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
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
|
|
|
|
local infos = statm:read("*all")
|
|
|
|
statm:close()
|
|
|
|
local rss = infos:match("^%S+ (%S+) ")
|
|
|
|
-- we got the nb of 4Kb-pages used, that we convert to Mb
|
|
|
|
rss = math.floor(tonumber(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)
|
|
|
|
local symbol_type = footer.settings.item_prefix or "icons"
|
|
|
|
local prefix = symbol_prefix[symbol_type].wifi_status
|
2017-10-28 15:51:34 +00:00
|
|
|
local NetworkMgr = require("ui/network/manager")
|
|
|
|
if NetworkMgr:isWifiOn() then
|
2019-08-16 21:22:58 +00:00
|
|
|
return T(_("%1 On"), prefix)
|
2017-10-28 15:51:34 +00:00
|
|
|
else
|
2019-08-16 21:22:58 +00:00
|
|
|
return T(_("%1 Off"), prefix)
|
2017-10-28 15:51:34 +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,
|
2014-10-07 09:09:37 +00:00
|
|
|
toc_level = 0,
|
2014-03-13 13:52:43 +00:00
|
|
|
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-09-27 10:56:47 +00:00
|
|
|
text_font_size = DMINIBAR_FONT_SIZE,
|
2014-11-20 22:07:39 +00:00
|
|
|
bar_height = Screen:scaleBySize(DMINIBAR_HEIGHT),
|
|
|
|
height = Screen:scaleBySize(DMINIBAR_CONTAINER_HEIGHT),
|
2016-03-12 08:59:15 +00:00
|
|
|
horizontal_margin = Screen:scaleBySize(10),
|
|
|
|
text_left_margin = Screen:scaleBySize(10),
|
2017-10-08 15:50:05 +00:00
|
|
|
bottom_padding = Screen:scaleBySize(1),
|
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
|
|
|
}
|
|
|
|
|
2013-02-24 07:25:08 +00:00
|
|
|
function ReaderFooter:init()
|
2015-03-12 06:35:43 +00:00
|
|
|
self.settings = G_reader_settings:readSetting("footer") or {
|
2017-04-11 09:44:58 +00:00
|
|
|
-- enable progress bar by default
|
|
|
|
-- disable_progress_bar = true,
|
2015-03-12 06:35:43 +00:00
|
|
|
disabled = false,
|
|
|
|
all_at_once = false,
|
2019-05-01 00:09:01 +00:00
|
|
|
reclaim_height = false,
|
2015-03-12 06:35:43 +00:00
|
|
|
toc_markers = true,
|
|
|
|
battery = true,
|
|
|
|
time = true,
|
|
|
|
page_progress = true,
|
2015-03-12 07:51:59 +00:00
|
|
|
pages_left = true,
|
2015-03-12 06:35:43 +00:00
|
|
|
percentage = true,
|
2015-11-27 15:13:01 +00:00
|
|
|
book_time_to_read = true,
|
|
|
|
chapter_time_to_read = true,
|
2016-10-16 17:22:26 +00:00
|
|
|
frontlight = false,
|
2017-03-11 12:22:44 +00:00
|
|
|
mem_usage = false,
|
2017-10-28 15:51:34 +00:00
|
|
|
wifi_status = false,
|
2019-08-16 21:22:58 +00:00
|
|
|
item_prefix = "icons"
|
2015-03-12 06:35:43 +00:00
|
|
|
}
|
2016-11-02 08:38:52 +00:00
|
|
|
|
2019-09-17 12:50:03 +00:00
|
|
|
if not self.settings.order then
|
|
|
|
self.mode_nb = 0
|
|
|
|
self.mode_index = {}
|
|
|
|
local mode_tbl = {}
|
|
|
|
for k,v in pairs(MODE) do
|
|
|
|
mode_tbl[v] = k
|
|
|
|
end
|
|
|
|
local mode_name
|
|
|
|
for i = 0, #mode_tbl do
|
|
|
|
mode_name = mode_tbl[i]
|
|
|
|
if mode_name == "wifi_status" and not Device:isAndroid() then
|
|
|
|
do end -- luacheck: ignore 541
|
|
|
|
elseif mode_name == "frontlight" and not Device:hasFrontlight() then
|
|
|
|
do end -- luacheck: ignore 541
|
|
|
|
else
|
|
|
|
self.mode_index[self.mode_nb] = mode_name
|
|
|
|
self.mode_nb = self.mode_nb + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
self.mode_index = self.settings.order
|
|
|
|
self.mode_nb = #self.mode_index
|
|
|
|
end
|
|
|
|
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
|
2016-11-02 08:38:52 +00:00
|
|
|
-- footer featuren disabled completely, stop initialization now
|
|
|
|
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
|
2019-05-01 00:09:01 +00:00
|
|
|
self.reclaim_height = self.settings.reclaim_height or false
|
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 = '',
|
2014-03-13 13:52:43 +00:00
|
|
|
face = Font:getFace(self.text_font_face, self.text_font_size),
|
|
|
|
}
|
2016-11-02 08:38:52 +00:00
|
|
|
-- all width related values will be initialized in self:resetLayout()
|
|
|
|
self.text_width = 0
|
2014-06-05 04:48:48 +00:00
|
|
|
self.progress_bar = ProgressWidget:new{
|
2016-11-02 08:38:52 +00:00
|
|
|
width = nil,
|
2014-07-17 13:27:35 +00:00
|
|
|
height = self.bar_height,
|
2014-06-05 04:48:48 +00:00
|
|
|
percentage = self.progress_percentage,
|
2014-10-07 09:09:37 +00:00
|
|
|
tick_width = DMINIBAR_TOC_MARKER_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
|
|
|
}
|
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
|
|
|
}
|
2017-04-11 09:44:58 +00:00
|
|
|
|
|
|
|
local margin_span = HorizontalSpan:new{ width = self.horizontal_margin }
|
|
|
|
self.horizontal_group = HorizontalGroup:new{
|
|
|
|
margin_span,
|
|
|
|
self.progress_bar,
|
|
|
|
self.text_container,
|
|
|
|
margin_span,
|
|
|
|
}
|
2016-12-04 06:57:57 +00:00
|
|
|
|
2019-08-11 17:58:39 +00:00
|
|
|
self:updateFooterContainer()
|
2016-03-08 06:42:46 +00:00
|
|
|
|
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()
|
|
|
|
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()
|
|
|
|
else
|
|
|
|
self:applyFooterMode()
|
|
|
|
end
|
2016-03-08 06:42:46 +00:00
|
|
|
if self.settings.auto_refresh_time then
|
2016-11-02 08:38:52 +00:00
|
|
|
self:setupAutoRefreshTime()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-11 17:58:39 +00:00
|
|
|
function ReaderFooter:updateFooterContainer()
|
|
|
|
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
|
|
|
|
|
|
|
|
if self.settings.bottom_horizontal_separator then
|
|
|
|
local separator_line = LineWidget:new{
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = Screen:getWidth() - 2 * self.horizontal_margin,
|
|
|
|
h = Size.line.medium,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
local vertical_span = VerticalSpan:new{width = self.bottom_padding *2}
|
|
|
|
self.vertical_frame = VerticalGroup:new{
|
|
|
|
separator_line,
|
|
|
|
vertical_span,
|
|
|
|
self.footer_container,
|
|
|
|
}
|
|
|
|
else
|
|
|
|
self.vertical_frame = VerticalGroup:new{
|
|
|
|
self.footer_container,
|
2019-08-11 17:58:39 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
function ReaderFooter:setupAutoRefreshTime()
|
|
|
|
if not self.autoRefreshTime then
|
|
|
|
self.autoRefreshTime = function()
|
2019-02-11 02:28:46 +00:00
|
|
|
self:updateFooter(true)
|
2016-11-02 08:38:52 +00:00
|
|
|
UIManager:scheduleIn(61 - tonumber(os.date("%S")), self.autoRefreshTime)
|
2016-03-08 06:42:46 +00:00
|
|
|
end
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
self.onCloseDocument = function()
|
|
|
|
UIManager:unschedule(self.autoRefreshTime)
|
|
|
|
end
|
|
|
|
UIManager:scheduleIn(61 - tonumber(os.date("%S")), self.autoRefreshTime)
|
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 = {
|
2019-03-30 20:05:44 +00:00
|
|
|
"tap_forward",
|
|
|
|
"tap_backward",
|
|
|
|
"readerconfigmenu_tap",
|
2016-12-19 04:27:56 +00:00
|
|
|
},
|
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,
|
|
|
|
handler = function() return self:onHoldFooter() end,
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"readerhighlight_hold",
|
|
|
|
},
|
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
|
|
|
|
else
|
|
|
|
self.progress_bar.width = math.floor(
|
|
|
|
new_screen_width - self.text_width - self.horizontal_margin*2)
|
|
|
|
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
|
|
|
|
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
|
|
|
|
self.onCloseDocument = nil
|
|
|
|
self.onPageUpdate = function() end
|
|
|
|
self.onPosUpdate = function() end
|
|
|
|
self.onUpdatePos = function() end
|
|
|
|
self.onSetStatusLine = 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.footerTextGenerators = footerTextGenerators
|
|
|
|
self.genFooterText = self.genAllFooterText
|
|
|
|
end
|
|
|
|
-- notify caller that UI needs update
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2019-08-16 21:22:58 +00:00
|
|
|
function ReaderFooter:progressPercentage(digits)
|
|
|
|
local symbol_type = self.settings.item_prefix or "icons"
|
|
|
|
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)
|
|
|
|
local symbol = self.settings.item_prefix or "icons"
|
|
|
|
local option_titles = {
|
|
|
|
all_at_once = _("Show all at once"),
|
|
|
|
reclaim_height = _("Reclaim bar height from bottom margin"),
|
|
|
|
page_progress = T(_("Current page (%1)"), "/"),
|
|
|
|
time = symbol_prefix[symbol].time
|
|
|
|
and T(_("Current time (%1)"), symbol_prefix[symbol].time) or _("Current time"),
|
|
|
|
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
|
|
|
|
and T(_("Progress percentage (%1)"), symbol_prefix[symbol].percentage) or ("Progress percentage"),
|
|
|
|
book_time_to_read = T(_("Book time to read (%1)"),symbol_prefix[symbol].book_time_to_read),
|
|
|
|
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),
|
|
|
|
}
|
|
|
|
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
|
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,
|
2016-11-02 08:38:52 +00:00
|
|
|
callback = function() self:onTapFooter() end,
|
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]
|
|
|
|
G_reader_settings:saveSetting("footer", self.settings)
|
|
|
|
-- 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
|
2019-05-01 00:09:01 +00:00
|
|
|
self.reclaim_height = self.settings.reclaim_height or false
|
2017-08-08 17:06:11 +00:00
|
|
|
-- refresh margins position
|
|
|
|
if self.has_no_mode then
|
2019-05-01 00:09:01 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
|
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-05-01 00:09:01 +00:00
|
|
|
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
|
2017-08-08 17:06:11 +00:00
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", first_enabled_mode_num)
|
2019-05-01 00:09:01 +00:00
|
|
|
elseif self.reclaim_height ~= prev_reclaim_height then
|
|
|
|
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
|
|
|
|
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
|
|
|
|
end
|
|
|
|
should_update = true
|
|
|
|
self:applyFooterMode()
|
|
|
|
end
|
|
|
|
if should_update then
|
|
|
|
self:updateFooter()
|
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
|
|
|
UIManager:setDirty(nil, "ui")
|
2016-11-02 08:38:52 +00:00
|
|
|
end
|
|
|
|
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"),
|
|
|
|
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
|
|
|
|
G_reader_settings:saveSetting("footer", self.settings)
|
|
|
|
self:updateFooterTextGenerator()
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(sort_item)
|
|
|
|
end,
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
getMinibarOption("all_at_once", self.updateFooterTextGenerator),
|
|
|
|
getMinibarOption("reclaim_height"),
|
|
|
|
{
|
|
|
|
text = _("Auto refresh time"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.auto_refresh_time == true
|
|
|
|
end,
|
|
|
|
-- only enable auto refresh when time is shown
|
|
|
|
enabled_func = function() return self.settings.time end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.auto_refresh_time = not self.settings.auto_refresh_time
|
|
|
|
G_reader_settings:saveSetting("footer", self.settings)
|
|
|
|
if self.settings.auto_refresh_time then
|
|
|
|
self:setupAutoRefreshTime()
|
|
|
|
else
|
|
|
|
UIManager:unschedule(self.autoRefreshTime)
|
|
|
|
self.onCloseDocument = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
},
|
2019-09-05 11:58:34 +00:00
|
|
|
{
|
|
|
|
text = _("Show footer separator"),
|
|
|
|
separator = true,
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.bottom_horizontal_separator
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.bottom_horizontal_separator = not self.settings.bottom_horizontal_separator
|
|
|
|
self:updateFooterContainer()
|
|
|
|
self:resetLayout(true)
|
|
|
|
self:updateFooter()
|
|
|
|
self.ui:handleEvent(Event:new("SetPageBottomMargin", self.view.document.configurable.b_page_margin))
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
2019-08-16 21:22:58 +00:00
|
|
|
{
|
|
|
|
text = _("Alignment"),
|
|
|
|
enabled_func = function()
|
2019-08-17 17:45:18 +00:00
|
|
|
return self.settings.disable_progress_bar == true
|
2019-08-16 21:22:58 +00:00
|
|
|
end,
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Center"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.align == "center" or self.settings.align == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.align = "center"
|
|
|
|
self:updateFooterContainer()
|
|
|
|
self:resetLayout(true)
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Left"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.align == "left"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.align = "left"
|
|
|
|
self:updateFooterContainer()
|
|
|
|
self:resetLayout(true)
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Right"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.align == "right"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.align = "right"
|
|
|
|
self:updateFooterContainer()
|
|
|
|
self:resetLayout(true)
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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()
|
|
|
|
return self.settings.item_prefix == "icons" or self.settings.item_prefix == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.item_prefix = "icons"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
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"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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()
|
|
|
|
return self.settings.items_separator == "bar" or self.settings.items_separator == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.items_separator = "bar"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("No separator"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.items_separator == "none"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.items_separator = "none"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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()
|
|
|
|
return self.settings.progress_pct_format == "0" or self.settings.progress_pct_format == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.progress_pct_format = "0"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Time format"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
text_func = function()
|
|
|
|
local footer = {}
|
|
|
|
footer.settings = {}
|
|
|
|
footer.settings.time_format = "24"
|
|
|
|
footer.settings.item_prefix = self.settings.item_prefix or "icons"
|
|
|
|
return T(_("24-hour (%1)"),footerTextGeneratorMap.time(footer))
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
checked_func = function()
|
|
|
|
return self.settings.time_format == "24" or self.settings.time_format == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.time_format = "24"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
text_func = function()
|
|
|
|
local footer = {}
|
|
|
|
footer.settings = {}
|
|
|
|
footer.settings.time_format = "12"
|
|
|
|
footer.settings.item_prefix = self.settings.item_prefix or "icons"
|
|
|
|
return T(_("12-hour (%1)"),footerTextGeneratorMap.time(footer))
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
checked_func = function()
|
|
|
|
return self.settings.time_format == "12"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.time_format = "12"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
text = _("Duration format"),
|
2019-08-16 21:22:58 +00:00
|
|
|
sub_item_table = {
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
text_func = function()
|
|
|
|
local current_duration_format = self.settings.duration_format
|
|
|
|
local return_text
|
|
|
|
self.settings.duration_format = "modern"
|
|
|
|
return_text = footerTextGeneratorMap.book_time_to_read(self)
|
|
|
|
self.settings.duration_format = current_duration_format
|
|
|
|
return T(_("Modern (%1)"), return_text)
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
checked_func = function()
|
|
|
|
return self.settings.duration_format == "modern" or self.settings.duration_format == nil
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.duration_format = "modern"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
2019-08-17 17:45:18 +00:00
|
|
|
text_func = function()
|
|
|
|
local current_duration_format = self.settings.duration_format
|
|
|
|
local return_text
|
|
|
|
self.settings.duration_format = "classic"
|
|
|
|
return_text = footerTextGeneratorMap.book_time_to_read(self)
|
|
|
|
self.settings.duration_format = current_duration_format
|
|
|
|
return T(_("Classic (%1)"), return_text)
|
|
|
|
end,
|
2019-08-16 21:22:58 +00:00
|
|
|
checked_func = function()
|
|
|
|
return self.settings.duration_format == "classic"
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.duration_format = "classic"
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
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
|
|
|
|
self:updateFooter()
|
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
|
|
|
UIManager:setDirty(nil, "ui")
|
2017-04-11 09:44:58 +00:00
|
|
|
end,
|
|
|
|
},
|
2019-09-11 15:56:26 +00:00
|
|
|
{
|
|
|
|
text = _("Show chapter markers"),
|
|
|
|
checked_func = function()
|
|
|
|
return self.settings.toc_markers
|
|
|
|
end,
|
|
|
|
enabled_func = function()
|
|
|
|
return not self.settings.disable_progress_bar
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
self.settings.toc_markers = not self.settings.toc_markers
|
|
|
|
self:setTocMarkers()
|
|
|
|
self:updateFooter()
|
|
|
|
UIManager:setDirty(nil, "ui")
|
|
|
|
end,
|
|
|
|
},
|
2017-04-11 09:44:58 +00:00
|
|
|
}
|
|
|
|
})
|
2016-11-02 08:38:52 +00:00
|
|
|
table.insert(sub_items, getMinibarOption("page_progress"))
|
|
|
|
table.insert(sub_items, getMinibarOption("time"))
|
|
|
|
table.insert(sub_items, getMinibarOption("pages_left"))
|
|
|
|
table.insert(sub_items, getMinibarOption("battery"))
|
|
|
|
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"))
|
2017-10-28 15:51:34 +00:00
|
|
|
if Device:isAndroid() then
|
|
|
|
table.insert(sub_items, getMinibarOption("wifi_status"))
|
|
|
|
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 = " "
|
|
|
|
if self.settings.items_separator == "bar" or self.settings.items_separator == nil then
|
|
|
|
separator = " | "
|
|
|
|
elseif self.settings.items_separator == "bullet" then
|
|
|
|
separator = " • "
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
for _, gen in ipairs(self.footerTextGenerators) do
|
|
|
|
table.insert(info, gen(self))
|
2016-03-12 08:59:15 +00:00
|
|
|
end
|
2019-08-16 21:22:58 +00:00
|
|
|
return table.concat(info, separator)
|
2014-10-07 09:09:37 +00:00
|
|
|
end
|
|
|
|
|
2017-04-11 09:44:58 +00:00
|
|
|
-- this method should never get called when footer is disabled
|
2018-06-13 22:46:52 +00:00
|
|
|
function ReaderFooter:setTocMarkers(reset)
|
|
|
|
if reset then
|
|
|
|
self.progress_bar.ticks = nil
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
if self.settings.toc_markers then
|
|
|
|
if self.progress_bar.ticks ~= nil then return end
|
|
|
|
local ticks_candidates = {}
|
|
|
|
if self.ui.toc then
|
|
|
|
local max_level = self.ui.toc:getMaxDepth()
|
|
|
|
for i = 0, -max_level, -1 do
|
|
|
|
local ticks = self.ui.toc:getTocTicks(i)
|
|
|
|
table.insert(ticks_candidates, ticks)
|
|
|
|
end
|
|
|
|
-- find the finest toc ticks by sorting out the largest one
|
|
|
|
table.sort(ticks_candidates, function(a, b) return #a > #b end)
|
|
|
|
end
|
2015-03-12 06:35:43 +00:00
|
|
|
|
2016-11-02 08:38:52 +00:00
|
|
|
if #ticks_candidates > 0 then
|
|
|
|
self.progress_bar.ticks = ticks_candidates[1]
|
|
|
|
self.progress_bar.last = self.pages or self.view.document:getPageCount()
|
|
|
|
else
|
|
|
|
-- we still set ticks here so self.progress_bar.ticks will not be
|
|
|
|
-- initialized again if ticks_candidates is empty
|
|
|
|
self.progress_bar.ticks = {}
|
|
|
|
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
|
|
|
|
|
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)
|
2015-12-23 06:35:46 +00:00
|
|
|
local sec = 'na'
|
2017-09-16 11:36:54 +00:00
|
|
|
local average_time_per_page = self:getAvgTimePerPage()
|
|
|
|
if average_time_per_page then
|
2019-08-16 21:22:58 +00:00
|
|
|
if self.settings.duration_format == "classic" then
|
|
|
|
sec = util.secondsToClock(pages * average_time_per_page, true)
|
|
|
|
else
|
|
|
|
sec = util.secondsToHClock(pages * average_time_per_page, true)
|
|
|
|
end
|
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
|
|
|
|
|
2019-02-11 02:28:46 +00:00
|
|
|
function ReaderFooter:updateFooter(force_repaint)
|
2016-03-12 08:59:15 +00:00
|
|
|
if self.pageno then
|
2019-02-11 02:28:46 +00:00
|
|
|
self:updateFooterPage(force_repaint)
|
2016-03-12 08:59:15 +00:00
|
|
|
else
|
2019-02-11 02:28:46 +00:00
|
|
|
self:updateFooterPos(force_repaint)
|
2016-03-12 08:59:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-11 02:28:46 +00:00
|
|
|
function ReaderFooter:updateFooterPage(force_repaint)
|
2014-03-13 13:52:43 +00:00
|
|
|
if type(self.pageno) ~= "number" then return end
|
|
|
|
self.progress_bar.percentage = self.pageno / self.pages
|
2019-02-11 02:28:46 +00:00
|
|
|
self:updateFooterText(force_repaint)
|
2016-03-12 08:59:15 +00:00
|
|
|
end
|
|
|
|
|
2019-02-11 02:28:46 +00:00
|
|
|
function ReaderFooter:updateFooterPos(force_repaint)
|
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-02-11 02:28:46 +00:00
|
|
|
self:updateFooterText(force_repaint)
|
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-02-11 02:28:46 +00:00
|
|
|
function ReaderFooter:updateFooterText(force_repaint)
|
2016-06-03 08:31:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- only call this function after document is fully loaded
|
2019-02-11 02:28:46 +00:00
|
|
|
function ReaderFooter:_updateFooterText(force_repaint)
|
2019-03-29 19:12:09 +00:00
|
|
|
local text = self:genFooterText()
|
|
|
|
if text then
|
2019-08-21 13:00:09 +00:00
|
|
|
self.footer_text:setText(text)
|
2019-03-29 19:12:09 +00:00
|
|
|
end
|
2017-04-11 09:44:58 +00:00
|
|
|
if self.settings.disable_progress_bar then
|
2019-03-29 19:12:09 +00:00
|
|
|
if self.has_no_mode or not text then
|
2017-04-11 09:44:58 +00:00
|
|
|
self.text_width = 0
|
|
|
|
else
|
|
|
|
self.text_width = self.footer_text:getSize().w
|
|
|
|
end
|
|
|
|
self.progress_bar.width = 0
|
2014-07-02 08:43:24 +00:00
|
|
|
else
|
2019-03-29 19:12:09 +00:00
|
|
|
if self.has_no_mode or not text then
|
2017-04-11 09:44:58 +00:00
|
|
|
self.text_width = 0
|
|
|
|
else
|
|
|
|
self.text_width = self.footer_text:getSize().w + self.text_left_margin
|
|
|
|
end
|
|
|
|
self.progress_bar.width = math.floor(
|
|
|
|
self._saved_screen_width - self.text_width - self.horizontal_margin*2)
|
2014-07-02 08:43:24 +00:00
|
|
|
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
|
|
|
|
-- NOTE: We need to repaint everything when toggling the progress bar, for some reason.
|
|
|
|
UIManager:setDirty(self.view.dialog, function()
|
|
|
|
return "ui", self.footer_content.dimen
|
|
|
|
end)
|
|
|
|
end
|
2014-02-12 07:26:56 +00:00
|
|
|
end
|
|
|
|
|
2013-02-24 07:25:08 +00:00
|
|
|
function ReaderFooter:onPageUpdate(pageno)
|
2014-03-13 13:52:43 +00:00
|
|
|
self.pageno = pageno
|
2016-03-19 06:22:17 +00:00
|
|
|
self.pages = self.view.document:getPageCount()
|
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
|
|
|
|
self.doc_height = self.view.document.info.doc_height
|
2017-10-05 19:49:59 +00:00
|
|
|
if pageno then
|
|
|
|
self.pageno = pageno
|
|
|
|
self.pages = self.view.document:getPageCount()
|
|
|
|
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.
|
2016-11-02 08:38:52 +00:00
|
|
|
ReaderFooter.onUpdatePos = ReaderFooter.updateFooter
|
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()
|
|
|
|
self:resetLayout() -- 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
|
|
|
|
self:updateFooter()
|
|
|
|
end
|
2016-03-19 06:22:17 +00:00
|
|
|
|
2014-05-19 06:23:31 +00:00
|
|
|
function ReaderFooter:applyFooterMode(mode)
|
2014-04-04 13:20:26 +00:00
|
|
|
-- three modes switcher for reader footer
|
|
|
|
-- 0 for footer off
|
|
|
|
-- 1 for footer page info
|
2014-07-02 08:32:17 +00:00
|
|
|
-- 2 for footer time info
|
|
|
|
-- 3 for footer next_chapter info
|
2014-07-04 12:42:36 +00:00
|
|
|
-- 4 for battery status
|
2015-03-12 06:35:43 +00:00
|
|
|
-- 5 for progress percentage
|
2015-11-27 15:13:01 +00:00
|
|
|
-- 6 for from statistics book time to read
|
|
|
|
-- 7 for from statistics chapter time to read
|
2016-10-16 17:22:26 +00:00
|
|
|
-- 8 for front light level
|
2017-03-11 12:22:44 +00:00
|
|
|
-- 9 for memory usage
|
2017-10-28 15:51:34 +00:00
|
|
|
-- 10 for wifi status
|
2014-05-19 06:23:31 +00:00
|
|
|
if mode ~= nil then self.mode = mode end
|
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
|
|
|
|
|
|
|
-- If all-at-once is enabled, just hide, but the text will keep being processed...
|
|
|
|
if self.settings.all_at_once then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
-- We're not in all-at-once mode, disable text generation entirely when we're hidden
|
|
|
|
if not self.view.footer_visible then
|
|
|
|
self.genFooterText = footerTextGeneratorMap.empty
|
|
|
|
return
|
|
|
|
end
|
2016-11-02 08:38:52 +00:00
|
|
|
|
2019-09-17 12:50:03 +00:00
|
|
|
local mode_name = self.mode_index[self.mode]
|
2016-11-02 08:38:52 +00:00
|
|
|
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]
|
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)
|
2014-05-19 06:23:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderFooter:onExitFlippingMode()
|
|
|
|
self:applyFooterMode(self.orig_mode)
|
|
|
|
end
|
|
|
|
|
2017-04-02 10:42:25 +00:00
|
|
|
function ReaderFooter:onTapFooter(ges)
|
2017-08-08 17:06:11 +00:00
|
|
|
if self.has_no_mode then
|
|
|
|
return
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
if self.view.flipping_visible then
|
|
|
|
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
|
2014-03-13 13:52:43 +00:00
|
|
|
else
|
2016-11-02 08:38:52 +00:00
|
|
|
if self.settings.all_at_once or self.has_no_mode then
|
2016-04-28 07:02:15 +00:00
|
|
|
if self.mode >= 1 then
|
2019-09-17 12:50:03 +00:00
|
|
|
self.mode = self.mode_list.off
|
2016-04-28 07:02:15 +00:00
|
|
|
else
|
2019-09-17 12:50:03 +00:00
|
|
|
self.mode = self.mode_list.page_progress
|
2016-04-28 07:02:15 +00:00
|
|
|
end
|
|
|
|
else
|
2019-09-17 12:50:03 +00:00
|
|
|
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
|
2016-04-28 07:02:15 +00:00
|
|
|
if self.mode == i then
|
|
|
|
if self.settings[m] then
|
|
|
|
break
|
|
|
|
else
|
2019-09-17 12:50:03 +00:00
|
|
|
self.mode = (self.mode + 1) % self.mode_nb
|
2016-04-28 07:02:15 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-07-02 08:32:17 +00:00
|
|
|
end
|
2014-04-04 13:20:26 +00:00
|
|
|
self:applyFooterMode()
|
2014-11-30 17:28:18 +00:00
|
|
|
G_reader_settings:saveSetting("reader_footer_mode", self.mode)
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
2019-02-11 02:28:46 +00:00
|
|
|
self:updateFooter(true)
|
2014-04-04 13:20:26 +00:00
|
|
|
return true
|
2013-12-15 12:19:06 +00:00
|
|
|
end
|
|
|
|
|
2016-12-04 06:57:57 +00:00
|
|
|
function ReaderFooter:onHoldFooter()
|
2019-09-17 12:50:03 +00:00
|
|
|
if self.mode == self.mode_list.off then return end
|
2018-07-24 19:47:07 +00:00
|
|
|
self.ui:handleEvent(Event:new("ShowSkimtoDialog"))
|
2014-03-13 13:52:43 +00:00
|
|
|
return true
|
2014-02-12 12:41:16 +00:00
|
|
|
end
|
|
|
|
|
2018-10-22 16:29:36 +00:00
|
|
|
function ReaderFooter:setVisible(visible)
|
|
|
|
if visible then
|
|
|
|
-- If it was off, just do as if we tap'ed on it (so we don't
|
|
|
|
-- duplicate onTapFooter() code - not if flipping_visible as in
|
|
|
|
-- this case, a ges.pos argument to onTapFooter(ges) is required)
|
2019-09-17 12:50:03 +00:00
|
|
|
if self.mode == self.mode_list.off and not self.view.flipping_visible then
|
2018-10-12 15:58:07 +00:00
|
|
|
self:onTapFooter()
|
|
|
|
end
|
2019-09-17 12:50:03 +00:00
|
|
|
self.view.footer_visible = (self.mode ~= self.mode_list.off)
|
2016-07-24 00:57:29 +00:00
|
|
|
else
|
2019-09-17 12:50:03 +00:00
|
|
|
self:applyFooterMode(self.mode_list.off)
|
2016-07-24 00:57:29 +00:00
|
|
|
end
|
2014-02-12 07:26:56 +00:00
|
|
|
end
|
|
|
|
|
2017-03-24 17:57:07 +00:00
|
|
|
function ReaderFooter:onResume()
|
|
|
|
self:updateFooter()
|
2017-04-04 18:24:06 +00:00
|
|
|
if self.settings.auto_refresh_time then
|
|
|
|
self:setupAutoRefreshTime()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderFooter:onSuspend()
|
|
|
|
if self.settings.auto_refresh_time then
|
|
|
|
UIManager:unschedule(self.autoRefreshTime)
|
|
|
|
self.onCloseDocument = nil
|
|
|
|
end
|
2017-03-24 17:57:07 +00:00
|
|
|
end
|
|
|
|
|
2017-06-20 02:00:36 +00:00
|
|
|
function ReaderFooter:onFrontlightStateChanged()
|
|
|
|
if self.settings.frontlight then
|
2019-04-15 18:06:24 +00:00
|
|
|
self:updateFooter(true)
|
2017-06-20 02:00:36 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-18 09:13:51 +00:00
|
|
|
function ReaderFooter:onChangeScreenMode()
|
|
|
|
self:updateFooterContainer()
|
|
|
|
self:resetLayout(true)
|
|
|
|
end
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
return ReaderFooter
|