Skip to content

Commit

Permalink
Add FXIOS-10683 Focus iOS: Add new setting to control crash reporting (
Browse files Browse the repository at this point in the history
…#23812)

* Add crash toggle

* format

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

* Update focus-ios/Blockzilla/Settings/Controller/SettingsViewController.swift

Co-authored-by: Nishant Bhasin <[email protected]>

---------

Co-authored-by: Nishant Bhasin <[email protected]>
  • Loading branch information
razvanlitianu and nbhasin2 authored Jan 13, 2025
1 parent e47bb03 commit 199c003
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 17 deletions.
2 changes: 1 addition & 1 deletion focus-ios/Blockzilla/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private let SentryDSNKey = "SentryDSN"
extension AppDelegate {
func setupCrashReporting() {
// Do not enable crash reporting if collection of anonymous usage data is disabled.
if !Settings.getToggle(.sendAnonymousUsageData) {
if !Settings.getToggle(.crashToggle) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DesignSystem

class SettingsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
enum Section: String {
case defaultBrowser, general, privacy, usageData, studies, search, siri, integration, mozilla, secret
case defaultBrowser, general, privacy, usageData, crashReports, studies, search, siri, integration, mozilla, secret

var headerText: String? {
switch self {
Expand All @@ -28,14 +28,33 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
case .integration: return UIConstants.strings.toggleSectionSafari
case .mozilla: return UIConstants.strings.toggleSectionMozilla
case .secret: return nil
case .crashReports: return nil
}
}

static func getSections() -> [Section] {
var sections = [.defaultBrowser, .general, .privacy, .usageData, .studies, .search, .siri, integration, .mozilla]
var sections: [Section] = [
.defaultBrowser,
.general,
.privacy,
.usageData,
.studies,
.crashReports
]

// FXIOS-10900 Add the TOS section to the list of sections

sections.append(contentsOf: [
.search,
.siri,
integration,
.mozilla
])

if Settings.getToggle(.displaySecretMenu) {
sections.append(.secret)
}

return sections
}
}
Expand Down Expand Up @@ -106,6 +125,11 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
let studiesToggle = BlockerToggle(label: UIConstants.strings.labelStudies, setting: SettingsToggle.studies, subtitle: studiesSubtitle)
let usageDataSubtitle = String(format: UIConstants.strings.detailTextSendUsageData, AppInfo.productName)
let usageDataToggle = BlockerToggle(label: UIConstants.strings.labelSendAnonymousUsageData, setting: SettingsToggle.sendAnonymousUsageData, subtitle: usageDataSubtitle)
let crashToggle = BlockerToggle(
label: UIConstants.strings.labelCrashReports,
setting: SettingsToggle.crashToggle,
subtitle: UIConstants.strings.detailTextCrashReports
)
let searchSuggestionSubtitle = String(format: UIConstants.strings.detailTextSearchSuggestion, AppInfo.productName)
let searchSuggestionToggle = BlockerToggle(label: UIConstants.strings.settingsSearchSuggestions, setting: SettingsToggle.enableSearchSuggestions, subtitle: searchSuggestionSubtitle)
let safariToggle = BlockerToggle(label: UIConstants.strings.toggleSafari, setting: SettingsToggle.safari)
Expand All @@ -124,6 +148,9 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
if let studiesIndex = getSectionIndex(Section.studies) {
toggles[studiesIndex] = [0: studiesToggle]
}
if let crashIndex = getSectionIndex(.crashReports) {
toggles[crashIndex] = [0: crashToggle]
}
if let searchIndex = getSectionIndex(Section.search) {
toggles[searchIndex] = [2: searchSuggestionToggle]
}
Expand Down Expand Up @@ -355,6 +382,8 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
case .secret:
cell = SettingsTableViewCell(style: .subtitle, reuseIdentifier: "secretSettingsCell")
cell.textLabel?.text = "Internal Settings"
case .crashReports:
cell = setupToggleCell(indexPath: indexPath, navigationController: navigationController)
}

cell.textLabel?.textColor = .primaryText
Expand All @@ -378,6 +407,7 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
case .integration: return 1
case .mozilla: return 3
case .secret: return 1
case .crashReports: return 1
}
}

Expand All @@ -394,34 +424,32 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
}

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
// If a toggle subtitle exists, create a standard footer with optional learn more actions
if let text = toggles[section]?.first?.value.subtitle {
let footer = ActionFooterView(frame: .zero)
footer.textLabel.text = text

if section == getSectionIndex(.usageData) || section == getSectionIndex(.studies) || section == getSectionIndex(.search) {
var selector: Selector?
if section == getSectionIndex(.usageData) {
selector = #selector(tappedLearnMoreFooter)
} else if section == getSectionIndex(.search) {
selector = #selector(tappedLearnMoreSearchSuggestionsFooter)
} else if section == getSectionIndex(.studies) {
selector = #selector(tappedLearnMoreStudies)
}

let learnMoreActions: [Int?: Selector] = [
getSectionIndex(.usageData): #selector(tappedLearnMoreFooter),
getSectionIndex(.search): #selector(tappedLearnMoreSearchSuggestionsFooter),
getSectionIndex(.studies): #selector(tappedLearnMoreStudies),
getSectionIndex(.crashReports): #selector(tappedLearnMoreCrashReports)
]
if let selector = learnMoreActions[section] {
let tapGesture = UITapGestureRecognizer(target: self, action: selector)
footer.detailTextButton.setTitle(UIConstants.strings.learnMore, for: .normal)
footer.detailTextButton.addGestureRecognizer(tapGesture)
}
return footer
} else if section == getSectionIndex(.defaultBrowser) {
}
if section == getSectionIndex(.defaultBrowser) {
let footer = ActionFooterView(frame: .zero)
footer.textLabel.text = String(format: UIConstants.strings.setAsDefaultBrowserDescriptionLabel, AppInfo.productName)
return footer
} else {
return nil
}
return nil
}


