Skip to content

Commit

Permalink
Merge branch 'release/7.120.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed May 14, 2024
2 parents 273f982 + 78338f6 commit cb58823
Show file tree
Hide file tree
Showing 50 changed files with 1,101 additions and 283 deletions.
42 changes: 27 additions & 15 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,18 @@ extension Pixel {
case toggleReportDoNotSend
case toggleReportDismiss

case userBehaviorReloadTwice
case userBehaviorReloadAndRestart
case userBehaviorReloadAndFireButton
case userBehaviorReloadAndOpenSettings
case userBehaviorReloadAndTogglePrivacyControls
case userBehaviorFireButtonAndRestart
case userBehaviorFireButtonAndTogglePrivacyControls
case userBehaviorReloadTwiceWithin12Seconds
case userBehaviorReloadTwiceWithin24Seconds
case userBehaviorReloadAndRestartWithin30Seconds
case userBehaviorReloadAndRestartWithin50Seconds
case userBehaviorReloadThreeTimesWithin20Seconds
case userBehaviorReloadThreeTimesWithin40Seconds

case siteNotWorkingShown
case siteNotWorkingDismiss
case siteNotWorkingDismissByNavigation
case siteNotWorkingDismissByRefresh
case siteNotWorkingWebsiteIsBroken

// MARK: History
case historyStoreLoadFailed
Expand Down Expand Up @@ -1234,14 +1239,21 @@ extension Pixel.Event {
// MARK: - Apple Ad Attribution
case .appleAdAttribution: return "m_apple-ad-attribution"

// MARK: - User behavior
case .userBehaviorReloadTwice: return "m_reload-twice"
case .userBehaviorReloadAndRestart: return "m_reload-and-restart"
case .userBehaviorReloadAndFireButton: return "m_reload-and-fire-button"
case .userBehaviorReloadAndOpenSettings: return "m_reload-and-open-settings"
case .userBehaviorReloadAndTogglePrivacyControls: return "m_reload-and-toggle-privacy-controls"
case .userBehaviorFireButtonAndRestart: return "m_fire-button-and-restart"
case .userBehaviorFireButtonAndTogglePrivacyControls: return "m_fire-button-and-toggle-privacy-controls"
// MARK: - User behavior
case .userBehaviorReloadTwiceWithin12Seconds: return "m_reload-twice-within-12-seconds"
case .userBehaviorReloadTwiceWithin24Seconds: return "m_reload-twice-within-24-seconds"

case .userBehaviorReloadAndRestartWithin30Seconds: return "m_reload-and-restart-within-30-seconds"
case .userBehaviorReloadAndRestartWithin50Seconds: return "m_reload-and-restart-within-50-seconds"

case .userBehaviorReloadThreeTimesWithin20Seconds: return "m_reload-three-times-within-20-seconds"
case .userBehaviorReloadThreeTimesWithin40Seconds: return "m_reload-three-times-within-40-seconds"

case .siteNotWorkingShown: return "m_site-not-working_shown"
case .siteNotWorkingDismiss: return "m_site-not-working_dismiss"
case .siteNotWorkingDismissByNavigation: return "m_site-not-working.dismiss-by-navigation"
case .siteNotWorkingDismissByRefresh: return "m_site-not-working.dismiss-by-refresh"
case .siteNotWorkingWebsiteIsBroken: return "m_site-not-working_website-is-broken"

// MARK: - History debug
case .historyStoreLoadFailed: return "m_debug_history-store-load-failed"
Expand Down
1 change: 1 addition & 0 deletions Core/PixelExperiment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum PixelExperiment: String, CaseIterable {

// Internal state for users not included in any variant
case noVariant

}

extension PixelExperiment {
Expand Down
7 changes: 6 additions & 1 deletion Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,17 @@ public struct UserDefaultsWrapper<T> {
case appleAdAttributionReportCompleted = "com.duckduckgo.ios.appleAdAttributionReport.completed"

case didRefreshTimestamp = "com.duckduckgo.ios.userBehavior.didRefreshTimestamp"
case didBurnTimestamp = "com.duckduckgo.ios.userBehavior.didBurnTimestamp"
case didDoubleRefreshTimestamp = "com.duckduckgo.ios.userBehavior.didDoubleRefreshTimestamp"
case didRefreshCounter = "com.duckduckgo.ios.userBehavior.didRefreshCounter"
case userDidInteractWithBrokenSitePrompt = "com.duckduckgo.ios.userBehavior.userDidInteractWithBrokenSitePrompt"

case pixelExperimentInstalled = "com.duckduckgo.ios.pixel.experiment.installed"
case pixelExperimentCohort = "com.duckduckgo.ios.pixel.experiment.cohort"
case pixelExperimentEnrollmentDate = "com.duckduckgo.ios.pixel.experiment.enrollment.date"

case pixelExperimentForBrokenSitesInstalled = "com.duckduckgo.ios.pixel.experiment.for.broken.sites.installed"
case pixelExperimentForBrokenSitesCohort = "com.duckduckgo.ios.pixel.experiment.for.broken.sites.cohort"

}

private let key: Key
Expand Down
78 changes: 49 additions & 29 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "72be4e73360989af170399bc063fd5c628e1e84c",
"version" : "144.0.6"
"revision" : "c1ce2cb5015890868bac3be85fbac3794ab30cb4",
"version" : "144.0.7"
}
},
{
Expand Down Expand Up @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/privacy-dashboard",
"state" : {
"revision" : "14b13d0c3db38f471ce4ba1ecb502ee1986c84d7",
"version" : "3.5.0"
"revision" : "25b8903191a40b21b09525085fe325ae3386092e",
"version" : "3.6.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "NO"
language = "en"
codeCoverageEnabled = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
DaxDialogs.shared.primeForUse()
}

PixelExperimentForBrokenSites.install()
PixelExperiment.install()

// MARK: Sync initialisation
Expand Down Expand Up @@ -668,6 +669,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
showKeyboardIfSettingOn = true
syncService.scheduler.resumeSyncQueue()
}

AppDependencyProvider.shared.userBehaviorMonitor.handleAction(.reopenApp)
}

