Improve Settings UI

This commit is contained in:
Thomas Farstrike
2026-03-18 11:54:45 +01:00
parent 8db23976f7
commit 4262bacc42
2 changed files with 15 additions and 5 deletions
@@ -8,13 +8,13 @@ class HotspotSettings(Activity):
Hotspot configuration app.
Uses SettingsActivity to render and edit hotspot preferences stored under
com.micropythonos.system.hotspot.
com.micropythonos.hotspot.
"""
DEFAULTS = {
"ssid": "MicroPythonOS",
"password": "",
"authmode": "wpa2",
"authmode": "none",
}
status_label = None
@@ -24,7 +24,8 @@ class HotspotSettings(Activity):
prefs = None
def onCreate(self):
self.prefs = SharedPreferences("com.micropythonos.system.hotspot", defaults=self.DEFAULTS)
self.prefs = SharedPreferences("com.micropythonos.hotspot", defaults=self.DEFAULTS)
self.ui_prefs = SharedPreferences("com.micropythonos.hotspot")
screen = lv.obj()
screen.set_style_border_width(0, lv.PART.MAIN)
screen.set_style_pad_all(DisplayMetrics.pct_of_width(3), lv.PART.MAIN)
@@ -88,7 +89,7 @@ class HotspotSettings(Activity):
def open_settings(self, event):
intent = Intent(activity_class=SettingsActivity)
intent.putExtra("prefs", self.prefs)
intent.putExtra("prefs", self.ui_prefs)
intent.putExtra("settings", self._settings_entries())
self.startActivity(intent)
@@ -98,11 +99,13 @@ class HotspotSettings(Activity):
"title": "Network Name (SSID)",
"key": "ssid",
"placeholder": "Hotspot SSID",
"default_value": self.DEFAULTS["ssid"],
},
{
"title": "Password",
"key": "password",
"placeholder": "Leave empty for open network",
"default_value": self.DEFAULTS["password"],
"should_show": self.should_show_password,
},
{
@@ -113,6 +116,7 @@ class HotspotSettings(Activity):
("None", "none"),
("WPA2", "wpa2"),
],
"default_value": self.DEFAULTS["authmode"],
"changed_callback": self.toggle_hotspot,
},
]
@@ -124,6 +128,8 @@ class HotspotSettings(Activity):
def should_show_password(self, setting):
authmode = self.prefs.get_string("authmode", None)
if authmode is None:
authmode = self.DEFAULTS["authmode"]
return authmode != "none"
def _format_security_label(self, authmode):
@@ -13,6 +13,7 @@ class WebServerSettings(Activity):
def onCreate(self):
self.prefs = SharedPreferences(WebServer.PREFS_NAMESPACE, defaults=WebServer.DEFAULTS)
self.ui_prefs = SharedPreferences(WebServer.PREFS_NAMESPACE)
screen = lv.obj()
screen.set_style_border_width(0, lv.PART.MAIN)
screen.set_style_pad_all(DisplayMetrics.pct_of_width(3), lv.PART.MAIN)
@@ -85,7 +86,7 @@ class WebServerSettings(Activity):
def open_settings(self, event):
intent = Intent(activity_class=SettingsActivity)
intent.putExtra("prefs", self.prefs)
intent.putExtra("prefs", self.ui_prefs)
intent.putExtra(
"settings",
[
@@ -94,18 +95,21 @@ class WebServerSettings(Activity):
"key": "autostart",
"ui": "radiobuttons",
"ui_options": [("On", "True"), ("Off", "False")],
"default_value": WebServer.DEFAULTS["autostart"],
"changed_callback": self.settings_changed,
},
{
"title": "Port",
"key": "port",
"placeholder": "WebServer port, e.g. 7890",
"default_value": WebServer.DEFAULTS["port"],
"changed_callback": self.settings_changed,
},
{
"title": "Password",
"key": "password",
"placeholder": "Max 9 characters",
"default_value": WebServer.DEFAULTS["password"],
"changed_callback": self.settings_changed,
},
],