Skip to content

Commit

Permalink
ui: hide commit hashes in user-facing version string (#534)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
agottardo authored Oct 4, 2024
1 parent a32c2aa commit cd993fe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
20 changes: 20 additions & 0 deletions android/src/main/java/com/tailscale/ipn/ui/util/AppVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

package com.tailscale.ipn.ui.util

import com.tailscale.ipn.BuildConfig

class AppVersion {
companion object {
// Returns the short version of the build version, which is what users typically expect.
// For instance, if the build version is "1.75.80-t8fdffb8da-g2daeee584df",
// this function returns "1.75.80".
fun Short(): String {
// Split the full version string by hyphen (-)
val parts = BuildConfig.VERSION_NAME.split("-")
// Return only the part before the first hyphen
return parts[0]
}
}
}
8 changes: 7 additions & 1 deletion android/src/main/java/com/tailscale/ipn/ui/view/AboutView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.tailscale.ipn.BuildConfig
import com.tailscale.ipn.R
import com.tailscale.ipn.ui.Links
import com.tailscale.ipn.ui.theme.logoBackground
import com.tailscale.ipn.ui.util.AppVersion

@Composable
fun AboutView(backToSettings: BackNavigation) {
Expand Down Expand Up @@ -69,9 +70,14 @@ fun AboutView(backToSettings: BackNavigation) {
Text(
modifier =
Modifier.clickable {
// When users tap on the version number, the extended version string
// (including commit hashes) is copied to the clipboard.
// This may be useful for debugging purposes...
localClipboardManager.setText(AnnotatedString(BuildConfig.VERSION_NAME))
},
text = "${stringResource(R.string.version)} ${BuildConfig.VERSION_NAME}",
// ... but we always display the short version in the UI to avoid user
// confusion.
text = "${stringResource(R.string.version)} ${AppVersion.Short()}",
fontWeight = MaterialTheme.typography.bodyMedium.fontWeight,
fontSize = MaterialTheme.typography.bodyMedium.fontSize)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.tailscale.ipn.ui.viewModel.SettingsNav
import com.tailscale.ipn.ui.viewModel.SettingsViewModel
import com.tailscale.ipn.ui.viewModel.VpnViewModel
import com.tailscale.ipn.ui.notifier.Notifier
import com.tailscale.ipn.ui.util.AppVersion

@Composable
fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewModel(), vpnViewModel: VpnViewModel = viewModel()) {
Expand Down Expand Up @@ -112,7 +113,7 @@ fun SettingsView(settingsNav: SettingsNav, viewModel: SettingsViewModel = viewMo
Lists.ItemDivider()
Setting.Text(
R.string.about_tailscale,
subtitle = "${stringResource(id = R.string.version)} ${BuildConfig.VERSION_NAME}",
subtitle = "${stringResource(id = R.string.version)} ${AppVersion.Short()}",
onClick = settingsNav.onNavigateToAbout)

// TODO: put a heading for the debug section
Expand Down

0 comments on commit cd993fe

Please sign in to comment.