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
+64 -3
View File
@@ -36,16 +36,68 @@ if (hasReleaseSigning) {
}
}
// --- Monetisation configuration --------------------------------------------------------------
//
// Real AdMob IDs and the legacy-Pro cutoff are machine/release specific, so they never live in
// version control. Put them in `local.properties` (git-ignored) or pass them on the command line:
//
// admob.appId=ca-app-pub-XXXXXXXXXXXXXXXX~YYYYYYYYYY
// admob.bannerUnitId=ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN
// legacyPro.cutoffEpochMs=1760918400000
//
// The defaults are Google's public test IDs, which are safe to click and produce no revenue.
// A release build that still uses a test ID is almost certainly a misconfiguration, hence the
// warning below. See docs/MONETIZATION.md for the complete setup.
val localProperties = Properties().apply {
val file = rootProject.file("local.properties")
if (file.exists()) file.inputStream().use { load(it) }
}
fun configValue(key: String, default: String): String =
(project.findProperty(key) as String?)?.takeIf { it.isNotBlank() }
?: localProperties.getProperty(key)?.takeIf { it.isNotBlank() }
?: default
val testAdMobAppId = "ca-app-pub-3940256099942544~3347511713"
val testAdMobBannerUnitId = "ca-app-pub-3940256099942544/9214589741"
val adMobAppId = configValue("admob.appId", testAdMobAppId)
val adMobBannerUnitId = configValue("admob.bannerUnitId", testAdMobBannerUnitId)
val legacyProCutoffEpochMs = configValue("legacyPro.cutoffEpochMs", "0").toLongOrNull() ?: 0L
if (adMobAppId == testAdMobAppId || adMobBannerUnitId == testAdMobBannerUnitId) {
logger.warn(
"AdMob is using Google's TEST ids. Set admob.appId and admob.bannerUnitId in " +
"local.properties (or -Padmob.appId=... -Padmob.bannerUnitId=...) before a release build.",
)
}
if (legacyProCutoffEpochMs <= 0L) {
logger.warn(
"legacyPro.cutoffEpochMs is unset: installs that predate the freemium release will NOT " +
"be grandfathered into Pro. Set it before shipping if the app was sold as a paid app.",
)
}
android {
namespace = "de.softwareapp_hb.fotodup.finder"
compileSdk = 36
defaultConfig {
applicationId = "de.softwareapp_hb.fotodup.finder"
// The installed package. This is intentionally different from `namespace`:
// the code package stays `de.softwareapp_hb.fotodup.finder`, while the Play
// listing is a new app at `.free`. Relative manifest class names resolve
// against the namespace, so `.MainActivity` still means the existing class.
applicationId = "de.softwareapp_hb.fotodup.finder.free"
minSdk = 26
targetSdk = 36
versionCode = 3
versionName = "1.0.2"
versionCode = 4
versionName = "1.1.0"
// AdMob reads its application id from the manifest, so it has to be a placeholder:
// the value differs between a developer machine, CI and a release build.
manifestPlaceholders["admobAppId"] = adMobAppId
buildConfigField("String", "ADMOB_BANNER_UNIT_ID", "\"$adMobBannerUnitId\"")
buildConfigField("long", "LEGACY_PRO_CUTOFF_EPOCH_MS", "${legacyProCutoffEpochMs}L")
vectorDrawables {
useSupportLibrary = true
@@ -93,6 +145,8 @@ android {
buildFeatures {
compose = true
// AdMob unit id + legacy-Pro cutoff are injected here.
buildConfig = true
}
testOptions {
@@ -186,6 +240,13 @@ dependencies {
implementation(libs.kotlinx.coroutines.android)
implementation(libs.coil.compose)
// Free tier: AdMob banner + UMP consent. Pro tier: one-time Play Billing product.
// The ads SDK merges INTERNET, ACCESS_NETWORK_STATE, AD_ID and the Privacy Sandbox
// permissions into the release manifest; billing-ktx merges com.android.vending.BILLING.
implementation(libs.play.services.ads)
implementation(libs.user.messaging.platform)
implementation(libs.billing.ktx)
debugImplementation(libs.androidx.compose.ui.tooling)
testImplementation(libs.junit)