feat: turn the paid app into a freemium app with ads and Pro

- add a single AdMob anchored adaptive banner to the free tier
- add UMP consent and a privacy-options entry point before ads load
- add the one-time Play Billing product `pro_no_ads`; Pro removes the banner
  and nothing else, every scan/selection/deletion feature stays free
- cache the entitlement locally, handle pending purchases, acknowledge and
  retry acknowledgement, and restore from Play on resume
- grandfather paid installs through `legacyPro.cutoffEpochMs`, checking both
  the new package and the old paid package declared in <queries>
- move the Play identity to `de.softwareapp_hb.fotodup.finder.free` while
  keeping the Kotlin namespace `de.softwareapp_hb.fotodup.finder`
- add a debug-only Pro toggle and focused monetisation tests
- add AGENTS.md, docs/codemap.md, docs/codemap.mmd and docs/MONETIZATION.md
- update README, PRIVACY, CHANGELOG, ROADMAP, store copy and the Play checklist
- bump to 1.1.0 / versionCode 4
This commit is contained in:
2026-10-20 09:28:29 +02:00
parent 3afa7d777d
commit 22091dd808
36 changed files with 3268 additions and 295 deletions
+114 -26
View File
@@ -1,19 +1,26 @@
# Foto Dup Finder
A fast, **ad-free**, **fully offline** Android app that finds and removes duplicate
and near-duplicate photos. Built as a direct answer to the slow, ad-laden cleanup
tools that ship with many phones.
A fast, private Android app that finds and removes duplicate and near-duplicate
photos. The free tier is supported by a single banner ad; a one-time **Pro**
purchase removes it.
Nothing ever leaves the device: the app declares no network permission, contains no
analytics and needs no account.
Your photos never leave the device: all scanning, hashing and grouping happen
on-device. The only network traffic is the ad/consent SDK and Google Play Billing
(for the optional Pro purchase). There is no account, no app-level analytics and no
upload; the ads SDK's own data collection is described in [PRIVACY.md](PRIVACY.md).
## Features
- **Free with one banner, Pro without ads**
- The free tier has every feature and one anchored banner at the bottom.
- A one-time in-app purchase (`pro_no_ads`) removes the banner.
- Nothing is locked behind Pro; the duplicate cleaner stays fully usable for free.
- **Two kinds of duplicates**
- *Exact* — byte-identical copies, found with a cheap size/head/tail signature
followed by a full SHA-256.
- *Near* — resized, recompressed or lightly edited versions, found with a 64-bit
perceptual difference hash (`dHash`) plus a Hamming-distance threshold.
pHash plus one RGB difference hash per colour channel, compared with
Hamming-distance thresholds.
- **Tiered, parallel pipeline**: only plausible candidates get a full hash, and the
work is spread across all CPU cores.
- **Persistent index** so a re-scan only touches new or changed files.
@@ -32,11 +39,15 @@ analytics and needs no account.
| Area | Choice |
|---|---|
| Application ID | `de.softwareapp_hb.fotodup.finder.free` (namespace/code package stays `de.softwareapp_hb.fotodup.finder`) |
| 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 |
| Image loading | Coil 3.5.0 |
| Storage | MediaStore read + a small SQLite hash cache |
| Ads | Google Mobile Ads 25.5.0 + UMP 4.0.0 |
| Purchases | Play Billing 9.1.0, one-time `pro_no_ads` |
| Network | only the ad/consent SDK and Play Billing; photos never leave the device |
| SDK levels | `compileSdk`/`targetSdk` 36, `minSdk` 26 |
`targetSdk` is 36 because Google Play requires new apps and updates to target
@@ -50,20 +61,27 @@ Android 16 (API 36) from 31 August 2026.
```
app/src/main/java/de/softwareapp_hb/fotodup/finder/
├── core/ Pure-Kotlin duplicate engine (no Android imports!)
├── core/ Pure-Kotlin duplicate engine (no Android imports!)
│ ├── Hashing.kt SHA-256 + cheap size/head/tail signature
│ ├── PerceptualHash.kt 64-bit dHash + Hamming distance
│ ├── PerceptualHash.kt 64-bit pHash
│ ├── RgbDHash.kt one difference hash per colour channel
│ ├── DuplicateGrouper.kt exact + perceptual grouping (union-find)
│ ├── DuplicatePolicy.kt Exact / Balanced / Aggressive thresholds
│ └── …
├── data/ MediaStore access, hashing, permissions, SQLite index, deletion
├── domain/ ScanEngine (tiered pipeline) + progress/result models
└── ui/ Compose theme, scanner screen, ViewModel, components
app/src/test/java/… JVM unit tests for the core engine
├── data/ MediaStore access, hashing, permissions, SQLite index, deletion
├── domain/ ScanController + ScanEngine (tiered pipeline) + result models
├── service/ dataSync foreground service + scan notification
├── monetization/ ProStore (Billing), AdsController (UMP + Ads), AdPolicy, LegacyPro
├── text/ shared enum → string-resource mappings
└── ui/ Compose theme, scanner, ad slot, Pro sheet, components
app/src/test/java/… JVM unit tests for core/data/domain/monetization
```
`core/` deliberately has **no Android dependencies**, so the trickiest logic
(hashing, perceptual hashing, grouping) is covered by fast JVM tests.
(hashing, perceptual hashing, grouping) is covered by fast JVM tests. The full
layered map, runtime flows and change-impact matrix are in
[`docs/codemap.md`](docs/codemap.md); the standalone graph is
[`docs/codemap.mmd`](docs/codemap.mmd).
## Building
@@ -73,16 +91,34 @@ Prerequisites:
- 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
# Copy the machine-specific template (this file is git-ignored)
cp local.properties.example local.properties
# then set sdk.dir=... and optionally the real AdMob ids
./gradlew :app:assembleDebug # debug APK
./gradlew :app:testDebugUnitTest # JVM unit tests for the engine
./gradlew :app:testDebugUnitTest # JVM unit tests
./gradlew :app:lintDebug # Android Lint
./gradlew :app:assembleRelease # R8-minified release APK
./gradlew :app:bundleRelease # Play-ready .aab
```
### AdMob / Pro configuration
Debug builds default to Google's public **test** ad ids, which are safe to click
and produce no revenue. A release build needs real ids and — if the app was sold as
a paid app — the legacy-Pro cutoff:
```properties
# local.properties (git-ignored)
admob.appId=ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY
admob.bannerUnitId=ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN
legacyPro.cutoffEpochMs=1793491200000 # first freemium release, epoch ms
```
The Gradle build warns while test ids or a zero cutoff are still in use. The full
AdMob, UMP, Play Console and Data Safety setup is in
[`docs/MONETIZATION.md`](docs/MONETIZATION.md).
### Installing on a device
```bash
@@ -137,9 +173,13 @@ Banding gives *exact* candidate recall for pHash distances up to 7 (see the comm
| `WRITE_EXTERNAL_STORAGE` (**API ≤ 29 only**) | legacy delete path on Android 10 |
| `POST_NOTIFICATIONS` (API 33+) | shows the scan-progress notification (optional — the scan runs without it) |
| `FOREGROUND_SERVICE` + `FOREGROUND_SERVICE_DATA_SYNC` | keeps a long scan alive while the app is backgrounded |
| `INTERNET` + `ACCESS_NETWORK_STATE` | free-tier ads/consent and the optional Pro purchase |
| `AD_ID` + `ACCESS_ADSERVICES_*` | merged by the Google Mobile Ads SDK; used for advertising |
| `WAKE_LOCK` | merged by the Google Mobile Ads SDK for ad rendering |
| `com.android.vending.BILLING` | merged by Play Billing; used only for `pro_no_ads` |
Deletion on Android 11+ always goes through the system consent dialog. The app
never requests `MANAGE_EXTERNAL_STORAGE`.
never requests `MANAGE_EXTERNAL_STORAGE`, and the ad/Billing SDKs never read photos.
### Scanning in the background
@@ -154,11 +194,32 @@ foreground service with a progress notification that has a **Cancel** action. So
When `POST_NOTIFICATIONS` is denied the scan still works; the notification is simply
not shown.
## Free tier, Pro and consent
- **Free** — all features plus one anchored adaptive banner at the bottom of the
scanner.
- **Pro** — one-time Play Billing product `pro_no_ads`; removes the banner. Price is
read from Play and shown localized; there is no subscription and no account.
- **Consent** — UMP is asked for consent before `MobileAds.initialize()`; a refused
or unresolved consent simply means no ad. Where UMP requires it, **Privacy
options** is available in the Options menu.
- **Existing paid customers** — grandfathered by the earliest `firstInstallTime` of
the new package and the old paid package (`de.softwareapp_hb.fotodup.finder`),
compared with `legacyPro.cutoffEpochMs`. The old app must still be installed on the
first freemium launch; otherwise use a promo code or support flow.
The entitlement is cached locally so an already-Pro install opens ad-free offline;
Play is re-queried on resume and is authoritative when it answers. The trade-off is
that this is a client-side entitlement — there is no backend or account.
Full setup, Play Console steps, Data Safety answers and testing matrix:
[`docs/MONETIZATION.md`](docs/MONETIZATION.md).
## Testing
`app/src/test` holds JVM unit tests for `core/`: SHA-256 test vectors, dHash bit
patterns, Hamming distance, exact/perceptual grouping, aspect-ratio filtering and
the reclaimable-bytes maths.
`app/src/test` holds JVM unit tests for `core/` (hashing, pHash/RGB dHash,
grouping, thresholds), `data/BoundedCall`, the Robolectric end-to-end scan, and the
pure monetisation rules (`AdPolicyTest`, `LegacyProTest`).
```bash
./gradlew :app:testDebugUnitTest
@@ -170,17 +231,33 @@ hand or with `adb shell input tap`. That is how the store screenshots are taken;
shot on AOSP AVDs running in **software emulation**, because this machine exposes no `/dev/kvm`
(see [docs/STORE_LISTING.md](docs/STORE_LISTING.md)).
Ads and Billing cannot be completed on an AOSP emulator: it has no Play services. Use a real device
with Play services for ads, and an internal-testing track plus a license tester for a purchase.
For the free/Pro UI split without a purchase, use the debug-only broadcast:
```bash
adb shell am broadcast -a de.softwareapp_hb.fotodup.finder.debug.GRANT_PRO \
-n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.debug.DebugProToggle
adb shell am broadcast -a de.softwareapp_hb.fotodup.finder.debug.REVOKE_PRO \
-n de.softwareapp_hb.fotodup.finder.free.debug/de.softwareapp_hb.fotodup.finder.debug.DebugProToggle
```
## Releasing to Google Play
See [docs/PLAY_RELEASE_CHECKLIST.md](docs/PLAY_RELEASE_CHECKLIST.md) (signing, store
listing, Data Safety, release notes, rollout), [docs/STORE_LISTING.md](docs/STORE_LISTING.md)
(ready-to-paste listing copy plus the icon / feature graphic generators),
[docs/AD_COPY.md](docs/AD_COPY.md) (the Google Ads headlines and descriptions, with a
character-count check) and [PRIVACY.md](PRIVACY.md).
character-count check), [`docs/MONETIZATION.md`](docs/MONETIZATION.md) and
[PRIVACY.md](PRIVACY.md).
The app is published as a **one-time paid app** — no ads, no subscription, no in-app purchases, and
therefore no Billing code or `com.android.vending.BILLING` permission in the APK: the price lives on
the listing, not in the build ([why](docs/STORE_LISTING.md#app-pricing)).
The app is **freemium** and uses the new applicationId
`de.softwareapp_hb.fotodup.finder.free`, so publish it as a **new free Play listing**;
the old paid listing at `.finder` is untouched. Create and activate the one-time
in-app product `pro_no_ads` on the new listing, and update the **Ads**,
**Advertising ID** and **Data Safety** declarations. Existing paid installs are
grandfathered via the legacy cutoff when the old app is still installed on the first
freemium launch. The old “pay once / no ads / no INTERNET” copy is historical.
The upload-ready graphics and screenshots live in [`store-assets/`](store-assets/).
`tools/make-store-assets.sh` regenerates the Play icon and feature graphic *and* the Google Ads
@@ -230,12 +307,23 @@ Byte units ("KB", "MB") and the duration formatter are intentionally left unloca
- The Aggressive policy may miss some pairs because of the banded candidate search.
- The very first scan of a huge library (50k+ photos) takes a while; later scans
reuse the hash index and are much faster.
- The Pro entitlement is **client-side** and can be tampered with on a rooted
device. There is no account or backend to verify it server-side.
- Ads and Billing need Google Play services; an AOSP emulator shows no banner and
cannot complete a purchase. The scanner still works there.
- Grandfathering a paid install is best-effort: the old paid app must still be installed
on the first freemium launch, and uninstall/reinstall, cleared data or a backup restore
that resets `firstInstallTime` can lose it.
- The committed store screenshots and feature graphic predate the banner and Pro
sheet; they need a re-shoot before the freemium listing goes live.
## Roadmap
The project is tracked against a milestone plan (M0–M10). What is done, what remains,
The project is tracked against a milestone plan (M0–M11). What is done, what remains,
the current release blockers and the candidate features all live in
[docs/ROADMAP.md](docs/ROADMAP.md).
[docs/ROADMAP.md](docs/ROADMAP.md). The architecture map is
[docs/codemap.md](docs/codemap.md) / [docs/codemap.mmd](docs/codemap.mmd), and
agent rules are in [AGENTS.md](AGENTS.md).
## Licence