android: keep screen awake toggle (using wakelocks) & bump luajit-launcher

This commit is contained in:
Martín Fernández
2019-01-10 03:11:06 +01:00
parent d02c340085
commit 2009ffa12f
4 changed files with 34 additions and 4 deletions

View File

@@ -30,9 +30,9 @@ function Device:init()
logger.dbg("Android application event", ev.code)
if ev.code == C.APP_CMD_SAVE_STATE then
return "SaveState"
elseif ev.code == C.APP_CMD_GAINED_FOCUS then
this.device.screen:refreshFull()
elseif ev.code == C.APP_CMD_WINDOW_REDRAW_NEEDED then
elseif ev.code == C.APP_CMD_GAINED_FOCUS
or ev.code == C.APP_CMD_INIT_WINDOW
or ev.code == C.APP_CMD_WINDOW_REDRAW_NEEDED then
this.device.screen:refreshFull()
end
end,
@@ -60,6 +60,11 @@ function Device:init()
self.isTouchDevice = yes
end
-- check if we disabled support for wakelocks
if G_reader_settings:isTrue("disable_android_wakelock") then
android.setWakeLock(false)
end
Generic.init(self)
end

View File

@@ -125,6 +125,7 @@ else
end
if Device:isAndroid() then
table.insert(common_settings.screen.sub_item_table, require("ui/elements/screen_fullscreen_menu_table"))
table.insert(common_settings.screen.sub_item_table, require("ui/elements/screen_keep_on_menu_table"))
end
if Device:hasKeys() then

View File

@@ -0,0 +1,24 @@
local isAndroid, android = pcall(require, "android")
local _ = require("gettext")
if not isAndroid then return end
local function isWakeLock()
return not G_reader_settings:isTrue("disable_android_wakelock")
end
local function setWakeLock(enable)
G_reader_settings:saveSetting("disable_android_wakelock", not enable)
end
return {
text = _("Keep screen on"),
checked_func = function()
return isWakeLock()
end,
callback = function()
local current = isWakeLock()
android.setWakeLock(not current)
setWakeLock(not current)
end,
}