Fold the debug logging flip inside the "Report a bug" entry

Also, implement a Notification source that will *always* be shown,
regardless of user preferences, and use it here.
reviewable/pr11388/r1
NiLuJe 3 months ago
parent 72250daba8
commit 5e4d182608

@ -1,6 +1,8 @@
local BD = require("ui/bidi")
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local InfoMessage = require("ui/widget/infomessage")
local Notification = require("ui/widget/notification")
local UIManager = require("ui/uimanager")
local Version = require("version")
local dbg = require("dbg")
@ -51,38 +53,21 @@ common_info.about = {
})
end
}
common_info.debug_logging = {
text = _("Enable verbose debug logging"),
checked_func = function()
return G_reader_settings:isTrue("debug_verbose")
end,
callback = function()
-- Unlike in the dev options, we flip everything at once.
common_info.report_bug = {
text_func = function()
local label = _("Report a bug")
if G_reader_settings:isTrue("debug_verbose") then
dbg:setVerbose(false)
dbg:turnOff()
G_reader_settings:makeFalse("debug_verbose")
G_reader_settings:makeFalse("debug")
else
dbg:turnOn()
dbg:setVerbose(true)
G_reader_settings:makeTrue("debug")
G_reader_settings:makeTrue("debug_verbose")
label = label .. " " .. _("(verbose logging is enabled)")
end
-- Also unlike the dev options, explicitly ask for a restart,
-- to make sure framebuffer pulls in a logger.dbg ref that doesn't point to noop on init ;).
UIManager:askForRestart()
return label
end,
}
common_info.report_bug = {
text = _("Report a bug"),
keep_menu_open = true,
callback_func = function()
callback = function(touchmenu_instance)
local DataStorage = require("datastorage")
local log_path = string.format("%s/%s", DataStorage:getDataDir(), "crash.log")
local common_msg = T(_("Please report bugs to \nhttps://github.com/koreader/koreader/issues\n\nVersion:\n%1\n\nDetected device:\n%2"),
Version:getCurrentRevision(), Device:info())
local log_msg = T(_("Reproduce the issue with verbose debug logging enabled, and attach %1 to your bug report."), log_path)
local log_msg = T(_("Verbose logs will make our investigations easier. If possible, try to reproduce the issue while it's enabled, and attach %1 to your bug report."), log_path)
if Device:isAndroid() then
local android = require("android")
@ -95,8 +80,37 @@ common_info.report_bug = {
else
msg = common_msg
end
UIManager:show(InfoMessage:new{
UIManager:show(ConfirmBox:new{
text = msg,
icon = "notice-info",
no_ok_button = true,
other_buttons_first = true,
other_buttons = {{
{
text = G_reader_settings:isTrue("debug_verbose") and _("Disable verbose logging") or _("Enable verbose logging"),
callback = function()
-- Flip verbose logging on dismissal
-- Unlike in the dev options, we flip everything at once.
if G_reader_settings:isTrue("debug_verbose") then
dbg:setVerbose(false)
dbg:turnOff()
G_reader_settings:makeFalse("debug_verbose")
G_reader_settings:makeFalse("debug")
Notification:notify(_("Verbose logging disabled"), Notification.SOURCE_ALWAYS_SHOW)
else
dbg:turnOn()
dbg:setVerbose(true)
G_reader_settings:makeTrue("debug")
G_reader_settings:makeTrue("debug_verbose")
Notification:notify(_("Verbose logging enabled"), Notification.SOURCE_ALWAYS_SHOW)
end
touchmenu_instance:updateItems()
-- Also unlike the dev options, explicitly ask for a restart,
-- to make sure framebuffer pulls in a logger.dbg ref that doesn't point to noop on init ;).
UIManager:askForRestart()
end,
}
}},
})
end
}

@ -182,7 +182,6 @@ local order = {
"----------------------------",
"search_menu",
"----------------------------",
"debug_logging",
"report_bug",
"----------------------------",
"system_statistics", -- if enabled (Plugin)

@ -242,7 +242,6 @@ local order = {
"----------------------------",
"search_menu",
"----------------------------",
"debug_logging",
"report_bug",
"----------------------------",
"system_statistics", -- if enabled (Plugin)

@ -51,6 +51,7 @@ local ConfirmBox = InputContainer:extend{
cancel_callback = function() end,
other_buttons = nil,
other_buttons_first = false, -- set to true to place other buttons above Cancel-OK row
no_ok_button = false,
margin = Size.margin.default,
padding = Size.padding.default,
dismissable = true, -- set to false if any button callback is required
@ -120,6 +121,9 @@ function ConfirmBox:init()
end,
},
}}
if self.no_ok_button then
table.remove(buttons[1], 2)
end
if self.other_buttons then -- additional rows
local rownum = self.other_buttons_first and 0 or 1

@ -30,6 +30,7 @@ local SOURCE_BOTTOM_MENU_MORE = 0x0008 -- three dots in bottom menu
local SOURCE_BOTTOM_MENU_PROGRESS = 0x0010 -- progress indicator on bottom menu
local SOURCE_DISPATCHER = 0x0020 -- dispatcher
local SOURCE_OTHER = 0x0040 -- all other sources (e.g. keyboard)
local SOURCE_ALWAYS_SHOW = 0x8000 -- display this, no matter the display preferences
-- All bottom menu bits
local SOURCE_BOTTOM_MENU = SOURCE_BOTTOM_MENU_ICON +
@ -71,6 +72,7 @@ local Notification = InputContainer:extend{
SOURCE_BOTTOM_MENU_PROGRESS = SOURCE_BOTTOM_MENU_PROGRESS,
SOURCE_DISPATCHER = SOURCE_DISPATCHER,
SOURCE_OTHER = SOURCE_OTHER,
SOURCE_ALWAYS_SHOW = SOURCE_ALWAYS_SHOW,
SOURCE_BOTTOM_MENU = SOURCE_BOTTOM_MENU,
@ -79,6 +81,7 @@ local Notification = InputContainer:extend{
SOURCE_MORE = SOURCE_MORE,
SOURCE_DEFAULT = SOURCE_DEFAULT,
SOURCE_ALL = SOURCE_ALL,
_past_messages = {}, -- a static class member to store the N last messages text
}
@ -148,7 +151,7 @@ function Notification:setNotifySource(source)
end
function Notification:resetNotifySource()
self.notify_source = Notification.SOURCE_OTHER
self.notify_source = SOURCE_OTHER
end
function Notification:getNotifySource()
@ -158,8 +161,8 @@ end
-- Display a notification popup if `source` or `self.notify_source` is not masked by the `notification_sources_to_show_mask` setting
function Notification:notify(arg, source, refresh_after)
source = source or self.notify_source
local mask = G_reader_settings:readSetting("notification_sources_to_show_mask") or self.SOURCE_DEFAULT
if source and band(mask, source) ~= 0 then
local mask = G_reader_settings:readSetting("notification_sources_to_show_mask") or SOURCE_DEFAULT
if source and (source == SOURCE_ALWAYS_SHOW or band(mask, source) ~= 0) then
UIManager:show(Notification:new{
text = arg,
})

Loading…
Cancel
Save