mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Footer: add Warmth as footer item (#8060)
This commit is contained in:
@@ -43,6 +43,7 @@ local MODE = {
|
||||
book_chapter = 13,
|
||||
bookmark_count = 14,
|
||||
chapter_progress = 15,
|
||||
frontlight_warmth = 16,
|
||||
}
|
||||
|
||||
local symbol_prefix = {
|
||||
@@ -62,6 +63,8 @@ local symbol_prefix = {
|
||||
chapter_time_to_read = C_("FooterLetterPrefix", "TC:"),
|
||||
-- @translators This is the footer letter prefix for frontlight level.
|
||||
frontlight = C_("FooterLetterPrefix", "L:"),
|
||||
-- @translators This is the footer letter prefix for frontlight warmth (redshift).
|
||||
frontlight_warmth = C_("FooterLetterPrefix", "R:"),
|
||||
-- @translators This is the footer letter prefix for memory usage.
|
||||
mem_usage = C_("FooterLetterPrefix", "M:"),
|
||||
-- @translators This is the footer letter prefix for Wi-Fi status.
|
||||
@@ -77,6 +80,7 @@ local symbol_prefix = {
|
||||
book_time_to_read = "⏳",
|
||||
chapter_time_to_read = BD.mirroredUILayout() and "⥖" or "⤻",
|
||||
frontlight = "☼",
|
||||
frontlight_warmth = "💡",
|
||||
mem_usage = "",
|
||||
wifi_status = "",
|
||||
wifi_status_off = "",
|
||||
@@ -144,6 +148,23 @@ local footerTextGeneratorMap = {
|
||||
end
|
||||
end
|
||||
end,
|
||||
frontlight_warmth = function(footer)
|
||||
local symbol_type = footer.settings.item_prefix
|
||||
local prefix = symbol_prefix[symbol_type].frontlight_warmth
|
||||
local powerd = Device:getPowerDevice()
|
||||
if powerd:isFrontlightOn() then
|
||||
local warmth = powerd:getWarmth()
|
||||
if warmth then
|
||||
return (prefix .. " %d%%"):format(warmth)
|
||||
end
|
||||
else
|
||||
if footer.settings.all_at_once and footer.settings.hide_empty_generators then
|
||||
return ""
|
||||
else
|
||||
return T(_("%1 Off"), prefix)
|
||||
end
|
||||
end
|
||||
end,
|
||||
battery = function(footer)
|
||||
local symbol_type = footer.settings.item_prefix
|
||||
local prefix = symbol_prefix[symbol_type].battery
|
||||
@@ -869,6 +890,7 @@ function ReaderFooter:textOptionTitles(option)
|
||||
and T(_("Book time to read (%1)"),symbol_prefix[symbol].book_time_to_read) or _("Book time to read"),
|
||||
chapter_time_to_read = T(_("Chapter time to read (%1)"), symbol_prefix[symbol].chapter_time_to_read),
|
||||
frontlight = T(_("Frontlight level (%1)"), symbol_prefix[symbol].frontlight),
|
||||
frontlight_warmth = T(_("Frontlight warmth (%1)"), symbol_prefix[symbol].frontlight_warmth),
|
||||
mem_usage = T(_("KOReader memory usage (%1)"), symbol_prefix[symbol].mem_usage),
|
||||
wifi_status = T(_("Wi-Fi status (%1)"), symbol_prefix[symbol].wifi_status),
|
||||
book_title = _("Book title"),
|
||||
@@ -1788,6 +1810,9 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
if Device:hasFrontlight() then
|
||||
table.insert(sub_items, getMinibarOption("frontlight"))
|
||||
end
|
||||
if Device:hasNaturalLight() then
|
||||
table.insert(sub_items, getMinibarOption("frontlight_warmth"))
|
||||
end
|
||||
table.insert(sub_items, getMinibarOption("mem_usage"))
|
||||
if Device:hasFastWifiStatusQuery() then
|
||||
table.insert(sub_items, getMinibarOption("wifi_status"))
|
||||
|
||||
@@ -50,6 +50,7 @@ function AndroidPowerD:setWarmth(warmth)
|
||||
self.fl_warmth = warmth
|
||||
local new_warmth = math.floor(warmth * self.fl_warmth_max / 100)
|
||||
android.setScreenWarmth(new_warmth)
|
||||
self:stateChanged()
|
||||
end
|
||||
|
||||
function AndroidPowerD:getWarmth()
|
||||
|
||||
@@ -146,6 +146,12 @@ function CervantesPowerD:setWarmth(warmth)
|
||||
end
|
||||
self.fl_warmth = warmth or self.fl_warmth
|
||||
self.fl:setWarmth(self.fl_warmth)
|
||||
self:stateChanged()
|
||||
end
|
||||
|
||||
function CervantesPowerD:getWarmth()
|
||||
if self.fl == nil then return end
|
||||
return self.fl_warmth
|
||||
end
|
||||
|
||||
function CervantesPowerD:calculateAutoWarmth()
|
||||
|
||||
@@ -60,7 +60,7 @@ function DeviceListener:onShowWarmth(value)
|
||||
if powerd.fl_warmth ~= nil then
|
||||
-- powerd.fl_warmth holds the warmth-value in the internal koreader scale [0,100]
|
||||
-- powerd.fl_warmth_max is the maximum value the hardware accepts
|
||||
Notification:notify(T(_("Warmth set to %1."), math.floor(powerd.fl_warmth/100*powerd.fl_warmth_max)))
|
||||
Notification:notify(T(_("Warmth set to %1%."), math.floor(powerd.fl_warmth)))
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -252,6 +252,7 @@ function KoboPowerD:setWarmth(warmth)
|
||||
if self.fl == nil then return end
|
||||
if not warmth and self.auto_warmth then
|
||||
self:calculateAutoWarmth()
|
||||
self:stateChanged()
|
||||
end
|
||||
self.fl_warmth = warmth or self.fl_warmth
|
||||
-- Don't turn the light back on on legacy NaturalLight devices just for the sake of setting the warmth!
|
||||
@@ -259,6 +260,14 @@ function KoboPowerD:setWarmth(warmth)
|
||||
-- On older ones, calling setWarmth *will* actually set the brightness, too!
|
||||
if self.device:hasNaturalLightMixer() or self:isFrontlightOnHW() then
|
||||
self.fl:setWarmth(self.fl_warmth)
|
||||
self:stateChanged()
|
||||
end
|
||||
end
|
||||
|
||||
function KoboPowerD:getWarmth()
|
||||
if self.fl == nil then return end
|
||||
if self.device:hasNaturalLight() then
|
||||
return self.fl_warmth
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -64,6 +64,13 @@ function PocketBookPowerD:setWarmth(level)
|
||||
if self.fl_warmth then
|
||||
self.fl_warmth = level or self.fl_warmth
|
||||
inkview.SetFrontlightColor(self.fl_warmth)
|
||||
self:stateChanged()
|
||||
end
|
||||
end
|
||||
|
||||
function PocketBookPowerD:getWarmth()
|
||||
if self.fl_warmth then
|
||||
return self.fl_warmth
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,12 @@ end
|
||||
function SDLPowerD:setWarmth(level)
|
||||
require("logger").info("set warmth to", level)
|
||||
self.fl_warmth = level or self.fl_warmth
|
||||
self:stateChanged()
|
||||
end
|
||||
|
||||
function SDLPowerD:getWarmth()
|
||||
if self.hw_intensity == 0 then return end
|
||||
return self.fl_warmth
|
||||
end
|
||||
|
||||
function SDLPowerD:getCapacityHW()
|
||||
|
||||
Reference in New Issue
Block a user