summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt4
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt19
2 files changed, 18 insertions, 5 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
index f9d0a76a32..6f1568327d 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt
@@ -152,10 +152,8 @@ class AdvancedFragment : ServiceDependentFragment(OnNoService.GoBack) {
parentActivity.backButtonHandler = {
if (customDnsAdapter.isEditing) {
customDnsAdapter.stopEditing()
- true
- } else {
- false
}
+ false
}
}
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 8b0ce3b48b..1c8b36e062 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
@@ -60,6 +60,12 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
init {
customDns.apply {
onDnsServersChanged.subscribe(this) { dnsServers ->
+ jobTracker.newBackgroundJob("toggleCustomDns") {
+ if (dnsServers.isEmpty()) {
+ customDns.disable()
+ }
+ }
+
jobTracker.newUiJob("updateDnsServers") {
customDnsServersLock.withLock {
activeCustomDnsServers = dnsServers
@@ -136,6 +142,11 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
}
fun onDestroy() {
+ jobTracker.newBackgroundJob("toggleCustomDns") {
+ if (cachedCustomDnsServers.isEmpty()) {
+ customDns.disable()
+ }
+ }
customDns.apply {
onDnsServersChanged.unsubscribe(this)
onEnabledChanged.unsubscribe(this)
@@ -215,13 +226,17 @@ class CustomDnsAdapter(val customDns: CustomDns) : Adapter<CustomDnsItemHolder>(
customDnsServersLock.withLock {
val position = jobTracker.runOnBackground {
val index = cachedCustomDnsServers.indexOf(address)
-
cachedCustomDnsServers.removeAt(index)
customDns.removeDnsServer(address)
-
index
}
+ // Immediately disable custom dns in the ui when the last server in the list has
+ // been removed to avoid glitches with the ADD_SERVER view.
+ if (cachedCustomDnsServers.size == 0) {
+ enabled = false
+ }
+
notifyItemRemoved(position)
}
}