Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds VPN Control Center widget and Siri Commands. #3414

Merged
merged 40 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3d66ea3
Adds a VPN control widget for the control center and lock screen
diegoreymendez Oct 6, 2024
925493f
Merged the latest from main
diegoreymendez Dec 3, 2024
7f58bcc
Updated the ControlCenter VPN icon
diegoreymendez Dec 3, 2024
20d8a76
Implements new Shortcuts section in VPN settings
diegoreymendez Dec 3, 2024
f6def20
WIP: Implementing new shortcuts section in VPN settings
diegoreymendez Dec 6, 2024
dfc9604
WIP
diegoreymendez Dec 6, 2024
f499f0e
WIP
diegoreymendez Dec 9, 2024
3acb595
WIP
diegoreymendez Dec 9, 2024
4940afb
WIP
diegoreymendez Dec 13, 2024
d909c58
Updates a string
diegoreymendez Dec 13, 2024
b05a83c
Add Siri support to start and stop the VPN. (#3415)
diegoreymendez Dec 18, 2024
f39f494
Merges the latest changes
diegoreymendez Dec 18, 2024
9ef3956
Rolls back some unintentional changes
diegoreymendez Dec 18, 2024
d791fea
Merges the latest from main
diegoreymendez Dec 18, 2024
c28cdc3
Rolls back an unintentional change
diegoreymendez Dec 18, 2024
300436a
Updates DRK
diegoreymendez Dec 18, 2024
34b1f57
Cleans some code and updates copy
diegoreymendez Dec 19, 2024
ad75a7c
Updates pixels
diegoreymendez Dec 19, 2024
abef952
Fixes an issue with the widget education screen
diegoreymendez Dec 19, 2024
091f90d
Fixes some issues that were introduced by mistake
diegoreymendez Dec 19, 2024
cae4958
Feature flagged for ALPHA builds, cleaned up code
diegoreymendez Dec 20, 2024
8c886fc
Fixed a header
diegoreymendez Dec 20, 2024
1f2f8ad
swiftlint fixes
diegoreymendez Dec 20, 2024
ebb5214
Updates DRK
diegoreymendez Dec 20, 2024
826dd13
Rolls back an unintentional change
diegoreymendez Dec 20, 2024
446cff2
Rolled back an unintentional change
diegoreymendez Dec 20, 2024
5890980
Rolls back an unnecessary build step
diegoreymendez Dec 20, 2024
75ac9b3
Addresses PR feedback
diegoreymendez Dec 20, 2024
4470c03
Rolls back an unnecessary line
diegoreymendez Dec 20, 2024
47fce05
Fixes an issue in last commit
diegoreymendez Dec 20, 2024
654699e
Localized some strings
diegoreymendez Dec 20, 2024
ff62cc1
Update DuckDuckGo/VPNAutoShortcuts.swift
diegoreymendez Dec 20, 2024
45e2fce
Localizes some text
diegoreymendez Dec 20, 2024
3eae753
Merge branch 'diego/vpn-control-widget' of github.com:duckduckgo/iOS …
diegoreymendez Dec 20, 2024
b57333e
Rolls back some changes
diegoreymendez Dec 20, 2024
72538e0
Rolls back some unintentional changes
diegoreymendez Dec 20, 2024
f2977ba
Updates to DRK 3.3.1
diegoreymendez Dec 20, 2024
4793044
Merges the latest from main
diegoreymendez Dec 20, 2024
b712681
Added an explicit dependency to DRK 3.3.1 in aichat to try and get ar…
diegoreymendez Dec 20, 2024
0f9a9ca
Merged the latest from main
diegoreymendez Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Core/Pixel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class Pixel {
}

public static let storage = UserDefaults(suiteName: Constant.pixelStorageIdentifier)!

private init() {
}

Expand All @@ -203,7 +203,7 @@ public class Pixel {
includedParameters: [QueryParameters] = [.appVersion],
onComplete: @escaping (Error?) -> Void = { _ in },
debounce: Int = 0) {

let date = Date().addingTimeInterval(-TimeInterval(debounce))
if !pixel.hasBeenFiredSince(pixelStorage: storage, date: date) {
fire(
Expand Down
32 changes: 30 additions & 2 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,22 @@ extension Pixel {

case networkProtectionWidgetConnectAttempt
case networkProtectionWidgetConnectSuccess
case networkProtectionWidgetConnectCancelled
case networkProtectionWidgetConnectFailure
case networkProtectionWidgetDisconnectAttempt
case networkProtectionWidgetDisconnectSuccess
case networkProtectionWidgetDisconnectCancelled
case networkProtectionWidgetDisconnectFailure

case vpnControlCenterConnectAttempt
case vpnControlCenterConnectSuccess
case vpnControlCenterConnectCancelled
case vpnControlCenterConnectFailure

case vpnControlCenterDisconnectAttempt
case vpnControlCenterDisconnectSuccess
case vpnControlCenterDisconnectCancelled
case vpnControlCenterDisconnectFailure

case networkProtectionDNSUpdateCustom
case networkProtectionDNSUpdateDefault
Expand Down Expand Up @@ -1360,9 +1374,9 @@ extension Pixel.Event {
case .remoteMessagePrimaryActionClicked: return "m_remote_message_primary_action_clicked"
case .remoteMessageSecondaryActionClicked: return "m_remote_message_secondary_action_clicked"
case .remoteMessageSheet: return "m_remote_message_sheet"

// MARK: debug pixels

case .dbCrashDetected: return "m_d_crash"
case .crashOnCrashHandlersSetUp: return "m_d_crash_on_handlers_setup"
case .dbMigrationError: return "m_d_dbme"
Expand Down Expand Up @@ -1660,8 +1674,22 @@ extension Pixel.Event {

case .networkProtectionWidgetConnectAttempt: return "m_netp_widget_connect_attempt"
case .networkProtectionWidgetConnectSuccess: return "m_netp_widget_connect_success"
case .networkProtectionWidgetConnectCancelled: return "m_netp_widget_connect_cancelled"
samsymons marked this conversation as resolved.
Show resolved Hide resolved
case .networkProtectionWidgetConnectFailure: return "m_netp_widget_connect_failure"
case .networkProtectionWidgetDisconnectAttempt: return "m_netp_widget_disconnect_attempt"
case .networkProtectionWidgetDisconnectSuccess: return "m_netp_widget_disconnect_success"
case .networkProtectionWidgetDisconnectCancelled: return "m_netp_widget_disconnect_cancelled"
case .networkProtectionWidgetDisconnectFailure: return "m_netp_widget_disconnect_failure"

case .vpnControlCenterConnectAttempt: return "m_vpn_control-center_connect_attempt"
case .vpnControlCenterConnectSuccess: return "m_vpn_control-center_connect_success"
case .vpnControlCenterConnectCancelled: return "m_vpn_control-center_connect_cancelled"
case .vpnControlCenterConnectFailure: return "m_vpn_control-center_connect_failure"

case .vpnControlCenterDisconnectAttempt: return "m_vpn_control-center_disconnect_attempt"
case .vpnControlCenterDisconnectSuccess: return "m_vpn_control-center_disconnect_success"
case .vpnControlCenterDisconnectCancelled: return "m_vpn_control-center_disconnect_cancelled"
case .vpnControlCenterDisconnectFailure: return "m_vpn_control-center_disconnect_failure"

// MARK: Secure Vault
case .secureVaultL1KeyMigration: return "m_secure-vault_keystore_event_l1-key-migration"
Expand Down
173 changes: 148 additions & 25 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@
"version" : "6.41.0"
}
},
{
"identity" : "designresourceskit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/DesignResourcesKit",
"state" : {
"revision" : "ad133f76501edcb2bfa841e33aebc0da5f92bb5c",
"version" : "3.3.0"
}
},
{
"identity" : "duckduckgo-autofill",
"kind" : "remoteSourceControl",
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/DuckDuckGo.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<array>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.developer.siri</key>
samsymons marked this conversation as resolved.
Show resolved Hide resolved
<true/>
<key>com.apple.developer.web-browser</key>
<true/>
<key>com.apple.security.application-groups</key>
Expand Down
2 changes: 2 additions & 0 deletions DuckDuckGo/DuckDuckGoAlpha.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<array>
<string>packet-tunnel-provider</string>
</array>
<key>com.apple.developer.siri</key>
<true/>
<key>com.apple.developer.web-browser</key>
<true/>
<key>com.apple.security.application-groups</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Frame 624697 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "[email protected]",
"filename" : "Frame 624697.pdf",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Binary file not shown.
21 changes: 11 additions & 10 deletions DuckDuckGo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>youtube</string>
</array>
diegoreymendez marked this conversation as resolved.
Show resolved Hide resolved
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.duckduckgo.app.configurationRefresh</string>
Expand Down Expand Up @@ -168,10 +164,16 @@
<string>$(GROUP_ID_PREFIX)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>youtube</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://duckduckgo.com</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
Expand All @@ -189,10 +191,15 @@
<string>Allows you to save images to your device</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>This is required to use voice search. DuckDuckGo never records what you say.</string>
<key>NSSupportsLiveActivities</key>
<true/>
<key>NSUserActivityTypes</key>
<array>
<string>CancelSnoozeLiveActivityAppIntentIntent</string>
<string>ConfigurationIntent</string>
</array>
<key>SUBSCRIPTION_APP_GROUP</key>
<string>$(AppIdentifierPrefix)$(SUBSCRIPTION_APP_GROUP)</string>
<key>UIApplicationShortcutItems</key>
<array>
<dict>
Expand Down Expand Up @@ -227,10 +234,6 @@
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>SUBSCRIPTION_APP_GROUP</key>
<string>$(AppIdentifierPrefix)$(SUBSCRIPTION_APP_GROUP)</string>
<key>NSSupportsLiveActivities</key>
<true/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleDefault</string>
<key>UISupportedInterfaceOrientations~ipad</key>
Expand All @@ -240,8 +243,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://duckduckgo.com</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
</dict>
Expand Down
5 changes: 4 additions & 1 deletion DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ struct NetworkProtectionStatusView: View {
})
.applyInsetGroupedListStyle()
.sheet(isPresented: $statusModel.showAddWidgetEducationView) {
widgetEducationSheet()
if #available(iOS 17.0, *) {
samsymons marked this conversation as resolved.
Show resolved Hide resolved
widgetEducationSheet()
}
}
.onAppear {
if #available(iOS 18.0, *) {
Expand Down Expand Up @@ -413,6 +415,7 @@ struct NetworkProtectionStatusView: View {

// MARK: - Sheets

@available(iOS 17.0, *)
private func widgetEducationSheet() -> some View {
NavigationView {
WidgetEducationView()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/NetworkProtectionStatusViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ final class NetworkProtectionStatusViewModel: ObservableObject {
await disableNetP()
}

WidgetCenter.shared.reloadTimelines(ofKind: "VPNStatusWidget")
VPNReloadStatusWidgets()
samsymons marked this conversation as resolved.
Show resolved Hide resolved
}

@MainActor
Expand Down
71 changes: 55 additions & 16 deletions DuckDuckGo/NetworkProtectionVPNSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,14 @@ struct NetworkProtectionVPNSettingsView: View {
var body: some View {
VStack {
List {
// Widget only available for iOS 17 and up
if #available(iOS 17.0, *) {
Section {
NavigationLink {
WidgetEducationView.vpn
} label: {
Text(UserText.vpnSettingsAddWidget).daxBodyRegular()
}
}
.listRowBackground(Color(designSystemColor: .surface))
}
samsymons marked this conversation as resolved.
Show resolved Hide resolved

switch viewModel.viewKind {
case .loading: EmptyView()
case .unauthorized: notificationsUnauthorizedView
case .authorized: notificationAuthorizedView
}

shortcutsView

toggleSection(
text: UserText.netPExcludeLocalNetworksSettingTitle,
headerText: UserText.netPExcludeLocalNetworksSettingHeader,
Expand Down Expand Up @@ -156,17 +146,66 @@ struct NetworkProtectionVPNSettingsView: View {
.listRowBackground(Color(designSystemColor: .surface))
}

@ViewBuilder
private var shortcutsView: some View {
// Widget only available for iOS 17 and up
if #available(iOS 17.0, *) {
Section {
NavigationLink {
WidgetEducationView.vpn
} label: {
Label {
Text(UserText.vpnSettingsAddWidget)
} icon: {
Image(.addWidgetColor24)
.frame(width: 24, height: 24)
}.daxBodyRegular()
}

if #available(iOS 18.0, *) {
NavigationLink {
ControlCenterWidgetEducationView(navBarTitle: "Add DuckDuckGo VPN Shortcut to Your Control Center",
diegoreymendez marked this conversation as resolved.
Show resolved Hide resolved
widget: .vpnToggle)
} label: {
Label {
Text(UserText.vpnSettingsAddControlCenterWidget)
} icon: {
Image(.settingsColor24)
.frame(width: 24, height: 24)
}.daxBodyRegular()
}
}

NavigationLink {
SiriEducationView()
} label: {
Label {
Text(UserText.vpnSettingsControlWithSiri)
} icon: {
Image(.askSiriColor24)
.frame(width: 24, height: 24)
}.daxBodyRegular()
}
} header: {
Text(UserText.netPVPNShortcutsSectionHeader)
}
.listRowBackground(Color(designSystemColor: .surface))
}
}
}

@available(iOS 17.0, *)
private extension WidgetEducationView {

static var vpn: Self {
WidgetEducationView(
navBarTitle: UserText.vpnSettingsAddWidget,
navBarTitle: UserText.settingsAddWidgetTitle,
thirdParagraphText: UserText.addVPNWidgetSettingsThirdParagraph,
widgetExampleImageConfig: .init(
image: Image("WidgetEducationVPNWidgetExample"),
thirdParagraphDetail: .image(
Image("WidgetEducationVPNWidgetExample"),
maxWidth: 164,
horizontalOffset: -7
horizontalOffset: -7,
dropsShadow: true
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/NetworkProtectionWidgetRefreshModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NetworkProtectionWidgetRefreshModel {
}

public func refreshVPNWidget() {
WidgetCenter.shared.reloadTimelines(ofKind: "VPNStatusWidget")
VPNReloadStatusWidgets()
samsymons marked this conversation as resolved.
Show resolved Hide resolved
}

}
Loading