From 8db23976f735b55bea0cb52315086da2c916fd78 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Wed, 18 Mar 2026 11:40:41 +0100 Subject: [PATCH] Improve settings UI --- .../assets/settings.py | 24 ++++++++++++++++--- .../lib/mpos/ui/settings_activity.py | 17 ++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) 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 19b8ef73..78bd1237 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py @@ -57,9 +57,27 @@ class Settings(SettingsActivity): from mpos import SharedPreferences intent.putExtra("prefs", SharedPreferences("com.micropythonos.settings")) intent.putExtra("settings", [ - {"title": "Wi-Fi", "key": "wifi_settings", "ui": "activity", "activity_class": LaunchWiFi}, - {"title": "Hotspot", "key": "hotspot_settings", "ui": "activity", "activity_class": LaunchHotspot}, - {"title": "WebServer", "key": "webserver_settings", "ui": "activity", "activity_class": LaunchWebServer}, + { + "title": "Wi-Fi", + "key": "wifi_settings", + "ui": "activity", + "activity_class": LaunchWiFi, + "placeholder": "Scan and connect to Wi-Fi", + }, + { + "title": "Hotspot", + "key": "hotspot_settings", + "ui": "activity", + "activity_class": LaunchHotspot, + "placeholder": "Standalone Wi-Fi access point", + }, + { + "title": "WebServer", + "key": "webserver_settings", + "ui": "activity", + "activity_class": LaunchWebServer, + "placeholder": "WebREPL, password, port etc", + }, # 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, "default_value": AppearanceManager.DEFAULT_PRIMARY_COLOR}, diff --git a/internal_filesystem/lib/mpos/ui/settings_activity.py b/internal_filesystem/lib/mpos/ui/settings_activity.py index 000ab027..064133f0 100644 --- a/internal_filesystem/lib/mpos/ui/settings_activity.py +++ b/internal_filesystem/lib/mpos/ui/settings_activity.py @@ -62,7 +62,22 @@ class SettingsActivity(Activity): # Value label (smaller, below title) value = lv.label(setting_cont) - value.set_text(self.prefs.get_string(setting["key"], "(not set)" if not setting.get("dont_persist") else "(not persisted)")) + if setting.get("activity_class"): + placeholder = setting.get("placeholder") or "" + value_text = placeholder + elif setting.get("dont_persist"): + value_text = "(not persisted)" + else: + stored_value = self.prefs.get_string(setting["key"]) + if stored_value is None: + default_value = setting.get("default_value") + if default_value is not None: + value_text = f"(defaults to {default_value})" + else: + value_text = "(not set)" + else: + value_text = stored_value + value.set_text(value_text) value.set_style_text_font(lv.font_montserrat_12, lv.PART.MAIN) value.set_style_text_color(lv.color_hex(0x666666), lv.PART.MAIN) value.set_pos(0, 20)