android: make ping peer relay aware (#714)

Updates tailscale/tailscale#17743

Signed-off-by: Jordan Whited <jordan@tailscale.com>
main
Jordan Whited 20 hours ago committed by GitHub
parent 9b7885ae8c
commit be50a28f72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -26,6 +26,7 @@ class IpnState {
val Addrs: List<String>? = null,
val CurAddr: String? = null,
val Relay: String? = null,
val PeerRelay: String? = null,
val Online: Boolean,
val ExitNode: Boolean,
val ExitNodeOption: Boolean,

@ -17,12 +17,15 @@ sealed class ConnectionMode {
class Direct : ConnectionMode()
class PeerRelay : ConnectionMode()
@Composable
fun titleString(): String {
return when (this) {
is NotConnected -> stringResource(id = R.string.not_connected)
is Derp -> stringResource(R.string.relayed_connection, relayName)
is Direct -> stringResource(R.string.direct_connection)
is PeerRelay -> stringResource(R.string.peer_relayed_connection)
}
}
@ -31,6 +34,7 @@ sealed class ConnectionMode {
is NotConnected -> "NotConnected"
is Derp -> "Derp($relayName)"
is Direct -> "Direct"
is PeerRelay -> "PeerRelay"
}
}
@ -38,7 +42,8 @@ sealed class ConnectionMode {
return when (this) {
is NotConnected -> R.drawable.xmark_circle
is Derp -> R.drawable.link_off
is Direct -> R.drawable.link
is Direct -> R.drawable.arrow_right_alt_24px
is PeerRelay -> R.drawable.redo_24px
}
}
@ -48,6 +53,7 @@ sealed class ConnectionMode {
is NotConnected -> MaterialTheme.colorScheme.onPrimary
is Derp -> MaterialTheme.colorScheme.error
is Direct -> MaterialTheme.colorScheme.on
is PeerRelay -> MaterialTheme.colorScheme.on
}
}
}

@ -116,9 +116,12 @@ class PingViewModel : ViewModel() {
result.Peer?.let { map ->
map[peer.value?.Key]?.let { peerStatus ->
val curAddr = peerStatus.CurAddr.orEmpty()
val peerRelay = peerStatus.PeerRelay.orEmpty()
val relay = peerStatus.Relay.orEmpty()
if (curAddr.isNotEmpty()) {
this.connectionMode.set(ConnectionMode.Direct())
} else if (peerRelay.isNotEmpty()) {
this.connectionMode.set(ConnectionMode.PeerRelay())
} else if (relay.isNotEmpty()) {
this.connectionMode.set(ConnectionMode.Derp(relayName = relay.uppercase()))
}

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M560,720L504,662L646,520L160,520L160,440L646,440L504,298L560,240L800,480L560,720Z"/>
</vector>

@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M396,760Q299,760 229.5,697Q160,634 160,540Q160,446 229.5,383Q299,320 396,320L648,320L544,216L600,160L800,360L600,560L544,504L648,400L396,400Q333,400 286.5,440Q240,480 240,540Q240,600 286.5,640Q333,680 396,680L680,680L680,760L396,760Z"/>
</vector>

@ -303,6 +303,7 @@
<string name="ping">Ping</string>
<string name="relayed_connection">Relayed connection (%1$s)</string>
<string name="direct_connection">Direct connection</string>
<string name="peer_relayed_connection">Peer relayed connection</string>
<string name="pinging_node_name">Pinging %1$s</string>
<string name="pingFailed">Ping failed</string>
<string name="an_unknown_error_occurred_please_try_again">An unknown error occurred. Please try again.</string>

Loading…
Cancel
Save