You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Fix wificonf
This commit is contained in:
@@ -24,7 +24,8 @@ class MainActivity(mpos.apps.Activity):
|
||||
main_screen.set_style_radius(0, 0)
|
||||
main_screen.set_pos(0, mpos.ui.NOTIFICATION_BAR_HEIGHT) # leave some margin for the notification bar
|
||||
main_screen.set_size(lv.pct(100), lv.pct(100))
|
||||
main_screen.set_style_pad_all(10, 0)
|
||||
main_screen.set_style_pad_hor(5, 0)
|
||||
main_screen.set_style_pad_ver(mpos.ui.NOTIFICATION_BAR_HEIGHT, 0)
|
||||
main_screen.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
|
||||
self.setContentView(main_screen)
|
||||
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
{
|
||||
"name": "WiFi",
|
||||
"publisher": "ACME Inc",
|
||||
"short_description": "Wireless Network Configuration",
|
||||
"long_description": "",
|
||||
"icon_url": "http://demo.lnpiggy.com:2121/apps/com.example.wificonf_0.0.2.mpk_icon_64x64.png",
|
||||
"download_url": "http://demo.lnpiggy.com:2121/apps/com.example.wificonf_0.0.2.mpk",
|
||||
"fullname": "com.example.wificonf",
|
||||
"version": "0.0.2",
|
||||
"entrypoint": "assets/wificonf.py",
|
||||
"category": "wificonf"
|
||||
"publisher": "MicroPythonOS",
|
||||
"short_description": "WiFi Network Configuration",
|
||||
"long_description": "Scans for wireless networks, shows a list of SSIDs, allows for password entry, and connecting.",
|
||||
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.wificonf/icons/com.micropythonos.wificonf_0.0.3_64x64.png",
|
||||
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.wificonf/mpks/com.micropythonos.wificonf_0.0.3.mpk",
|
||||
"fullname": "com.micropythonos.wificonf",
|
||||
"version": "0.0.3",
|
||||
"category": "wificonf",
|
||||
"activities": [
|
||||
{
|
||||
"entrypoint": "assets/wificonf.py",
|
||||
"classname": "WiFiConfig",
|
||||
"intent_filters": [
|
||||
{
|
||||
"action": "main",
|
||||
"category": "launcher"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -247,6 +247,9 @@ class Activity:
|
||||
def startActivity(self, intent):
|
||||
ActivityNavigator.startActivity(intent)
|
||||
|
||||
def startActivityForResult(self, intent, result_callback):
|
||||
ActivityNavigator.startActivityForResult(intent, result_callback)
|
||||
|
||||
def initError(self, e):
|
||||
print(f"WARNING: You might have inherited from Activity with a custom __init__() without calling super().__init__(). Got AttributeError: {e}")
|
||||
|
||||
@@ -290,31 +293,53 @@ class Intent:
|
||||
|
||||
|
||||
class ActivityNavigator:
|
||||
|
||||
@staticmethod
|
||||
def startActivity(intent):
|
||||
if not isinstance(intent, Intent):
|
||||
raise ValueError("Must provide an Intent")
|
||||
if intent.action: # Implicit intent: resolve handlers
|
||||
if intent.action: # Implicit intent: resolve handlers
|
||||
handlers = APP_REGISTRY.get(intent.action, [])
|
||||
if len(handlers) == 1:
|
||||
intent.activity_class = handlers[0]
|
||||
ActivityNavigator._launch_activity(intent)
|
||||
elif handlers:
|
||||
_show_chooser(intent, handlers)
|
||||
ActivityNavigator._show_chooser(intent, handlers)
|
||||
else:
|
||||
raise ValueError(f"No handlers for action: {intent.action}")
|
||||
else:
|
||||
# Explicit intent
|
||||
ActivityNavigator._launch_activity(intent)
|
||||
|
||||
def _launch_activity(intent):
|
||||
@staticmethod
|
||||
def startActivityForResult(intent, result_callback):
|
||||
"""Launch an activity and pass a callback for the result."""
|
||||
if not isinstance(intent, Intent):
|
||||
raise ValueError("Must provide an Intent")
|
||||
if intent.action: # Implicit intent: resolve handlers
|
||||
handlers = APP_REGISTRY.get(intent.action, [])
|
||||
if len(handlers) == 1:
|
||||
intent.activity_class = handlers[0]
|
||||
return ActivityNavigator._launch_activity(intent, result_callback)
|
||||
elif handlers:
|
||||
ActivityNavigator._show_chooser(intent, handlers)
|
||||
return None # Chooser handles result forwarding
|
||||
else:
|
||||
raise ValueError(f"No handlers for action: {intent.action}")
|
||||
else:
|
||||
return ActivityNavigator._launch_activity(intent, result_callback)
|
||||
|
||||
@staticmethod
|
||||
def _launch_activity(intent, result_callback=None):
|
||||
"""Launch an activity and set up result callback."""
|
||||
activity = intent.activity_class()
|
||||
activity.intent = intent
|
||||
activity._result_callback = result_callback # Pass callback to activity
|
||||
activity.onCreate()
|
||||
return activity
|
||||
|
||||
@staticmethod
|
||||
def _show_chooser(intent, handlers):
|
||||
chooser_intent = Intent(ChooserActivity, extras={"original_intent": intent, "handlers": [h.__name__ for h in handlers]})
|
||||
_launch_activity(chooser_intent)
|
||||
ActivityNavigator._launch_activity(chooser_intent)
|
||||
|
||||
|
||||
class ChooserActivity(Activity):
|
||||
|
||||
@@ -25,7 +25,7 @@ for apprepo in internal_filesystem/apps internal_filesystem/builtin/apps; do
|
||||
version=$( jq -r '.version' "$manifest" )
|
||||
cat "$manifest" | tee -a "$outputjson"
|
||||
echo -n "," | tee -a "$outputjson"
|
||||
thisappdir="$output"/"$appdir"
|
||||
thisappdir="$output"/apps/"$appdir"
|
||||
mkdir -p "$thisappdir"
|
||||
mkdir -p "$thisappdir"/mpks
|
||||
mkdir -p "$thisappdir"/icons
|
||||
|
||||
Reference in New Issue
Block a user