Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit163511f

Browse files
Dependency hell
1 parentc2c5089 commit163511f

File tree

12 files changed

+67
-51
lines changed

12 files changed

+67
-51
lines changed

‎internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/appstore.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
frommpos.appsimportActivity,Intent
1010
frommpos.appimportApp
1111
importmpos.ui
12-
frommpos.package_managerimportPackageManager
12+
frommpos.content.pmimportPackageManager
1313

1414

1515
classAppStore(Activity):

‎internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
importmpos.apps
1616
importmpos.ui
17-
frommpos.package_managerimportPackageManager
17+
frommpos.content.pmimportPackageManager
1818
frommposimportActivity
1919

2020
classLauncher(Activity):

‎internal_filesystem/lib/mpos/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .app.activityimportActivity
44
from .content.intentimportIntent
55
from .navigatorimportActivityNavigator
6-
from .package_managerimportPackageManager
6+
from .content.pmimportPackageManager
77

88
# Optional: re-export activities
99
from .app.activities.chooserimportChooserActivity

‎internal_filesystem/lib/mpos/app/activities/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Import all activity modules → triggers self-registration
12
from .chooserimportChooserActivity
23
from .viewimportViewActivity
34
from .shareimportShareActivity

‎internal_filesystem/lib/mpos/app/activities/chooser.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from ..activityimportActivity
2+
# Chooser doesn't handle an action — it shows handlers
3+
# → No registration needed
24

3-
importmpos.package_manager
5+
from ...content.pmimportPackageManager
46

57
classChooserActivity(Activity):
68
def__init__(self):
@@ -25,7 +27,7 @@ def onCreate(self):
2527
self.setContentView(screen)
2628

2729
def_select_handler(self,handler_name,original_intent):
28-
forhandlerinmpos.package_manager.PackageManager.APP_REGISTRY.get(original_intent.action, []):
30+
forhandlerinPackageManager.APP_REGISTRY.get(original_intent.action, []):
2931
ifhandler.__name__==handler_name:
3032
original_intent.activity_class=handler
3133
navigator.startActivity(original_intent)
@@ -37,3 +39,5 @@ def onStop(self, screen):
3739
print("Stopped for Chooser")
3840
else:
3941
print("Stopped for other screen")
42+
43+

‎internal_filesystem/lib/mpos/app/activities/share.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ..activityimportActivity
2+
from ...content.pmimportPackageManager
23

34
classShareActivity(Activity):
45
def__init__(self):
@@ -33,3 +34,5 @@ def onStop(self, screen):
3334
print("Stopped for Share")
3435
else:
3536
print("Stopped for other screen")
37+
38+
PackageManager.register_activity("share",ShareActivity)

‎internal_filesystem/lib/mpos/app/activities/view.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ..activityimportActivity
2+
from ...content.pmimportPackageManager
23

34
classViewActivity(Activity):
45
def__init__(self):
@@ -25,3 +26,6 @@ def onStop(self, screen):
2526
print("Stopped for View")
2627
else:
2728
print("Stopped for other screen")
29+
30+
# Register this activity for "view" intents
31+
PackageManager.register_activity("view",ViewActivity)

‎internal_filesystem/lib/mpos/app/activity.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
frommpos.navigatorimportActivityNavigator
1+
#from mpos.navigator import ActivityNavigator
22

33
importmpos.ui
44

@@ -26,7 +26,10 @@ def setContentView(self, screen):
2626
mpos.ui.setContentView(self,screen)
2727

2828
defstartActivity(self,intent):
29-
ActivityNavigator.startActivity(intent)
29+
ifnothasattr(self,'app')ornotself.app:
30+
print("ERROR: Activity has no .app – cannot startActivity")
31+
return
32+
self.app.start_activity(intent)
3033

3134
defstartActivityForResult(self,intent,result_callback):
3235
ActivityNavigator.startActivityForResult(intent,result_callback)

‎internal_filesystem/lib/mpos/app/app.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importujson
22
#from ..content.intent import Intent # optional, if App uses Intent
3-
3+
from ..navigatorimportActivityNavigator
44

55
classApp:
66
def__init__(
@@ -71,3 +71,7 @@ def from_manifest(cls, appdir):
7171
activities=data.get("activities",default.activities),
7272
installed_path=appdir,
7373
)
74+
75+
defstart_activity(self,intent):
76+
"""Android-like: App.startActivity(Intent)"""
77+
returnActivityNavigator.startActivity(intent)

‎internal_filesystem/lib/mpos/apps.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
importmpos.info
1212
importmpos.ui
1313
frommposimportActivity,Intent
14-
frommpos.package_managerimportPackageManager
14+
frommpos.content.pmimportPackageManager
1515

1616
defgood_stack_size():
1717
stacksize=24*1024
@@ -21,7 +21,7 @@ def good_stack_size():
2121
returnstacksize
2222

2323
# Run the script in the current thread:
24-
defexecute_script(script_source,is_file,cwd=None,classname=None):
24+
defexecute_script(script_source,is_file,cwd=None,classname=None,app=None):
2525
importutime# for timing read and compile
2626
thread_id=_thread.get_ident()
2727
compile_name='script'ifnotis_fileelsescript_source
@@ -63,7 +63,13 @@ def execute_script(script_source, is_file, cwd=None, classname=None):
6363
main_activity=script_globals.get(classname)
6464
ifmain_activity:
6565
start_time=utime.ticks_ms()
66-
Activity.startActivity(None,Intent(activity_class=main_activity))
66+
frommpos.app.activityimportActivityasBaseActivity
67+
ifapp:
68+
dummy=BaseActivity()
69+
dummy.app=app
70+
returned_activity=dummy.startActivity(Intent(activity_class=main_activity))
71+
else:
72+
print("Warning: app not found in PackageManager")
6773
end_time=utime.ticks_diff(utime.ticks_ms(),start_time)
6874
print(f"execute_script: Activity.startActivity took{end_time}ms")
6975
else:
@@ -123,7 +129,7 @@ def start_app(fullname):
123129
print(f"WARNING: start_app can't start{fullname} because it doesn't have a main_launcher_activity")
124130
return
125131
start_script_fullpath=f"{app.installed_path}/{app.main_launcher_activity.get('entrypoint')}"
126-
execute_script(start_script_fullpath,True,app.installed_path+"/assets/",app.main_launcher_activity.get("classname"))
132+
execute_script(start_script_fullpath,True,app.installed_path+"/assets/",app.main_launcher_activity.get("classname"),app)
127133
# Launchers have the bar, other apps don't have it
128134
ifapp.is_valid_launcher():
129135
mpos.ui.topmenu.open_bar()
@@ -137,7 +143,7 @@ def restart_launcher():
137143
print("restart_launcher")
138144
mpos.ui.empty_screen_stack()
139145
# No need to stop the other launcher first, because it exits after building the screen
140-
forappinmpos.package_manager.PackageManager.get_app_list():
146+
forappinPackageManager.get_app_list():
141147
ifapp.is_valid_launcher():
142148
print(f"Found launcher, starting{app.fullname}")
143149
start_app(app.fullname)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp