From 03c8e43ce7ec45a325276e3513ccca25ffa22bca Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:12:24 +0100 Subject: [PATCH 1/5] Tweak intent donations - Activate -> EnableVPN - Connect -> ConnectVPN/MoveToLocation - Disconnect -> DisableVPN --- .../Scenes/Organizer/OrganizerViewController.swift | 4 ++-- Passepartout-iOS/Scenes/ServiceViewController.swift | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 094ef709..eaed87c0 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -497,7 +497,7 @@ extension OrganizerViewController: ConnectionServiceDelegate { tableView.reloadData() if #available(iOS 12, *) { - IntentDispatcher.donateConnection(with: profile) + IntentDispatcher.donateEnableVPN() } // XXX: hack around bad replace when detail presented in compact view @@ -544,7 +544,7 @@ extension OrganizerViewController: ConnectionServiceDelegate { tableView.reloadData() if #available(iOS 12, *) { - IntentDispatcher.donateConnection(with: profile) + IntentDispatcher.donateEnableVPN() } } } diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 1a051dd6..aa2d6762 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -227,6 +227,9 @@ class ServiceViewController: UIViewController, TableModelHost { private func toggleVpnService(cell: ToggleTableViewCell) { if cell.isOn { + if #available(iOS 12, *) { + IntentDispatcher.donateConnection(with: uncheckedProfile) + } guard !service.needsCredentials(for: uncheckedProfile) else { let alert = Macros.alert( L10n.Service.Sections.Vpn.header, @@ -247,16 +250,14 @@ class ServiceViewController: UIViewController, TableModelHost { self.updateViewsIfNeeded() } } else { + if #available(iOS 12, *) { + IntentDispatcher.donateDisableVPN() + } vpn.disconnect { (error) in self.reloadModel() self.updateViewsIfNeeded() } } - - if #available(iOS 12, *) { - IntentDispatcher.donateEnableVPN() - IntentDispatcher.donateDisableVPN() - } } private func confirmVpnReconnection() { From c0be33dacc9d17a2c3e58bbe159714ea9373d48f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:31:07 +0100 Subject: [PATCH 2/5] Add descriptive footer to Siri section --- Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift | 1 + Passepartout/Resources/en.lproj/Localizable.strings | 1 + Passepartout/Sources/SwiftGen+Strings.swift | 2 ++ 3 files changed, 4 insertions(+) diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index eaed87c0..32d32eca 100644 --- a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift @@ -56,6 +56,7 @@ class OrganizerViewController: UITableViewController, TableModelHost { model.setFooter(L10n.Organizer.Sections.Hosts.footer, for: .hosts) if #available(iOS 12, *) { model.setHeader(L10n.Organizer.Sections.Siri.header, for: .siri) + model.setFooter(L10n.Organizer.Sections.Siri.footer, for: .siri) model.set([.siriShortcuts], in: .siri) } model.set([.openAbout], in: .about) diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index c6b25067..7ded4cb6 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -40,6 +40,7 @@ "organizer.sections.hosts.header" = "Hosts"; "organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files."; "organizer.sections.siri.header" = "Siri"; +"organizer.sections.siri.footer" = "Get help from Siri to speed up your most common interactions with the app."; "organizer.cells.profile.value.current" = "In use"; "organizer.cells.add_provider.caption" = "Add new network"; "organizer.cells.add_host.caption" = "Add new host"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 575fa86d..5a1ccd64 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -383,6 +383,8 @@ public enum L10n { public static let header = L10n.tr("Localizable", "organizer.sections.providers.header") } public enum Siri { + /// Get help from Siri to speed up your most common interactions with the app. + public static let footer = L10n.tr("Localizable", "organizer.sections.siri.footer") /// Siri public static let header = L10n.tr("Localizable", "organizer.sections.siri.header") } From 63d74b6feb4e41c97884623439d4e6a03b78efb7 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:35:27 +0100 Subject: [PATCH 3/5] Reorganize shortcut sections --- .../Organizer/ShortcutsViewController.swift | 29 +++++++++++-------- .../Resources/en.lproj/Localizable.strings | 7 +++-- Passepartout/Sources/SwiftGen+Strings.swift | 18 +++++++----- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift index e1117628..642e261d 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift @@ -34,11 +34,14 @@ class ShortcutsViewController: UITableViewController, TableModelHost { let model: TableModel = { let model: TableModel = TableModel() model.add(.vpn) - model.add(.trust) + model.add(.wifi) + model.add(.cellular) model.set([.connect, .enableVPN, .disableVPN], in: .vpn) - model.set([.trustWiFi, .untrustWiFi, .trustCellular, .untrustCellular], in: .trust) + model.set([.trustCurrentWiFi, .untrustCurrentWiFi], in: .wifi) + model.set([.trustCellular, .untrustCellular], in: .cellular) model.setHeader(L10n.Shortcuts.Sections.Vpn.header, for: .vpn) - model.setHeader(L10n.Shortcuts.Sections.Trust.header, for: .trust) + model.setHeader(L10n.Shortcuts.Sections.Wifi.header, for: .wifi) + model.setHeader(L10n.Shortcuts.Sections.Cellular.header, for: .cellular) return model }() @@ -59,7 +62,9 @@ extension ShortcutsViewController { enum SectionType { case vpn - case trust + case wifi + + case cellular } enum RowType { @@ -69,9 +74,9 @@ extension ShortcutsViewController { case disableVPN - case trustWiFi + case trustCurrentWiFi - case untrustWiFi + case untrustCurrentWiFi case trustCellular @@ -102,11 +107,11 @@ extension ShortcutsViewController { case .disableVPN: cell.leftText = L10n.Shortcuts.Cells.DisableVpn.caption - case .trustWiFi: - cell.leftText = L10n.Shortcuts.Cells.TrustWifi.caption + case .trustCurrentWiFi: + cell.leftText = L10n.Shortcuts.Cells.TrustCurrentWifi.caption - case .untrustWiFi: - cell.leftText = L10n.Shortcuts.Cells.UntrustWifi.caption + case .untrustCurrentWiFi: + cell.leftText = L10n.Shortcuts.Cells.UntrustCurrentWifi.caption case .trustCellular: cell.leftText = L10n.Shortcuts.Cells.TrustCellular.caption @@ -132,10 +137,10 @@ extension ShortcutsViewController { case .disableVPN: addDisable() - case .trustWiFi: + case .trustCurrentWiFi: addTrustWiFi() - case .untrustWiFi: + case .untrustCurrentWiFi: addUntrustWiFi() case .trustCellular: diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 7ded4cb6..9baea107 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -197,12 +197,13 @@ "issue_reporter.email.description" = "description of the issue:"; "shortcuts.sections.vpn.header" = "VPN"; -"shortcuts.sections.trust.header" = "Trust"; +"shortcuts.sections.wifi.header" = "Wi-Fi"; +"shortcuts.sections.cellular.header" = "Cellular"; "shortcuts.cells.connect.caption" = "Connect to"; "shortcuts.cells.enable_vpn.caption" = "Enable VPN"; "shortcuts.cells.disable_vpn.caption" = "Disable VPN"; -"shortcuts.cells.trust_wifi.caption" = "Trust current Wi-Fi"; -"shortcuts.cells.untrust_wifi.caption" = "Untrust current Wi-Fi"; +"shortcuts.cells.trust_current_wifi.caption" = "Trust current Wi-Fi"; +"shortcuts.cells.untrust_current_wifi.caption" = "Untrust current Wi-Fi"; "shortcuts.cells.trust_cellular.caption" = "Trust cellular network"; "shortcuts.cells.untrust_cellular.caption" = "Untrust cellular network"; "shortcuts.alerts.no_profiles.message" = "There is no profile to connect to."; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 5a1ccd64..eab4778a 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -684,28 +684,32 @@ public enum L10n { /// Trust cellular network public static let caption = L10n.tr("Localizable", "shortcuts.cells.trust_cellular.caption") } - public enum TrustWifi { + public enum TrustCurrentWifi { /// Trust current Wi-Fi - public static let caption = L10n.tr("Localizable", "shortcuts.cells.trust_wifi.caption") + public static let caption = L10n.tr("Localizable", "shortcuts.cells.trust_current_wifi.caption") } public enum UntrustCellular { /// Untrust cellular network public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_cellular.caption") } - public enum UntrustWifi { + public enum UntrustCurrentWifi { /// Untrust current Wi-Fi - public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_wifi.caption") + public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_current_wifi.caption") } } public enum Sections { - public enum Trust { - /// Trust - public static let header = L10n.tr("Localizable", "shortcuts.sections.trust.header") + public enum Cellular { + /// Cellular + public static let header = L10n.tr("Localizable", "shortcuts.sections.cellular.header") } public enum Vpn { /// VPN public static let header = L10n.tr("Localizable", "shortcuts.sections.vpn.header") } + public enum Wifi { + /// Wi-Fi + public static let header = L10n.tr("Localizable", "shortcuts.sections.wifi.header") + } } } From af51911536bdc30403fbba79e11ebf504539f37d Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:52:09 +0100 Subject: [PATCH 4/5] Replace Cancel with X to exit shortcuts Misleading! --- Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift | 1 - Passepartout-iOS/en.lproj/Shortcuts.storyboard | 2 +- Passepartout/Resources/en.lproj/Localizable.strings | 1 + Passepartout/Sources/SwiftGen+Strings.swift | 2 ++ 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift index 642e261d..5e5b85fb 100644 --- a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift @@ -54,7 +54,6 @@ class ShortcutsViewController: UITableViewController, TableModelHost { super.viewDidLoad() title = L10n.Organizer.Cells.SiriShortcuts.caption -// itemNext.title = L10n.Global.next } } diff --git a/Passepartout-iOS/en.lproj/Shortcuts.storyboard b/Passepartout-iOS/en.lproj/Shortcuts.storyboard index 59f8d9e5..a564b5af 100644 --- a/Passepartout-iOS/en.lproj/Shortcuts.storyboard +++ b/Passepartout-iOS/en.lproj/Shortcuts.storyboard @@ -49,7 +49,7 @@ - + diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 9baea107..5e2e45ba 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -26,6 +26,7 @@ "global.ok" = "OK"; "global.cancel" = "Cancel"; "global.next" = "Next"; +"global.close" = "Close"; "global.host.title_input.message" = "Acceptable characters are alphanumerics plus dash \"-\", underscore \"_\" and dot \".\"."; "global.host.title_input.placeholder" = "My Profile"; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index eab4778a..b12911d3 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -269,6 +269,8 @@ public enum L10n { public enum Global { /// Cancel public static let cancel = L10n.tr("Localizable", "global.cancel") + /// Close + public static let close = L10n.tr("Localizable", "global.close") /// Next public static let next = L10n.tr("Localizable", "global.next") /// OK From 3bf340c74c48bdf88c19859d8e5f213157a23d51 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 17:57:51 +0100 Subject: [PATCH 5/5] Prepare before disconnection intent manager is nil otherwise in connect/disconnect. Doesn't apply to reinstall/reconnect. --- Passepartout/Sources/Intents/IntentDispatcher.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Passepartout/Sources/Intents/IntentDispatcher.swift b/Passepartout/Sources/Intents/IntentDispatcher.swift index c050d0be..a611e311 100644 --- a/Passepartout/Sources/Intents/IntentDispatcher.swift +++ b/Passepartout/Sources/Intents/IntentDispatcher.swift @@ -200,9 +200,13 @@ public class IntentDispatcher { public static func handleDisableVPN(_ intent: DisableVPNIntent, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) { log.info("Disabling VPN...") - VPN.shared.disconnect { (error) in - notifyServiceUpdate() - completionHandler?(error) + + let vpn = VPN.shared + vpn.prepare { + vpn.disconnect { (error) in + notifyServiceUpdate() + completionHandler?(error) + } } }