From b05ee8a463ff8f49af8b2e3c7c58b26b8e792eae Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 3 Mar 2023 00:39:07 +0100 Subject: WIP: add dhcp addresses to tunnel details --- .../wireguard/android/model/ObservableTunnel.kt | 21 ++++++++++++- ui/src/main/res/layout/tunnel_detail_fragment.xml | 35 +++++++++++++++++++--- ui/src/main/res/values/strings.xml | 1 + 3 files changed, 52 insertions(+), 5 deletions(-) (limited to 'ui') 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 252e8759..d21b942b 100644 --- a/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt +++ b/ui/src/main/java/com/wireguard/android/model/ObservableTunnel.kt @@ -8,6 +8,7 @@ import android.util.Log import androidx.databinding.BaseObservable import androidx.databinding.Bindable 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 @@ -55,7 +56,10 @@ class ObservableTunnel internal constructor( } fun onStateChanged(state: Tunnel.State): Tunnel.State { - if (state != Tunnel.State.UP) onStatisticsChanged(null) + if (state != Tunnel.State.UP) { + onStatisticsChanged(null) + onDhcpChanged(null) + } this.state = state notifyPropertyChanged(BR.state) return state @@ -137,6 +141,21 @@ class ObservableTunnel internal constructor( } + @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 + } + + suspend fun deleteAsync() = manager.delete(this) diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index aef71e18..d869216e 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -142,8 +142,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/dhcp_addresses_text" + android:nextFocusForward="@id/dhcp_addresses_text" android:onClick="@{ClipboardUtils::copyTextView}" android:text="@{config.interface.addresses}" android:visibility="@{config.interface.addresses.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}" @@ -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/dhcp_addresses_text" /> Currently using dark (night) theme Use dark theme Delete + DHCP Addresses Select tunnel to delete Select a storage drive Please install a file management utility to browse files -- cgit v1.2.3