mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[plugin] AutoWarmth: add more gestures for autowarmth activation (#11946)
Fixes #11274.
This commit is contained in:
@@ -16,6 +16,7 @@ local FFIUtil = require("ffi/util")
|
||||
local Font = require("ui/font")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local Math = require("optmath")
|
||||
local Notification = require("ui/widget/notification")
|
||||
local SpinWidget = require("ui/widget/spinwidget")
|
||||
local SunTime = require("suntime")
|
||||
@@ -118,6 +119,15 @@ function AutoWarmth:onDispatcherRegisterActions()
|
||||
{category="none", event="ShowEphemeris", title=_("Show ephemeris"), general=true})
|
||||
Dispatcher:registerAction("auto_warmth_off",
|
||||
{category="none", event="AutoWarmthOff", title=_("Auto warmth off"), screen=true})
|
||||
Dispatcher:registerAction("auto_warmth_activate_sun",
|
||||
{category="none", event="AutoWarmthMode", arg=activate_sun, title=_("Auto warmth use sun position"), screen=true})
|
||||
Dispatcher:registerAction("auto_warmth_activate_schedule",
|
||||
{category="none", event="AutoWarmthMode", arg=activate_schedule, title=_("Auto warmth use schedule"), screen=true})
|
||||
Dispatcher:registerAction("auto_warmth_activate_closer_midnight",
|
||||
{category="none", event="AutoWarmthMode", arg=activate_closer_midnight, title=_("Auto warmth use closer midnight"), screen=true})
|
||||
Dispatcher:registerAction("auto_warmth_activate_closer_noon",
|
||||
{category="none", event="AutoWarmthMode", arg=activate_closer_noon, title=_("Auto warmth use closer noon"), screen=true})
|
||||
|
||||
Dispatcher:registerAction("auto_warmth_cycle_trough",
|
||||
{category="none", event="AutoWarmthMode", title=_("Auto warmth cycle through modes"), screen=true})
|
||||
end
|
||||
@@ -127,17 +137,19 @@ function AutoWarmth:onShowEphemeris()
|
||||
end
|
||||
|
||||
function AutoWarmth:onAutoWarmthOff()
|
||||
self.activate = 0
|
||||
G_reader_settings:saveSetting("autowarmth_activate", self.activate)
|
||||
Notification:notify(_("Auto warmth turned off"))
|
||||
self:scheduleMidnightUpdate()
|
||||
self:onAutoWarmthMode(0)
|
||||
end
|
||||
|
||||
function AutoWarmth:onAutoWarmthMode()
|
||||
if self.activate > 0 then
|
||||
self.activate = self.activate - 1
|
||||
-- select one mode of autowarmth directly
|
||||
function AutoWarmth:onAutoWarmthMode(forced_method)
|
||||
if forced_method then
|
||||
self.activate = Math.clamp(forced_method, 0, activate_closer_midnight)
|
||||
else
|
||||
self.activate = activate_closer_midnight
|
||||
if self.activate > 0 then
|
||||
self.activate = self.activate - 1
|
||||
else
|
||||
self.activate = activate_closer_midnight
|
||||
end
|
||||
end
|
||||
local notify_text
|
||||
if self.activate == 0 then
|
||||
|
||||
Reference in New Issue
Block a user