Use PluginShare to share the keepalive state (#7416)

* use pluginshare to share keepalive state

* oops, formatting error
pull/7434/head
Hzj_jie 3 years ago committed by GitHub
parent 29dbb98b8b
commit 1cd478fd70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,12 +1,13 @@
local ConfirmBox = require("ui/widget/confirmbox") local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device") local Device = require("device")
local PluginShare = require("pluginshare")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer") local WidgetContainer = require("ui/widget/container/widgetcontainer")
local _ = require("gettext") local _ = require("gettext")
local menuItem = { local menuItem = {
text = _("Keep alive"), text = _("Keep alive"),
checked = false, checked_func = function() return PluginShare.keepalive end,
} }
local disable local disable
@ -18,17 +19,16 @@ local function showConfirmBox()
cancel_text = _("Close"), cancel_text = _("Close"),
cancel_callback = function() cancel_callback = function()
disable() disable()
menuItem.checked =false PluginShare.keepalive = false
end, end,
ok_text = _("Stay alive"), ok_text = _("Stay alive"),
ok_callback = function() ok_callback = function()
menuItem.checked = true PluginShare.keepalive = true
end, end,
}) })
end end
if Device:isCervantes() or Device:isKobo() then if Device:isCervantes() or Device:isKobo() then
local PluginShare = require("pluginshare")
enable = function() PluginShare.pause_auto_suspend = true end enable = function() PluginShare.pause_auto_suspend = true end
disable = function() PluginShare.pause_auto_suspend = false end disable = function() PluginShare.pause_auto_suspend = false end
elseif Device:isKindle() then elseif Device:isKindle() then

Loading…
Cancel
Save