Merge branch 'enrich-interactions'

This commit is contained in:
Davide De Rosa 2019-03-19 18:05:07 +01:00
commit 05d777ca86
7 changed files with 55 additions and 34 deletions

View File

@ -56,6 +56,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
model.setFooter(L10n.Organizer.Sections.Hosts.footer, for: .hosts) model.setFooter(L10n.Organizer.Sections.Hosts.footer, for: .hosts)
if #available(iOS 12, *) { if #available(iOS 12, *) {
model.setHeader(L10n.Organizer.Sections.Siri.header, for: .siri) 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([.siriShortcuts], in: .siri)
} }
model.set([.openAbout], in: .about) model.set([.openAbout], in: .about)
@ -497,7 +498,7 @@ extension OrganizerViewController: ConnectionServiceDelegate {
tableView.reloadData() tableView.reloadData()
if #available(iOS 12, *) { if #available(iOS 12, *) {
IntentDispatcher.donateConnection(with: profile) IntentDispatcher.donateEnableVPN()
} }
// XXX: hack around bad replace when detail presented in compact view // XXX: hack around bad replace when detail presented in compact view
@ -544,7 +545,7 @@ extension OrganizerViewController: ConnectionServiceDelegate {
tableView.reloadData() tableView.reloadData()
if #available(iOS 12, *) { if #available(iOS 12, *) {
IntentDispatcher.donateConnection(with: profile) IntentDispatcher.donateEnableVPN()
} }
} }
} }

View File

