Some more KoboUSBMS tweaks (#6566)

* Enable i18n in KoboUSBMS

* Rejig the "No confirmation" USBMS setting:

In now *only* affects the USB plug in event.
The menu entry will never show the popup (clicking on it should already
be confirmation enough, that, yes, we really would like to do that,
please ;)).

Also, enable said plug in behavior on Cervantes, too ;).

* Add an option to disable USBMS entirely

* Bump base

https://github.com/koreader/koreader-base/pull/1170
reviewable/pr6579/r1
NiLuJe 4 years ago committed by GitHub
parent 29d83b67d3
commit 1919764825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 42819cc85d9e3ec82c4ad56cc4fea33519114f06
Subproject commit eb88e0e0339adcedab6d813b9c2fc4182239a99b

@ -45,10 +45,7 @@ if Device:canToggleMassStorage() then
}
-- mass storage actions
common_settings.mass_storage_actions = {
text = _("Start USB storage"),
callback = function() MassStorage:start() end,
}
common_settings.mass_storage_actions = MassStorage:getActionsMenuTable()
end
-- This affects the topmenu, we want to be able to access it even if !Device:setDateTime()

@ -1,3 +1,4 @@
local Device = require("device")
local UIManager = require("ui/uimanager")
local _ = require("gettext")
@ -8,35 +9,50 @@ function MassStorage:requireConfirmation()
return not G_reader_settings:isTrue("mass_storage_confirmation_disabled")
end
function MassStorage:isEnabled()
return not G_reader_settings:isTrue("mass_storage_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!]]),
help_text = _([[This will ONLY affect what happens when you 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,
},
{
text = _("Disable mass storage functionality"),
help_text = _([[In case your device uses an unsupported setup where you know it won't work properly.]]),
checked_func = function() return not self:isEnabled() end,
callback = function()
G_reader_settings:saveSetting("mass_storage_disabled", self:isEnabled())
end,
},
}
end
-- mass storage actions
function MassStorage:getActionsMenuTable()
return {
{
text = _("Start USB storage"),
callback = function()
self:start()
end,
},
text = _("Start USB storage"),
enabled_func = function() return self:isEnabled() end,
callback = function()
self:start(true)
end,
}
end
-- exit KOReader and start mass storage mode.
function MassStorage:start(always_ask)
if self:requireConfirmation() or always_ask then
function MassStorage:start(never_ask)
if not Device:canToggleMassStorage() or not self:isEnabled() then
return
end
if not never_ask and self:requireConfirmation() then
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:show(ConfirmBox:new{
text = _("Share storage via USB?"),

@ -161,7 +161,7 @@ function UIManager:init()
else
-- Potentially start an USBMS session
local MassStorage = require("ui/elements/mass_storage")
MassStorage:start(true)
MassStorage:start()
end
end
self.event_handlers["NotCharging"] = function()
@ -315,6 +315,10 @@ function UIManager:init()
self:_beforeCharging()
if Device.screen_saver_mode then
self:suspend()
else
-- Potentially start an USBMS session
local MassStorage = require("ui/elements/mass_storage")
MassStorage:start()
end
end
self.event_handlers["USbPlugOut"] = function()

@ -365,9 +365,16 @@ while [ ${RETURN_VALUE} -ne 0 ]; do
mkdir -p "/tmp/usbms"
./tar xzf "./data/KoboUSBMS.tar.gz" -C "/tmp/usbms"
# Then siphon KOReader's language for i18n...
if grep -q '\["language"\]' 'settings.reader.lua' 2>/dev/null; then
usbms_lang="$(grep '\["language"\]' 'settings.reader.lua' | cut -d'"' -f4)"
else
usbms_lang="C"
fi
# Here we go!
cd "/tmp/usbms" || continue
if ! ./usbms; then
if ! env LANGUAGE="${usbms_lang}" ./usbms; then
# Hu, oh, something went wrong... Stay around for 90s (enough time to look at the syslog over Wi-Fi), and then shutdown.
sleep 90
poweroff -f

Loading…
Cancel
Save