Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -31,6 +34,7 @@ sealed class ConnectionMode {
is NotConnected -> "NotConnected"
is Derp -> "Derp($relayName)"
is Direct -> "Direct"
is PeerRelay -> "PeerRelay"
}
}

Expand All @@ -39,6 +43,7 @@ sealed class ConnectionMode {
is NotConnected -> R.drawable.xmark_circle
is Derp -> R.drawable.link_off
is Direct -> R.drawable.link
is PeerRelay -> R.drawable.link_off
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design input required.

}
}

Expand All @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design input required.

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
1 change: 1 addition & 0 deletions android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down