From baaa85db804a09635500eafeb40548a0adb61cb3 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Mon, 2 Nov 2020 11:10:18 +0100 Subject: [PATCH] Closes #16256: Introduce build flag for "Mozilla Online" variant. This patch introduces a build flag that can be used on demand on the command line (`./gradlew -PmozillaOnline [..}`) or permanently when added to local.properties (`mozillaOnline`). At runtime `Config.channel.isMozillaOnline` will return `true` if the flag was set at build time. --- app/build.gradle | 7 +++++++ app/src/main/java/org/mozilla/fenix/Config.kt | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 55b4e3176..34fef5de7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,6 +36,13 @@ android { manifestPlaceholders = [ "deepLinkScheme": deepLinkSchemeValue ] + + // Build flag for "Mozilla Online" variants. See `Config.isMozillaOnline`. + if (project.hasProperty("mozillaOnline") || gradle.hasProperty("localProperties.mozillaOnline")) { + buildConfigField "boolean", "MOZILLA_ONLINE", "true" + } else { + buildConfigField "boolean", "MOZILLA_ONLINE", "false" + } } def releaseTemplate = { diff --git a/app/src/main/java/org/mozilla/fenix/Config.kt b/app/src/main/java/org/mozilla/fenix/Config.kt index 5ee692e40..702bb532a 100644 --- a/app/src/main/java/org/mozilla/fenix/Config.kt +++ b/app/src/main/java/org/mozilla/fenix/Config.kt @@ -52,6 +52,13 @@ enum class ReleaseChannel { */ val isFenix: Boolean get() = !isFennec + + /** + * Is this a "Mozilla Online" build of Fenix? "Mozilla Online" is the Chinese branch of Mozilla + * and this flag will be `true` for builds shipping to Chinese app stores. + */ + val isMozillaOnline: Boolean + get() = BuildConfig.MOZILLA_ONLINE } object Config {