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
reviewable/pr6848/r1
Martín Fernández 4 years ago committed by GitHub
parent 43ba8a1173
commit 91708e25d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -227,8 +227,9 @@ function Device:init()
local timeout = G_reader_settings:readSetting("android_screen_timeout") local timeout = G_reader_settings:readSetting("android_screen_timeout")
if timeout then if timeout then
if timeout == C.AKEEP_SCREEN_ON_ENABLED if timeout == C.AKEEP_SCREEN_ON_ENABLED
or (timeout > C.AKEEP_SCREEN_ON_DISABLED or timeout > C.AKEEP_SCREEN_ON_DISABLED
and android.settings.canWrite()) then and android.settings.hasPermission("settings")
then
android.timeout.set(timeout) android.timeout.set(timeout)
end end
end end

@ -268,6 +268,24 @@ if Device:isAndroid() then
callback = function() require("ui/elements/screen_android"):toggleFullscreen() end, callback = function() require("ui/elements/screen_android"):toggleFullscreen() end,
} }
end end
-- ignore battery optimization
if Device.firmware_rev >= 23 then
common_settings.ignore_battery_optimizations = {
text = _("Battery optimizations"),
checked_func = function() return not android.settings.hasPermission("battery") end,
callback = function()
local text = _([[
Go to Android battery optimization settings?
You will be prompted with a permission management screen.
Please don't change any settings unless you know what you're doing.]])
android.settings.requestPermission("battery", text, _("OK"), _("Cancel"))
end,
}
end
end end
if Device:isTouchDevice() then if Device:isTouchDevice() then

@ -47,6 +47,7 @@ local order = {
"autoshutdown", "autoshutdown",
"ignore_sleepcover", "ignore_sleepcover",
"ignore_open_sleepcover", "ignore_open_sleepcover",
"ignore_battery_optimizations",
"mass_storage_settings", -- if Device:canToggleMassStorage() "mass_storage_settings", -- if Device:canToggleMassStorage()
"file_ext_assoc", "file_ext_assoc",
"screenshot", "screenshot",

@ -68,6 +68,7 @@ local order = {
"autoshutdown", "autoshutdown",
"ignore_sleepcover", "ignore_sleepcover",
"ignore_open_sleepcover", "ignore_open_sleepcover",
"ignore_battery_optimizations",
"mass_storage_settings", -- if Device:canToggleMassStorage() "mass_storage_settings", -- if Device:canToggleMassStorage()
"file_ext_assoc", "file_ext_assoc",
"screenshot", "screenshot",

@ -37,7 +37,7 @@ local function canModifyTimeout(timeout)
if timeout == system or timeout == screenOn then if timeout == system or timeout == screenOn then
return true return true
else else
return android.settings.canWrite() return android.settings.hasPermission("settings")
end end
end end
@ -51,16 +51,12 @@ local function saveAndApplyTimeout(timeout)
end end
local function requestWriteSettings() local function requestWriteSettings()
local UIManager = require("ui/uimanager") local text = _([[
local ConfirmBox = require("ui/widget/confirmbox") Allow KOReader to modify system settings?
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."), You 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() android.settings.requestPermission("settings", text, _("Allow"), _("Cancel"))
UIManager:scheduleIn(1, function() UIManager:quit() end)
android.settings.requestWritePermission()
end,
})
end end
local ScreenHelper = {} 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, { table.insert(t, 1, {
text = _("Allow system settings override"), text = _("Allow system settings override"),
enabled_func = function() return not android.settings.canWrite() end, enabled_func = function() return not android.settings.hasPermission("settings") end,
checked_func = function() return android.settings.canWrite() end, checked_func = function() return android.settings.hasPermission("settings") end,
callback = function() requestWriteSettings() end, callback = function() requestWriteSettings() end,
separator = true, separator = true,
}) })

@ -1 +1 @@
Subproject commit c3895090e26ff55a597f25e367cb23b14546d796 Subproject commit f2d946b3b49e728272df4cb56185a2fe57cdb4ff
Loading…
Cancel
Save