You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Simplify is_launcher
This commit is contained in:
@@ -122,7 +122,7 @@ def start_app(fullname):
|
||||
start_script_fullpath = f"{app.installed_path}/{app.main_launcher_activity.get('entrypoint')}"
|
||||
execute_script(start_script_fullpath, True, app.installed_path + "/assets/", app.main_launcher_activity.get("classname"))
|
||||
# Launchers have the bar, other apps don't have it
|
||||
if PackageManager.is_launcher(fullname):
|
||||
if PackageManager.is_valid_launcher(app):
|
||||
mpos.ui.topmenu.open_bar()
|
||||
else:
|
||||
mpos.ui.topmenu.close_bar()
|
||||
@@ -135,12 +135,10 @@ def restart_launcher():
|
||||
mpos.ui.empty_screen_stack()
|
||||
# No need to stop the other launcher first, because it exits after building the screen
|
||||
for app in mpos.package_manager.PackageManager.get_app_list():
|
||||
#print(f"checking {app}")
|
||||
if app.category == "launcher" and app.main_launcher_activity: # if it's a launcher and it has a main_launcher_activity
|
||||
if PackageManager.is_valid_launcher(app):
|
||||
print(f"Found launcher, starting {app.fullname}")
|
||||
start_app(app.fullname)
|
||||
|
||||
|
||||
class App:
|
||||
def __init__(self, name, publisher, short_description, long_description, icon_url, download_url, fullname, version, category, activities, installed_path=None):
|
||||
self.name = name
|
||||
|
||||
@@ -221,7 +221,6 @@ class PackageManager:
|
||||
return PackageManager.is_installed_by_path(f"apps/{app_fullname}") or PackageManager.is_installed_by_path(f"builtin/apps/{app_fullname}")
|
||||
|
||||
@staticmethod
|
||||
def is_launcher(app_name):
|
||||
print(f"checking is_launcher for {app_name}")
|
||||
# Simple check, could be more elaborate by checking the MANIFEST.JSON for the app...
|
||||
return "launcher" in app_name or len(mpos.ui.screen_stack) < 2 # assumes the first one on the stack is the launcher
|
||||
def is_valid_launcher(app_obj):
|
||||
#print(f"checking is_valid_launcher for {app_obj}")
|
||||
return app_obj.category == "launcher" and app_obj.main_launcher_activity
|
||||
|
||||
Reference in New Issue
Block a user