2021-05-20 21:14:11 +00:00
|
|
|
local Notification = require("ui/widget/notification")
|
2023-03-05 14:21:56 +00:00
|
|
|
local TextViewer = require("ui/widget/textviewer")
|
|
|
|
local UIManager = require("ui/uimanager")
|
2021-05-20 21:14:11 +00:00
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
local band = bit.band
|
|
|
|
local bor = bit.bor
|
|
|
|
|
|
|
|
local function setMask(source)
|
|
|
|
G_reader_settings:saveSetting("notification_sources_to_show_mask", source)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function getMask()
|
|
|
|
return G_reader_settings:readSetting("notification_sources_to_show_mask") or Notification.SOURCE_DEFAULT
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
text = _("Notifications"),
|
|
|
|
help_text = _([[Notification popups may be shown at the top of screen on various occasions.
|
|
|
|
This allows selecting which to show or hide.]]),
|
|
|
|
checked_func = function()
|
|
|
|
local value = G_reader_settings:readSetting("notification_sources_to_show_mask") or Notification.SOURCE_DEFAULT
|
|
|
|
return value ~= 0
|
|
|
|
end,
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
2021-05-22 18:45:06 +00:00
|
|
|
text = _("Some notifications from bottom menu"),
|
|
|
|
help_text = _("Show notification popups for bottom menu settings with no visual feedback."),
|
|
|
|
checked_func = function()
|
|
|
|
return band(getMask(), Notification.SOURCE_BOTTOM_MENU) == band(Notification.SOURCE_SOME, Notification.SOURCE_BOTTOM_MENU)
|
|
|
|
end,
|
|
|
|
callback = function()
|
2021-05-22 21:47:55 +00:00
|
|
|
if band(getMask(), Notification.SOURCE_BOTTOM_MENU) == band(Notification.SOURCE_SOME, Notification.SOURCE_BOTTOM_MENU) then
|
|
|
|
setMask(bor(
|
|
|
|
Notification.SOURCE_NONE,
|
|
|
|
band(getMask(), Notification.SOURCE_DISPATCHER)))
|
|
|
|
else
|
|
|
|
setMask(bor(
|
2021-05-22 18:45:06 +00:00
|
|
|
band(Notification.SOURCE_SOME, Notification.SOURCE_BOTTOM_MENU),
|
|
|
|
band(getMask(), Notification.SOURCE_DISPATCHER)))
|
2021-05-22 21:47:55 +00:00
|
|
|
end
|
2021-05-22 18:45:06 +00:00
|
|
|
end,
|
2021-05-20 21:14:11 +00:00
|
|
|
},
|
|
|
|
{
|
2021-05-22 18:45:06 +00:00
|
|
|
text = _("More notifications from bottom menu"),
|
|
|
|
help_text = _("Show notification popups for more bottom menu settings."),
|
|
|
|
checked_func = function()
|
|
|
|
return band(getMask(), Notification.SOURCE_BOTTOM_MENU) == band(Notification.SOURCE_DEFAULT, Notification.SOURCE_BOTTOM_MENU)
|
|
|
|
end,
|
|
|
|
callback = function()
|
2021-05-22 21:47:55 +00:00
|
|
|
if band(getMask(), Notification.SOURCE_BOTTOM_MENU) == band(Notification.SOURCE_DEFAULT, Notification.SOURCE_BOTTOM_MENU) then
|
|
|
|
setMask(bor(
|
|
|
|
Notification.SOURCE_NONE,
|
|
|
|
band(getMask(), Notification.SOURCE_DISPATCHER)))
|
|
|
|
else
|
|
|
|
setMask(bor(
|
2021-05-22 18:45:06 +00:00
|
|
|
band(Notification.SOURCE_DEFAULT, Notification.SOURCE_BOTTOM_MENU),
|
|
|
|
band(getMask(), Notification.SOURCE_DISPATCHER)))
|
2021-05-22 21:47:55 +00:00
|
|
|
end
|
2021-05-22 18:45:06 +00:00
|
|
|
end,
|
2021-05-20 21:14:11 +00:00
|
|
|
},
|
|
|
|
{
|
2021-05-22 18:45:06 +00:00
|
|
|
text = _("Notifications from gestures and profiles"),
|
|
|
|
help_text = _("Show notification popups for changes from gestures and the profiles plugin."),
|
|
|
|
checked_func = function()
|
2021-05-22 21:47:55 +00:00
|
|
|
return band(getMask(), Notification.SOURCE_DISPATCHER) == Notification.SOURCE_DISPATCHER
|
2021-05-22 18:45:06 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-05-22 21:47:55 +00:00
|
|
|
if band(getMask(), Notification.SOURCE_DISPATCHER) == Notification.SOURCE_DISPATCHER then
|
|
|
|
setMask(bor(
|
|
|
|
Notification.SOURCE_NONE,
|
|
|
|
band(getMask(), Notification.SOURCE_BOTTOM_MENU)))
|
|
|
|
else
|
|
|
|
setMask(bor(
|
2021-05-22 18:45:06 +00:00
|
|
|
Notification.SOURCE_DISPATCHER,
|
|
|
|
band(getMask(), Notification.SOURCE_BOTTOM_MENU)))
|
2021-05-22 21:47:55 +00:00
|
|
|
end
|
2021-05-22 18:45:06 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
2021-05-20 21:14:11 +00:00
|
|
|
},
|
2023-03-05 14:21:56 +00:00
|
|
|
{
|
|
|
|
text = _("Show past notifications"),
|
|
|
|
callback = function()
|
|
|
|
local content = require("ui/widget/notification"):getPastMessages()
|
|
|
|
|
|
|
|
if not content or #content == 0 then
|
|
|
|
content = _("No notifications available.")
|
|
|
|
else
|
|
|
|
content = table.concat(content, "\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
local textviewer
|
|
|
|
textviewer = TextViewer:new{
|
|
|
|
title = _("Past notifications"),
|
|
|
|
text = content,
|
|
|
|
justified = false,
|
|
|
|
}
|
|
|
|
UIManager:show(textviewer)
|
|
|
|
end,
|
|
|
|
keep_menu_open = true,
|
|
|
|
},
|
2021-05-20 21:14:11 +00:00
|
|
|
}
|
|
|
|
}
|