mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
* \o/ * Make sure the (debug) event log doesn't end up in the fd table of our child processes... Otherwise, it breaks USBMS. * Close suspicious fds in the Wi-Fi scripts To prevent any and all issues w/ USBMS down the road... * Minor USBMS UI tweaks * Always ask for confirmation to start on USBMS session on plug * Bump base https://github.com/koreader/koreader-base/pull/1161 https://github.com/koreader/koreader-base/pull/1162 https://github.com/koreader/koreader-base/pull/1163 https://github.com/koreader/koreader-base/pull/1165 https://github.com/koreader/koreader-base/pull/1167
56 lines
1.6 KiB
Lua
56 lines
1.6 KiB
Lua
local UIManager = require("ui/uimanager")
|
|
local _ = require("gettext")
|
|
|
|
local MassStorage = {}
|
|
|
|
-- if required a popup will ask before entering mass storage mode
|
|
function MassStorage:requireConfirmation()
|
|
return not G_reader_settings:isTrue("mass_storage_confirmation_disabled")
|
|
end
|
|
|
|
-- mass storage settings menu
|
|
function MassStorage:getSettingsMenuTable()
|
|
return {
|
|
{
|
|
text = _("Disable confirmation popup"),
|
|
help_text = _([[This will NOT affect what happens when you simply plug in the device!]]),
|
|
checked_func = function() return not self:requireConfirmation() end,
|
|
callback = function()
|
|
G_reader_settings:saveSetting("mass_storage_confirmation_disabled", self:requireConfirmation())
|
|
end,
|
|
},
|
|
}
|
|
end
|
|
|
|
-- mass storage actions
|
|
function MassStorage:getActionsMenuTable()
|
|
return {
|
|
{
|
|
text = _("Start USB storage"),
|
|
callback = function()
|
|
self:start()
|
|
end,
|
|
},
|
|
}
|
|
end
|
|
|
|
-- exit KOReader and start mass storage mode.
|
|
function MassStorage:start(always_ask)
|
|
if self:requireConfirmation() or always_ask then
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
|
UIManager:show(ConfirmBox:new{
|
|
text = _("Share storage via USB?"),
|
|
ok_text = _("Share"),
|
|
ok_callback = function()
|
|
UIManager:quit()
|
|
UIManager._exit_code = 86
|
|
end,
|
|
})
|
|
else
|
|
UIManager:quit()
|
|
UIManager._exit_code = 86
|
|
end
|
|
end
|
|
|
|
return MassStorage
|