Skip to content

Commit d0e5130

Browse files
Add support for activities and intent filters to MANIFEST.JSON
1 parent 8a0eac0 commit d0e5130

File tree

13 files changed

+136
-65
lines changed

13 files changed

+136
-65
lines changed

internal_filesystem/apps/com.example.camtest/META-INF/MANIFEST.JSON

Lines changed: 0 additions & 13 deletions
This file was deleted.

internal_filesystem/apps/com.lightningpiggy.displaywallet/META-INF/MANIFEST.JSON

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
"publisher": "LightningPiggy Foundation",
44
"short_description": "Display wallet that shows balance, transactions, receive QR code etc.",
55
"long_description": "See https://www.LightningPiggy.com",
6-
"icon_url": "http://demo.lnpiggy.com:2121/apps/com.lightningpiggy.displaywallet_0.0.1.mpk_icon_64x64.png",
7-
"download_url": "http://demo.lnpiggy.com:2121/apps/com.lightningpiggy.displaywallet_0.0.1.mpk",
6+
"icon_url": "https://apps.micropythonos.com/icons/com.lightningpiggy.displaywallet_0.0.1.mpk_icon_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/mpks/com.lightningpiggy.displaywallet_0.0.1.mpk",
88
"fullname": "com.lightningpiggy.displaywallet",
99
"version": "0.0.1",
10-
"entrypoint": "assets/displaywallet.py",
11-
"category": "finance"
10+
"category": "finance",
11+
"activities": [
12+
{
13+
"entrypoint": "assets/displaywallet.py",
14+
"classname": "MainActivity",
15+
"intent_filters": [
16+
{
17+
"action": "main",
18+
"category": "launcher"
19+
}
20+
]
21+
}
22+
]
1223
}

internal_filesystem/apps/com.lightningpiggy.displaywallet/assets/captureqr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
status_label_text_searching = "Searching QR codes...\n\nHold still and make them big!\n10cm for simple QR codes,\n20cm for complex."
2222
status_label_text_found = "Decoding QR..."
2323

24-
class CameraActivity(Activity):
24+
class Camera(Activity):
2525

2626
def __init__(self):
27+
super().__init__()
2728
self.cam = None
2829
self.current_cam_buffer = None # Variable to hold the current memoryview to prevent garbage collection
2930
self.image_dsc = None

internal_filesystem/apps/com.lightningpiggy.displaywallet/assets/displaywallet.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from mpos.apps import Activity, Intent
22
import mpos.config
3-
import mpos.ui
43

54
from wallet import LNBitsWallet, NWCWallet
6-
from captureqr import CameraActivity
5+
from captureqr import Camera
76

87
class MainActivity(Activity):
98

@@ -328,7 +327,7 @@ def gotqr_callback(self, success, data):
328327

329328
def cambutton_cb(self, event):
330329
print("cambutton clicked!")
331-
self.startActivity(Intent(activity_class=CameraActivity).putExtra("scanqr_callback", self.gotqr_callback))
330+
self.startActivity(Intent(activity_class=Camera).putExtra("scanqr_callback", self.gotqr_callback))
332331

333332
def save_setting(self, setting):
334333
if setting["key"] == "wallet_type" and self.radio_container:
@@ -344,9 +343,7 @@ def save_setting(self, setting):
344343
setting["value_label"].set_text(new_value if new_value else "Not set")
345344
self.finish()
346345

347-
348346
class FullscreenQR(Activity):
349-
350347
def onCreate(self):
351348
receive_qr_data = self.getIntent().extras.get("receive_qr_data")
352349
qr_screen = lv.obj()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "Camera",
3+
"publisher": "MicroPythonOS",
4+
"short_description": "Camera with QR decoding",
5+
"long_description": "Camera for both internal camera's and webcams, that includes QR decoding.",
6+
"icon_url": "https://apps.micropythonos.com/com.micropython.camera_0.0.3.mpk_icon_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/com.micropython.camera_0.0.3.mpk",
8+
"fullname": "com.micropython.camera",
9+
"version": "0.0.3",
10+
"category": "camera",
11+
"activities": [
12+
{
13+
"entrypoint": "assets/camera.py",
14+
"classname": "Camera",
15+
"intent_filters": [
16+
{
17+
"action": "main",
18+
"category": "launcher"
19+
},
20+
{
21+
"action": "scan_qr_code",
22+
"category": "default"
23+
}
24+
]
25+
}
26+
]
27+
}
28+

internal_filesystem/apps/com.example.camtest/assets/camtest.py renamed to internal_filesystem/apps/com.micropythonos.camera/assets/camera.py

File renamed without changes.

internal_filesystem/apps/com.example.camtest/res/mipmap-mdpi/icon_64x64.png renamed to internal_filesystem/apps/com.micropythonos.camera/res/mipmap-mdpi/icon_64x64.png

File renamed without changes.

internal_filesystem/builtin/apps/com.example.launcher/META-INF/MANIFEST.JSON

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "Launcher",
3+
"publisher": "MicroPythonOS",
4+
"short_description": "Simple launcher to start apps.",
5+
"long_description": "",
6+
"icon_url": "https://apps.micropythonos.com/icons/com.micropythonos.launcher_0.0.3.mpk_icon_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/mpks/com.micropythonos.launcher_0.0.3.mpk",
8+
"fullname": "com.micropythonos.launcher",
9+
"version": "0.0.3",
10+
"category": "launcher",
11+
"activities": [
12+
{
13+
"entrypoint": "assets/launcher.py",
14+
"classname": "MainActivity",
15+
"intent_filters": [
16+
{
17+
"action": "main",
18+
"category": "launcher"
19+
}
20+
]
21+
}
22+
]
23+
}
24+

internal_filesystem/builtin/apps/com.example.launcher/assets/launcher.py renamed to internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
class MainActivity(mpos.apps.Activity):
1919

2020
def onCreate(self):
21+
print("launcher.py onCreate()")
2122
main_screen = lv.obj()
2223
main_screen.set_style_border_width(0, 0)
2324
main_screen.set_style_radius(0, 0)
@@ -27,7 +28,6 @@ def onCreate(self):
2728
main_screen.set_flex_flow(lv.FLEX_FLOW.ROW_WRAP)
2829
self.setContentView(main_screen)
2930

30-
def onResume(self, main_screen):
3131
# Grid parameters
3232
icon_size = 64 # Adjust based on your display
3333
label_height = 24
@@ -63,9 +63,12 @@ def load_icon(icon_path):
6363
base_name = d
6464
if base_name not in seen_base_names: # Avoid duplicates
6565
seen_base_names.add(base_name)
66+
#print(f"seen_base_names: {seen_base_names}")
6667
app = mpos.apps.parse_manifest(f"{full_path}/META-INF/MANIFEST.JSON")
6768
if app.category != "launcher": # Skip launchers
68-
app_list.append((app.name, full_path))
69+
main_launcher = mpos.apps.find_main_launcher_activity(app)
70+
if main_launcher:
71+
app_list.append((app.name, full_path))
6972
except OSError:
7073
pass
7174

@@ -74,7 +77,7 @@ def load_icon(icon_path):
7477

7578
# Create UI for each app
7679
for app_name, app_dir_fullpath in app_list:
77-
#print(f"Adding app {app_name} from {app_dir_fullpath}")
80+
print(f"Adding app {app_name} from {app_dir_fullpath}")
7881
# Create container for each app (icon + label)
7982
app_cont = lv.obj(main_screen)
8083
app_cont.set_size(iconcont_width, iconcont_height)

0 commit comments

Comments
 (0)