Can't access files on Android
I am unable to open any files on the Android version of MegaZeux; they don't appear in the MZX file browser, despite granting permission to "Allow MegaZeux to access photos, videos, music, and audio on this device."
I'm running Android 14 on a Samsung Galaxy S22.
This is most likely the same Android "feature" (Scoped Storage) as this bug report. I don't have a workaround for it right now.
Unless there are plans to eventually release MegaZeux on the Play Store (which would likely disallow this due to not being "core functionality"), would it be possible to request the MANAGE_EXTERNAL_STORAGE permission? It would likely demand far less of a rework compared to e.g. using the Storage Access Framework. I'm not well-versed in Android development, admittedly, so I don't know what exactly would need to be done to make that happen.
As is, this issue renders MZX completely unusable in Android 12+, since there's no way to even access the app's own private data folder under .../Android/data (paths can't be manually entered in the MZX file browser, trying to navigate there leads to being blocked by lack of permissions, and even using adb to set the default path in config.txt doesn't seem to do anything).
Unless there are plans to eventually release MegaZeux on the Play Store (which would likely disallow this due to not being "core functionality"), would it be possible to request the MANAGE_EXTERNAL_STORAGE permission? It would likely demand far less of a rework compared to e.g. using the Storage Access Framework. I'm not well-versed in Android development, admittedly, so I don't know what exactly would need to be done to make that happen.
I suspect this is possible. I'm currently waiting on having an Android 12+ device to test with, but if there's a permissions fix for this that doesn't conflict with the current (old) SDL this port uses, a workaround like this might not take too long.
edit: I pinged asie about this, who I think has a newer Android device to test with.
paths can't be manually entered in the MZX file browser
This is incorrect; the file manager fully supports entering relative and absolute folder paths in filename field to navigate. I have had to regularly use this feature to get around Android's strange permissions on /storage vs /storage/emulated vs /storage/emulated/0 (as the file manager can't list some of these directories...).
There might be a different problem causing what you're describing e.g. if a literal three dots ... is part of the path exactly as you wrote, MegaZeux's internal path construction is more likely at fault because it doesn't support that.
This is incorrect; the file manager fully supports entering relative and absolute folder paths in filename field to navigate. I have had to regularly use this feature to get around Android's strange permissions on /storage vs /storage/emulated vs /storage/emulated/0 (as the file manager can't list some of these directories...).
There might be a different problem causing what you're describing e.g. if a literal three dots
...is part of the path exactly as you wrote, MegaZeux's internal path construction is more likely at fault because it doesn't support that.
I stand corrected. Granted, I did have to plug in an external keyboard, which I didn't think of at first (guess I'm too used to trying to get this to work with a joystick, which probably isn't ideal for a lot of MZX games anyway). And yeah, the three dots ... were just a placeholder.
I did some more testing with config.txt, and it seems like it gets reset every time MZX launches? I set startup_path to /storage/emulated/0/Android/data/net.digitalmzx.megazeux/files/games/Zeux2_Caverns and startup_file to CAVERNS.mzx (just to make sure case-sensitivity wasn't a problem), also making sure to uncomment those lines. After launching MegaZeux, they get commented out again and are back to their default values of /home/username/MegaZeux and caverns.mzx, respectively.
If I manually go to that path in the MZX file browser, I can successfully start CAVERNS.mzx normally.
edit: I pinged asie about this, who I think has a newer Android device to test with.
Please test this build and let me know if it works (sorry for the useless zip container, Github doesn't allow attaching an apk): mzxgit-android.apk.zip
Something I was suspicious about and didn't mention is that MegaZeux already should have been requesting MANAGE_EXTERNAL_STORAGE; it seems there's a certain way this needs to be requested in newer Android versions, and asie implemented that.
I stand corrected. Granted, I did have to plug in an external keyboard, which I didn't think of at first (guess I'm too used to trying to get this to work with a joystick, which probably isn't ideal for a lot of MZX games anyway). And yeah, the three dots
...were just a placeholder.
Yeah—while joystick support is a lot better than it was a few years back, onscreen keyboards are still per-platform and the Android port doesn't have hooks to bind R1 to the Android keyboard yet (and touch-only controls are nonexistent..). SDL3 support forced some changes that should make implementing an onscreen keyboard button easier.
I did some more testing with config.txt, and it seems like [
startup_path] gets reset every time MZX launches?
I think that's a quirk of how the Android port handles its assets bundle—my (possibly wrong) understanding is that currently it will extract the bundle every time MegaZeux starts up, including config.txt. I will have to verify this.
Something I was suspicious about and didn't mention is that MegaZeux already should have been requesting MANAGE_EXTERNAL_STORAGE; it seems there's a certain way this needs to be requested in newer Android versions, and asie implemented that.
That's not entirely accurate. What I missed is that API level 30 is the first one where requesting WRITE_EXTERNAL_STORAGE is not, on its own, sufficient; it was, in other words, an off-by-one/not reading enough documentation error.
Please test this build and let me know if it works (sorry for the useless zip container, Github doesn't allow attaching an apk): mzxgit-android.apk.zip
That works now, thank you!
I think that's a quirk of how the Android port handles its assets bundle—my (possibly wrong) understanding is that currently it will extract the bundle every time MegaZeux starts up, including config.txt. I will have to verify this.
That would make sense; whatever the cause, it still happens even in this build. I'll open a new issue about this.