feat: add standalone Android file manager for PaperMC directories#1
feat: add standalone Android file manager for PaperMC directories#1coobbi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1452f1e77c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| private void saveContent() { | ||
| try { | ||
| Files.writeString(editingFile.toPath(), binding.editor.getText().toString(), StandardCharsets.UTF_8); |
There was a problem hiding this comment.
Block save when initial file read failed
If Files.readString(...) fails (for example on binary or non-UTF-8 files), the activity only shows a toast and keeps the Save button active; pressing Save then writes the current editor buffer (often empty) back to the same path and can silently corrupt the original file. This is reproducible by opening a .jar/binary file from the list and tapping Save after the read error.
Useful? React with 👍 / 👎.
| fileName = "imported_" + System.currentTimeMillis(); | ||
| } | ||
|
|
||
| File dest = new File(currentDirectory, fileName); |
There was a problem hiding this comment.
Sanitize imported display names before building destination path
DISPLAY_NAME comes from the document provider and is used directly in new File(currentDirectory, fileName); a crafted name containing path separators or .. can escape the current folder and write outside the intended PaperMC subtree. This makes import behavior unsafe against malicious/buggy providers and can overwrite unrelated files the app can access.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| private void setupDirectory() { | ||
| File base = new File(getExternalFilesDir(null), "home/mcpaper"); |
There was a problem hiding this comment.
Guard against null external storage directory
getExternalFilesDir(null) may return null when external storage is unavailable, but the code still constructs new File(null, "home/mcpaper") and continues as if setup succeeded. In that state the app points at an invalid/relative root and later file operations (listing/import) fail unpredictably instead of failing fast with a clear fallback.
Useful? React with 👍 / 👎.
Motivation
Description
appmodule and project build files (settings.gradle,build.gradle,gradle.properties) to bootstrap the project and dependencies.MainActivityto display thehome/mcpaperroot (inside app external files), navigate folders, show file metadata, and import files via the system document picker (ActivityResultContracts.OpenDocument).EditorActivityto load and save text file content, plus helperFileUtilsand adapterFileListAdapterfor the file list UI, and include corresponding layouts, drawables and resource values (res/layout/*,res/drawable/*,res/values/*).README.mdwith usage and run instructions and add basic ProGuard and theme resources.Testing
gradle -vin the environment and it completed successfully.gradle wrapperto validate AGP resolution and wrapper generation, which failed because the Android Gradle Plugin artifact could not be resolved in this environment (plugin resolution issue, not application logic failure).Codex Task