diff --git a/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift b/Passepartout-iOS/Scenes/Organizer/OrganizerViewController.swift index 094ef709..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) @@ -497,7 +498,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 +545,7 @@ extension OrganizerViewController: ConnectionServiceDelegate { tableView.reloadData() if #available(iOS 12, *) { - IntentDispatcher.donateConnection(with: profile) + IntentDispatcher.donateEnableVPN() } } } diff --git a/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift b/Passepartout-iOS/Scenes/Organizer/ShortcutsViewController.swift index e1117628..5e5b85fb 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 }() @@ -51,7 +54,6 @@ class ShortcutsViewController: UITableViewController, TableModelHost { super.viewDidLoad() title = L10n.Organizer.Cells.SiriShortcuts.caption -// itemNext.title = L10n.Global.next } } @@ -59,7 +61,9 @@ extension ShortcutsViewController { enum SectionType { case vpn - case trust + case wifi + + case cellular } enum RowType { @@ -69,9 +73,9 @@ extension ShortcutsViewController { case disableVPN - case trustWiFi + case trustCurrentWiFi - case untrustWiFi + case untrustCurrentWiFi case trustCellular @@ -102,11 +106,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 +136,10 @@ extension ShortcutsViewController { case .disableVPN: addDisable() - case .trustWiFi: + case .trustCurrentWiFi: addTrustWiFi() - case .untrustWiFi: + case .untrustCurrentWiFi: addUntrustWiFi() case .trustCellular: 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() { 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 c6b25067..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"; @@ -40,6 +41,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"; @@ -196,12 +198,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/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) + } } } diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 575fa86d..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 @@ -383,6 +385,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") } @@ -682,28 +686,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") + } } }