Skip to content

Commit c34fcb6

Browse files
App class: automatically load icon_data
1 parent 12f6dd8 commit c34fcb6

File tree

1 file changed

+12
-2
lines changed
  • internal_filesystem/lib/mpos/app

1 file changed

+12
-2
lines changed

internal_filesystem/lib/mpos/app/app.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(
1010
short_description="",
1111
long_description="",
1212
icon_url="",
13+
icon_path="builtin/res/mipmap-mdpi/default_icon_64x64.png",
1314
download_url="",
1415
fullname="Unknown",
1516
version="0.0.0",
@@ -32,16 +33,25 @@ def __init__(
3233
self.image = None
3334
self.image_dsc = None
3435
self.icon_path = self._find_icon_path()
36+
if self.icon_path:
37+
self.icon_data = self._load_icon_data(self.icon_path)
3538
self.main_launcher_activity = self._find_main_launcher_activity()
3639

3740
def __str__(self):
38-
return f"App({self.name}, v{self.version}, {self.category})"
41+
return f"App({self.name}, version {self.version}, {self.category})"
42+
43+
def _load_icon_data(self, icon_path):
44+
try:
45+
f = open(icon_path, 'rb')
46+
return f.read()
47+
except Exception as e:
48+
print(f"open {icon_path} got error: {e}")
3949

4050
def _check_icon_path(self, tocheck):
4151
try:
4252
#print(f"checking {tocheck}")
4353
st = os.stat(tocheck)
44-
#print(f"_find_icon_path got {st}")
54+
print(f"_find_icon_path for {tocheck} found {st}")
4555
return tocheck
4656
except Exception as e:
4757
#print(f"No app icon found: {e}")

0 commit comments

Comments
 (0)