Skip to content

Commit cd993fe

Browse files
authored
ui: hide commit hashes in user-facing version string (#534)
We currently show the full version number everywhere. This pointlessly causes confusion for users, and is only really useful for Tailscale employees. Let's show the marketing version everywhere instead. Users can still tap on the version number to copy the full version string. The extended version is also available in the Android settings, when inspecting Tailscale from the Apps list. Signed-off-by: Andrea Gottardo <[email protected]>
1 parent a32c2aa commit cd993fe

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
package com.tailscale.ipn.ui.util
5+
6+
import com.tailscale.ipn.BuildConfig
7+
8+
class AppVersion {
9+
companion object {
10+
// Returns the short version of the build version, which is what users typically expect.
11+
// For instance, if the build version is "1.75.80-t8fdffb8da-g2daeee584df",
12+
// this function returns "1.75.80".
13+
fun Short(): String {
14+
// Split the full version string by hyphen (-)
15+
val parts = BuildConfig.VERSION_NAME.split("-")
16+
// Return only the part before the first hyphen
17+
return parts[0]
18+
}
19+
}
20+
}

android/src/main/java/com/tailscale/ipn/ui/view/AboutView.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.tailscale.ipn.BuildConfig
3333
import com.tailscale.ipn.R
3434
import com.tailscale.ipn.ui.Links
3535
import com.tailscale.ipn.ui.theme.logoBackground
36+
import com.tailscale.ipn.ui.util.AppVersion
3637

3738
@Composable
3839
fun AboutView(backToSettings: BackNavigation) {
@@ -69,9 +70,14 @@ fun AboutView(backToSettings: BackNavigation) {
6970
Text(
7071
modifier =
7172
Modifier.clickable {
73+
// When users tap on the version number, the extended version string
74+
// (including commit hashes) is copied to the clipboard.
75+
// This may be useful for debugging purposes...
7276
localClipboardManager.setText(AnnotatedString(BuildConfig.VERSION_NAME))
7377
},
74-
text = "${stringResource(R.string.version)} ${BuildConfig.VERSION_NAME}",
78+
// ... but we always display the short version in the UI to avoid user
79+
// confusion.
80+
text = "${stringResource(R.string.version)} ${AppVersion.Short()}",
7581
fontWeight = MaterialTheme.typography.bodyMedium.fontWeight,
7682
fontSize = MaterialTheme.typography.bodyMedium.fontSize)
7783
}

android/src/main/java/com/tailscale/ipn/ui/view/SettingsView.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import com.tailscale.ipn.ui.viewModel.SettingsNav
3939
import com.tailscale.ipn.ui.viewModel.SettingsViewModel
4040
import com.tailscale.ipn.ui.viewModel.VpnViewModel
4141
import com.tailscale.ipn.ui.notifier.Notifier
42+
import com.tailscale.ipn.ui.util.AppVersion
4243

4344
@Composable
4445
fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewModel(), vpnViewModel: VpnViewModel = viewModel()) {
@@ -112,7 +113,7 @@ fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewMo
112113
Lists.ItemDivider()
113114
Setting.Text(
114115
R.string.about_tailscale,
115-
subtitle = "${stringResource(id = R.string.version)} ${BuildConfig.VERSION_NAME}",
116+
subtitle = "${stringResource(id = R.string.version)} ${AppVersion.Short()}",
116117
onClick = settingsNav.onNavigateToAbout)
117118

118119
// TODO: put a heading for the debug section

0 commit comments

Comments
 (0)