public override void Cleanup()
 {
     if (ResumeEventEnabled)
     {
         PowerEventHandler.DeregisterResumeEvent();
     }
     if (DarkThemeOnBatteryEnabled)
     {
         PowerEventHandler.DeregisterThemeEvent();
     }
 }
Example #2
0
        /// <summary>
        /// Registers or deregisters events based on their enabled setting
        /// </summary>
        public void UpdateEventStates()
        {
            if (builder.Config.Events.DarkThemeOnBattery)
            {
                PowerEventHandler.RegisterThemeEvent();
            }
            else
            {
                PowerEventHandler.DeregisterThemeEvent();
            }

            if (builder.Config.Events.SystemResumeTrigger)
            {
                PowerEventHandler.RegisterResumeEvent();
            }
            else
            {
                PowerEventHandler.DeregisterResumeEvent();
            }
        }
        public override void Fire()
        {
            if (builder.Config.Events.DarkThemeOnBattery)
            {
                if (!DarkThemeOnBatteryEnabled)
                {
                    PowerEventHandler.RegisterThemeEvent();
                    Logger.Info("enabling event handler for dark mode on battery state discharging");
                    DarkThemeOnBatteryEnabled = true;
                }
            }
            else
            {
                if (DarkThemeOnBatteryEnabled)
                {
                    PowerEventHandler.DeregisterThemeEvent();
                    Logger.Info("disabling event handler for dark mode on battery state discharging");
                    DarkThemeOnBatteryEnabled = false;
                }
            }

            if (builder.Config.Tunable.SystemResumeTrigger)
            {
                if (!ResumeEventEnabled)
                {
                    PowerEventHandler.RegisterResumeEvent();
                    Logger.Info("enabling theme refresh at system resume");
                    ResumeEventEnabled = true;
                }
            }
            else
            {
                if (ResumeEventEnabled)
                {
                    PowerEventHandler.DeregisterResumeEvent();
                    Logger.Info("disabling theme refresh at system resume");
                    ResumeEventEnabled = false;
                }
            }
        }