aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-09-25 22:22:09 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2021-09-25 22:22:09 -0600
commit3935a369b866c67705f3e27944be56b94ea2b245 (patch)
tree8357994922ec99c4a6ad4a4683b8ce716bfdd203 /ui
parentversion: bump (diff)
downloadwireguard-android-3935a369b866c67705f3e27944be56b94ea2b245.tar.xz
wireguard-android-3935a369b866c67705f3e27944be56b94ea2b245.zip
ui,tunnel: support DNS search domains
wg-quick has supported this for a while, but not the config layer, and not the Go backend, so wire this all up. Requested-by: Alexis Geoffrey <alexis.geoffrey97@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt6
-rw-r--r--ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt2
-rw-r--r--ui/src/main/res/layout/tunnel_detail_fragment.xml37
-rw-r--r--ui/src/main/res/values/strings.xml1
4 files changed, 40 insertions, 6 deletions
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 adc42e7..e5ff4bc 100644
--- a/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt
+++ b/ui/src/main/java/com/wireguard/android/databinding/BindingAdapters.kt
@@ -153,6 +153,12 @@ object BindingAdapters {
}
@JvmStatic
+ @BindingAdapter("android:text")
+ fun setStringSetText(view: TextView, strings: Iterable<String?>?) {
+ view.text = if (strings != null) Attribute.join(strings) else ""
+ }
+
+ @JvmStatic
fun tryParseInt(s: String?): Int {
if (s == null)
return 0
diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
index bd2a983..16af043 100644
--- a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
+++ b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
@@ -81,7 +81,7 @@ class InterfaceProxy : BaseObservable, Parcelable {
constructor(other: Interface) {
addresses = Attribute.join(other.addresses)
- val dnsServerStrings = other.dnsServers.map { it.hostAddress }
+ val dnsServerStrings = other.dnsServers.map { it.hostAddress }.plus(other.dnsSearchDomains)
dnsServers = Attribute.join(dnsServerStrings)
excludedApplications.addAll(other.excludedApplications)
includedApplications.addAll(other.includedApplications)
diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml
index 16bc2dd..8e34f08 100644
--- a/ui/src/main/res/layout/tunnel_detail_fragment.xml
+++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml
@@ -167,8 +167,8 @@
android:layout_height="wrap_content"
android:contentDescription="@string/dns_servers"
android:nextFocusUp="@id/addresses_text"
- android:nextFocusDown="@id/listen_port_text"
- android:nextFocusForward="@id/listen_port_text"
+ android:nextFocusDown="@id/dns_search_domains_text"
+ android:nextFocusForward="@id/dns_search_domains_text"
android:onClick="@{ClipboardUtils::copyTextView}"
android:text="@{config.interface.dnsServers}"
android:visibility="@{config.interface.dnsServers.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
@@ -177,6 +177,33 @@
tools:text="8.8.8.8, 8.8.4.4" />
<TextView
+ android:id="@+id/dns_search_domains_label"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:labelFor="@+id/dns_search_domain_text"
+ android:text="@string/dns_search_domains"
+ android:visibility="@{config.interface.dnsSearchDomains.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/dns_servers_text" />
+
+ <TextView
+ android:id="@+id/dns_search_domains_text"
+ style="@style/DetailText"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/dns_search_domains"
+ android:nextFocusUp="@id/dns_servers_text"
+ android:nextFocusDown="@id/listen_port_text"
+ android:nextFocusForward="@id/listen_port_text"
+ android:onClick="@{ClipboardUtils::copyTextView}"
+ android:text="@{config.interface.dnsSearchDomains}"
+ android:visibility="@{config.interface.dnsSearchDomains.isEmpty() ? android.view.View.GONE : android.view.View.VISIBLE}"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/dns_search_domains_label"
+ tools:text="zx2c4.com" />
+
+ <TextView
android:id="@+id/listen_port_label"
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -187,7 +214,7 @@
app:layout_constraintEnd_toStartOf="@id/mtu_label"
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@id/dns_servers_text" />
+ app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" />
<TextView
android:id="@+id/listen_port_text"
@@ -196,7 +223,7 @@
android:layout_height="wrap_content"
android:contentDescription="@string/listen_port"
android:nextFocusRight="@id/mtu_text"
- android:nextFocusUp="@id/dns_servers_text"
+ android:nextFocusUp="@id/dns_search_domains_text"
android:nextFocusDown="@id/applications_text"
android:nextFocusForward="@id/mtu_text"
android:onClick="@{ClipboardUtils::copyTextView}"
@@ -220,7 +247,7 @@
app:layout_constraintHorizontal_weight="0.5"
app:layout_constraintLeft_toRightOf="@id/listen_port_label"
app:layout_constraintStart_toEndOf="@id/listen_port_label"
- app:layout_constraintTop_toBottomOf="@id/dns_servers_text" />
+ app:layout_constraintTop_toBottomOf="@id/dns_search_domains_text" />
<TextView
android:id="@+id/mtu_text"
diff --git a/ui/src/main/res/values/strings.xml b/ui/src/main/res/values/strings.xml
index 3be6979..badae61 100644
--- a/ui/src/main/res/values/strings.xml
+++ b/ui/src/main/res/values/strings.xml
@@ -109,6 +109,7 @@
<string name="disable_config_export_title">Disable config exporting</string>
<string name="disable_config_export_description">Disabling config exporting makes private keys less accessible</string>
<string name="dns_servers">DNS servers</string>
+ <string name="dns_search_domains">Search domains</string>
<string name="edit">Edit</string>
<string name="endpoint">Endpoint</string>
<string name="error_down">Error bringing down tunnel: %s</string>