2020-01-04 00:18:51 +00:00
local BD = require ( " ui/bidi " )
2024-01-16 17:06:15 +00:00
local ConfirmBox = require ( " ui/widget/confirmbox " )
2014-11-21 14:41:14 +00:00
local Device = require ( " device " )
2024-02-28 05:29:33 +00:00
local Event = require ( " ui/event " )
2014-11-21 14:41:14 +00:00
local InfoMessage = require ( " ui/widget/infomessage " )
2024-01-16 17:06:15 +00:00
local Notification = require ( " ui/widget/notification " )
2014-11-21 14:41:14 +00:00
local UIManager = require ( " ui/uimanager " )
2020-08-29 03:20:28 +00:00
local Version = require ( " version " )
2024-01-16 04:55:53 +00:00
local dbg = require ( " dbg " )
2022-09-27 23:10:50 +00:00
local lfs = require ( " libs/libkoreader-lfs " )
2014-11-21 14:41:14 +00:00
local _ = require ( " gettext " )
2017-04-03 21:52:47 +00:00
local T = require ( " ffi/util " ) . template
2014-11-21 14:41:14 +00:00
local common_info = { }
2024-02-28 05:29:33 +00:00
-- tools tab
common_info.more_tools = {
text = _ ( " More tools " ) ,
}
-- main tab
2018-10-06 05:55:35 +00:00
if Device : hasOTAUpdates ( ) then
2014-11-21 14:41:14 +00:00
local OTAManager = require ( " ui/otamanager " )
2017-03-03 06:41:10 +00:00
common_info.ota_update = OTAManager : getOTAMenuTable ( )
2014-11-21 14:41:14 +00:00
end
2024-02-28 05:29:33 +00:00
2017-03-03 06:41:10 +00:00
common_info.help = {
2014-11-21 14:41:14 +00:00
text = _ ( " Help " ) ,
2017-04-03 21:52:47 +00:00
}
2017-04-15 12:45:56 +00:00
common_info.quickstart_guide = {
text = _ ( " Quickstart guide " ) ,
callback = function ( )
2017-04-24 06:27:29 +00:00
local QuickStart = require ( " ui/quickstart " )
2017-04-15 12:45:56 +00:00
local ReaderUI = require ( " apps/reader/readerui " )
ReaderUI : showReader ( QuickStart : getQuickStart ( ) )
end
}
2024-02-28 05:29:33 +00:00
common_info.search_menu = {
text = _ ( " Menu search " ) ,
2017-04-03 21:52:47 +00:00
callback = function ( )
2024-02-28 05:29:33 +00:00
UIManager : sendEvent ( Event : new ( " ShowMenuSearch " ) )
end ,
keep_menu_open = true ,
2017-04-03 21:52:47 +00:00
}
2024-01-16 17:06:15 +00:00
common_info.report_bug = {
text_func = function ( )
local label = _ ( " Report a bug " )
2024-01-16 04:55:53 +00:00
if G_reader_settings : isTrue ( " debug_verbose " ) then
2024-01-16 17:06:15 +00:00
label = label .. " " .. _ ( " (verbose logging is enabled) " )
2024-01-16 04:55:53 +00:00
end
2024-01-16 17:06:15 +00:00
return label
2024-01-16 04:55:53 +00:00
end ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2024-01-16 17:06:15 +00:00
callback = function ( touchmenu_instance )
2021-05-22 23:20:13 +00:00
local DataStorage = require ( " datastorage " )
local log_path = string.format ( " %s/%s " , DataStorage : getDataDir ( ) , " crash.log " )
local common_msg = T ( _ ( " Please report bugs to \n https://github.com/koreader/koreader/issues \n \n Version: \n %1 \n \n Detected device: \n %2 " ) ,
Version : getCurrentRevision ( ) , Device : info ( ) )
2024-01-16 17:06:15 +00:00
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 )
2021-05-22 23:20:13 +00:00
if Device : isAndroid ( ) then
local android = require ( " android " )
2021-06-07 15:13:34 +00:00
android.dumpLogs ( )
2021-05-22 23:20:13 +00:00
end
local msg
if lfs.attributes ( log_path , " mode " ) == " file " then
msg = string.format ( " %s \n \n %s " , common_msg , log_msg )
else
msg = common_msg
end
2024-01-16 17:06:15 +00:00
UIManager : show ( ConfirmBox : new {
2021-05-22 23:20:13 +00:00
text = msg ,
2024-01-16 17:06:15 +00:00
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 ,
}
} } ,
2014-11-21 14:41:14 +00:00
} )
end
2017-02-28 21:46:32 +00:00
}
2024-02-28 05:29:33 +00:00
common_info.version = {
text = T ( _ ( " Version: %1 " ) , Version : getShortVersion ( ) ) ,
keep_menu_open = true ,
callback = function ( )
UIManager : show ( InfoMessage : new {
text = Version : getCurrentRevision ( ) ,
} )
end
}
common_info.about = {
text = _ ( " About " ) ,
keep_menu_open = true ,
callback = function ( )
UIManager : show ( InfoMessage : new {
text = T ( _ ( " KOReader %1 \n \n A document viewer for E Ink devices. \n \n Licensed under Affero GPL v3. All dependencies are free software. \n \n http://koreader.rocks " ) , BD.ltr ( Version : getCurrentRevision ( ) ) ) ,
icon = " koreader " ,
} )
end
}
2017-09-03 13:40:50 +00:00
2014-11-21 14:41:14 +00:00
return common_info