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 2 commits
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
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/wire/android/WireApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.wire.android.feature.analytics.AnonymousAnalyticsRecorderImpl
import com.wire.android.feature.analytics.globalAnalyticsManager
import com.wire.android.feature.analytics.model.AnalyticsEvent
import com.wire.android.feature.analytics.model.AnalyticsSettings
import com.wire.android.util.AppNameUtil
import com.wire.android.util.CurrentScreenManager
import com.wire.android.util.DataDogLogger
import com.wire.android.util.LogFileWriter
Expand Down Expand Up @@ -240,7 +241,7 @@ class WireApplication : BaseApp() {
appLogger.d(
"""
> Device info:
App version=${BuildConfig.VERSION_NAME}
App version=${AppNameUtil.createAppName()}
OS version=${Build.VERSION.SDK_INT}
Phone model=${Build.BRAND}/${Build.MODEL}
Commit hash=${applicationContext.getGitBuildId()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import androidx.work.WorkManager
import com.wire.android.BuildConfig
import com.wire.android.appLogger
import com.wire.android.util.AppNameUtil
import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.android.workmanager.worker.enqueueMigrationWorker
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -46,7 +46,7 @@ class UpdateReceiver : BroadcastReceiver() {
}

override fun onReceive(context: Context, intent: Intent?) {
appLogger.i("App updated to ${BuildConfig.VERSION_NAME}")
appLogger.i("App updated to ${AppNameUtil.createAppName()}")
scope.launch {
if (migrationManager.shouldMigrate()) {
appLogger.i("Migration worker enqueued")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/com/wire/android/ui/debug/DebugScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.wire.android.navigation.WireDestination
import com.wire.android.ui.common.topappbar.NavigationIconType
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.destinations.MigrationScreenDestination
import com.wire.android.util.AppNameUtil
import com.wire.android.util.getMimeType
import com.wire.android.util.getUrisOfFilesInDirectory
import com.wire.android.util.multipleFileSharingIntent
Expand Down Expand Up @@ -103,7 +104,7 @@ internal fun UserDebugContent(
onShareLogs = debugContentState::shareLogs,
)
DebugDataOptions(
appVersion = BuildConfig.VERSION_NAME,
appVersion = AppNameUtil.createAppName(),
buildVariant = "${BuildConfig.FLAVOR}${BuildConfig.BUILD_TYPE.replaceFirstChar { it.uppercase() }}",
onCopyText = debugContentState::copyToClipboard,
onManualMigrationPressed = onManualMigrationPressed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.RootNavGraph
import com.wire.android.BuildConfig
import com.wire.android.R
import com.wire.android.model.Clickable
import com.wire.android.navigation.NavigationCommand
Expand Down Expand Up @@ -159,12 +158,12 @@ 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,
onClick = {
aboutThisAppContentState.copyToClipboard(BuildConfig.VERSION_NAME)
aboutThisAppContentState.copyToClipboard(state.appName)
}
)
)
Expand Down Expand Up @@ -210,7 +209,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.util.AppNameUtil
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 = AppNameUtil.createAppName()
)
)

init {
Expand Down
46 changes: 46 additions & 0 deletions app/src/main/kotlin/com/wire/android/util/AppNameUtil.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.util

import com.wire.android.BuildConfig

internal object AppNameUtil {

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
}
}
3 changes: 1 addition & 2 deletions app/src/main/kotlin/com/wire/android/util/EmailComposer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package com.wire.android.util

import android.os.Build
import com.wire.android.BuildConfig
import java.util.Date

sealed interface EmailComposer {
Expand Down Expand Up @@ -52,7 +51,7 @@ sealed interface EmailComposer {

private fun emailDebugHeader(deviceHash: String?, commitHash: String? = "unavailable"): String = """
--- DO NOT EDIT---
App Version: ${BuildConfig.VERSION_NAME}
App Version: ${AppNameUtil.createAppName()}
Device Hash: $deviceHash
Device: ${Build.MANUFACTURER} - ${Build.MODEL}
SDK: ${Build.VERSION.RELEASE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package com.wire.android.util

import android.content.Context
import android.os.Build
import com.wire.android.BuildConfig
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -28,7 +27,7 @@ import javax.inject.Singleton
class UserAgentProvider @Inject constructor(@ApplicationContext private val context: Context) {

val defaultUserAgent =
"Wire/${BuildConfig.VERSION_NAME}/${context.getGitBuildId()}/${getAndroidVersion()}"
"Wire/${AppNameUtil.createAppName()}/${context.getGitBuildId()}/${getAndroidVersion()}"

private fun getAndroidVersion(): String {
val sdkVersion: Int = Build.VERSION.SDK_INT
Expand Down
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