From 6717852825c7906004cf5ef83d1c23fe63996b01 Mon Sep 17 00:00:00 2001 From: zwim <36999612+zwim@users.noreply.github.com> Date: Thu, 3 Nov 2022 06:32:47 +0100 Subject: [PATCH] AutoWarmth: add message on user change of night mode (#9715) --- plugins/autowarmth.koplugin/main.lua | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugins/autowarmth.koplugin/main.lua b/plugins/autowarmth.koplugin/main.lua index 49f915e8b..4a47977be 100644 --- a/plugins/autowarmth.koplugin/main.lua +++ b/plugins/autowarmth.koplugin/main.lua @@ -170,11 +170,47 @@ end AutoWarmth._onEnterStandby = AutoWarmth._onSuspend +function AutoWarmth:_onToggleNightMode() + if self.control_nightmode and not self.hide_nightmode_warning then + local RadioButtonWidget = require("ui/widget/radiobuttonwidget") + local radio_buttons = { + {{ + text = _("Show this warning again"), + provider = function() end + }}, + {{ + text = _("Hide the warning until the next book is opened"), + provider = function() + self.hide_nightmode_warning = true + end, + }}, + {{ + text = _("Disable AutoWarmth's nightmode control"), + provider = function() + self.control_nightmode = false + G_reader_settings:makeFalse("autowarmth_control_nightmode") + end, + }}, + } + UIManager:show(RadioButtonWidget:new{ + title_text = _("Night mode changed"), + info_text = _("The AutoWarmth plugin might change it again."), + width_factor = 0.9, + radio_buttons = radio_buttons, + callback = function(radio) + radio.provider() + end, + }) + end +end + function AutoWarmth:setEventHandlers() self.onResume = self._onResume self.onSuspend = self._onSuspend self.onEnterStandby = self._onEnterStandby self.onLeaveStandby = self._onLeaveStandby + self.onToggleNightMode = self._onToggleNightMode + self.onSetNightMode = self._onToggleNightMode end function AutoWarmth:clearEventHandlers() @@ -182,6 +218,8 @@ function AutoWarmth:clearEventHandlers() self.onSuspend = nil self.onEnterStandby = nil self.onLeaveStandby = nil + self.onToggleNightMode = nil + self.onSetNightMode = nil end -- from_resume ... true if called from onResume