mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Fixes https://github.com/mozilla-mobile/fenix/issues/1735 - adds the ability to write code against the build channel (https://github.com/mozilla-mobile/fenix/pull/2388)
This commit is contained in:
parent
0785b7923e
commit
018b182c7e
@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- #2308 - Update the deprecated BitmapDrawable constructor
|
||||
- #1311 - Enable downloads in custom tabs.
|
||||
- #1874 - Added TOP info panel dialog for custom tabs.
|
||||
- #1735 - Adds API to see the release channel
|
||||
|
||||
### Changed
|
||||
- #1429 - Updated site permissions ui for MVP
|
||||
|
@ -32,8 +32,7 @@ android {
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
testInstrumentationRunnerArguments clearPackageData: 'true'
|
||||
manifestPlaceholders.isRaptorEnabled = "false"
|
||||
buildConfigField "boolean", "IS_RELEASED", "false"
|
||||
resValue "bool", "IS_NOT_RELEASED", "true"
|
||||
resValue "bool", "IS_DEBUG", "true"
|
||||
}
|
||||
|
||||
def releaseTemplate = {
|
||||
@ -55,13 +54,11 @@ android {
|
||||
applicationIdSuffix ".raptor"
|
||||
}
|
||||
nightly releaseTemplate >> {
|
||||
buildConfigField "boolean", "IS_RELEASED", "true"
|
||||
resValue "bool", "IS_NOT_RELEASED", "false"
|
||||
resValue "bool", "IS_DEBUG", "false"
|
||||
}
|
||||
beta releaseTemplate >> {
|
||||
applicationIdSuffix ".beta"
|
||||
buildConfigField "boolean", "IS_RELEASED", "true"
|
||||
resValue "bool", "IS_NOT_RELEASED", "false"
|
||||
resValue "bool", "IS_DEBUG", "false"
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,9 +130,10 @@ android.applicationVariants.all { variant ->
|
||||
|
||||
def buildType = variant.buildType.name
|
||||
def versionCode = null
|
||||
def isReleased = variant.buildType.buildConfigFields['IS_RELEASED']?.value ?: false
|
||||
def releaseChannels = ["nightly", "beta", "release"]
|
||||
def isReleased = releaseChannels.contains(buildType)
|
||||
|
||||
buildConfigField 'Boolean', 'COLLECTIONS_ENABLED', (buildType != "release").toString()
|
||||
buildConfigField 'Boolean', 'COLLECTIONS_ENABLED', (!isReleased).toString()
|
||||
|
||||
if (isReleased) {
|
||||
versionCode = generatedVersionCode
|
||||
|
24
app/src/main/java/org/mozilla/fenix/Config.kt
Normal file
24
app/src/main/java/org/mozilla/fenix/Config.kt
Normal file
@ -0,0 +1,24 @@
|
||||
/* 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
|
||||
|
||||
enum class ReleaseChannel {
|
||||
Debug, Nightly, Beta, Release;
|
||||
|
||||
val isReleased: Boolean
|
||||
get() = when (this) {
|
||||
Release, Beta, Nightly -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
object Config {
|
||||
val channel = when (BuildConfig.BUILD_TYPE) {
|
||||
"release" -> ReleaseChannel.Release
|
||||
"beta" -> ReleaseChannel.Beta
|
||||
"nightly" -> ReleaseChannel.Nightly
|
||||
else -> ReleaseChannel.Debug
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ import com.adjust.sdk.Adjust
|
||||
import com.adjust.sdk.AdjustConfig
|
||||
import com.adjust.sdk.LogLevel
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.Config
|
||||
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
class AdjustMetricsService(private val application: Application) : MetricsService {
|
||||
@ -18,7 +20,7 @@ class AdjustMetricsService(private val application: Application) : MetricsServic
|
||||
if ((BuildConfig.ADJUST_TOKEN.isNullOrEmpty())) {
|
||||
Log.i(LOGTAG, "No adjust token defined")
|
||||
|
||||
if (BuildConfig.IS_RELEASED) {
|
||||
if (Config.channel.isReleased) {
|
||||
throw IllegalStateException("No adjust token defined for release build")
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,9 @@ import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import kotlinx.android.synthetic.main.fragment_about.*
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.geckoview.BuildConfig
|
||||
import org.mozilla.geckoview.BuildConfig as GeckoViewBuildConfig
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
@ -30,7 +31,7 @@ class AboutFragment : Fragment() {
|
||||
val aboutText = try {
|
||||
val packageInfo = requireContext().packageManager.getPackageInfo(requireContext().packageName, 0)
|
||||
val geckoVersion = PackageInfoCompat.getLongVersionCode(packageInfo).toString() + " \uD83E\uDD8E " +
|
||||
BuildConfig.MOZ_APP_VERSION + "-" + BuildConfig.MOZ_APP_BUILDID
|
||||
GeckoViewBuildConfig.MOZ_APP_VERSION + "-" + GeckoViewBuildConfig.MOZ_APP_BUILDID
|
||||
String.format(
|
||||
"%s (Build #%s)",
|
||||
packageInfo.versionName,
|
||||
@ -40,7 +41,7 @@ class AboutFragment : Fragment() {
|
||||
""
|
||||
}
|
||||
|
||||
val buildDate = org.mozilla.fenix.BuildConfig.BUILD_DATE
|
||||
val buildDate = BuildConfig.BUILD_DATE
|
||||
val content = resources.getString(R.string.about_content, appName)
|
||||
|
||||
about_text.text = aboutText
|
||||
|
@ -24,10 +24,10 @@ import mozilla.components.concept.sync.OAuthAccount
|
||||
import mozilla.components.concept.sync.Profile
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import mozilla.components.service.fxa.FxaUnauthorizedException
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.FenixApplication
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
@ -206,7 +206,7 @@ class SettingsFragment : PreferenceFragmentCompat(), CoroutineScope, AccountObse
|
||||
preferenceMakeDefaultBrowser?.onPreferenceClickListener =
|
||||
getClickListenerForMakeDefaultBrowser()
|
||||
|
||||
if (!BuildConfig.IS_RELEASED) {
|
||||
if (!Config.channel.isReleased) {
|
||||
preferenceLeakCanary?.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||
(context?.applicationContext as FenixApplication).toggleLeakCanary(newValue as Boolean)
|
||||
|
@ -9,6 +9,7 @@ import android.content.Context.MODE_PRIVATE
|
||||
import android.content.SharedPreferences
|
||||
import mozilla.components.feature.sitepermissions.SitePermissionsRules
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import java.security.InvalidParameterException
|
||||
@ -52,7 +53,7 @@ class Settings private constructor(context: Context) {
|
||||
|
||||
val isCrashReportingEnabled: Boolean
|
||||
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_crash_reporter), true) &&
|
||||
BuildConfig.CRASH_REPORTING && BuildConfig.IS_RELEASED
|
||||
BuildConfig.CRASH_REPORTING && Config.channel.isReleased
|
||||
|
||||
val isRemoteDebuggingEnabled: Boolean
|
||||
get() = preferences.getBoolean(appContext.getPreferenceKey(R.string.pref_key_remote_debugging), false)
|
||||
|
@ -62,7 +62,7 @@
|
||||
android:icon="@drawable/ic_info"
|
||||
android:key="@string/pref_key_leakcanary"
|
||||
android:title="@string/preference_leakcanary"
|
||||
app:isPreferenceVisible="@bool/IS_NOT_RELEASED" />
|
||||
app:isPreferenceVisible="@bool/IS_DEBUG" />
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
@ -1,5 +1,5 @@
|
||||
import org.gradle.api.Project
|
||||
import java.lang.RuntimeException
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
Loading…
Reference in New Issue
Block a user