diff --git a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py index 698e9442..4c60c70e 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py @@ -1,6 +1,6 @@ import lvgl as lv -from mpos import Intent, AppManager, SettingActivity, SettingsActivity, TimeZone +from mpos import Intent, AppearanceManager, AppManager, SettingActivity, SettingsActivity, TimeZone from bootloader import ResetIntoBootloader from calibrate_imu import CalibrateIMUActivity @@ -11,29 +11,29 @@ class Settings(SettingsActivity): """Override getIntent to provide prefs and settings via Intent extras""" def getIntent(self): theme_colors = [ + ("Amethyst", "9966cc"), ("Aqua Blue", "00ffff"), ("Bitcoin Orange", "f0a010"), - ("Coral Red", "ff7f50"), - ("Dark Slate", "2f4f4f"), - ("Forest Green", "228b22"), - ("Piggy Pink", "ff69b4"), - ("Matrix Green", "03a062"), - ("Midnight Blue", "191970"), - ("Nostr Purple", "ff00ff"), - ("Saddle Brown", "8b4513"), - ("Sky Blue", "87ceeb"), - ("Solarized Yellow", "b58900"), - ("Vivid Violet", "9f00ff"), - ("Amethyst", "9966cc"), ("Burnt Orange", "cc5500"), ("Charcoal Gray", "36454f"), + ("Coral Red", "ff7f50"), ("Crimson", "dc143c"), + ("Dark Slate", "2f4f4f"), ("Emerald", "50c878"), + ("Forest Green", "228b22"), ("Goldenrod", "daa520"), ("Indigo", "4b0082"), ("Lime", "00ff00"), + ("Matrix Green", "03a062"), + ("Midnight Blue", "191970"), + ("Nostr Purple", "ff00ff"), + ("Piggy Pink", "ff69b4"), + ("Saddle Brown", "8b4513"), + ("Sky Blue", "87ceeb"), + ("Solarized Yellow", "b58900"), ("Teal", "008080"), - ("Turquoise", "40e0d0") + ("Turquoise", "40e0d0"), + ("Vivid Violet", "9f00ff") ] intent = Intent() from mpos import SharedPreferences @@ -41,7 +41,7 @@ class Settings(SettingsActivity): intent.putExtra("settings", [ # Basic settings, alphabetically: {"title": "Light/Dark Theme", "key": "theme_light_dark", "ui": "radiobuttons", "ui_options": [("Light", "light"), ("Dark", "dark")], "changed_callback": self.theme_changed}, - {"title": "Theme Color", "key": "theme_primary_color", "placeholder": "HTML hex color, like: EC048C", "ui": "dropdown", "ui_options": theme_colors, "changed_callback": self.theme_changed}, + {"title": "Theme Color", "key": "theme_primary_color", "placeholder": "HTML hex color, like: EC048C", "ui": "dropdown", "ui_options": theme_colors, "changed_callback": self.theme_changed, "default_value": AppearanceManager.DEFAULT_PRIMARY_COLOR}, {"title": "Timezone", "key": "timezone", "ui": "dropdown", "ui_options": [(tz, tz) for tz in TimeZone.get_timezones()], "changed_callback": lambda *args: TimeZone.refresh_timezone_preference()}, # Advanced settings, alphabetically: {"title": "Auto Start App", "key": "auto_start_app", "ui": "radiobuttons", "ui_options": [(app.name, app.fullname) for app in AppManager.get_app_list()]}, diff --git a/internal_filesystem/lib/mpos/ui/appearance_manager.py b/internal_filesystem/lib/mpos/ui/appearance_manager.py index 87e1a98e..f8d85a76 100644 --- a/internal_filesystem/lib/mpos/ui/appearance_manager.py +++ b/internal_filesystem/lib/mpos/ui/appearance_manager.py @@ -43,6 +43,7 @@ class AppearanceManager: # ========== UI Dimensions ========== # These are constants that define the layout of the UI NOTIFICATION_BAR_HEIGHT = 24 # Height of the notification bar in pixels + DEFAULT_PRIMARY_COLOR = "f0a010" # ========== Private Class Variables ========== # State variables shared across all "instances" (there is only one logical instance) @@ -77,20 +78,20 @@ class AppearanceManager: theme_light_dark = prefs.get_string("theme_light_dark", "light") theme_dark_bool = (theme_light_dark == "dark") cls._is_light_mode = not theme_dark_bool - - # Load primary color preference - primary_color = lv.theme_get_color_primary(None) - color_string = prefs.get_string("theme_primary_color") - if color_string: - try: - color_string = color_string.replace("0x", "").replace("#", "").strip().lower() - color_int = int(color_string, 16) - print(f"[AppearanceManager] Setting primary color: {color_int}") - primary_color = lv.color_hex(color_int) - cls._primary_color = primary_color - except Exception as e: - print(f"[AppearanceManager] Converting color setting '{color_string}' failed: {e}") - + + primary_color = lv.theme_get_color_primary(None) # Load primary color from LVGL default + + # Try to get a valid color from the preferences + color_string = prefs.get_string("theme_primary_color", cls.DEFAULT_PRIMARY_COLOR) + try: + color_string = color_string.replace("0x", "").replace("#", "").strip().lower() + color_int = int(color_string, 16) + print(f"[AppearanceManager] Setting primary color: {color_int}") + primary_color = lv.color_hex(color_int) + cls._primary_color = primary_color + except Exception as e: + print(f"[AppearanceManager] Converting color setting '{color_string}' failed: {e}") + # Initialize LVGL theme with loaded settings # Get the display driver from the active screen screen = lv.screen_active() @@ -102,7 +103,7 @@ class AppearanceManager: theme_dark_bool, lv.font_montserrat_12 ) - + # Reset keyboard button fix style so it's recreated with new theme colors cls._keyboard_button_fix_style = None