From 4910edc398a9ad74414d5b198286055f182dea97 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Tue, 7 Mar 2023 20:18:07 +0100 Subject: WIP: add valid and preferred lifetime to dhcp leases --- .../main/java/com/wireguard/android/databinding/BindingAdapters.kt | 7 +++++++ ui/src/main/res/layout/tunnel_detail_fragment.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'ui/src') diff --git a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt index afba41cb..6b2040e1 100644 --- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt +++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt @@ -20,6 +20,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.wireguard.android.BR import com.wireguard.android.R +import com.wireguard.android.backend.Dhcp; import com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler import com.wireguard.android.widget.ToggleSwitch import com.wireguard.android.widget.ToggleSwitch.OnBeforeCheckedChangeListener @@ -169,6 +170,12 @@ object BindingAdapters { view.text = if (strings != null) Attribute.join(strings) else "" } + @JvmStatic + @BindingAdapter("android:text") + fun setDhcpLeaseSetText(view: TextView, dhcp: Dhcp?) { + view.text = if (dhcp?.leases != null) Attribute.join(dhcp.leases.map { it }) else "" + } + @JvmStatic fun tryParseInt(s: String?): Int { if (s == null) diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 425b364d..9b17a06c 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -171,7 +171,7 @@ android:nextFocusDown="@id/dns_servers_text" android:nextFocusForward="@id/dns_servers_text" android:onClick="@{ClipboardUtils::copyTextView}" - android:text="@{tunnel.dhcp.addresses}" + android:text="@{tunnel.dhcp}" android:textAppearance="?attr/textAppearanceBodyLarge" android:visibility="@{tunnel.dhcp == null ? android.view.View.GONE : android.view.View.VISIBLE}" app:layout_constraintStart_toStartOf="parent" -- cgit v1.2.3