From 6686184a9fc9b68b3c28086b41842227f3819453 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 22 Jan 2021 20:19:45 +0100 Subject: [PATCH] Disable DNS HTTPS/TLS editing if non-manual --- .../iOS/Scenes/NetworkSettingsViewController.swift | 12 ++++++++++++ .../Service/Customization/DNSViewController.swift | 12 ++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Passepartout/App/iOS/Scenes/NetworkSettingsViewController.swift b/Passepartout/App/iOS/Scenes/NetworkSettingsViewController.swift index 1328951c..30e51a8a 100644 --- a/Passepartout/App/iOS/Scenes/NetworkSettingsViewController.swift +++ b/Passepartout/App/iOS/Scenes/NetworkSettingsViewController.swift @@ -451,12 +451,20 @@ extension NetworkSettingsViewController { let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.leftText = L10n.Core.Global.Captions.protocol cell.rightText = (networkSettings.dnsProtocol ?? .fallback)?.description + if networkChoices.dns == .manual { + cell.accessoryType = .disclosureIndicator + cell.isTappable = true + } else { + cell.accessoryType = .none + cell.isTappable = false + } return cell case .dnsCustom: let cell = Cells.field.dequeue(from: tableView, for: indexPath) cell.caption = nil cell.field.tag = FieldTag.dnsCustom.rawValue + cell.field.isEnabled = (networkChoices.dns == .manual) switch networkSettings.dnsProtocol { case .https: cell.field.placeholder = AppConstants.Placeholders.dohURL @@ -646,6 +654,10 @@ extension NetworkSettingsViewController { navigationController?.pushViewController(vc, animated: true) case .dnsProtocol: + guard networkChoices.dns == .manual else { + break + } + let vc = SingleOptionViewController() vc.applyTint(.current) vc.title = (cell as? SettingTableViewCell)?.leftText diff --git a/Passepartout/App/macOS/Scenes/Service/Customization/DNSViewController.swift b/Passepartout/App/macOS/Scenes/Service/Customization/DNSViewController.swift index 89b526dc..7f1a37d6 100644 --- a/Passepartout/App/macOS/Scenes/Service/Customization/DNSViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/Customization/DNSViewController.swift @@ -192,8 +192,11 @@ class DNSViewController: NSViewController, ProfileCustomization { } } - tableDNSAddresses.reset(withRows: networkSettings.dnsServers ?? [], isAddEnabled: currentChoice == .manual) - tableDNSDomains.reset(withRows: networkSettings.dnsSearchDomains ?? [], isAddEnabled: currentChoice == .manual) + let isManual = (currentChoice == .manual) + popupDNSProtocol.isEnabled = isManual + textDNSCustom.isEnabled = isManual + tableDNSAddresses.reset(withRows: networkSettings.dnsServers ?? [], isAddEnabled: isManual) + tableDNSDomains.reset(withRows: networkSettings.dnsSearchDomains ?? [], isAddEnabled: isManual) let isServer = (currentChoice == .server) constraintChoiceBottom.priority = isServer ? .defaultHigh : .defaultLow @@ -204,16 +207,17 @@ class DNSViewController: NSViewController, ProfileCustomization { } private func updateProtocolVisibility() { + let isManual = (currentChoice == .manual) let isCustom: Bool switch networkSettings.dnsProtocol { case .https: isCustom = true - textDNSCustom.placeholderString = AppConstants.Placeholders.dohURL + textDNSCustom.placeholderString = isManual ? AppConstants.Placeholders.dohURL : "" textDNSCustom.stringValue = networkSettings.dnsHTTPSURL?.absoluteString ?? "" case .tls: isCustom = true - textDNSCustom.placeholderString = AppConstants.Placeholders.dotServerName + textDNSCustom.placeholderString = isManual ? AppConstants.Placeholders.dotServerName : "" textDNSCustom.stringValue = networkSettings.dnsTLSServerName ?? "" default: