Rename PackageManager to AppManager

This commit is contained in:
Thomas Farstrike
2026-01-25 00:19:38 +01:00
parent 31dcfba683
commit c2ae169638
29 changed files with 123 additions and 124 deletions
@@ -2,7 +2,7 @@ import os
import json
import lvgl as lv
from mpos import Activity, DownloadManager, PackageManager, TaskManager
from mpos import Activity, DownloadManager, AppManager, TaskManager
class AppDetail(Activity):
@@ -142,7 +142,7 @@ class AppDetail(Activity):
self.install_label = lv.label(self.install_button)
self.install_label.center()
self.set_install_label(self.app.fullname)
if app.version and PackageManager.is_update_available(self.app.fullname, app.version):
if app.version and AppManager.is_update_available(self.app.fullname, app.version):
self.install_button.set_size(lv.pct(47), 40) # make space for update button
print("Update available, adding update button.")
self.update_button = lv.button(buttoncont)
@@ -171,10 +171,10 @@ class AppDetail(Activity):
# - update is separate button, only shown if already installed and new version
is_installed = True
update_available = False
builtin_app = PackageManager.is_builtin_app(app_fullname)
overridden_builtin_app = PackageManager.is_overridden_builtin_app(app_fullname)
builtin_app = AppManager.is_builtin_app(app_fullname)
overridden_builtin_app = AppManager.is_overridden_builtin_app(app_fullname)
if not overridden_builtin_app:
is_installed = PackageManager.is_installed_by_name(app_fullname)
is_installed = AppManager.is_installed_by_name(app_fullname)
if is_installed:
if builtin_app:
if overridden_builtin_app:
@@ -214,12 +214,12 @@ class AppDetail(Activity):
self._show_progress_bar()
await self._update_progress(21)
await self._update_progress(42)
PackageManager.uninstall_app(app_fullname)
AppManager.uninstall_app(app_fullname)
await self._update_progress(100, wait=False)
self._hide_progress_bar()
self.set_install_label(app_fullname)
self.install_button.remove_state(lv.STATE.DISABLED)
if PackageManager.is_builtin_app(app_fullname):
if AppManager.is_builtin_app(app_fullname):
self.update_button.remove_flag(lv.obj.FLAG.HIDDEN)
self.install_button.set_size(lv.pct(47), 40) # if a builtin app was removed, then it was overridden, and a new version is available, so make space for update button
@@ -256,7 +256,7 @@ class AppDetail(Activity):
else:
print("Downloaded .mpk file, size:", os.stat(temp_zip_path)[6], "bytes")
# Install it:
PackageManager.install_mpk(temp_zip_path, dest_folder) # 60 until 80 percent is the unzip but no progress there...
AppManager.install_mpk(temp_zip_path, dest_folder) # 60 until 80 percent is the unzip but no progress there...
await self._update_progress(80, wait=False)
except Exception as e:
print(f"Download failed with exception: {e}")
@@ -9,7 +9,7 @@
# All icons took: 1250ms
# Most of this time is actually spent reading and parsing manifests.
import lvgl as lv
from mpos import AppearanceManager, PackageManager, Activity, DisplayMetrics
from mpos import AppearanceManager, AppManager, Activity, DisplayMetrics
import time
import uhashlib
import ubinascii
@@ -54,7 +54,7 @@ class Launcher(Activity):
# ------------------------------------------------------------------
# 1. Build a *compact* representation of the current app list
current_apps = []
for app in PackageManager.get_app_list():
for app in AppManager.get_app_list():
if app.category == "launcher":
continue
icon_hash = Launcher._hash_file(app.icon_path) # cheap SHA-1 of the icon file
@@ -90,7 +90,7 @@ class Launcher(Activity):
iconcont_width = icon_size + label_height
iconcont_height = icon_size + label_height
for app in PackageManager.get_app_list():
for app in AppManager.get_app_list():
if app.category == "launcher":
continue
@@ -128,7 +128,7 @@ class Launcher(Activity):
# ----- events --------------------------------------------------
app_cont.add_event_cb(
lambda e, fullname=app.fullname: PackageManager.start_app(fullname),
lambda e, fullname=app.fullname: AppManager.start_app(fullname),
lv.EVENT.CLICKED, None)
app_cont.add_event_cb(
lambda e, cont=app_cont: self.focus_app_cont(cont),
@@ -2,7 +2,7 @@ import lvgl as lv
import ujson
import time
from mpos import Activity, PackageManager, ConnectivityManager, TaskManager, DownloadManager, DisplayMetrics, DeviceInfo, BuildInfo
from mpos import Activity, AppManager, ConnectivityManager, TaskManager, DownloadManager, DisplayMetrics, DeviceInfo, BuildInfo
class OSUpdate(Activity):
@@ -770,7 +770,7 @@ class UpdateChecker:
Returns:
bool: True if remote version is newer
"""
return PackageManager.compare_versions(remote_version, current_version)
return AppManager.compare_versions(remote_version, current_version)
# Non-class functions:
@@ -1,6 +1,6 @@
import lvgl as lv
from mpos import Intent, PackageManager, SettingActivity, SettingsActivity, TimeZone
from mpos import Intent, AppManager, SettingActivity, SettingsActivity, TimeZone
from calibrate_imu import CalibrateIMUActivity
from check_imu_calibration import CheckIMUCalibrationActivity
@@ -44,7 +44,7 @@ class Settings(SettingsActivity):
{"title": "Theme Color", "key": "theme_primary_color", "placeholder": "HTML hex color, like: EC048C", "ui": "dropdown", "ui_options": theme_colors, "changed_callback": self.theme_changed},
{"title": "Timezone", "key": "timezone", "ui": "dropdown", "ui_options": [(tz, tz) for tz in TimeZone.get_timezones()], "changed_callback": lambda *args: mpos.time.refresh_timezone_preference()},
# Advanced settings, alphabetically:
{"title": "Auto Start App", "key": "auto_start_app", "ui": "radiobuttons", "ui_options": [(app.name, app.fullname) for app in PackageManager.get_app_list()]},
{"title": "Auto Start App", "key": "auto_start_app", "ui": "radiobuttons", "ui_options": [(app.name, app.fullname) for app in AppManager.get_app_list()]},
{"title": "Check IMU Calibration", "key": "check_imu_calibration", "ui": "activity", "activity_class": CheckIMUCalibrationActivity},
{"title": "Calibrate IMU", "key": "calibrate_imu", "ui": "activity", "activity_class": CalibrateIMUActivity},
# Expert settings, alphabetically
@@ -92,7 +92,7 @@ class Settings(SettingsActivity):
# This will throw an exception if there is already a "/builtin" folder present
print("settings.py: WARNING: could not import/run freezefs_mount_builtin: ", e)
print("Done mounting, refreshing apps")
PackageManager.refresh_apps()
AppManager.refresh_apps()
def theme_changed(self, new_value):
from mpos import AppearanceManager