diff options
| author | Albin <albin@mullvad.net> | 2021-11-04 09:23:09 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2021-11-04 09:23:09 +0100 |
| commit | ab10241a35aa5fe59b9007bf781e86d69c22bba0 (patch) | |
| tree | 151d3e638e948f3573460fed938c74f6dfbc316c | |
| parent | ff53b6000de722b23715b93aa1fd064bea22504f (diff) | |
| parent | 14a75ba1ceb36e338d2090f5403b43558c1a85fb (diff) | |
| download | mullvadvpn-ab10241a35aa5fe59b9007bf781e86d69c22bba0.tar.xz mullvadvpn-ab10241a35aa5fe59b9007bf781e86d69c22bba0.zip | |
Merge branch 'fix-custom-dns-auto-disable'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AdvancedFragment.kt | 4 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/customdns/CustomDnsAdapter.kt | 19 |
3 files changed, 19 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1835c4f4e7..4b2abd7901 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Line wrap the file at 100 chars. Th #### Android - Fix reconnect on app resume. Don't reconnect the tunnel every time the app is opened. - Fix invalid URLs. Rely on browser locale rather than app/system language. +- Automatically disable custom DNS when no servers have been added. #### macOS - Prevent app from showing when dragging tray icon on macOS. 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) } } |