@ -34,11 +34,14 @@ class ShortcutsViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = { let model: TableModel<SectionType, RowType> = {
let model: TableModel<SectionType, RowType> = TableModel() let model: TableModel<SectionType, RowType> = TableModel()
model.add(.vpn) model.add(.vpn)
model.add(.trust) model.add(.wifi)
model.add(.cellular)
model.set([.connect, .enableVPN, .disableVPN], in: .vpn) 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.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 return model
}() }()
@ -51,7 +54,6 @@ class ShortcutsViewController: UITableViewController, TableModelHost {
super.viewDidLoad() super.viewDidLoad()
title = L10n.Organizer.Cells.SiriShortcuts.caption title = L10n.Organizer.Cells.SiriShortcuts.caption
// itemNext.title = L10n.Global.next
} }
} }
@ -59,7 +61,9 @@ extension ShortcutsViewController {
enum SectionType { enum SectionType {
case vpn case vpn
case trust case wifi
case cellular
} }
enum RowType { enum RowType {
@ -69,9 +73,9 @@ extension ShortcutsViewController {
case disableVPN case disableVPN
case trustWiFi case trustCurrentWiFi
case untrustWiFi case untrustCurrentWiFi
case trustCellular case trustCellular
@ -102,11 +106,11 @@ extension ShortcutsViewController {
case .disableVPN: case .disableVPN:
cell.leftText = L10n.Shortcuts.Cells.DisableVpn.caption cell.leftText = L10n.Shortcuts.Cells.DisableVpn.caption
case .trustWiFi: case .trustCurrentWiFi:
cell.leftText = L10n.Shortcuts.Cells.TrustWifi.caption cell.leftText = L10n.Shortcuts.Cells.TrustCurrentWifi.caption
case .untrustWiFi: case .untrustCurrentWiFi:
cell.leftText = L10n.Shortcuts.Cells.UntrustWifi.caption cell.leftText = L10n.Shortcuts.Cells.UntrustCurrentWifi.caption
case .trustCellular: case .trustCellular:
cell.leftText = L10n.Shortcuts.Cells.TrustCellular.caption cell.leftText = L10n.Shortcuts.Cells.TrustCellular.caption
@ -132,10 +136,10 @@ extension ShortcutsViewController {
case .disableVPN: case .disableVPN:
addDisable() addDisable()
case .trustWiFi: case .trustCurrentWiFi:
addTrustWiFi() addTrustWiFi()
case .untrustWiFi: case .untrustCurrentWiFi:
addUntrustWiFi() addUntrustWiFi()
case .trustCellular: case .trustCellular:

View File

@ -227,6 +227,9 @@ class ServiceViewController: UIViewController, TableModelHost {
private func toggleVpnService(cell: ToggleTableViewCell) { private func toggleVpnService(cell: ToggleTableViewCell) {
if cell.isOn { if cell.isOn {
if #available(iOS 12, *) {
IntentDispatcher.donateConnection(with: uncheckedProfile)
}
guard !service.needsCredentials(for: uncheckedProfile) else { guard !service.needsCredentials(for: uncheckedProfile) else {
let alert = Macros.alert( let alert = Macros.alert(
L10n.Service.Sections.Vpn.header, L10n.Service.Sections.Vpn.header,
@ -247,16 +250,14 @@ class ServiceViewController: UIViewController, TableModelHost {
self.updateViewsIfNeeded() self.updateViewsIfNeeded()
} }
} else { } else {
if #available(iOS 12, *) {
IntentDispatcher.donateDisableVPN()
}
vpn.disconnect { (error) in vpn.disconnect { (error) in
self.reloadModel() self.reloadModel()
self.updateViewsIfNeeded() self.updateViewsIfNeeded()
} }
} }
if #available(iOS 12, *) {
IntentDispatcher.donateEnableVPN()
IntentDispatcher.donateDisableVPN()
}
} }
private func confirmVpnReconnection() { private func confirmVpnReconnection() {

View File

@ -49,7 +49,7 @@
</connections> </connections>
</tableView> </tableView>
<navigationItem key="navigationItem" id="Yck-NS-FzJ"> <navigationItem key="navigationItem" id="Yck-NS-FzJ">
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="8HE-Ax-VIa"> <barButtonItem key="leftBarButtonItem" systemItem="stop" id="8HE-Ax-VIa">
<connections> <connections>
<action selector="close" destination="mG2-gQ-aPy" id="Eua-Wd-kuz"/> <action selector="close" destination="mG2-gQ-aPy" id="Eua-Wd-kuz"/>
</connections> </connections>

View File

@ -26,6 +26,7 @@
"global.ok" = "OK"; "global.ok" = "OK";
"global.cancel" = "Cancel"; "global.cancel" = "Cancel";
"global.next" = "Next"; "global.next" = "Next";
"global.close" = "Close";
"global.host.title_input.message" = "Acceptable characters are alphanumerics plus dash \"-\", underscore \"_\" and dot \".\"."; "global.host.title_input.message" = "Acceptable characters are alphanumerics plus dash \"-\", underscore \"_\" and dot \".\".";
"global.host.title_input.placeholder" = "My Profile"; "global.host.title_input.placeholder" = "My Profile";
@ -40,6 +41,7 @@
"organizer.sections.hosts.header" = "Hosts"; "organizer.sections.hosts.header" = "Hosts";
"organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files."; "organizer.sections.hosts.footer" = "Import hosts from raw .ovpn configuration files.";
"organizer.sections.siri.header" = "Siri"; "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.profile.value.current" = "In use";
"organizer.cells.add_provider.caption" = "Add new network"; "organizer.cells.add_provider.caption" = "Add new network";
"organizer.cells.add_host.caption" = "Add new host"; "organizer.cells.add_host.caption" = "Add new host";
@ -196,12 +198,13 @@
"issue_reporter.email.description" = "description of the issue:"; "issue_reporter.email.description" = "description of the issue:";
"shortcuts.sections.vpn.header" = "VPN"; "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.connect.caption" = "Connect to";
"shortcuts.cells.enable_vpn.caption" = "Enable VPN"; "shortcuts.cells.enable_vpn.caption" = "Enable VPN";
"shortcuts.cells.disable_vpn.caption" = "Disable VPN"; "shortcuts.cells.disable_vpn.caption" = "Disable VPN";
"shortcuts.cells.trust_wifi.caption" = "Trust current Wi-Fi"; "shortcuts.cells.trust_current_wifi.caption" = "Trust current Wi-Fi";
"shortcuts.cells.untrust_wifi.caption" = "Untrust current Wi-Fi"; "shortcuts.cells.untrust_current_wifi.caption" = "Untrust current Wi-Fi";
"shortcuts.cells.trust_cellular.caption" = "Trust cellular network"; "shortcuts.cells.trust_cellular.caption" = "Trust cellular network";
"shortcuts.cells.untrust_cellular.caption" = "Untrust cellular network"; "shortcuts.cells.untrust_cellular.caption" = "Untrust cellular network";
"shortcuts.alerts.no_profiles.message" = "There is no profile to connect to."; "shortcuts.alerts.no_profiles.message" = "There is no profile to connect to.";

View File

@ -200,11 +200,15 @@ public class IntentDispatcher {
public static func handleDisableVPN(_ intent: DisableVPNIntent, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) { public static func handleDisableVPN(_ intent: DisableVPNIntent, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) {
log.info("Disabling VPN...") log.info("Disabling VPN...")
VPN.shared.disconnect { (error) in
let vpn = VPN.shared
vpn.prepare {
vpn.disconnect { (error) in
notifyServiceUpdate() notifyServiceUpdate()
completionHandler?(error) completionHandler?(error)
} }
} }
}
public static func handleCurrentNetwork(trust: Bool, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) { public static func handleCurrentNetwork(trust: Bool, interaction: INInteraction?, completionHandler: ((Error?) -> Void)?) {
guard let currentWifi = Utils.currentWifiNetworkName() else { guard let currentWifi = Utils.currentWifiNetworkName() else {

View File

@ -269,6 +269,8 @@ public enum L10n {
public enum Global { public enum Global {
/// Cancel /// Cancel
public static let cancel = L10n.tr("Localizable", "global.cancel") public static let cancel = L10n.tr("Localizable", "global.cancel")
/// Close
public static let close = L10n.tr("Localizable", "global.close")
/// Next /// Next
public static let next = L10n.tr("Localizable", "global.next") public static let next = L10n.tr("Localizable", "global.next")
/// OK /// OK
@ -383,6 +385,8 @@ public enum L10n {
public static let header = L10n.tr("Localizable", "organizer.sections.providers.header") public static let header = L10n.tr("Localizable", "organizer.sections.providers.header")
} }
public enum Siri { 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 /// Siri
public static let header = L10n.tr("Localizable", "organizer.sections.siri.header") public static let header = L10n.tr("Localizable", "organizer.sections.siri.header")
} }
@ -682,28 +686,32 @@ public enum L10n {
/// Trust cellular network /// Trust cellular network
public static let caption = L10n.tr("Localizable", "shortcuts.cells.trust_cellular.caption") public static let caption = L10n.tr("Localizable", "shortcuts.cells.trust_cellular.caption")
} }
public enum TrustWifi { public enum TrustCurrentWifi {
/// Trust current Wi-Fi /// 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 { public enum UntrustCellular {
/// Untrust cellular network /// Untrust cellular network
public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_cellular.caption") public static let caption = L10n.tr("Localizable", "shortcuts.cells.untrust_cellular.caption")
} }
public enum UntrustWifi { public enum UntrustCurrentWifi {
/// Untrust current Wi-Fi /// 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 Sections {
public enum Trust { public enum Cellular {
/// Trust /// Cellular
public static let header = L10n.tr("Localizable", "shortcuts.sections.trust.header") public static let header = L10n.tr("Localizable", "shortcuts.sections.cellular.header")
} }
public enum Vpn { public enum Vpn {
/// VPN /// VPN
public static let header = L10n.tr("Localizable", "shortcuts.sections.vpn.header") 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")
}
} }
} }