func applicationDidEnterBackground(_ application: UIApplication) {
Expand Down
61 changes: 61 additions & 0 deletions DuckDuckGo/BrokenSitePromptView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// BrokenSitePromptView.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import SwiftUI
import DuckUI
import DesignResourcesKit

struct BrokenSitePromptView: View {

let viewModel: BrokenSitePromptViewModel

var body: some View {
VStack {
VStack(alignment: .leading, spacing: 8) {
VStack(alignment: .leading) {
Text(UserText.siteNotWorkingTitle)
.font(Font(uiFont: .daxSubheadSemibold()))
Text(UserText.siteNotWorkingSubtitle)
.font(Font(uiFont: .daxSubheadRegular()))
}
HStack {
Spacer()
Button(UserText.siteNotWorkingDismiss, action: viewModel.onDidDismiss)
.buttonStyle(GhostButtonStyle())
.fixedSize()
Button(UserText.siteNotWorkingWebsiteIsBroken, action: viewModel.onDidSubmit)
.buttonStyle(PrimaryButtonStyle(compact: true))
.fixedSize()
}
}
.padding(EdgeInsets(top: 12, leading: 16, bottom: 4, trailing: 16))
Color(designSystemColor: .lines).frame(height: 1 / UIScreen.main.scale)
}
.background(Color(designSystemColor: .panel))
}

}

#Preview {

let viewModel = BrokenSitePromptViewModel(onDidDismiss: {},
onDidSubmit: {})
return BrokenSitePromptView(viewModel: viewModel)

}
32 changes: 32 additions & 0 deletions DuckDuckGo/BrokenSitePromptViewModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// BrokenSitePromptViewModel.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

