Add checked tag for keepalive plugin

pull/2493/head
Zijie He 7 years ago committed by Qingping Hou
parent 9b605c95a0
commit 8549d98805

@ -41,7 +41,7 @@ table.insert(common_settings, {
},
})
table.insert(common_settings, {
text = _("Save Document"),
text = _("Save document"),
sub_item_table = {
{
text = _("Prompt"),

@ -5,38 +5,60 @@ local UIManager = require("ui/uimanager")
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local _ = require("gettext")
local function showConfirmBox(disable)
local menuItem = {
text = _("Keep alive"),
checked = false,
}
local disable
local enable
local function showConfirmBox()
UIManager:show(ConfirmBox:new{
text = _("The system won't sleep when this message is showing.\nPress \"Stay Alive\" if you prefer to keep system on even after closing this notification. *It will drain the battery.*\n\nIf for any reasons KOReader died before \"Close\" is pressed, please start and close KeepAlive plugin again to ensure settings are reset."),
text = _("The system won't sleep when this message is showing.\nPress \"Stay alive\" if you prefer to keep system on even after closing this notification. *It will drain the battery.*\n\nIf for any reasons KOReader died before \"Close\" is pressed, please start and close KeepAlive plugin again to ensure settings are reset."),
ok_text = _("Close"),
ok_callback = disable,
cancel_text = _("Stay Alive"),
ok_callback = function()
disable()
menuItem.checked =false
end,
cancel_text = _("Stay alive"),
cancel_callback = function()
menuItem.checked = true
end,
})
end
local menuItem = {
text = _("Keep Alive"),
}
local disable
if Device:isKobo() then
disable = function() UIManager:_startAutoSuspend() end
menuItem.callback = function()
UIManager:_stopAutoSuspend()
showConfirmBox(disable)
end
enable = function() UIManager:_stopAutoSuspend() end
elseif Device:isKindle() then
disable = function()
os.execute("lipc-set-prop com.lab126.powerd preventScreenSaver 0")
end
menuItem.callback = function()
enable = function()
os.execute("lipc-set-prop com.lab126.powerd preventScreenSaver 1")
showConfirmBox(disable)
end
elseif Device:isSDL() then
local InfoMessage = require("ui/widget/infomessage")
disable = function()
UIManager:show(InfoMessage:new{
text = _("This is a dummy implementation of 'disable' function.")
})
end
enable = function()
UIManager:show(InfoMessage:new{
text = _("This is a dummy implementation of 'enable' function.")
})
end
else
return { disabled = true, }
end
menuItem.callback = function()
enable()
showConfirmBox()
end
local KeepAlive = WidgetContainer:new{
name = "keepalive",
}

@ -20,7 +20,7 @@ local _ = require("gettext")
local StorageStat = WidgetContainer:new{
name = "storagestat",
menuItem = {
text = _("Storage Statistics"),
text = _("Storage statistics"),
callback = function()
local std_out = io.popen(
"df -h | sed -r 's/ +/ /g' | grep " .. filter ..

Loading…
Cancel
Save