Files
file-manager/README.md
T
SoftwareApp 0bbee25ab3 Test the interface as a user sees it, and let a debug build tell on itself
Fifteen rendering tests across four files are the first tests in this project that compose a screen,
and they cover the claims that used to be prose only: the app bar's star exists where there is a folder
to star and says Add or Remove according to the state, the selection bar offers Rename to several files
and Details only to one, the batch dialog spells out the names it will produce and refuses a collision
with the file named, the shared name dialog refuses a slash while it is typed, and a favourite that has
gone says "Folder not found" rather than showing a path that is not there. They run on the JVM through
Robolectric - the Compose test artifacts plus the test manifest - so they belong to the same verify.sh
gate as everything else instead of needing a device: 386 tests in total.

Writing them turned up one behaviour worth recording. The batch dialog continues the folder's series by
default, so a collision cannot be shown unless the start number is forced back to 1 - which is precisely
why the feature works in practice, and now also why two of these tests set the field explicitly.

The debug build now enables StrictMode (disk reads and writes, network, leaked closables; logged, not
fatal) and attaches LeakCanary. A file manager is the worst possible app for a blocking disk read on the
main thread, and a debug build is the last place where noticing it is still cheap. Logging rather than a
crash is deliberate: turning a slow screen into a crash on someone's phone is the worse trade. The flag
is read from the manifest, not from BuildConfig, which this build does not generate.

Performance has a number for the first time, and it immediately paid for itself. tools/measure-startup.sh
takes cold start with `am start -W` - median of several runs, one warm-up discarded because the first
launch after an install pays for dexopt - and docs/PERFORMANCE.md records 1814 ms over five runs, in the
debug build, which is the slow case by construction. StrictMode's first run then produced five violations
against that number: 492 ms resolving `app.cacheDir` inside the view-model factory, 397 ms reading free
space with StatFs for every volume inside refresh(), 477 ms of the platform loading its own typefaces,
and two 54 ms OEM font hooks. That is about 1.5 s of main-thread disk I/O in a 1.8 s start, of which
~0.9 s is ours and mechanical to move. Neither of ours is fixed here on purpose: the numbers and the two
fixes are recorded in PERFORMANCE.md, and they are the first items of the speed work.

What is not measured is stated in the same file rather than left to be assumed: folder open at 1 000 /
5 000 / 20 000 files, thumbnail paint while scrolling, and keystroke-to-result all need a `:benchmark`
module and a profileable build under the release package id, and this device waits for a confirmation
dialog on the first install of a new package id. The module is deliberately absent instead of
half-configured: build wiring nobody can run is worse than a recorded gap.

Gate green (map current, detekt, 386 tests, lint), and CHANGELOG, README, AGENTS.md, ROADMAP,
PERFORMANCE.md, EDGE_CASE_TESTING and the regenerated map carry it.
2026-10-17 09:23:11 +02:00

