mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Dispatcher: Allow toggling USBMS (#11123)
It's right next to actual exit/restart actions, so it'll never ask for confirmation.
This commit is contained in:
@@ -328,6 +328,14 @@ function DeviceListener:onToggleKeyRepeat(toggle)
|
||||
Device:toggleKeyRepeat(G_reader_settings:nilOrFalse("input_no_key_repeat"))
|
||||
end
|
||||
|
||||
function DeviceListener:onRequestUSBMS()
|
||||
local MassStorage = require("ui/elements/mass_storage")
|
||||
-- It already takes care of the canToggleMassStorage cap check for us
|
||||
-- NOTE: Never request confirmation, it's sorted right next to exit, restart & friends in Dispatcher,
|
||||
-- and they don't either...
|
||||
MassStorage:start(false)
|
||||
end
|
||||
|
||||
function DeviceListener:onRestart()
|
||||
self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end)
|
||||
end
|
||||
|
||||
@@ -66,6 +66,7 @@ local settingsList = {
|
||||
|
||||
-- Device
|
||||
exit_screensaver = {category="none", event="ExitScreensaver", title=_("Exit screensaver"), device=true},
|
||||
start_usbms = {category="none", event="RequestUSBMS", title=_("Start USB storage"), device=true, condition=Device:canToggleMassStorage()},
|
||||
suspend = {category="none", event="RequestSuspend", title=_("Suspend"), device=true, condition=Device:canSuspend()},
|
||||
restart = {category="none", event="Restart", title=_("Restart KOReader"), device=true, condition=Device:canRestart()},
|
||||
reboot = {category="none", event="RequestReboot", title=_("Reboot the device"), device=true, condition=Device:canReboot()},
|
||||
@@ -281,6 +282,7 @@ local dispatcher_menu_order = {
|
||||
|
||||
-- Device
|
||||
"exit_screensaver",
|
||||
"start_usbms",
|
||||
"suspend",
|
||||
"restart",
|
||||
"reboot",
|
||||
|
||||
@@ -43,18 +43,25 @@ function MassStorage:getActionsMenuTable()
|
||||
text = _("Start USB storage"),
|
||||
enabled_func = function() return self:isEnabled() end,
|
||||
callback = function()
|
||||
self:start(true)
|
||||
self:start(false)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- exit KOReader and start mass storage mode.
|
||||
function MassStorage:start(never_ask)
|
||||
function MassStorage:start(with_confirmation)
|
||||
if not Device:canToggleMassStorage() or not self:isEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
if not never_ask and self:requireConfirmation() then
|
||||
local ask
|
||||
if with_confirmation ~= nil then
|
||||
ask = with_confirmation
|
||||
else
|
||||
ask = self:requireConfirmation()
|
||||
end
|
||||
|
||||
if ask then
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
self.usbms_widget = ConfirmBox:new{
|
||||
text = _("Share storage via USB?"),
|
||||
|
||||
Reference in New Issue
Block a user