Skip to content

Commit e1d7967

Browse files
committed
ui/UserView: show custom control server URL in account switcher
Fixes tailscale/corp#23660 Brings each row of the account switcher to parity with iOS by using `LoginName` instead of `DisplayName`, and showing a custom control server hostname as a third row when it is set. Signed-off-by: Andrea Gottardo <[email protected]>
1 parent be89cb1 commit e1d7967

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

android/src/main/java/com/tailscale/ipn/ui/model/IpnState.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@ class IpnLocal {
123123
val UserProfile: Tailcfg.UserProfile,
124124
val NetworkProfile: Tailcfg.NetworkProfile? = null,
125125
val LocalUserID: String,
126+
var ControlURL: String? = null,
126127
) {
127128
fun isEmpty(): Boolean {
128129
return ID.isEmpty()
129130
}
131+
132+
// Returns true if the profile uses a custom control server (not Tailscale SaaS).
133+
fun isUsingCustomControlServer(): Boolean {
134+
return ControlURL != null && ControlURL != "controlplane.tailscale.com"
135+
}
130136
}
131137
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.tailscale.ipn.ui.view
55

66
import androidx.compose.foundation.clickable
77
import androidx.compose.foundation.layout.Box
8+
import androidx.compose.foundation.layout.Column
89
import androidx.compose.foundation.layout.offset
910
import androidx.compose.material.icons.Icons
1011
import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight
@@ -54,17 +55,26 @@ fun UserView(
5455
leadingContent = { Avatar(profile = profile, size = 36) },
5556
headlineContent = {
5657
AutoResizingText(
57-
text = profile.UserProfile.DisplayName,
58+
text = profile.UserProfile.LoginName,
5859
style = MaterialTheme.typography.titleMedium.short,
5960
minFontSize = MaterialTheme.typography.minTextSize,
6061
overflow = TextOverflow.Ellipsis)
6162
},
6263
supportingContent = {
63-
AutoResizingText(
64-
text = profile.NetworkProfile?.DomainName ?: "",
65-
style = MaterialTheme.typography.bodyMedium.short,
66-
minFontSize = MaterialTheme.typography.minTextSize,
67-
overflow = TextOverflow.Ellipsis)
64+
Column {
65+
AutoResizingText(
66+
text = profile.NetworkProfile?.DomainName ?: "",
67+
style = MaterialTheme.typography.bodyMedium.short,
68+
minFontSize = MaterialTheme.typography.minTextSize,
69+
overflow = TextOverflow.Ellipsis)
70+
if (profile.isUsingCustomControlServer()) {
71+
AutoResizingText(
72+
text = profile.ControlURL ?: "",
73+
style = MaterialTheme.typography.bodyMedium.short,
74+
minFontSize = MaterialTheme.typography.minTextSize,
75+
overflow = TextOverflow.Ellipsis)
76+
}
77+
}
6878
},
6979
trailingContent = {
7080
when (actionState) {

0 commit comments

Comments
 (0)