244 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# File Manager
An **ad-free**, **one-time-paid** Android file manager. It browses and manages the
files on your device — locally, with no ads, no account and no analytics.
Nothing ever leaves the device: the app declares no network permission and contains
no advertising or tracking SDKs.
> **Working title.** The display name and the store listing are decided before the
> first Play upload (see [docs/ROADMAP.md](docs/ROADMAP.md), M10). The `applicationId`
> is already fixed and can never change after the first release.
## Status
**M15 — favourites: done.** A star in any folder's app bar puts that folder on the home screen, above
the libraries, where a folder that has gone is marked *not found* rather than silently dropped and
the row's own star removes it. Before it: **M14 — renaming a batch** (selecting several files and
choosing Rename opens a **pattern** dialog instead of the single-file one: one name, the number to
start at, and a preview of the names
it will produce — and the numbering **carries on from the folder's own**, so `series (1)` and
`series (2)` already there make the next batch start at 3. A batch that cannot be done is refused
before anything moves, naming the file in the way, and the whole batch is one undo step. Before it:
**M13 — video thumbnails** (a video row shows a frame of the video itself rather than a film icon —
the platform's own retriever, through Coil, with a frame taken a second in and the icon kept as the
fallback when a file cannot be decoded), **M12 — duplicate finder** (size, then the head of every
candidate, then the survivors in full), **M11 — library views** (a **Libraries** section on the
root screen — Images, Videos, Audio, Documents, Archives and Recent — whose rows open
ordinary listings of those files, each carrying a count from the search index), and **M10 — store
assets**: the app is named **Plain Files**, the icon and feature graphic come from the app's own
vectors, and [docs/STORE_LISTING.md](docs/STORE_LISTING.md) holds length-checked listing copy.
Screenshots exist for 5 phone (1080×2160), 4 on a 7-inch tablet (1200×1920) and 4 on a 10-inch
tablet (2560×1600) — but they **predate M11**, so the home screen in them is the old volume list and
they will need re-shooting, which the library views make a privacy question as well as a cosmetic one
([docs/STORE_LISTING.md](docs/STORE_LISTING.md)).
## Tech stack
| Area | Choice |
|---|---|
| Language | Kotlin 2.4.10 (using AGP 9 *built-in Kotlin*) |
| UI | Jetpack Compose, BOM 2026.06.01, Material 3 |
| Build | Gradle 9.3.1, Android Gradle Plugin 9.1.0 |
| Storage access | `MANAGE_EXTERNAL_STORAGE` ("All files access") with a Storage Access Framework fallback |
| Archives | Apache Commons Compress + XZ for Java (both pure Java — no NDK) |
| SDK levels | `compileSdk`/`targetSdk` 36, `minSdk` 26 |
`targetSdk` is 36 because Google Play requires new apps and updates to target
Android 16 (API 36) from 31 August 2026.
## Project layout
```
app/src/main/java/de/softwareapp_hb/filemanager/
├── core/ Pure-Kotlin engine (no Android imports!) — paths, sorting, formatting,
│ search matching, copy/move planning, conflict policy
├── data/ Storage backends (all-files access + SAF), volumes, shares coming in
│ from other apps, the trash index (SQLite), file operations, archives,
│ deletion
├── domain/ Browser + operation controllers, models, permission state
├── service/ Foreground service for long-running file operations
├── ui/ Compose theme, browser screen, components, ViewModels
└── text/ Domain enum → string-resource mapping
app/src/test/java/… JVM unit tests for the core engine
```
`core/` deliberately has **no Android dependencies**, so the trickiest logic is
covered by fast JVM tests.
The per-file index — what each file holds, and every test name in the suite — is
[`docs/CODE_MAP.md`](docs/CODE_MAP.md), generated from the source by
`tools/make-code-map.py` (`--check` fails when it is stale). [`AGENTS.md`](AGENTS.md) is the
one-page briefing for whoever picks the repository up: the commands, the layout and its
dependency direction, the rules that have tests behind them, and the traps worth knowing
before spending an hour on them.
## Building
Prerequisites:
- JDK 17+ (JDK 25 verified)
- A **JDK 21** as well: detekt 1.23 cannot run on 25, so the analyser is pinned to a 21 toolchain and
Gradle will not download one.
- Android SDK with `platforms;android-36` and `build-tools;36.0.0`
```bash
# Tell Gradle where the SDK lives (this file is git-ignored)
echo "sdk.dir=$HOME/Android/Sdk" > local.properties
./gradlew :app:assembleDebug # debug APK
./gradlew :app:testDebugUnitTest # JVM unit tests for the engine
./gradlew :app:lintDebug # Android Lint
./gradlew :app:bundleRelease # Play upload bundle (.aab)
# Everything the gate requires, in one command — what CI and the pre-push hook run:
./tools/verify.sh
```
The gate is the code-map check, [detekt](https://detekt.dev) against a frozen baseline, the unit tests
and Android Lint, cheapest first; `--release` adds an R8 build. CI
(`.github/workflows/verify.yml`) runs it on every push and pull request and nightly with `--release`,
because R8 is the one check that has caught a defect nothing else could. To run it before pushing:
`git config core.hooksPath .githooks`.
The numbers that do exist — and the ones deliberately still missing — are in
[docs/PERFORMANCE.md](docs/PERFORMANCE.md).
Release signing is optional and driven by a git-ignored `keystore.properties`
(see `keystore.properties.example`); without it the release build still runs
R8/minification but produces an unsigned artefact.
## Tracked in git
- Source, resources and Gradle build files.
- `docs/` — the roadmap, the generated code map and the release documentation.
- `PRIVACY.md`, `CHANGELOG.md`, `AGENTS.md`, and (from M10) `store-assets/`.
Not tracked: `local.properties`, `keystore.properties`, `*.jks`, build outputs.
## Releasing
Release signing is driven by the git-ignored `keystore.properties` (see
`keystore.properties.example`). Without that file the release build still runs R8 and
resource shrinking, but produces an unsigned artefact that cannot be uploaded.
```bash
./gradlew :app:bundleRelease # Play upload bundle (.aab)
./gradlew :app:assembleRelease # APK, for local checks
# Audit what is actually shipped — in particular that there is no INTERNET permission:
$ANDROID_HOME/build-tools/36.0.0/aapt2 dump permissions \
app/build/outputs/apk/release/app-release.apk
```
Read [docs/PLAY_RELEASE_CHECKLIST.md](docs/PLAY_RELEASE_CHECKLIST.md) before uploading.
Step 4 is the one that matters most for this app: a file manager must declare **"All files
access"** through Play's Permissions Declaration Form, and have the core purpose documented
in its store description. [PRIVACY.md](PRIVACY.md) is written to match the shipped
permissions.
## Localisation
All user-visible text lives in `app/src/main/res/values/strings.xml`, with real `<plurals>`
wherever a count can be one, and the screen and the progress notification resolve their
labels through `text/TextRes.kt` so the two cannot drift apart. **English is currently the
only locale.**
Adding a language is then a file, not a refactor:
```
app/src/main/res/values-de/strings.xml # same keys, translated values
```
Deliberately **not** localised, and why:
- **Byte units** ("KB", "MB") — symbols, not words, and every file manager and the system
Settings app show them the same way.
- **The timestamp pattern** (`yyyy-MM-dd HH:mm`) — a fixed, sortable format; the zone is
passed in explicitly rather than assumed.
### Checking that nothing was missed
Two things are easy to get wrong: a literal typed into a composable, and showing an enum
constant directly (`FileKind.name` puts untranslatable English on screen — the details
sheet used to do exactly that). The mechanical check is the pseudo-locale:
```bash
./gradlew :app:assembleDebug
# Settings > System > Languages > English (XA), then launch the debug build.
```
The debug build type sets `isPseudoLocalesEnabled = true`, so every string that came from
`strings.xml` renders accented and bracketed (`[Îmàgé]`). **Anything that looks normal is a
string that never went through resources.** The release build is unaffected.
One caveat: **Google Play's automatic translation translates your store listing, not the app
UI.** Translated UI text has to be supplied in `values-<locale>/`.
## Known limitations
- **The trash is a time window, not a bin you manage.** A delete stages the item in a hidden
`.plainfiles-trash` folder on the same volume and keeps it for 24 hours; the **Trash** entry
in the overflow menu lists what is still there and puts a whole batch back. There is no
"empty it now" action — expired batches are swept the next time something is deleted — and a
name taken again in the meantime is never overwritten, so a restored item can arrive beside
the new one rather than replacing it.
- **Where a trashed item came from is remembered in the app's own database**, not on the
volume. The staged files are the truth and the database is only an index, so the two are
reconciled in both directions: an entry whose file has gone is not offered back, and a
batch folder no entry mentions is swept.
- **Sharing a file *out* only works in the all-files mode.** A SAF path is relative to the
granted tree rather than a filesystem path, so it cannot be handed to `FileProvider`.
Receiving a share and being picked from another app's chooser work either way: the first
needs no filesystem path, and the second falls back to `RESULT_CANCELED` rather than
returning a URI the caller could not read.
- **RAR, CAB, ISO and WIM are refused**, not supported — they need native code, which this
project deliberately does not ship. (The Commons Compress jar contains no RAR classes at
all.) **7z is different**: Commons Compress reads it in pure Java, so it *is* supported —
but the format needs a seekable channel rather than a stream, because its header lives at
the end of the file. All-files access can supply one; the SAF fallback cannot, so 7z
extraction reports that plainly in folder mode instead of half-working.
- **7z files can be opened but not created** — writing stays ZIP-only.
- **Archive extraction does not restore original timestamps or permissions**, and there is
no archive encryption or password support.
- **Cancellation happens between entries**, so a single very large file finishes before a
stop is honoured.
- **A batch rename is refused rather than half-done when one of its names is taken**, including when
the file holding that name is part of the same batch: `a.txt` taking `a (1).txt` while `a (1).txt`
is itself being renamed needs the files shuffled through temporary names, so the dialog names the
file in the way instead. Renaming in the other order, or starting the numbering past the block,
does what you want.
- **A library is not restored across process death.** The persisted view state holds a path, and a
library has none, so a restart returns to the root screen rather than to Images or Recent.
- **Long-press multi-select is awkward to script from the host.** The gesture that opens the
selection bar (`input swipe x y x y 900`) works on the MIUI test device but has also
registered as a plain tap, so compress/extract from the UI wants a manual pass (see
[docs/EDGE_CASE_TESTING.md](docs/EDGE_CASE_TESTING.md)).
- The display name is still the working title — decided before the first upload (M10).
## Monetisation
**One-time paid: €4.49 base, with a €2.29 launch price for the first 14 days.** No ads, no
subscription, no in-app purchases, no free tier.
The price lives on the Play listing, not in the build, which is why there is no Billing
client in the dependencies and no `com.android.vending.BILLING` permission in the APK —
that is what keeps "no network permission, nothing leaves your device" true of the
*shipped artefact* rather than just the source. Rationale, market anchors, the rejected
alternatives and the Console steps: [docs/MONETISATION.md](docs/MONETISATION.md).
⚠️ **The price must be set before the first upload** — Play allows paid → free but never
free → paid.
## Competitive context
The category leader is **File Manager Plus** (AlphaInventor; 100 M+ installs, 4.7–4.8★, free
with ads and in-app purchases, and a Data Safety form that shares device IDs with third
parties). What it offers, what its users praise, what they complain about, and which of those
complaints this app can answer without asking for a single new permission:
[docs/COMPETITIVE_ANALYSIS.md](docs/COMPETITIVE_ANALYSIS.md).
## Licence
Proprietary — all rights reserved.