python-editor-v3 icon indicating copy to clipboard operation
python-editor-v3 copied to clipboard

[DEMO - DO NOT MERGE] Demo opening hex directly in the micro:bit app

Open microbit-robert opened this issue 2 years ago • 7 comments

microbit-robert avatar Dec 15 '22 16:12 microbit-robert

Preview build will be at https://review-python-editor-v3.microbit.org/app-protocol-demo/

github-actions[bot] avatar Dec 15 '22 16:12 github-actions[bot]

Does not check what browser/device you are using. Just assumes you are on iPad/mobile and attempts to open the project hex in the micro:bit app. Not sure what happens if you don't have the app downloaded, but it is likely to fail in the same semi-silent way that MakeCode does.

MakeCode manages to preserve project titles with spaces, this implementation resorts to URI encoding. Needs fixing.

microbit-robert avatar Dec 15 '22 17:12 microbit-robert

Notes from conversation with Jonny:

If we're on iOS, we should aim to open the .hex in the micro:bit app.

It seems that there is no way to determine whether an iOS device has an app installed from the browser. This is a possible work around: https://stackoverflow.com/questions/13044805/how-can-i-check-if-an-app-is-installed-from-a-web-page-on-an-iphone

The plan is to raise a new issue in microbit-ios repo, linking this branch and tagging Martin. We'd need to tweak the app so that Python .hex files are opened in the Python Editor instead of MakeCode if the user attempts to edit the project from the app. To do this we'd need to update the migration code to handle the current format, and a multiple project format. Perhaps we should do this first before raising an issue?

Current migration format as JSON:

{
  "meta": {
    "cloudId": "microbit.org",
    "comment": "",
    "editor": "python",
    "name": "beating-heart",
  },
  "source": "code as text"
};

microbit-robert avatar Dec 16 '22 12:12 microbit-robert

MakeCode shows a banner if the app is not installed. Will the app launch the Python Editor via a URL with the encoded project appended?

martinwork avatar Dec 16 '22 12:12 martinwork

Yep, MakeCode in Safari shows a banner at the top prompting the user to either install the app, or open in the app.

The Python Editor V3 doesn't currently support opening a project as a base64 encoded .hex file appended on the URL. We'd need to change this first before being able to launch via the app.

microbit-robert avatar Dec 16 '22 13:12 microbit-robert

Right. sorry, I was meaning... is that the intended method?

martinwork avatar Dec 16 '22 15:12 martinwork

Right. sorry, I was meaning... is that the intended method?

Yes, it's my understanding that is the intended method.

microbit-robert avatar Dec 16 '22 15:12 microbit-robert