diff --git a/app/build.gradle b/app/build.gradle
index 91969d20f1..9df434e57b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,10 +12,10 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "org.mozilla.fenix"
- minSdkVersion 21
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
+ minSdkVersion Config.minSdkVersion
+ targetSdkVersion Config.targetSdkVersion
+ versionCode Config.versionCode
+ versionName Config.versionName + Config.generateVersionSuffix()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
diff --git a/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt b/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt
new file mode 100644
index 0000000000..121ed55593
--- /dev/null
+++ b/app/src/main/java/org/mozilla/fenix/AppRequestInterceptor.kt
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package org.mozilla.fenix
+
+import android.content.Context
+import mozilla.components.browser.errorpages.ErrorPages
+import mozilla.components.browser.errorpages.ErrorType
+import mozilla.components.concept.engine.EngineSession
+import mozilla.components.concept.engine.request.RequestInterceptor
+import org.mozilla.fenix.settings.AboutPage
+import org.mozilla.fenix.settings.SettingsFragment
+
+class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
+ override fun onLoadRequest(
+ session: EngineSession,
+ uri: String
+ ): RequestInterceptor.InterceptionResponse? {
+ return when (uri) {
+ SettingsFragment.aboutURL -> {
+ val page = AboutPage.createAboutPage(context)
+ return RequestInterceptor.InterceptionResponse.Content(page, encoding = base64)
+ }
+
+ else -> null
+ }
+ }
+
+ override fun onErrorRequest(
+ session: EngineSession,
+ errorType: ErrorType,
+ uri: String?
+ ): RequestInterceptor.ErrorResponse? {
+ return RequestInterceptor.ErrorResponse(ErrorPages.createErrorPage(context, errorType))
+ }
+
+ companion object {
+ const val base64 = "base64"
+ }
+}
diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt
index de81ba7749..cc9c18f42f 100644
--- a/app/src/main/java/org/mozilla/fenix/components/Core.kt
+++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt
@@ -16,6 +16,7 @@ import mozilla.components.concept.engine.Engine
import mozilla.components.concept.engine.EngineSession.TrackingProtectionPolicy
import mozilla.components.feature.session.HistoryDelegate
import mozilla.components.lib.crash.handler.CrashHandlerService
+import org.mozilla.fenix.AppRequestInterceptor
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoRuntimeSettings
@@ -32,6 +33,7 @@ class Core(private val context: Context) {
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val defaultSettings = DefaultSettings(
+ requestInterceptor = AppRequestInterceptor(context),
remoteDebuggingEnabled = false,
testingModeEnabled = false,
trackingProtectionPolicy = createTrackingProtectionPolicy(prefs),
diff --git a/app/src/main/java/org/mozilla/fenix/ext/String.kt b/app/src/main/java/org/mozilla/fenix/ext/String.kt
new file mode 100644
index 0000000000..04421f26f9
--- /dev/null
+++ b/app/src/main/java/org/mozilla/fenix/ext/String.kt
@@ -0,0 +1,16 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+package org.mozilla.fenix.ext
+
+/**
+ * Replaces the keys with the values with the map provided.
+ */
+fun String.replace(pairs: Map %about-version%Fenix
+
%1$s is produced by Mozilla. Our mission is to foster a healthy, open Internet.
+ ]]>
diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt
new file mode 100644
index 0000000000..616695148d
--- /dev/null
+++ b/buildSrc/src/main/java/Config.kt
@@ -0,0 +1,27 @@
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+object Config {
+ const val versionCode = 1
+ const val versionName = "1.0"
+
+ // Synchronized build configuration for all modules
+ const val compileSdkVersion = 28
+ const val minSdkVersion = 21
+ const val targetSdkVersion = 28
+
+ @JvmStatic
+ fun generateVersionSuffix(): String {
+ val today = Date()
+ // Append the year (2 digits) and week in year (2 digits). This will make it easier to distinguish versions and
+ // identify ancient versions when debugging issues. However this will still keep the same version number during
+ // the week so that we do not end up with a lot of versions in tools like Sentry. As an extra this matches the
+ // sections we use in the changelog (weeks).
+ return SimpleDateFormat(".yyww", Locale.US).format(today)
+ }
+}