From adf8c4596c726f599414fb2d26477346cb9a7ec4 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 3 Mar 2023 00:39:07 +0100 Subject: ui,tunnel: add dynamic addresses to tunnel details --- .../wireguard/android/model/ObservableTunnel.kt | 15 ++++++++++ ui/src/main/res/layout/tunnel_detail_fragment.xml | 35 +++++++++++++++++++--- ui/src/main/res/values/strings.xml | 1 + 3 files changed, 47 insertions(+), 4 deletions(-) (limited to 'ui/src') diff --git a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt index 03280b2f..55c84df5 100644 --- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt +++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt @@ -9,6 +9,7 @@ import androidx.databinding.BaseObservable import androidx.databinding.Bindable import com.wireguard.android.Application import com.wireguard.android.BR +import com.wireguard.android.backend.Dhcp import com.wireguard.android.backend.Statistics import com.wireguard.android.backend.Tunnel import com.wireguard.android.databinding.Keyed @@ -64,6 +65,7 @@ class ObservableTunnel internal constructor( fun onStateChanged(state: Tunnel.State): Tunnel.State { if (state != Tunnel.State.UP) { onStatisticsChanged(null) + onDhcpChanged(null) Application.getCoroutineScope().launch { onPeersReset() } @@ -159,6 +161,19 @@ class ObservableTunnel internal constructor( return statistics } + @get:Bindable + var dhcp: Dhcp? = null + private set + + override fun onDhcpChange(newDhcp: Dhcp) { + onDhcpChanged(newDhcp) + } + + fun onDhcpChanged(dhcp: Dhcp?): Dhcp? { + this.dhcp = dhcp + notifyPropertyChanged(BR.dhcp) + return dhcp + } // Remove dynamic peers, and reset static peers fun onPeersReset() { diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 6e2aaf16..425b364d 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -141,8 +141,8 @@ android:layout_height="wrap_content" android:contentDescription="@string/addresses" android:nextFocusUp="@id/public_key_text" - android:nextFocusDown="@id/dns_servers_text" - android:nextFocusForward="@id/dns_servers_text" + android:nextFocusDown="@id/dynamic_addresses_text" + android:nextFocusForward="@id/dynamic_addresses_text" android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{config.config.interface.addresses}" android:textAppearance="?attr/textAppearanceBodyLarge" @@ -151,6 +151,33 @@ app:layout_constraintTop_toBottomOf="@+id/addresses_label" tools:text="fc00:bbbb:bbbb:bb11::3:368b/128" /> + + + + + app:layout_constraintTop_toBottomOf="@id/dynamic_addresses_text" /> Currently using dark (night) theme Use dark theme Delete + Dynamic addresses Select tunnel to delete Select a storage drive Please install a file management utility to browse files -- cgit v1.2.3