android-luajit-launcher refactor (#6821)

- Lcd devices won't use the SurfaceView, just the good old native content/window (except AndroidTv and ChromeOS)
- All android dialogs will be presented with Material Design on recent devices.
- Added an option to device settings to manage application battery optimization.
- Permissions that require the user to go to a settings page will be presented with a native android dialog.
- bump android-luajit-launcher

- Changes under the hood: koreader/android-luajit-launcher#257
This commit is contained in:
Martín Fernández
2020-11-04 19:15:07 +01:00
committed by GitHub
parent 43ba8a1173
commit 91708e25d0
6 changed files with 34 additions and 17 deletions

View File

@@ -37,7 +37,7 @@ local function canModifyTimeout(timeout)
if timeout == system or timeout == screenOn then
return true
else
return android.settings.canWrite()
return android.settings.hasPermission("settings")
end
end
@@ -51,16 +51,12 @@ local function saveAndApplyTimeout(timeout)
end
local function requestWriteSettings()
local UIManager = require("ui/uimanager")
local ConfirmBox = require("ui/widget/confirmbox")
UIManager:show(ConfirmBox:new{
text = _("Allow KOReader to modify system settings?\n\nYou will be prompted with a permission management screen. You'll need to give KOReader permission and then restart the program."),
ok_text = _("Allow"),
ok_callback = function()
UIManager:scheduleIn(1, function() UIManager:quit() end)
android.settings.requestWritePermission()
end,
})
local text = _([[
Allow KOReader to modify system settings?
You will be prompted with a permission management screen. You'll need to give KOReader permission and then restart the program.]])
android.settings.requestPermission("settings", text, _("Allow"), _("Cancel"))
end
local ScreenHelper = {}
@@ -172,11 +168,11 @@ function ScreenHelper:getTimeoutMenuTable()
},
}
if not android.settings.canWrite() then
if not android.settings.hasPermission("settings") then
table.insert(t, 1, {
text = _("Allow system settings override"),
enabled_func = function() return not android.settings.canWrite() end,
checked_func = function() return android.settings.canWrite() end,
enabled_func = function() return not android.settings.hasPermission("settings") end,
checked_func = function() return android.settings.hasPermission("settings") end,
callback = function() requestWriteSettings() end,
separator = true,
})