Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update app version name #WPB-11429 #3489

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private fun AboutThisAppContent(
)
SettingsItem(
title = stringResource(R.string.app_version),
text = BuildConfig.VERSION_NAME,
text = state.appName,
trailingIcon = R.drawable.ic_copy,
onIconPressed = Clickable(
enabled = true,
Expand Down Expand Up @@ -210,7 +210,7 @@ data class AboutThisAppContentState(
@Composable
private fun PreviewAboutThisAppScreen() = WireTheme {
AboutThisAppContent(
state = AboutThisAppState(commitish = "abcd-1234"),
state = AboutThisAppState(commitish = "abcd-1234", appName = "4.1.9-1234-beta"),
onBackPressed = { },
onItemClicked = { }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
package com.wire.android.ui.settings.about

data class AboutThisAppState(
val commitish: String = "null"
val commitish: String = "null",
val appName: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.BuildConfig
import com.wire.android.util.getGitBuildId
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
Expand All @@ -35,7 +36,9 @@ class AboutThisAppViewModel @Inject constructor(
) : ViewModel() {

var state by mutableStateOf(
AboutThisAppState()
AboutThisAppState(
appName = createAppName()
)
)

init {
Expand All @@ -50,4 +53,27 @@ class AboutThisAppViewModel @Inject constructor(
)
}
}

private fun createAppName(): String {
return "${BuildConfig.VERSION_NAME}-${leastSignificantVersionCode()}-${BuildConfig.FLAVOR}"
}

/**
* The last 5 digits of the VersionCode. From 0 to 99_999.
* It's an [Int], so it can be less than 5 digits when doing [toString], of course.
* Considering versionCode bumps every 5min, these are
* 288 per day
* 8640 per month
* 51840 per semester
* 103_680 per year. ~99_999
*
* So it takes almost a whole year until it rotates back.
* It's very unlikely that two APKs with the same version (_e.g._ 4.8.0)
* will have the same [leastSignificantVersionCode],
* unless they are build almost one year apart.
*/
@Suppress("MagicNumber")
private fun leastSignificantVersionCode(): Int {
return BuildConfig.VERSION_CODE % 100_000
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
applicationId = AndroidApp.id
defaultConfig.targetSdk = AndroidSdk.target
versionCode = AndroidApp.versionCode
versionName = "${AndroidApp.versionName}-${AndroidApp.leastSignificantVersionCode}"
versionName = AndroidApp.versionName
setProperty("archivesBaseName", "$applicationId-v$versionName")
}

Expand Down
19 changes: 0 additions & 19 deletions build-logic/plugins/src/main/kotlin/AndroidCoordinates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,4 @@ object AndroidApp {
fun setRootDir(rootDir: File) {
this._rootDir = rootDir
}

/**
* The last 5 digits of the VersionCode. From 0 to 99_999.
* It's an [Int], so it can be less than 5 digits when doing [toString], of course.
* Considering versionCode bumps every 5min, these are
* 288 per day
* 8640 per month
* 51840 per semester
* 103_680 per year. ~99_999
*
* So it takes almost a whole year until it rotates back.
* It's very unlikely that two APKs with the same version (_e.g._ 4.8.0)
* will have the same [leastSignificantVersionCode],
* unless they are build almost one year apart.
*/
@Suppress("MagicNumber")
val leastSignificantVersionCode by lazy {
versionCode % 100_000
}
}
2 changes: 1 addition & 1 deletion build-logic/plugins/src/main/kotlin/AppVersionPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AppVersionPlugin : Plugin<Project> {
val currentTime = LocalDateTime.now()
val versnisor = Versionizer(projectDir, currentTime)
val versionCode = versnisor.versionCode
val versionName = "${AndroidApp.versionName}-${AndroidApp.leastSignificantVersionCode}-fdroid"
val versionName = AndroidApp.versionName
val buildTime = currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) ?: error("Failed to get build time")
val appName = "com.wire"
// git commit hash code
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/scripts/variants.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ fun NamedDomainObjectContainer<ApplicationProductFlavor>.createAppFlavour(
create(flavour.buildName) {
dimension = flavour.dimensions
applicationId = flavorApplicationId
versionNameSuffix = "-${flavour.buildName}"
resValue("string", "app_name", flavour.appName)
manifestPlaceholders["sharedUserId"] = sharedUserId
manifestPlaceholders["appAuthRedirectScheme"] = flavorApplicationId
Expand Down
Loading