Frontlight - Add checkbox use system settings (#5307)

See: https://github.com/koreader/koreader/issues/5205#issuecomment-526935357

Devices with `hasLightLevelFallback = true` (for now Android) has extra checkbutton `Use system settings`. Default unchecked.
This commit is contained in:
Robert
2019-09-04 20:52:24 +02:00
committed by Frans de Jonge
parent 2cd9b50137
commit ae50569055
6 changed files with 83 additions and 10 deletions

View File

@@ -66,6 +66,7 @@ local Device = Generic:new{
hasEinkScreen = function() return android.isEink() end,
hasColorScreen = function() return not android.isEink() end,
hasFrontlight = yes,
hasLightLevelFallback = yes,
canRestart = no,
firmware_rev = android.app.activity.sdkVersion,
display_dpi = android.lib.AConfiguration_getDensity(android.app.config),
@@ -194,6 +195,12 @@ function Device:init()
android.setVolumeKeysIgnored(true);
end
-- check if we enable a custom light level for this activity
local last_value = G_reader_settings:readSetting("fl_last_level")
if type(last_value) == "number" and last_value >= 0 then
Device:setScreenBrightness(last_value)
end
Generic.init(self)
end
@@ -233,6 +240,10 @@ function Device:setViewport(x,y,w,h)
self.screen:setViewport(viewport)
end
function Device:setScreenBrightness(level)
android.setScreenBrightness(level)
end
function Device:toggleFullscreen()
local api = android.app.activity.sdkVersion
if api >= 19 then