microbit-foundation / microbit-android

micro:bit official Android application code. The application is free to download from https://play.google.com/store/apps/details?id=com.samsung.microbit
Apache License 2.0
13 stars 10 forks source link

Going 'back' from MakeCode doesn't work the way you expect #54

Open jaustin opened 3 months ago

jaustin commented 3 months ago

Describe the bug

Using the Android 'back' button from the 'Create Code' menu doesn't behave as I would expect.

It appears that something is popping more views onto the stack than user is aware of. For example home screen, then editor.

To reproduce

Expected behaviour I think either

OR

Either way, needing to press back multiple times without user feedback that something has happened is not right.

CC @microbit-lucy

martinwork commented 3 months ago

@jaustin The MakeCode activity overrides onBackPressed to use webView.canGoBack()/goBack(). Somehow, each change from/to Home adds to the history, but goBack() doesn't do anything. https://github.com/microbit-foundation/microbit-android/blob/41cb284ef98bfedab6458c336b42f7cbef857165/app/src/main/java/com/samsung/microbit/ui/activity/MakeCodeWebView.java#L294

The iOS app implements Back by checking the current URL... If it's Makecode, leave Makecode, otherwise relaunch MakeCode, either home or editor, whichever was last. That supports cancelling GitHub login and MakeCode Sign In. The iOS app also displays a back button when the current URL isn't MakeCode.

I've experimented with this. Calling super.onBackPressed() works to leave Makecode, but I wonder if finish() might be safer. GitHub login worked for me, but MakeCode Sign In didn't.

Leaving Makecode goes back to whichever screen launched it (Home or FLASH).

EDIT: At least, I think it should! It doesn't return to FLASH right now because of this mistake https://github.com/microbit-foundation/microbit-android/blob/main/app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java#L223

martinwork commented 3 months ago

@jaustin @microbit-lucy I now notice that things like ?(Help)/Support and Reference are navigated to within the webview. To navigate the reference pages, for example, back would be needed to do more than return to MakeCode.

The iOS app allows certain specific domains and URLs inside the webview and sends all others out to the external browser.

EDIT: I think URL filtering can be done here. I'm not sure why "https://microbit.org/" has been singled out to trigger an exit. https://github.com/microbit-foundation/microbit-android/blob/main/app/src/main/java/com/samsung/microbit/ui/activity/MakeCodeWebView.java#L95