Skip to content
Merged
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,14 +34,16 @@ sealed class ConnectionMode {
is NotConnected -> "NotConnected"
is Derp -> "Derp($relayName)"
is Direct -> "Direct"
is PeerRelay -> "PeerRelay"
}
}

fun iconDrawable(): Int {
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
}
}

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
11 changes: 11 additions & 0 deletions android/src/main/res/drawable/arrow_right_alt_24px.xml
Original file line number Diff line number Diff line change
@@ -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>
11 changes: 11 additions & 0 deletions android/src/main/res/drawable/redo_24px.xml
Original file line number Diff line number Diff line change
@@ -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>
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