[UX] Add exit menu (#3167)

* fixes #2898 (prevents accidentally triggering reboot or poweroff)
  Add ConfirmBox before reboot/power off
* increases clarity by preventing second page
* add "sleep" menu entry
* Add exit menu hold callback
pull/3169/head
Frans de Jonge 7 years ago committed by GitHub
parent c24d75f18c
commit 177485f84f

@ -266,6 +266,12 @@ function FileManagerMenu:setUpdateItemTable()
for id, common_setting in pairs(require("ui/elements/common_info_menu_table")) do
self.menu_items[id] = common_setting
end
self.menu_items.exit_menu = {
text = _("Exit"),
hold_callback = function()
self:exitOrRestart()
end,
}
self.menu_items.exit = {
text = _("Exit"),
callback = function()

@ -184,13 +184,18 @@ function ReaderMenu:setUpdateItemTable()
self.menu_items[id] = common_setting
end
self.menu_items.exit_menu = {
text = _("Exit"),
hold_callback = function()
self:exitOrRestart()
end,
}
self.menu_items.exit = {
text = _("Exit"),
callback = function()
self:exitOrRestart()
end,
}
self.menu_items.restart_koreader = {
text = _("Restart KOReader"),
callback = function()

@ -1,3 +1,4 @@
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager")
@ -52,17 +53,38 @@ common_info.report_bug = {
})
end
}
if Device:isKindle() or Device:isKobo() then
common_info.sleep = {
text = _("Sleep"),
callback = function()
UIManager:suspend()
end,
}
end
if Device:isKobo() then
common_info.reboot = {
text = _("Reboot the device"),
callback = function()
UIManager:nextTick(UIManager.reboot_action)
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,
})
end
}
common_info.poweroff = {
text = _("Power off"),
callback = function()
UIManager:nextTick(UIManager.poweroff_action)
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,
})
end
}
end

@ -68,17 +68,14 @@ local order = {
"history",
"open_last_document",
"----------------------------",
"system_statistics",
"----------------------------",
"ota_update", --[[ if Device:isKindle() or Device:isKobo() or
Device:isPocketBook() or Device:isAndroid() ]]--
"version",
"help",
"system_statistics",
"----------------------------",
"restart_koreader",
"poweroff", -- if Device:isKobo()
"reboot", -- if Device:isKobo()
"----------------------------",
"exit",
"exit_menu",
},
help = {
"quickstart_guide",
@ -87,6 +84,15 @@ local order = {
"----------------------------",
"about",
},
exit_menu = {
"restart_koreader",
"----------------------------",
"sleep", -- if Device:isKindle() or Device:isKobo()
"poweroff", -- if Device:isKobo()
"reboot", -- if Device:isKobo()
"----------------------------",
"exit",
}
}
return order

@ -85,17 +85,14 @@ local order = {
"book_status",
"book_info",
"----------------------------",
"system_statistics",
"----------------------------",
"ota_update", --[[ if Device:isKindle() or Device:isKobo() or
Device:isPocketBook() or Device:isAndroid() ]]--
"version",
"help",
"system_statistics",
"----------------------------",
"restart_koreader",
"poweroff", -- if Device:isKobo()
"reboot", -- if Device:isKobo()
"----------------------------",
"exit",
"exit_menu",
},
help = {
"quickstart_guide",
@ -104,6 +101,15 @@ local order = {
"----------------------------",
"about",
},
exit_menu = {
"restart_koreader",
"----------------------------",
"sleep", -- if Device:isKindle() or Device:isKobo()
"poweroff", -- if Device:isKobo()
"reboot", -- if Device:isKobo()
"----------------------------",
"exit",
}
}
return order

@ -121,6 +121,7 @@ function MenuSorter:sort(item_table, order)
changed = true
local sub_menu_content = menu_table[sub_menu]
sub_menu_position.text = sub_menu_content.text
sub_menu_position.hold_callback = sub_menu_content.hold_callback
sub_menu_position.sub_item_table = sub_menu_content
-- remove reference from top level output
menu_table[sub_menu] = nil

Loading…
Cancel
Save