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)
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()
}
}
}

View File

@ -34,11 +34,14 @@ class ShortcutsViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = {
let model: TableModel<SectionType, RowType> = 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:

View File

@ -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() {

View File

@ -49,7 +49,7 @@
</connections>
</tableView>
<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>
<action selector="close" destination="mG2-gQ-aPy" id="Eua-Wd-kuz"/>
</connections>

View File

@ -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.";

View File

@ -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)
}
}
}

View File

@ -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")
}
}
}