|
|
|
@ -31,9 +31,11 @@ local FrontLightWidget = InputContainer:new{
|
|
|
|
|
height = nil,
|
|
|
|
|
-- This should stay active during natural light configuration
|
|
|
|
|
is_always_active = true,
|
|
|
|
|
use_system_fl = false,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function FrontLightWidget:init()
|
|
|
|
|
self.light_fallback = self.use_system_fl and G_reader_settings:nilOrTrue("light_fallback")
|
|
|
|
|
self.medium_font_face = Font:getFace("ffont")
|
|
|
|
|
self.larger_font_face = Font:getFace("cfont")
|
|
|
|
|
self.light_bar = {}
|
|
|
|
@ -76,7 +78,7 @@ function FrontLightWidget:init()
|
|
|
|
|
margin = button_margin,
|
|
|
|
|
padding = button_padding,
|
|
|
|
|
bordersize = button_bordersize,
|
|
|
|
|
enabled = true,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
width = self.button_width,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
}
|
|
|
|
@ -117,6 +119,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
local button_group_up = HorizontalGroup:new{ align = "center" }
|
|
|
|
|
local fl_group = HorizontalGroup:new{ align = "center" }
|
|
|
|
|
local vertical_group = VerticalGroup:new{ align = "center" }
|
|
|
|
|
self.fl_prog_button.enabled = not self.light_fallback
|
|
|
|
|
local set_fl
|
|
|
|
|
local enable_button_plus = true
|
|
|
|
|
local enable_button_minus = true
|
|
|
|
@ -136,6 +139,14 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
else
|
|
|
|
|
self.powerd:setIntensity(set_fl)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not self.light_fallback and self.fl_cur >= 0 then
|
|
|
|
|
G_reader_settings:saveSetting("fl_last_level", self.fl_cur * 10)
|
|
|
|
|
elseif self.light_fallback then
|
|
|
|
|
G_reader_settings:saveSetting("fl_last_level", nil)
|
|
|
|
|
Device:setScreenBrightness(-1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- get back the real level (different from set_fl if untoggle)
|
|
|
|
|
self.fl_cur = self.powerd:frontlightIntensity()
|
|
|
|
|
-- and update our step_num with it for accurate progress bar
|
|
|
|
@ -176,7 +187,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = "-1",
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = enable_button_minus,
|
|
|
|
|
enabled = enable_button_minus and not self.light_fallback,
|
|
|
|
|
width = self.screen_width * 0.20,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_cur - 1, step) end,
|
|
|
|
@ -185,7 +196,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = "+1",
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = enable_button_plus,
|
|
|
|
|
enabled = enable_button_plus and not self.light_fallback,
|
|
|
|
|
width = self.screen_width * 0.20,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_cur + 1, step) end,
|
|
|
|
@ -200,7 +211,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Min"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = true,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
width = self.screen_width * 0.20,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_min+1, step) end, -- min is 1 (use toggle for 0)
|
|
|
|
@ -209,7 +220,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Max"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = true,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
width = self.screen_width * 0.20,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_max, step) end,
|
|
|
|
@ -218,7 +229,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Toggle"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = true,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
width = self.screen_width * 0.20,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function()
|
|
|
|
@ -247,6 +258,20 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
-- widgets below.
|
|
|
|
|
table.insert(vertical_group, text_br)
|
|
|
|
|
end
|
|
|
|
|
local system_level_checkbutton
|
|
|
|
|
system_level_checkbutton = CheckButton:new{
|
|
|
|
|
text = _("Use system settings"),
|
|
|
|
|
checked = self.light_fallback,
|
|
|
|
|
callback = function()
|
|
|
|
|
if system_level_checkbutton.checked then
|
|
|
|
|
self.light_fallback = false
|
|
|
|
|
else
|
|
|
|
|
self.light_fallback = true
|
|
|
|
|
end
|
|
|
|
|
G_reader_settings:saveSetting("light_fallback", self.light_fallback)
|
|
|
|
|
self:setProgress(self.fl_cur, step)
|
|
|
|
|
end,
|
|
|
|
|
}
|
|
|
|
|
table.insert(button_group_up, button_table_up)
|
|
|
|
|
table.insert(button_group_down, button_table_down)
|
|
|
|
|
table.insert(vertical_group, padding_span)
|
|
|
|
@ -256,6 +281,10 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
table.insert(vertical_group, padding_span)
|
|
|
|
|
table.insert(vertical_group, button_group_down)
|
|
|
|
|
table.insert(vertical_group, padding_span)
|
|
|
|
|
if self.use_system_fl then
|
|
|
|
|
table.insert(vertical_group, system_level_checkbutton)
|
|
|
|
|
table.insert(vertical_group, padding_span)
|
|
|
|
|
end
|
|
|
|
|
if self.natural_light then
|
|
|
|
|
-- If the device supports natural light, add the widgets for 'warmth',
|
|
|
|
|
-- as well as a 'Configure' button for devices *without* a mixer
|
|
|
|
|