mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
moving git versioning to the buildMeta abstraction
This commit is contained in:
parent
d42c27bfe0
commit
df02f505ad
13 changed files with 48 additions and 29 deletions
|
@ -62,6 +62,7 @@ object Config {
|
|||
const val HANDLE_CALL_ASSERTED_IDENTITY_EVENTS = false
|
||||
|
||||
const val LOW_PRIVACY_LOG_ENABLE = false
|
||||
const val ENABLE_STRICT_MODE_LOGS = false
|
||||
|
||||
/**
|
||||
* The analytics configuration to use for the Debug build type.
|
||||
|
|
|
@ -237,9 +237,6 @@ android {
|
|||
resValue "string", "app_name", "Element dbg"
|
||||
resValue "color", "launcher_background", "#0DBD8B"
|
||||
|
||||
// Set to true if you want to enable strict mode in debug
|
||||
buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false"
|
||||
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
if (project.hasProperty("coverage")) {
|
||||
|
@ -251,9 +248,6 @@ android {
|
|||
resValue "string", "app_name", "Element"
|
||||
resValue "color", "launcher_background", "#0DBD8B"
|
||||
|
||||
buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false"
|
||||
|
||||
// When updating this block, please also update the same block in the `nightly` buildType below
|
||||
postprocessing {
|
||||
removeUnusedCode true
|
||||
removeUnusedResources true
|
||||
|
|
|
@ -198,7 +198,7 @@ class VectorApplication :
|
|||
}
|
||||
|
||||
private fun enableStrictModeIfNeeded() {
|
||||
if (BuildConfig.ENABLE_STRICT_MODE_LOGS) {
|
||||
if (buildMeta.enableStrictModeLogs) {
|
||||
StrictMode.setThreadPolicy(
|
||||
StrictMode.ThreadPolicy.Builder()
|
||||
.detectAll()
|
||||
|
|
|
@ -215,6 +215,12 @@ object VectorStaticModule {
|
|||
sdkInt = Build.VERSION.SDK_INT,
|
||||
applicationId = BuildConfig.APPLICATION_ID,
|
||||
lowPrivacyLoggingEnabled = Config.LOW_PRIVACY_LOG_ENABLE,
|
||||
enableStrictModeLogs = Config.ENABLE_STRICT_MODE_LOGS,
|
||||
versionName = BuildConfig.VERSION_NAME,
|
||||
gitRevision = BuildConfig.GIT_REVISION,
|
||||
gitRevisionDate = BuildConfig.GIT_REVISION_DATE,
|
||||
gitBranchName = BuildConfig.GIT_BRANCH_NAME,
|
||||
buildNumber = BuildConfig.BUILD_NUMBER,
|
||||
)
|
||||
|
||||
@Provides
|
||||
|
|
|
@ -21,4 +21,10 @@ data class BuildMeta(
|
|||
val sdkInt: Int,
|
||||
val applicationId: String,
|
||||
val lowPrivacyLoggingEnabled: Boolean,
|
||||
val enableStrictModeLogs: Boolean,
|
||||
val versionName: String,
|
||||
val gitRevision: String,
|
||||
val gitRevisionDate: String,
|
||||
val gitBranchName: String,
|
||||
val buildNumber: String,
|
||||
)
|
||||
|
|
|
@ -62,9 +62,9 @@ class LoginSplashFragment @Inject constructor(
|
|||
if (buildMeta.isDebug || vectorPreferences.developerMode()) {
|
||||
views.loginSplashVersion.isVisible = true
|
||||
@SuppressLint("SetTextI18n")
|
||||
views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" +
|
||||
"Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" +
|
||||
"Build: ${BuildConfig.BUILD_NUMBER}"
|
||||
views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" +
|
||||
"Branch: ${buildMeta.gitBranchName}\n" +
|
||||
"Build: ${buildMeta.buildNumber}"
|
||||
views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,9 +54,9 @@ class LoginSplashSignUpSignInSelectionFragment2 @Inject constructor(
|
|||
if (buildMeta.isDebug || vectorPreferences.developerMode()) {
|
||||
views.loginSplashVersion.isVisible = true
|
||||
@SuppressLint("SetTextI18n")
|
||||
views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" +
|
||||
"Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" +
|
||||
"Build: ${BuildConfig.BUILD_NUMBER}"
|
||||
views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" +
|
||||
"Branch: ${buildMeta.gitBranchName}\n" +
|
||||
"Build: ${buildMeta.buildNumber}"
|
||||
views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ class FtueAuthSplashCarouselFragment @Inject constructor(
|
|||
if (buildMeta.isDebug || vectorPreferences.developerMode()) {
|
||||
views.loginSplashVersion.isVisible = true
|
||||
@SuppressLint("SetTextI18n")
|
||||
views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}#${BuildConfig.BUILD_NUMBER}\n" +
|
||||
"Branch: ${BuildConfig.GIT_BRANCH_NAME}"
|
||||
views.loginSplashVersion.text = "Version : ${buildMeta.versionName}#${buildMeta.buildNumber}\n" +
|
||||
"Branch: ${buildMeta.gitBranchName}"
|
||||
views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) }
|
||||
}
|
||||
views.splashCarousel.registerAutomaticUntilInteractionTransitions()
|
||||
|
|
|
@ -64,9 +64,9 @@ class FtueAuthSplashFragment @Inject constructor(
|
|||
if (buildMeta.isDebug || vectorPreferences.developerMode()) {
|
||||
views.loginSplashVersion.isVisible = true
|
||||
@SuppressLint("SetTextI18n")
|
||||
views.loginSplashVersion.text = "Version : ${BuildConfig.VERSION_NAME}\n" +
|
||||
"Branch: ${BuildConfig.GIT_BRANCH_NAME}\n" +
|
||||
"Build: ${BuildConfig.BUILD_NUMBER}"
|
||||
views.loginSplashVersion.text = "Version : ${buildMeta.versionName}\n" +
|
||||
"Branch: ${buildMeta.gitBranchName}\n" +
|
||||
"Build: ${buildMeta.buildNumber}"
|
||||
views.loginSplashVersion.debouncedClicks { navigator.openDebug(requireContext()) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import im.vector.app.R
|
|||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.getAllChildFragments
|
||||
import im.vector.app.core.extensions.toOnOff
|
||||
import im.vector.app.core.resources.BuildMeta
|
||||
import im.vector.app.features.settings.VectorLocale
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.devtools.GossipingEventsSerializer
|
||||
|
@ -74,7 +75,8 @@ class BugReporter @Inject constructor(
|
|||
private val vectorPreferences: VectorPreferences,
|
||||
private val vectorFileLogger: VectorFileLogger,
|
||||
private val systemLocaleProvider: SystemLocaleProvider,
|
||||
private val matrix: Matrix
|
||||
private val matrix: Matrix,
|
||||
private val buildMeta: BuildMeta,
|
||||
) {
|
||||
var inMultiWindowMode = false
|
||||
|
||||
|
@ -278,14 +280,14 @@ class BugReporter @Inject constructor(
|
|||
.addFormDataPart("can_contact", canContact.toString())
|
||||
.addFormDataPart("device_id", deviceId)
|
||||
.addFormDataPart("version", versionProvider.getVersion(longFormat = true, useBuildNumber = false))
|
||||
.addFormDataPart("branch_name", BuildConfig.GIT_BRANCH_NAME)
|
||||
.addFormDataPart("branch_name", buildMeta.gitBranchName)
|
||||
.addFormDataPart("matrix_sdk_version", Matrix.getSdkVersion())
|
||||
.addFormDataPart("olm_version", olmVersion)
|
||||
.addFormDataPart("device", Build.MODEL.trim())
|
||||
.addFormDataPart("verbose_log", vectorPreferences.labAllowedExtendedLogging().toOnOff())
|
||||
.addFormDataPart("multi_window", inMultiWindowMode.toOnOff())
|
||||
.addFormDataPart(
|
||||
"os", Build.VERSION.RELEASE + " (API " + Build.VERSION.SDK_INT + ") " +
|
||||
"os", Build.VERSION.RELEASE + " (API " + buildMeta.sdkInt + ") " +
|
||||
Build.VERSION.INCREMENTAL + "-" + Build.VERSION.CODENAME
|
||||
)
|
||||
.addFormDataPart("locale", Locale.getDefault().toString())
|
||||
|
@ -299,7 +301,7 @@ class BugReporter @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val buildNumber = BuildConfig.BUILD_NUMBER
|
||||
val buildNumber = buildMeta.buildNumber
|
||||
if (buildNumber.isNotEmpty() && buildNumber != "0") {
|
||||
builder.addFormDataPart("build_number", buildNumber)
|
||||
}
|
||||
|
@ -339,9 +341,9 @@ class BugReporter @Inject constructor(
|
|||
screenshot = null
|
||||
|
||||
// add some github labels
|
||||
builder.addFormDataPart("label", BuildConfig.VERSION_NAME)
|
||||
builder.addFormDataPart("label", buildMeta.versionName)
|
||||
builder.addFormDataPart("label", BuildConfig.FLAVOR_DESCRIPTION)
|
||||
builder.addFormDataPart("label", BuildConfig.GIT_BRANCH_NAME)
|
||||
builder.addFormDataPart("label", buildMeta.gitBranchName)
|
||||
|
||||
// Special for Element
|
||||
builder.addFormDataPart("label", "[Element]")
|
||||
|
|
|
@ -70,7 +70,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor(
|
|||
append(versionProvider.getVersion(longFormat = false, useBuildNumber = true))
|
||||
if (buildMeta.isDebug) {
|
||||
append(" ")
|
||||
append(BuildConfig.GIT_BRANCH_NAME)
|
||||
append(buildMeta.gitBranchName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,14 @@
|
|||
package im.vector.app.features.version
|
||||
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.core.resources.BuildMeta
|
||||
import im.vector.app.core.resources.VersionCodeProvider
|
||||
import javax.inject.Inject
|
||||
|
||||
class VersionProvider @Inject constructor(private val versionCodeProvider: VersionCodeProvider) {
|
||||
class VersionProvider @Inject constructor(
|
||||
private val versionCodeProvider: VersionCodeProvider,
|
||||
private val buildMeta: BuildMeta,
|
||||
) {
|
||||
|
||||
fun getVersion(longFormat: Boolean, useBuildNumber: Boolean): String {
|
||||
var result = "${BuildConfig.VERSION_NAME} [${versionCodeProvider.getVersionCode()}]"
|
||||
|
@ -31,9 +35,9 @@ class VersionProvider @Inject constructor(private val versionCodeProvider: Versi
|
|||
flavor += "-"
|
||||
}
|
||||
|
||||
var gitVersion = BuildConfig.GIT_REVISION
|
||||
val gitRevisionDate = BuildConfig.GIT_REVISION_DATE
|
||||
val buildNumber = BuildConfig.BUILD_NUMBER
|
||||
var gitVersion = buildMeta.gitRevision
|
||||
val gitRevisionDate = buildMeta.gitRevisionDate
|
||||
val buildNumber = buildMeta.buildNumber
|
||||
|
||||
var useLongFormat = longFormat
|
||||
|
||||
|
|
|
@ -24,4 +24,10 @@ fun aBuildMeta() = BuildMeta(
|
|||
sdkInt = Build.VERSION_CODES.O,
|
||||
applicationId = "im.vector",
|
||||
lowPrivacyLoggingEnabled = false,
|
||||
enableStrictModeLogs = false,
|
||||
versionName = "app-version-name",
|
||||
gitRevision = "abcdef",
|
||||
gitRevisionDate = "01-01-01",
|
||||
gitBranchName = "a-branch-name",
|
||||
buildNumber = "100",
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue