[frontlight, kobo, cervantes] Remove auto_warmth (#8154)

The feature is now provided by the "Auto warmth
and night mode" plugin (#8129).
This commit is contained in:
zwim
2021-09-25 23:24:34 +02:00
committed by GitHub
parent 4a2f519600
commit 0c7d174cd7
6 changed files with 20 additions and 292 deletions

View File

@@ -1,7 +1,6 @@
local Blitbuffer = require("ffi/blitbuffer")
local Button = require("ui/widget/button")
local CenterContainer = require("ui/widget/container/centercontainer")
local CheckButton = require("ui/widget/checkbutton")
local CloseButton = require("ui/widget/closebutton")
local Device = require("device")
local FrameContainer = require("ui/widget/container/framecontainer")
@@ -39,7 +38,6 @@ local FrontLightWidget = InputContainer:new{
function FrontLightWidget:init()
self.medium_font_face = Font:getFace("ffont")
self.larger_font_face = Font:getFace("cfont")
self.light_bar = {}
self.screen_width = Screen:getWidth()
self.screen_height = Screen:getHeight()
@@ -71,7 +69,6 @@ function FrontLightWidget:init()
local button_margin = Size.margin.tiny
local button_padding = Size.padding.button
local button_bordersize = Size.border.button
self.auto_nl = false
self.button_width = math.floor(self.screen_width * 0.9 / self.steps) -
2 * (button_margin + button_padding + button_bordersize)
@@ -285,11 +282,9 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
local button_group_down = HorizontalGroup:new{ align = "center" }
local button_group_up = HorizontalGroup:new{ align = "center" }
local warmth_group = HorizontalGroup:new{ align = "center" }
local auto_nl_group = HorizontalGroup:new{ align = "center" }
local padding_span = VerticalSpan:new{ width = self.span }
local enable_button_plus = true
local enable_button_minus = true
local button_color = Blitbuffer.COLOR_WHITE
if self[1] then
--- @note Don't set the same value twice, to play nice with the update() sent by the swipe handler on the FL bar
@@ -298,23 +293,12 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
end
end
if self.powerd.auto_warmth then
enable_button_plus = false
enable_button_minus = false
button_color = Blitbuffer.COLOR_DARK_GRAY
else
if math.floor(num_warmth / self.nl_scale) <= self.nl_min then enable_button_minus = false end
if math.ceil(num_warmth / self.nl_scale) >= self.nl_max then enable_button_plus = false end
end
if self.natural_light and num_warmth then
local curr_warmth_step = math.floor(num_warmth / step)
for i = 0, curr_warmth_step do
table.insert(warmth_group, self.fl_prog_button:new{
text = "",
preselect = curr_warmth_step > 0 and true or false,
enabled = not self.powerd.auto_warmth,
background = curr_warmth_step > 0 and button_color or nil,
callback = function()
self:setProgress(self.fl_cur, step, i * step)
end
@@ -324,7 +308,6 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
for i = curr_warmth_step + 1, self.steps - 1 do
table.insert(warmth_group, self.fl_prog_button:new{
text = "",
enabled = not self.powerd.auto_warmth,
callback = function()
self:setProgress(self.fl_cur, step, i * step)
end
@@ -332,6 +315,9 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
end
end
if math.floor(num_warmth / self.nl_scale) <= self.nl_min then enable_button_minus = false end
if math.ceil(num_warmth / self.nl_scale) >= self.nl_max then enable_button_plus = false end
local text_warmth = TextBoxWidget:new{
text = "\n" .. _("Warmth"),
face = self.medium_font_face,
@@ -367,7 +353,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
text = _("Min"),
margin = Size.margin.small,
radius = 0,
enabled = not self.powerd.auto_warmth,
enabled = true,
width = math.floor(self.screen_width * 0.2),
show_parent = self,
callback = function() self:setProgress(self.fl_cur, step, self.nl_min) end,
@@ -376,7 +362,7 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
text = _("Max"),
margin = Size.margin.small,
radius = 0,
enabled = not self.powerd.auto_warmth,
enabled = true,
width = math.floor(self.screen_width * 0.2),
show_parent = self,
callback = function() self:setProgress(self.fl_cur, step, (self.nl_max * self.nl_scale)) end,
@@ -396,92 +382,10 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
empty_space,
button_max,
}
local checkbutton_auto_nl = CheckButton:new({
text = _("Auto"),
checked = self.powerd.auto_warmth,
max_width = math.floor(self.screen_width * 0.15),
callback = function()
if self.powerd.auto_warmth then
self.powerd.auto_warmth = false
else
self.powerd.auto_warmth = true
self.powerd:calculateAutoWarmth()
end
self:setProgress(self.fl_cur, step)
end
})
local text_auto_nl, text_hour, button_minus_one_hour, button_plus_one_hour
if not self.has_nl_api then
text_auto_nl = TextBoxWidget:new{
--- @todo Implement padding_right (etc.) on TextBoxWidget and remove the two-space hack.
text = _("Max. at:") .. " ",
face = self.larger_font_face,
alignment = "right",
fgcolor = self.powerd.auto_warmth and Blitbuffer.COLOR_BLACK or
Blitbuffer.COLOR_DARK_GRAY,
width = math.floor(self.screen_width * 0.3),
}
text_hour = TextBoxWidget:new{
text = " " .. math.floor(self.powerd.max_warmth_hour) .. ":" ..
self.powerd.max_warmth_hour % 1 * 6 .. "0",
face = self.larger_font_face,
alignment = "center",
fgcolor =self.powerd.auto_warmth and Blitbuffer.COLOR_BLACK or
Blitbuffer.COLOR_DARK_GRAY,
width = math.floor(self.screen_width * 0.15),
}
button_minus_one_hour = Button:new{
text = "",
margin = Size.margin.small,
radius = 0,
enabled = self.powerd.auto_warmth,
width = math.floor(self.screen_width * 0.1),
show_parent = self,
callback = function()
self.powerd.max_warmth_hour =
(self.powerd.max_warmth_hour - 1) % 24
self.powerd:calculateAutoWarmth()
self:setProgress(self.fl_cur, step)
end,
hold_callback = function()
self.powerd.max_warmth_hour =
(self.powerd.max_warmth_hour - 0.5) % 24
self.powerd:calculateAutoWarmth()
self:setProgress(self.fl_cur, step)
end,
}
button_plus_one_hour = Button:new{
text = "",
margin = Size.margin.small,
radius = 0,
enabled = self.powerd.auto_warmth,
width = math.floor(self.screen_width * 0.1),
show_parent = self,
callback = function()
self.powerd.max_warmth_hour =
(self.powerd.max_warmth_hour + 1) % 24
self.powerd:calculateAutoWarmth()
self:setProgress(self.fl_cur, step)
end,
hold_callback = function()
self.powerd.max_warmth_hour =
(self.powerd.max_warmth_hour + 0.5) % 24
self.powerd:calculateAutoWarmth()
self:setProgress(self.fl_cur, step)
end,
}
end
table.insert(vertical_group, text_warmth)
table.insert(button_group_up, button_table_up)
table.insert(button_group_down, button_table_down)
table.insert(auto_nl_group, checkbutton_auto_nl)
table.insert(auto_nl_group, text_auto_nl)
table.insert(auto_nl_group, button_minus_one_hour)
table.insert(auto_nl_group, text_hour)
table.insert(auto_nl_group, button_plus_one_hour)
table.insert(vertical_group, padding_span)
table.insert(vertical_group, button_group_up)
@@ -491,9 +395,6 @@ function FrontLightWidget:addWarmthWidgets(num_warmth, step, vertical_group)
table.insert(vertical_group, button_group_down)
table.insert(vertical_group, padding_span)
if not self.has_nl_api then
table.insert(vertical_group, auto_nl_group)
end
end
function FrontLightWidget:setFrontLightIntensity(num)