|
|
|
@ -33,13 +33,11 @@ local FrontLightWidget = InputContainer:new{
|
|
|
|
|
height = nil,
|
|
|
|
|
-- This should stay active during natural light configuration
|
|
|
|
|
is_always_active = true,
|
|
|
|
|
use_system_fl = false,
|
|
|
|
|
rate = Screen.low_pan_rate and 3 or 30, -- Widget update rate.
|
|
|
|
|
last_time = TimeVal:new{}, -- Tracks last update time to prevent update spamming.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 = {}
|
|
|
|
@ -82,7 +80,7 @@ function FrontLightWidget:init()
|
|
|
|
|
margin = button_margin,
|
|
|
|
|
padding = button_padding,
|
|
|
|
|
bordersize = button_bordersize,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
enabled = true,
|
|
|
|
|
width = self.button_width,
|
|
|
|
|
show_parent = self,
|
|
|
|
|
}
|
|
|
|
@ -132,7 +130,6 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
local button_group_down = HorizontalGroup:new{ align = "center" }
|
|
|
|
|
local button_group_up = HorizontalGroup:new{ align = "center" }
|
|
|
|
|
local vertical_group = VerticalGroup:new{ align = "center" }
|
|
|
|
|
self.fl_prog_button.enabled = not self.light_fallback
|
|
|
|
|
local enable_button_plus = true
|
|
|
|
|
local enable_button_minus = true
|
|
|
|
|
if self.natural_light then
|
|
|
|
@ -173,7 +170,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = "-1",
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = enable_button_minus and not self.light_fallback,
|
|
|
|
|
enabled = enable_button_minus,
|
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_cur - 1, step) end,
|
|
|
|
@ -182,7 +179,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = "+1",
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = enable_button_plus and not self.light_fallback,
|
|
|
|
|
enabled = enable_button_plus,
|
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_cur + 1, step) end,
|
|
|
|
@ -197,7 +194,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Min"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
enabled = true,
|
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_min+1, step) end, -- min is 1 (use toggle for 0)
|
|
|
|
@ -206,7 +203,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Max"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
enabled = true,
|
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function() self:setProgress(self.fl_max, step) end,
|
|
|
|
@ -215,7 +212,7 @@ function FrontLightWidget:setProgress(num, step, num_warmth)
|
|
|
|
|
text = _("Toggle"),
|
|
|
|
|
margin = Size.margin.small,
|
|
|
|
|
radius = 0,
|
|
|
|
|
enabled = not self.light_fallback,
|
|
|
|
|
enabled = true,
|
|
|
|
|
width = math.floor(self.screen_width * 0.2),
|
|
|
|
|
show_parent = self,
|
|
|
|
|
callback = function()
|
|
|
|
@ -244,20 +241,6 @@ 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)
|
|
|
|
@ -267,10 +250,6 @@ 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
|
|
|
|
@ -520,13 +499,6 @@ function FrontLightWidget:setFrontLightIntensity(num)
|
|
|
|
|
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()
|
|
|
|
|
end
|
|
|
|
|