Skip to content

Commit 061f3cb

Browse files
authored
Bugfix FXIOS-11139 [ToS] Incorrect settings are displayed after modifying the defaults values in Manage bottom sheet (#24300)
* FXIOS-11139 [Terms of service] Incorrect settings are displayed after modifying the defaults values in Manage bottom sheet * Fixed SettingsTests
1 parent 3ce441a commit 061f3cb

File tree

6 files changed

+95
-140
lines changed

6 files changed

+95
-140
lines changed

firefox-ios/Client/Application/AccessibilityIdentifiers.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,6 @@ struct AccessibilityIdentifiers {
713713
}
714714

715715
struct SendData {
716-
static let sendAnonymousUsageDataTitle = "SendAnonymousUsageData"
717716
static let sendTechnicalDataTitle = "SendTechnicalData"
718717
static let sendCrashReportsTitle = "SendCrashReports"
719718
static let sendDailyUsagePingTitle = "SendDailyUsagePing"

firefox-ios/Client/Frontend/Settings/Main/AppSettingsTableViewController.swift

Lines changed: 53 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class AppSettingsTableViewController: SettingsTableViewController,
5454
weak var parentCoordinator: SettingsFlowDelegate?
5555

5656
// MARK: - Data Settings
57-
private var sendAnonymousUsageDataSetting: BoolSetting?
5857
private var sendTechnicalDataSetting: BoolSetting?
5958
private var sendCrashReportsSetting: BoolSetting?
6059
private var sendDailyUsagePingSetting: BoolSetting?
@@ -183,87 +182,56 @@ class AppSettingsTableViewController: SettingsTableViewController,
183182
private func setupDataSettings() {
184183
guard let profile else { return }
185184

186-
let isTermsOfServiceFeatureEnabled = featureFlags.isFeatureEnabled(.tosFeature, checking: .buildOnly)
187-
188185
let studiesSetting = StudiesToggleSetting(
189186
prefs: profile.prefs,
190187
delegate: settingsDelegate,
191188
theme: themeManager.getCurrentTheme(for: windowUUID),
192189
settingsDelegate: parentCoordinator,
193-
title: isTermsOfServiceFeatureEnabled ? .StudiesSettingTitleV2 : .SettingsStudiesToggleTitle,
194-
message: isTermsOfServiceFeatureEnabled ? .StudiesSettingMessageV2 : .SettingsStudiesToggleMessage,
195-
linkedText: isTermsOfServiceFeatureEnabled ? .StudiesSettingLinkV2 : .SettingsStudiesToggleLink,
196-
isToSEnabled: isTermsOfServiceFeatureEnabled
190+
title: .StudiesSettingTitleV2,
191+
message: .StudiesSettingMessageV2,
192+
linkedText: .StudiesSettingLinkV2
197193
)
198194

199-
// Only add these toggles to the Settings if Terms Of Service feature flag is enabled
200-
if isTermsOfServiceFeatureEnabled {
201-
let sendTechnicalDataSettings = SendDataSetting(
202-
prefs: profile.prefs,
203-
delegate: settingsDelegate,
204-
theme: themeManager.getCurrentTheme(for: windowUUID),
205-
settingsDelegate: parentCoordinator,
206-
title: .SendTechnicalDataSettingTitleV2,
207-
message: String(format: .SendTechnicalDataSettingMessageV2, AppName.shortName.rawValue),
208-
linkedText: .SendTechnicalDataSettingLinkV2,
209-
prefKey: AppConstants.prefSendUsageData,
210-
a11yId: AccessibilityIdentifiers.Settings.SendData.sendTechnicalDataTitle,
211-
learnMoreURL: SupportUtils.URLForTopic("mobile-technical-and-interaction-data"),
212-
isToSEnabled: isTermsOfServiceFeatureEnabled
213-
)
214-
215-
sendTechnicalDataSettings.shouldSendData = { [weak self] value in
216-
guard let self, let profile = self.profile else { return }
217-
TermsOfServiceManager(prefs: profile.prefs).shouldSendTechnicalData(value: value)
218-
studiesSetting.updateSetting(for: value)
219-
}
220-
sendTechnicalDataSetting = sendTechnicalDataSettings
195+
let sendTechnicalDataSettings = SendDataSetting(
196+
prefs: profile.prefs,
197+
delegate: settingsDelegate,
198+
theme: themeManager.getCurrentTheme(for: windowUUID),
199+
settingsDelegate: parentCoordinator,
200+
title: .SendTechnicalDataSettingTitleV2,
201+
message: String(format: .SendTechnicalDataSettingMessageV2, AppName.shortName.rawValue),
202+
linkedText: .SendTechnicalDataSettingLinkV2,
203+
prefKey: AppConstants.prefSendUsageData,
204+
a11yId: AccessibilityIdentifiers.Settings.SendData.sendTechnicalDataTitle,
205+
learnMoreURL: SupportUtils.URLForTopic("mobile-technical-and-interaction-data")
206+
)
221207

222-
let sendDailyUsagePingSettings = SendDataSetting(
223-
prefs: profile.prefs,
224-
delegate: settingsDelegate,
225-
theme: themeManager.getCurrentTheme(for: windowUUID),
226-
settingsDelegate: parentCoordinator,
227-
title: .SendDailyUsagePingSettingTitle,
228-
message: String(format: .SendDailyUsagePingSettingMessage, MozillaName.shortName.rawValue),
229-
linkedText: .SendDailyUsagePingSettingLinkV2,
230-
prefKey: AppConstants.prefSendDailyUsagePing,
231-
a11yId: AccessibilityIdentifiers.Settings.SendData.sendDailyUsagePingTitle,
232-
learnMoreURL: SupportUtils.URLForTopic("usage-ping-settings-mobile"),
233-
isToSEnabled: isTermsOfServiceFeatureEnabled
234-
)
235-
sendDailyUsagePingSettings.shouldSendData = { [weak self] value in
236-
if value {
237-
self?.gleanLifecycleObserver.startObserving()
238-
} else {
239-
self?.gleanLifecycleObserver.stopObserving()
240-
}
241-
}
242-
sendDailyUsagePingSetting = sendDailyUsagePingSettings
243-
} else {
244-
let sendAnonymousUsageDataSettings = SendDataSetting(
245-
prefs: profile.prefs,
246-
delegate: settingsDelegate,
247-
theme: themeManager.getCurrentTheme(for: windowUUID),
248-
settingsDelegate: parentCoordinator,
249-
title: .SendUsageSettingTitle,
250-
message: String(format: .SendUsageSettingMessage,
251-
MozillaName.shortName.rawValue,
252-
AppName.shortName.rawValue),
253-
linkedText: .SendUsageSettingLink,
254-
prefKey: AppConstants.prefSendUsageData,
255-
a11yId: AccessibilityIdentifiers.Settings.SendData.sendAnonymousUsageDataTitle,
256-
learnMoreURL: SupportUtils.URLForTopic("adjust"),
257-
isToSEnabled: isTermsOfServiceFeatureEnabled
258-
)
208+
sendTechnicalDataSettings.shouldSendData = { [weak self] value in
209+
guard let self, let profile = self.profile else { return }
210+
TermsOfServiceManager(prefs: profile.prefs).shouldSendTechnicalData(value: value)
211+
studiesSetting.updateSetting(for: value)
212+
}
213+
sendTechnicalDataSetting = sendTechnicalDataSettings
259214

260-
sendAnonymousUsageDataSettings.shouldSendData = { [weak self] value in
261-
guard let self, let profile = self.profile else { return }
262-
TermsOfServiceManager(prefs: profile.prefs).shouldSendTechnicalData(value: value)
263-
studiesSetting.updateSetting(for: value)
215+
let sendDailyUsagePingSettings = SendDataSetting(
216+
prefs: profile.prefs,
217+
delegate: settingsDelegate,
218+
theme: themeManager.getCurrentTheme(for: windowUUID),
219+
settingsDelegate: parentCoordinator,
220+
title: .SendDailyUsagePingSettingTitle,
221+
message: String(format: .SendDailyUsagePingSettingMessage, MozillaName.shortName.rawValue),
222+
linkedText: .SendDailyUsagePingSettingLinkV2,
223+
prefKey: AppConstants.prefSendDailyUsagePing,
224+
a11yId: AccessibilityIdentifiers.Settings.SendData.sendDailyUsagePingTitle,
225+
learnMoreURL: SupportUtils.URLForTopic("usage-ping-settings-mobile")
226+
)
227+
sendDailyUsagePingSettings.shouldSendData = { [weak self] value in
228+
if value {
229+
self?.gleanLifecycleObserver.startObserving()
230+
} else {
231+
self?.gleanLifecycleObserver.stopObserving()
264232
}
265-
sendAnonymousUsageDataSetting = sendAnonymousUsageDataSettings
266233
}
234+
sendDailyUsagePingSetting = sendDailyUsagePingSettings
267235

268236
let sendCrashReportsSettings = SendDataSetting(
269237
prefs: profile.prefs,
@@ -272,11 +240,10 @@ class AppSettingsTableViewController: SettingsTableViewController,
272240
settingsDelegate: parentCoordinator,
273241
title: .SendCrashReportsSettingTitle,
274242
message: String(format: .SendCrashReportsSettingMessageV2, MozillaName.shortName.rawValue),
275-
linkedText: isTermsOfServiceFeatureEnabled ? .SendCrashReportsSettingLinkV2 : .SendCrashReportsSettingLink,
243+
linkedText: .SendCrashReportsSettingLinkV2,
276244
prefKey: AppConstants.prefSendCrashReports,
277245
a11yId: AccessibilityIdentifiers.Settings.SendData.sendCrashReportsTitle,
278-
learnMoreURL: SupportUtils.URLForTopic("ios-crash-reports"),
279-
isToSEnabled: isTermsOfServiceFeatureEnabled
246+
learnMoreURL: SupportUtils.URLForTopic("ios-crash-reports")
280247
)
281248
self.sendCrashReportsSetting = sendCrashReportsSettings
282249

@@ -452,8 +419,6 @@ class AppSettingsTableViewController: SettingsTableViewController,
452419
}
453420

454421
private func getSupportSettings() -> [SettingSection] {
455-
let isTermsOfServiceFeatureEnabled = featureFlags.isFeatureEnabled(.tosFeature, checking: .buildOnly)
456-
457422
var supportSettings = [
458423
ShowIntroductionSetting(settings: self, settingsDelegate: self),
459424
SendFeedbackSetting(settingsDelegate: parentCoordinator),
@@ -471,25 +436,20 @@ class AppSettingsTableViewController: SettingsTableViewController,
471436
)
472437
}
473438

474-
guard let studiesToggleSetting, let sendCrashReportsSetting else { return [] }
475-
476-
if isTermsOfServiceFeatureEnabled {
477-
guard let sendTechnicalDataSetting, let sendDailyUsagePingSetting else { return [] }
478-
supportSettings.append(contentsOf: [
479-
sendTechnicalDataSetting,
480-
studiesToggleSetting,
481-
sendDailyUsagePingSetting,
482-
sendCrashReportsSetting
483-
])
484-
} else {
485-
guard let sendAnonymousUsageDataSetting else { return [] }
486-
supportSettings.append(contentsOf: [
487-
sendAnonymousUsageDataSetting,
488-
sendCrashReportsSetting,
489-
studiesToggleSetting
490-
])
439+
guard let sendTechnicalDataSetting,
440+
let sendDailyUsagePingSetting,
441+
let studiesToggleSetting,
442+
let sendCrashReportsSetting else {
443+
return []
491444
}
492445

446+
supportSettings.append(contentsOf: [
447+
sendTechnicalDataSetting,
448+
studiesToggleSetting,
449+
sendDailyUsagePingSetting,
450+
sendCrashReportsSetting
451+
])
452+
493453
supportSettings.append(contentsOf: [
494454
OpenSupportPageSetting(delegate: settingsDelegate,
495455
theme: themeManager.getCurrentTheme(for: windowUUID),

firefox-ios/Client/Frontend/Settings/Main/Support/SendDataSetting.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ class SendDataSetting: BoolSetting {
2323
linkedText: String,
2424
prefKey: String,
2525
a11yId: String,
26-
learnMoreURL: URL?,
27-
isToSEnabled: Bool) {
26+
learnMoreURL: URL?) {
2827
let statusText = NSMutableAttributedString()
2928
statusText.append(
3029
NSAttributedString(
@@ -34,7 +33,7 @@ class SendDataSetting: BoolSetting {
3433
)
3534
statusText.append(
3635
NSAttributedString(
37-
string: isToSEnabled ? "\n" : " "
36+
string: "\n"
3837
)
3938
)
4039
statusText.append(

firefox-ios/Client/Frontend/Settings/Main/Support/StudiesToggleSetting.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ class StudiesToggleSetting: BoolSetting {
1515
settingsDelegate: SupportSettingsDelegate?,
1616
title: String,
1717
message: String,
18-
linkedText: String,
19-
isToSEnabled: Bool) {
18+
linkedText: String) {
2019
let statusText = NSMutableAttributedString()
2120
statusText.append(
2221
NSAttributedString(
2322
string: message,
2423
attributes: [NSAttributedString.Key.foregroundColor: theme.colors.textSecondary]
2524
)
2625
)
27-
statusText.append(NSAttributedString(string: isToSEnabled ? "\n" : " "))
26+
statusText.append(NSAttributedString(string: "\n"))
2827
statusText.append(
2928
NSAttributedString(
3029
string: linkedText,

firefox-ios/Shared/Strings.swift

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5382,31 +5382,11 @@ extension String {
53825382

53835383
// MARK: - Settings Home
53845384
extension String {
5385-
public static let SendUsageSettingTitle = MZLocalizedString(
5386-
key: "Settings.SendUsage.Title",
5387-
tableName: nil,
5388-
value: "Send Usage Data",
5389-
comment: "The title for the setting to send usage data.")
5390-
public static let SendUsageSettingLink = MZLocalizedString(
5391-
key: "Settings.SendUsage.Link",
5392-
tableName: nil,
5393-
value: "Learn More.",
5394-
comment: "title for a link that explains how mozilla collects telemetry")
5395-
public static let SendUsageSettingMessage = MZLocalizedString(
5396-
key: "Settings.SendUsage.Message",
5397-
tableName: nil,
5398-
value: "Mozilla strives to only collect what we need to provide and improve Firefox for everyone.",
5399-
comment: "A short description that explains why mozilla collects usage data.")
54005385
public static let SendCrashReportsSettingTitle = MZLocalizedString(
54015386
key: "Settings.CrashReports.Title.v135",
54025387
tableName: "Settings",
54035388
value: "Automatically Send Crash Reports",
54045389
comment: "On the Settings screen, this is the title text for a toggle which controls automatically sending crash reports.")
5405-
public static let SendCrashReportsSettingLink = MZLocalizedString(
5406-
key: "Settings.CrashReports.Link.v135",
5407-
tableName: "Settings",
5408-
value: "Learn More.",
5409-
comment: "Title for a link that explains how Mozilla send crash reports.")
54105390
public static let SendCrashReportsSettingLinkV2 = MZLocalizedString(
54115391
key: "Settings.CrashReports.Link.v136",
54125392
tableName: "Settings",
@@ -5479,25 +5459,6 @@ extension String {
54795459
comment: "The description of the open new tab siri shortcut")
54805460
}
54815461

5482-
// MARK: - Nimbus settings
5483-
extension String {
5484-
public static let SettingsStudiesToggleTitle = MZLocalizedString(
5485-
key: "Settings.Studies.Toggle.Title",
5486-
tableName: nil,
5487-
value: "Studies",
5488-
comment: "Label used as a toggle item in Settings. When this is off, the user is opting out of all studies.")
5489-
public static let SettingsStudiesToggleLink = MZLocalizedString(
5490-
key: "Settings.Studies.Toggle.Link",
5491-
tableName: nil,
5492-
value: "Learn More.",
5493-
comment: "Title for a link that explains what Mozilla means by Studies")
5494-
public static let SettingsStudiesToggleMessage = MZLocalizedString(
5495-
key: "Settings.Studies.Toggle.Message",
5496-
tableName: nil,
5497-
value: "Firefox may install and run studies from time to time.",
5498-
comment: "A short description that explains that Mozilla is running studies")
5499-
}
5500-
55015462
// MARK: - Share extension
55025463
extension String {
55035464
public static let SendToCancelButton = MZLocalizedString(
@@ -7699,6 +7660,41 @@ extension String {
76997660
tableName: "Onboarding",
77007661
value: "Agree and continue",
77017662
comment: "Title for the confirmation button for Terms of Service agreement, in the Terms of Service screen.")
7663+
public static let SendUsageSettingTitle = MZLocalizedString(
7664+
key: "Settings.SendUsage.Title",
7665+
tableName: nil,
7666+
value: "Send Usage Data",
7667+
comment: "The title for the setting to send usage data.")
7668+
public static let SendUsageSettingLink = MZLocalizedString(
7669+
key: "Settings.SendUsage.Link",
7670+
tableName: nil,
7671+
value: "Learn More.",
7672+
comment: "title for a link that explains how mozilla collects telemetry")
7673+
public static let SendUsageSettingMessage = MZLocalizedString(
7674+
key: "Settings.SendUsage.Message",
7675+
tableName: nil,
7676+
value: "Mozilla strives to only collect what we need to provide and improve Firefox for everyone.",
7677+
comment: "A short description that explains why mozilla collects usage data.")
7678+
public static let SettingsStudiesToggleTitle = MZLocalizedString(
7679+
key: "Settings.Studies.Toggle.Title",
7680+
tableName: nil,
7681+
value: "Studies",
7682+
comment: "Label used as a toggle item in Settings. When this is off, the user is opting out of all studies.")
7683+
public static let SettingsStudiesToggleLink = MZLocalizedString(
7684+
key: "Settings.Studies.Toggle.Link",
7685+
tableName: nil,
7686+
value: "Learn More.",
7687+
comment: "Title for a link that explains what Mozilla means by Studies")
7688+
public static let SettingsStudiesToggleMessage = MZLocalizedString(
7689+
key: "Settings.Studies.Toggle.Message",
7690+
tableName: nil,
7691+
value: "Firefox may install and run studies from time to time.",
7692+
comment: "A short description that explains that Mozilla is running studies")
7693+
public static let SendCrashReportsSettingLink = MZLocalizedString(
7694+
key: "Settings.CrashReports.Link.v135",
7695+
tableName: "Settings",
7696+
value: "Learn More.",
7697+
comment: "Title for a link that explains how Mozilla send crash reports.")
77027698
}
77037699
}
77047700
}

firefox-ios/firefox-ios-tests/Tests/XCUITests/SettingsTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ class SettingsTests: BaseTestCase {
155155
table.cells[settingsQuery.ClearData.title], app.switches[settingsQuery.ClosePrivateTabs.title],
156156
table.cells[settingsQuery.ContentBlocker.title], table.cells[settingsQuery.Notifications.title],
157157
table.cells[settingsQuery.ShowIntroduction.title],
158-
table.cells[settingsQuery.SendData.sendAnonymousUsageDataTitle],
158+
table.cells[settingsQuery.SendData.sendTechnicalDataTitle],
159+
table.cells[settingsQuery.SendData.sendDailyUsagePingTitle],
160+
table.cells[settingsQuery.SendData.sendCrashReportsTitle],
159161
table.cells[settingsQuery.StudiesToggle.title], table.cells[settingsQuery.Version.title],
160162
table.cells[settingsQuery.PrivacyPolicy.title], table.cells[settingsQuery.SendFeedback.title],
161163
table.cells[settingsQuery.Help.title], table.cells[settingsQuery.RateOnAppStore.title],

0 commit comments

Comments
 (0)