Skip to content

Commit 677ad7c

Browse files
WiFi app: improve perferences handling
1 parent 517f56a commit 677ad7c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- AppStore app: add support for BadgeHub backend
77
- OSUpdate app: show download speed
88
- WiFi app: new "Add network" functionality for out-of-range or hidden networks
9+
- WiFi app: add "Forget" button to delete networks
910
- API: add TaskManager that wraps asyncio
1011
- API: add DownloadManager that uses TaskManager
1112
- API: use aiorepl to eliminate another thread

internal_filesystem/builtin/apps/com.micropythonos.wifi/assets/wifi.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
class WiFi(Activity):
2424

25+
prefs = None
26+
2527
scan_button_scan_text = "Rescan"
2628
scan_button_scanning_text = "Scanning..."
2729

@@ -66,8 +68,12 @@ def onCreate(self):
6668
def onResume(self, screen):
6769
print("wifi.py onResume")
6870
super().onResume(screen)
71+
72+
if not self.prefs:
73+
self.prefs = mpos.config.SharedPreferences("com.micropythonos.system.wifiservice")
74+
6975
global access_points
70-
access_points = mpos.config.SharedPreferences("com.micropythonos.system.wifiservice").get_dict("access_points")
76+
access_points = self.prefs.get_dict("access_points")
7177
if len(self.ssids) == 0:
7278
if WifiService.wifi_busy == False:
7379
WifiService.wifi_busy = True
@@ -172,7 +178,7 @@ def edit_network_result_callback(self, result):
172178
if data:
173179
ssid = data.get("ssid")
174180
global access_points
175-
editor = mpos.config.SharedPreferences("com.micropythonos.system.wifiservice").edit()
181+
editor = self.prefs.edit()
176182
forget = data.get("forget")
177183
if forget:
178184
del access_points[ssid]

0 commit comments

Comments
 (0)