summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-11-09 13:46:06 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-12-10 12:55:06 +0000
commite0fb1fc375d5448a1fb3214244807706d4759041 (patch)
treee39273444e37434dcc8e64e7057c22c8a60646c6 /android/src
parent063b71a95e1376c0becef4ff9c2c9ab48f745f56 (diff)
downloadmullvadvpn-e0fb1fc375d5448a1fb3214244807706d4759041.tar.xz
mullvadvpn-e0fb1fc375d5448a1fb3214244807706d4759041.zip
Implement removal of DNS addresses
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt8
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsServerHolder.kt10
2 files changed, 16 insertions, 2 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
index f724d4e292..eb35e36005 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt
@@ -92,7 +92,7 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
}
ViewTypes.SHOW_SERVER -> {
val view = inflater.inflate(R.layout.custom_dns_server, parentView, false)
- return CustomDnsServerHolder(view)
+ return CustomDnsServerHolder(view, this)
}
}
}
@@ -127,4 +127,10 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
}
}
}
+
+ fun removeDnsServer(address: InetAddress) {
+ jobTracker.newBackgroundJob("removeDnsServer $address") {
+ customDns.removeDnsServer(address)
+ }
+ }
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsServerHolder.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsServerHolder.kt
index 42a8a14d94..967077818e 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsServerHolder.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsServerHolder.kt
@@ -7,10 +7,18 @@ import kotlin.properties.Delegates.observable
import net.mullvad.mullvadvpn.R
import net.mullvad.talpid.util.addressString
-class CustomDnsServerHolder(view: View) : CustomDnsItemHolder(view) {
+class CustomDnsServerHolder(view: View, adapter: CustomDnsAdapter) : CustomDnsItemHolder(view) {
private val label: TextView = view.findViewById(R.id.label)
var serverAddress by observable<InetAddress?>(null) { _, _, address ->
label.text = address?.addressString() ?: ""
}
+
+ init {
+ view.findViewById<View>(R.id.remove).setOnClickListener {
+ serverAddress?.let { address ->
+ adapter.removeDnsServer(address)
+ }
+ }
+ }
}