[UX] Add gesture - poweroff and restart device (#5202)

Also abstract canRestart, canReboot and CanPowerOff.
pull/5215/head
Robert 5 years ago committed by Frans de Jonge
parent aae6acb48c
commit 939538cc25

@ -437,7 +437,7 @@ function FileManagerMenu:setUpdateItemTable()
self:exitOrRestart(function() UIManager:restartKOReader() end) self:exitOrRestart(function() UIManager:restartKOReader() end)
end, end,
} }
if Device:isAndroid() then if not Device:canRestart() then
self.menu_items.exit_menu = self.menu_items.exit self.menu_items.exit_menu = self.menu_items.exit
self.menu_items.exit = nil self.menu_items.exit = nil
self.menu_items.restart_koreader = nil self.menu_items.restart_koreader = nil

@ -58,6 +58,8 @@ local action_strings = {
suspend = _("Suspend"), suspend = _("Suspend"),
exit = _("Exit KOReader"), exit = _("Exit KOReader"),
restart = _("Restart KOReader"), restart = _("Restart KOReader"),
reboot = _("Reboot the device"),
poweroff = _("Power off"),
show_menu = _("Show menu"), show_menu = _("Show menu"),
show_config_menu = _("Show bottom menu"), show_config_menu = _("Show bottom menu"),
show_frontlight_dialog = _("Show frontlight dialog"), show_frontlight_dialog = _("Show frontlight dialog"),
@ -685,7 +687,9 @@ function ReaderGesture:buildMenu(ges, default)
{"night_mode", true}, {"night_mode", true},
{"suspend", true}, {"suspend", true},
{"exit", true}, {"exit", true},
{"restart", not Device:isAndroid()}, {"restart", Device:canRestart()},
{"reboot", Device:canReboot()},
{"poweroff", Device:canPowerOff()},
{"show_menu", true}, {"show_menu", true},
{"show_config_menu", not self.is_docless, true}, {"show_config_menu", not self.is_docless, true},
@ -1415,6 +1419,22 @@ function ReaderGesture:gestureAction(action, ges)
self.ui.menu:exitOrRestart() self.ui.menu:exitOrRestart()
elseif action == "restart" then elseif action == "restart" then
self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end) self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end)
elseif action == "reboot" then
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,
})
elseif action == "poweroff" then
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,
})
elseif action == "zoom_contentwidth" then elseif action == "zoom_contentwidth" then
self.ui:handleEvent(Event:new("SetZoomMode", "contentwidth")) self.ui:handleEvent(Event:new("SetZoomMode", "contentwidth"))
elseif action == "zoom_contentheight" then elseif action == "zoom_contentheight" then

@ -208,7 +208,7 @@ function ReaderMenu:setUpdateItemTable()
self:exitOrRestart(function() UIManager:restartKOReader() end) self:exitOrRestart(function() UIManager:restartKOReader() end)
end, end,
} }
if Device:isAndroid() then if not Device:canRestart() then
self.menu_items.exit_menu = self.menu_items.exit self.menu_items.exit_menu = self.menu_items.exit
self.menu_items.exit = nil self.menu_items.exit = nil
self.menu_items.restart_koreader = nil self.menu_items.restart_koreader = nil

@ -66,6 +66,7 @@ local Device = Generic:new{
hasEinkScreen = function() return android.isEink() end, hasEinkScreen = function() return android.isEink() end,
hasColorScreen = function() return not android.isEink() end, hasColorScreen = function() return not android.isEink() end,
hasFrontlight = yes, hasFrontlight = yes,
canRestart = no,
firmware_rev = android.app.activity.sdkVersion, firmware_rev = android.app.activity.sdkVersion,
display_dpi = android.lib.AConfiguration_getDensity(android.app.config), display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
hasClipboard = yes, hasClipboard = yes,

@ -41,6 +41,8 @@ local Cervantes = Generic:new{
hasOTAUpdates = yes, hasOTAUpdates = yes,
hasKeys = yes, hasKeys = yes,
hasWifiManager = yes, hasWifiManager = yes,
canReboot = yes,
canPowerOff = yes,
-- do we support usb mass storage? -- do we support usb mass storage?
canToggleMassStorage = function() return isMassStorageSupported() end, canToggleMassStorage = function() return isMassStorageSupported() end,

@ -53,6 +53,9 @@ local Device = {
isSonyPRSTUX = no, isSonyPRSTUX = no,
isSDL = no, isSDL = no,
isEmulator = no, isEmulator = no,
canRestart = yes,
canReboot = no,
canPowerOff = no,
-- some devices have part of their screen covered by the bezel -- some devices have part of their screen covered by the bezel
viewport = nil, viewport = nil,

@ -25,6 +25,8 @@ local Kobo = Generic:new{
isTouchDevice = yes, -- all of them are isTouchDevice = yes, -- all of them are
hasOTAUpdates = yes, hasOTAUpdates = yes,
hasWifiManager = yes, hasWifiManager = yes,
canReboot = yes,
canPowerOff = yes,
-- most Kobos have X/Y switched for the touch screen -- most Kobos have X/Y switched for the touch screen
touch_switch_xy = true, touch_switch_xy = true,

@ -12,6 +12,8 @@ local SonyPRSTUX = Generic:new{
hasKeys = yes, hasKeys = yes,
hasOTAUpdates = yes, hasOTAUpdates = yes,
hasWifiManager = yes, hasWifiManager = yes,
canReboot = yes,
canPowerOff = yes,
} }

@ -74,7 +74,7 @@ if Device:isCervantes() or Device:isKindle() or Device:isKobo() then
end, end,
} }
end end
if Device:isCervantes() or Device:isKobo() or Device:isSonyPRSTUX() then if Device:canReboot() then
common_info.reboot = { common_info.reboot = {
text = _("Reboot the device"), text = _("Reboot the device"),
keep_menu_open = true, keep_menu_open = true,
@ -88,6 +88,8 @@ if Device:isCervantes() or Device:isKobo() or Device:isSonyPRSTUX() then
}) })
end end
} }
end
if Device:canPowerOff() then
common_info.poweroff = { common_info.poweroff = {
text = _("Power off"), text = _("Power off"),
keep_menu_open = true, keep_menu_open = true,

Loading…
Cancel
Save