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

Commit12f6dd8

Browse files
App class: automatically set icon_path
1 parentf6fb647 commit12f6dd8

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importos
12
importujson
23
from ..activity_navigatorimportActivityNavigator
34

@@ -30,11 +31,26 @@ def __init__(
3031

3132
self.image=None
3233
self.image_dsc=None
34+
self.icon_path=self._find_icon_path()
3335
self.main_launcher_activity=self._find_main_launcher_activity()
3436

3537
def__str__(self):
3638
returnf"App({self.name}, v{self.version},{self.category})"
3739

40+
def_check_icon_path(self,tocheck):
41+
try:
42+
#print(f"checking {tocheck}")
43+
st=os.stat(tocheck)
44+
#print(f"_find_icon_path got {st}")
45+
returntocheck
46+
exceptExceptionase:
47+
#print(f"No app icon found: {e}")
48+
returnNone
49+
50+
def_find_icon_path(self):
51+
fullpath="apps/"+self.fullname+"/res/mipmap-mdpi/icon_64x64.png"
52+
returnself._check_icon_path(fullpath)orself._check_icon_path("builtin/"+fullpath)
53+
3854
def_find_main_launcher_activity(self):
3955
foractinself.activities:
4056
ifnotact.get("entrypoint")ornotact.get("classname"):

‎tests/package_manager.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
importunittest
22

3-
frommposimportPackageManager
3+
frommposimportApp,PackageManager
44

55
classTestCompareVersions(unittest.TestCase):
66

@@ -35,3 +35,15 @@ def test_installed_not_builtin(self):
3535

3636
deftest_not_installed(self):
3737
self.assertFalse(PackageManager.is_installed_by_name("com.micropythonos.badname"))
38+
39+
classTestPackageManager_get_app_list(unittest.TestCase):
40+
41+
deftest_get_app_list(self):
42+
app_list=PackageManager.get_app_list()
43+
self.assertEqual(len(app_list),17)
44+
45+
deftest_get_app(self):
46+
app_list=PackageManager.get_app_list()
47+
hello_world_app=PackageManager.get("com.micropythonos.helloworld")
48+
self.assertIsInstance(hello_world_app,App)
49+
self.assertEqual(hello_world_app.icon_path,"apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp