From 8549d988053bd5b8e82347b96645da79cc20fb23 Mon Sep 17 00:00:00 2001 From: Zijie He Date: Mon, 16 Jan 2017 14:05:59 -0800 Subject: [PATCH] Add checked tag for keepalive plugin --- .../elements/common_settings_menu_table.lua | 2 +- plugins/keepalive.koplugin/main.lua | 52 +++++++++++++------ plugins/storagestat.koplugin/main.lua | 2 +- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/frontend/ui/elements/common_settings_menu_table.lua b/frontend/ui/elements/common_settings_menu_table.lua index bae257e62..4b4f148a7 100644 --- a/frontend/ui/elements/common_settings_menu_table.lua +++ b/frontend/ui/elements/common_settings_menu_table.lua @@ -41,7 +41,7 @@ table.insert(common_settings, { }, }) table.insert(common_settings, { - text = _("Save Document"), + text = _("Save document"), sub_item_table = { { text = _("Prompt"), diff --git a/plugins/keepalive.koplugin/main.lua b/plugins/keepalive.koplugin/main.lua index 0981dace2..485479a48 100644 --- a/plugins/keepalive.koplugin/main.lua +++ b/plugins/keepalive.koplugin/main.lua @@ -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", } diff --git a/plugins/storagestat.koplugin/main.lua b/plugins/storagestat.koplugin/main.lua index 41bad65d0..3171445fb 100644 --- a/plugins/storagestat.koplugin/main.lua +++ b/plugins/storagestat.koplugin/main.lua @@ -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 ..