2017-09-03 13:40:50 +00:00
local ConfirmBox = require ( " ui/widget/confirmbox " )
2014-11-21 14:41:14 +00:00
local Device = require ( " device " )
local InfoMessage = require ( " ui/widget/infomessage " )
local UIManager = require ( " ui/uimanager " )
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 = { }
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
2017-04-15 12:45:56 +00:00
local version = require ( " version " ) : getCurrentRevision ( )
2017-03-03 06:41:10 +00:00
common_info.version = {
2014-11-21 14:41:14 +00:00
text = _ ( " Version " ) ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2014-11-21 14:41:14 +00:00
callback = function ( )
UIManager : show ( InfoMessage : new {
2017-04-03 21:52:47 +00:00
text = version ,
2014-11-21 14:41:14 +00:00
} )
end
2017-02-28 21:46:32 +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-06-24 07:55:31 +00:00
common_info.more_plugins = {
text = _ ( " More plugins " ) ,
}
2018-08-11 20:47:33 +00:00
common_info.device = {
text = _ ( " Device " ) ,
}
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
}
2017-04-03 21:52:47 +00:00
common_info.about = {
text = _ ( " About " ) ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2017-04-03 21:52:47 +00:00
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/ " ) , version ) ,
2019-08-14 15:01:26 +00:00
icon_file = " resources/ko-icon.png " ,
alpha = true ,
2017-04-03 21:52:47 +00:00
} )
end
}
common_info.report_bug = {
text = _ ( " Report a bug " ) ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2014-11-21 14:41:14 +00:00
callback = function ( )
2019-06-18 23:57:52 +00:00
local device = Device.model
if Device : isAndroid ( ) then
device = Device : info ( )
end
2014-11-21 14:41:14 +00:00
UIManager : show ( InfoMessage : new {
2017-04-03 21:52:47 +00:00
text = T ( _ ( " Please report bugs to \n https://github.com/koreader/koreader/issues \n \n Version: \n %1 \n \n Detected device: \n %2 " ) ,
2019-06-18 23:57:52 +00:00
version , device ) ,
2014-11-21 14:41:14 +00:00
} )
end
2017-02-28 21:46:32 +00:00
}
2017-09-03 13:40:50 +00:00
2018-10-31 22:48:36 +00:00
if Device : isCervantes ( ) or Device : isKindle ( ) or Device : isKobo ( ) then
2017-09-03 13:40:50 +00:00
common_info.sleep = {
text = _ ( " Sleep " ) ,
callback = function ( )
UIManager : suspend ( )
end ,
}
end
2019-08-15 12:49:15 +00:00
if Device : canReboot ( ) then
2017-05-14 16:43:08 +00:00
common_info.reboot = {
text = _ ( " Reboot the device " ) ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2017-05-14 16:43:08 +00:00
callback = function ( )
2017-09-03 13:40:50 +00:00
UIManager : show ( ConfirmBox : new {
text = _ ( " Are you sure you want to reboot the device? " ) ,
ok_text = _ ( " Reboot " ) ,
ok_callback = function ( )
UIManager : nextTick ( UIManager.reboot_action )
end ,
} )
2017-05-14 16:43:08 +00:00
end
}
2019-08-15 12:49:15 +00:00
end
if Device : canPowerOff ( ) then
2017-05-14 16:43:08 +00:00
common_info.poweroff = {
text = _ ( " Power off " ) ,
2018-09-04 21:55:58 +00:00
keep_menu_open = true ,
2017-05-14 16:43:08 +00:00
callback = function ( )
2017-09-03 13:40:50 +00:00
UIManager : show ( ConfirmBox : new {
text = _ ( " Are you sure you want to power off the device? " ) ,
ok_text = _ ( " Power off " ) ,
ok_callback = function ( )
UIManager : nextTick ( UIManager.poweroff_action )
end ,
} )
2017-05-14 16:43:08 +00:00
end
}
end
2014-11-21 14:41:14 +00:00
return common_info