func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return sections[section] == .privacy ? 50 : 30
}
Expand Down Expand Up @@ -517,6 +545,9 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi
func tappedLearnMoreStudies(gestureRecognizer: UIGestureRecognizer) {
tappedFooter(forSupportTopic: .studies)
}
@objc func tappedLearnMoreCrashReports() {
tappedFooter(forSupportTopic: .mobileCrashReports)
}

@objc
private func dismissSettings() {
Expand Down
3 changes: 3 additions & 0 deletions focus-ios/Blockzilla/Utilities/SupportUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum SupportTopic: CaseIterable {
case autofillDomain
case trackingProtection
case addSearchEngine
case mobileCrashReports

public var slug: String {
switch self {
Expand All @@ -26,6 +27,8 @@ public enum SupportTopic: CaseIterable {
return "tracking-protection-focus-ios"
case .addSearchEngine:
return "add-search-engine-ios"
case .mobileCrashReports:
return "mobile-crash-reports"
}
}

Expand Down
2 changes: 2 additions & 0 deletions focus-ios/Shared/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum SettingsToggle: String, Equatable {
case safari = "Safari"
case sendAnonymousUsageData = "SendAnonymousUsageData"
case studies = "Studies"
case crashToggle = "CrashToggle"
case enableDomainAutocomplete = "enableDomainAutocomplete"
case enableCustomDomainAutocomplete = "enableCustomDomainAutocomplete"
case enableSearchSuggestions = "enableSearchSuggestions"
Expand Down Expand Up @@ -64,6 +65,7 @@ struct Settings {
case .enableCustomDomainAutocomplete: return true
case .enableSearchSuggestions: return false
case .displaySecretMenu: return false
case .crashToggle: return true
}
}

Expand Down

0 comments on commit 199c003

Please sign in to comment.