InfiniTime.git

commit 53dc9dafe7c4b3a9be89724df2226715d6626651

Author: mark9064 <30447455+mark9064@users.noreply.github.com>

aod: simplify AOD disablement based on notification status

 src/components/settings/Settings.h | 37 ++++---------------------------


diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index 1ab67095084ea0d7c376125e7e9caf32b8ea671d..602de3a585a849cb04b227e6624b021e4d74ca48 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -196,14 +196,6 @@       void SetNotificationStatus(Notification status) {
         if (status != settings.notificationStatus) {
           settingsChanged = true;
         }
-        // Disable always on screen while sleep mode is enabled
-        if (settings.alwaysOnDisplay.enabled) {
-          if (status == Notification::Sleep) {
-            settings.alwaysOnDisplay.state = false;
-          } else {
-            settings.alwaysOnDisplay.state = true;
-          }
-        }
         settings.notificationStatus = status;
       };
 
@@ -222,31 +214,19 @@       uint32_t GetScreenTimeOut() const {
         return settings.screenTimeOut;
       };
 
-      void SetAlwaysOnDisplay(bool state) {
-        if (state != settings.alwaysOnDisplay.state) {
-          settingsChanged = true;
-        }
-        settings.alwaysOnDisplay.state = state;
-      };
-
       bool GetAlwaysOnDisplay() const {
-        return settings.alwaysOnDisplay.state;
+        return settings.alwaysOnDisplay && GetNotificationStatus() != Notification::Sleep;
       };
 
       void SetAlwaysOnDisplaySetting(bool state) {
-        if (state != settings.alwaysOnDisplay.enabled) {
+        if (state != settings.alwaysOnDisplay) {
           settingsChanged = true;
         }
-        settings.alwaysOnDisplay.enabled = state;
-
-        // Don't enable always on if we are currently in notification sleep
-        if (GetNotificationStatus() != Notification::Sleep) {
-          SetAlwaysOnDisplay(state);
-        }
+        settings.alwaysOnDisplay = state;
       }
 
       bool GetAlwaysOnDisplaySetting() const {
-        return settings.alwaysOnDisplay.enabled;
+        return settings.alwaysOnDisplay;
       }
 
       void SetShakeThreshold(uint16_t thresh) {
@@ -323,19 +303,12 @@       Pinetime::Controllers::FS& fs;
 
       static constexpr uint32_t settingsVersion = 0x0008;
 
-      // To enable disabling it during notification sleep, differentiate between
-      // the setting being on, and the setting being set by the user
-      struct alwaysOnDisplayData {
-        bool enabled = false;
-        bool state = false;
-      };
-
       struct SettingsData {
         uint32_t version = settingsVersion;
         uint32_t stepsGoal = 10000;
         uint32_t screenTimeOut = 15000;
 
-        alwaysOnDisplayData alwaysOnDisplay;
+        bool alwaysOnDisplay = false;
 
         ClockType clockType = ClockType::H24;
         WeatherFormat weatherFormat = WeatherFormat::Metric;