From 39c2fcd105bb411a5d9eb21ec46e4f0bd062f41f Mon Sep 17 00:00:00 2001 From: Diego Mugetsu Date: Sat, 26 Sep 2026 08:20:30 -0600 Subject: [PATCH] Android Save Data Folder picker --- docs/launcher.md | 23 + mobile/ANDROID.md | 7 + .../android/app/src/main/AndroidManifest.xml | 14 +- .../love/src/jni/love/src/common/android.cpp | 178 ++++++- .../love/src/jni/love/src/common/android.h | 31 ++ .../jni/love/src/modules/system/System.cpp | 68 +++ .../src/jni/love/src/modules/system/System.h | 26 + .../love/src/modules/system/wrap_System.cpp | 52 ++ .../java/org/love2d/android/GameActivity.java | 494 +++++++++++++++++- scripts/build_android.sh | 75 ++- src/core/SaveData.lua | 29 +- src/import/CacheFs.lua | 53 +- src/import/RomImporter.lua | 98 +++- src/mods/Loader.lua | 3 + src/mods/Storage.lua | 18 +- 15 files changed, 1116 insertions(+), 53 deletions(-) mode change 100755 => 100644 scripts/build_android.sh diff --git a/docs/launcher.md b/docs/launcher.md index 8bf8eb3f6..1f28ad607 100644 --- a/docs/launcher.md +++ b/docs/launcher.md @@ -34,6 +34,29 @@ for the launcher to acknowledge on refocus. After a successful import the consumed save-dir file is removed. +## Android game-data / mods folder + +Android's default save identity (`Android/data//files/save/pokemon-love2d`) +is often on a small internal volume. Mods, ROM caches and imported base files +follow **GAME DATA FOLDER** in launcher Settings instead: + +- `love.system.pickFolder()` → `GameActivity.showFolderPicker`: a volume dialog + listing each `getExternalFilesDirs()` app folder (phone, SD card, with free + space) plus optional `ACTION_OPEN_DOCUMENT_TREE`. The chosen absolute path + is written to `picked_folder.txt`; `RomImporter:focus` / `_pollPickedFiles` + calls `SaveData.setDataDir`. +- Direct rows for each volume (`love.system.getExternalDataDirs`) skip the + dialog. `USE THE DEFAULT FOLDER` clears the setting. +- Writes go through `CacheFs` (`io.*`); reads need the folder on the PhysFS + path, so Android also exposes `love.system.mountDirectory`. +- Saves and `options.lua` stay in the identity folder on purpose. After + switching, **MOVE EXISTING DATA HERE** copies `mods/`, `modstorage/` and + `imports/base/` into the new place. + +Most shared folders (Downloads, Drive) are not writable via `io.open` on +Android 11+; the picker rejects those and asks for Phone storage or an SD +card. iOS still keeps everything in the app folder. + **Manual check (device/emulator):** import Red → switch to Blue → Choose → system file picker must appear (not a silent Red re-extract) → pick Blue → Blue becomes ready beside Red. On the MODS tab, Import mod .zip must open the diff --git a/mobile/ANDROID.md b/mobile/ANDROID.md index 3bbdca41b..d00098bd5 100644 --- a/mobile/ANDROID.md +++ b/mobile/ANDROID.md @@ -83,6 +83,13 @@ chosen file under the app save directory as `picked_rom.gb`, from that folder on Choose / refocus; see `docs/launcher.md`. The APK payload itself remains data-free (no embedded ROM or generated cache). +Mods and imported game data can leave that identity folder: launcher Settings +→ GAME DATA FOLDER → CHOOSE STORAGE (`love.system.pickFolder`) lists each +app-owned volume (`getExternalFilesDirs`, typically phone plus SD card) and +optionally a tree picker. The path is stored in `options.dataDir`; +`CacheFs` installs mods there and `love.system.mountDirectory` puts it on +the read path. Saves stay in the identity folder. See `docs/launcher.md`. + ROM routing is SHA-1 based (not filename based): the importer accepts canonical 1 MiB carts (Red/Blue/Yellow) and 2 MiB carts (Gold/Silver), then selects the target version from `src/core/GameVersion.lua` by ROM hash. diff --git a/mobile/android/app/src/main/AndroidManifest.xml b/mobile/android/app/src/main/AndroidManifest.xml index 5cf7b38a6..95b4433cc 100644 --- a/mobile/android/app/src/main/AndroidManifest.xml +++ b/mobile/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,16 @@ - + + + + +