final class BrokenSitePromptViewModel {

let onDidDismiss: () -> Void
let onDidSubmit: () -> Void

init(onDidDismiss: @escaping () -> Void, onDidSubmit: @escaping () -> Void) {
self.onDidDismiss = onDidDismiss
self.onDidSubmit = onDidSubmit
}

}
62 changes: 31 additions & 31 deletions DuckDuckGo/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extension MainViewFactory {
createLogoBackground()
createContentContainer()
createSuggestionTrayContainer()
createNotificationBarContainer()
createTopSlideContainer()
createStatusBackground()
createTabBarContainer()
createOmniBar()
Expand Down Expand Up @@ -109,12 +109,6 @@ extension MainViewFactory {
superview.addSubview(coordinator.navigationBarContainer)
}

final class NotificationBarContainer: UIView { }
private func createNotificationBarContainer() {
coordinator.notificationBarContainer = NotificationBarContainer()
superview.addSubview(coordinator.notificationBarContainer)
}

final class ContentContainer: UIView { }
private func createContentContainer() {
coordinator.contentContainer = ContentContainer()
Expand Down Expand Up @@ -180,16 +174,23 @@ extension MainViewFactory {
disableAutoresizingOnImmediateSubviews(coordinator.logoContainer)
}

final class TopSlideContainer: UIView { }
private func createTopSlideContainer() {
coordinator.topSlideContainer = TopSlideContainer()
coordinator.topSlideContainer.translatesAutoresizingMaskIntoConstraints = false
superview.addSubview(coordinator.topSlideContainer)
}

}

/// Add constraint functions
extension MainViewFactory {

private func constrainViews() {
constrainLogoBackground()
constrainTopSlideContainer()
constrainContentContainer()
constrainSuggestionTrayContainer()
constrainNotificationBarContainer()
constrainStatusBackground()
constrainTabBarContainer()
constrainNavigationBarContainer()
Expand Down Expand Up @@ -266,34 +267,12 @@ extension MainViewFactory {
])
}

private func constrainNotificationBarContainer() {
let notificationBarContainer = coordinator.notificationBarContainer!
let contentContainer = coordinator.contentContainer!
let navigationBarContainer = coordinator.navigationBarContainer!
let statusBackground = coordinator.statusBackground!

coordinator.constraints.notificationContainerTopToNavigationBar
= notificationBarContainer.constrainView(navigationBarContainer, by: .top, to: .bottom)
coordinator.constraints.notificationContainerTopToStatusBackground
= notificationBarContainer.constrainView(statusBackground, by: .top, to: .bottom)
coordinator.constraints.notificationContainerHeight = notificationBarContainer.constrainAttribute(.height, to: 0)

NSLayoutConstraint.activate([
notificationBarContainer.constrainView(superview, by: .width),
notificationBarContainer.constrainView(superview, by: .centerX),
coordinator.constraints.notificationContainerHeight,
notificationBarContainer.constrainView(contentContainer, by: .bottom, to: .top),
coordinator.constraints.notificationContainerTopToNavigationBar,
])
}

private func constrainContentContainer() {
let contentContainer = coordinator.contentContainer!
let toolbar = coordinator.toolbar!
let notificationBarContainer = coordinator.notificationBarContainer!
let navigationBarContainer = coordinator.navigationBarContainer!

coordinator.constraints.contentContainerTop = contentContainer.constrainView(notificationBarContainer, by: .top, to: .bottom)
coordinator.constraints.contentContainerTop = contentContainer.constrainView(coordinator.topSlideContainer!, by: .top, to: .bottom)
coordinator.constraints.contentContainerBottomToToolbarTop = contentContainer.constrainView(toolbar, by: .bottom, to: .top)
coordinator.constraints.contentContainerBottomToNavigationBarContainerTop
= contentContainer.constrainView(navigationBarContainer, by: .bottom, to: .top)
Expand Down Expand Up @@ -346,4 +325,25 @@ extension MainViewFactory {
])
}

private func constrainTopSlideContainer() {
let topSlideContainer = coordinator.topSlideContainer!
let navigationBarContainer = coordinator.navigationBarContainer!
let statusBackground = coordinator.statusBackground!

coordinator.constraints.topSlideContainerTopToNavigationBar = topSlideContainer.constrainView(navigationBarContainer, by: .top, to: .bottom)
coordinator.constraints.topSlideContainerTopToStatusBackground = topSlideContainer.constrainView(statusBackground, by: .top, to: .bottom)

coordinator.constraints.topSlideContainerBottomToNavigationBarBottom = topSlideContainer.constrainView(navigationBarContainer, by: .bottom)
coordinator.constraints.topSlideContainerBottomToStatusBackgroundBottom = topSlideContainer.constrainView(statusBackground, by: .bottom)

coordinator.constraints.topSlideContainerHeight = topSlideContainer.constrainAttribute(.height, to: 0, relatedBy: .greaterThanOrEqual)

NSLayoutConstraint.activate([
topSlideContainer.constrainView(superview, by: .width),
topSlideContainer.constrainView(superview, by: .centerX),
coordinator.constraints.topSlideContainerHeight,
coordinator.constraints.topSlideContainerBottomToNavigationBarBottom,
])
}

}
1 change: 1 addition & 0 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extension MainViewController {

currentTab?.privacyDashboard = controller
controller.popoverPresentationController?.delegate = controller
controller.view.backgroundColor = UIColor(designSystemColor: .backgroundSheets)

if UIDevice.current.userInterfaceIdiom == .pad {
controller.modalPresentationStyle = .formSheet
Expand Down
Loading

0 comments on commit cb58823

Please sign in to comment.