From 873fb58fd93d3cea6d62934b0d76ec5e055219d9 Mon Sep 17 00:00:00 2001 From: Graeme Arthur Date: Fri, 6 Oct 2023 20:52:58 +0200 Subject: [PATCH] NetP connection notifications improvements (#2073) --- ...workProtectionNotificationIdentifier.swift | 4 +--- DuckDuckGo.xcodeproj/project.pbxproj | 2 +- .../xcshareddata/swiftpm/Package.resolved | 8 ++++---- ...orkProtectionUNNotificationPresenter.swift | 19 +++++++++++++++---- PacketTunnelProvider/UserText.swift | 3 +++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Core/NetworkProtectionNotificationIdentifier.swift b/Core/NetworkProtectionNotificationIdentifier.swift index 66a29dcebd..20e1a7631a 100644 --- a/Core/NetworkProtectionNotificationIdentifier.swift +++ b/Core/NetworkProtectionNotificationIdentifier.swift @@ -20,9 +20,7 @@ import Foundation public enum NetworkProtectionNotificationIdentifier: String { - case reconnecting = "network-protection.notification.reconnecting" - case reconnected = "network-protection.notification.reconnected" - case connectionFailure = "network-protection.notification.connection-failure" + case connection = "network-protection.notification.connection" case superseded = "network-protection.notification.superseded" case test = "network-protection.notification.test" } diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 8c56d96777..479e0e274a 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -8970,7 +8970,7 @@ repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 80.4.1; + version = 81.0.0; }; }; C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 10ef7c2de8..4a2755a27d 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", "state": { "branch": null, - "revision": "9dea0583dc6269971fb4728bd3efa1ed53f88306", - "version": "80.4.1" + "revision": "5a77dc747a1bee25947b1d3ae3831922be05fd22", + "version": "81.0.0" } }, { @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/duckduckgo/content-scope-scripts", "state": { "branch": null, - "revision": "8def15fe8a4c2fb76730f640507e9fd1d6c1f8a7", - "version": "4.32.0" + "revision": "74b6142c016be354144f28551de41b50c4864b1f", + "version": "4.37.0" } }, { diff --git a/PacketTunnelProvider/NetworkProtection/NetworkProtectionUNNotificationPresenter.swift b/PacketTunnelProvider/NetworkProtection/NetworkProtectionUNNotificationPresenter.swift index 7ada176e81..28358d72c8 100644 --- a/PacketTunnelProvider/NetworkProtection/NetworkProtectionUNNotificationPresenter.swift +++ b/PacketTunnelProvider/NetworkProtection/NetworkProtectionUNNotificationPresenter.swift @@ -76,19 +76,30 @@ final class NetworkProtectionUNNotificationPresenter: NSObject, NetworkProtectio showNotification(.test, content) } - func showReconnectedNotification() { + func showConnectedNotification(serverLocation: String?) { + let body: String + if let serverLocation { + body = UserText.networkProtectionConnectionSuccessNotificationBody(serverLocation: serverLocation) + } else { + body = UserText.networkProtectionConnectionSuccessNotificationBody + } + let content = notificationContent(body: body) + showNotification(.connection, content) + } + + func showConnectionNotification(serverLocation: String?) { let content = notificationContent(body: UserText.networkProtectionConnectionSuccessNotificationBody) - showNotification(.reconnected, content) + showNotification(.connection, content) } func showReconnectingNotification() { let content = notificationContent(body: UserText.networkProtectionConnectionInterruptedNotificationBody) - showNotification(.reconnecting, content) + showNotification(.connection, content) } func showConnectionFailureNotification() { let content = notificationContent(body: UserText.networkProtectionConnectionFailureNotificationBody) - showNotification(.connectionFailure, content) + showNotification(.connection, content) } func showSupersededNotification() { diff --git a/PacketTunnelProvider/UserText.swift b/PacketTunnelProvider/UserText.swift index 0d2bd15fae..aa236db2e1 100644 --- a/PacketTunnelProvider/UserText.swift +++ b/PacketTunnelProvider/UserText.swift @@ -28,6 +28,9 @@ final class UserText { static let networkProtectionConnectionSuccessNotificationBody = NSLocalizedString("network.protection.success.notification.body", value: "Network Protection is On. Your location and online activity are protected.", comment: "The body of the notification shown when Network Protection reconnects successfully") + static func networkProtectionConnectionSuccessNotificationBody(serverLocation: String) -> String { NSLocalizedString("network.protection.success.notification.subtitle.including.serverLocation", value: "Routing device traffic through \(serverLocation).", comment: "The body of the notification shown when Network Protection connects successfully with the city + state/country as formatted parameter") + } + static let networkProtectionConnectionInterruptedNotificationBody = NSLocalizedString("network.protection.interrupted.notification.body", value: "Network Protection was interrupted. Attempting to reconnect now...", comment: "The body of the notification shown when Network Protection's connection is interrupted") static let networkProtectionConnectionFailureNotificationBody = NSLocalizedString("network.protection.failure.notification.body", value: "Network Protection failed to connect. Please try again later.", comment: "The body of the notification shown when Network Protection fails to reconnect")