Skip to content

Commit

Permalink
[CP] Add privacy policy attribution dialog action to v10 (#1758) (#1760)
Browse files Browse the repository at this point in the history
  • Loading branch information
evil159 authored Aug 23, 2023
1 parent f2caa05 commit 7a5dbcb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone.
## 10.16.0-beta.1 - Aug 9, 2023

* Update MapboxCoreMaps to 10.16.0-beta.1 and MapboxCommon to 23.8.0-beta.1.
* Add privacy policy attribution dialog action.

## 10.15.0-rc.1 - July 13, 2023

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@

/* Telemetry prompt title */
"TELEMETRY_TITLE" = "Make Mapbox Maps Better";

/* Privacy policy action in attribution sheet */
"ATTRIBUTION_PRIVACY_POLICY" = "Mapbox Privacy Policy";
10 changes: 10 additions & 0 deletions Sources/MapboxMaps/Style/Attribution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal struct Attribution: Hashable {
"https://www.mapbox.com/map-feedback/",
"https://apps.mapbox.com/feedback/"
]
private static let privacyPolicyURL = URL(string: "https://www.mapbox.com/legal/privacy#product-privacy-policy")

var title: String
var kind: Kind
Expand All @@ -46,6 +47,15 @@ internal struct Attribution: Hashable {
}
}

static func makePrivacyPolicyAttribution() -> Attribution {
let title = NSLocalizedString("ATTRIBUTION_PRIVACY_POLICY",
tableName: Ornaments.localizableTableName,
bundle: .mapboxMaps,
value: "Mapbox Privacy Policy",
comment: "Privacy policy action in attribution sheet")
return .init(title: title, url: Self.privacyPolicyURL)
}

internal init(title: String, url: URL?) {
self.title = title

Expand Down
7 changes: 7 additions & 0 deletions Sources/MapboxMaps/Style/AttributionDialogManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ extension AttributionDialogManager: InfoButtonOrnamentDelegate {

alert.addAction(telemetryAction)

let privacyPolicyAttribution = Attribution.makePrivacyPolicyAttribution()
let privacyPolicyAction = UIAlertAction(title: privacyPolicyAttribution.title, style: .default) { _ in
self.delegate?.attributionDialogManager(self, didTriggerActionFor: privacyPolicyAttribution)
}

alert.addAction(privacyPolicyAction)

let cancelTitle = NSLocalizedString("CANCEL",
tableName: Ornaments.localizableTableName,
bundle: bundle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class InfoButtonOrnamentTests: XCTestCase {
let firstAlert = try XCTUnwrap(parentViewController.currentAlert, "The first alert controller could not be found.")
XCTAssertNotNil(firstAlert)

XCTAssertEqual(firstAlert.actions.count, 2, "There should be two alerts present.")
XCTAssertEqual(firstAlert.actions.count, 3, "There should be three actions present.")
let telemetryTitle = NSLocalizedString("Mapbox Telemetry", comment: "Action in attribution sheet")
XCTAssertEqual(firstAlert.actions[0].title!, telemetryTitle)

XCTAssertEqual(firstAlert.actions[1].title, Attribution.makePrivacyPolicyAttribution().title)

let cancelTitle = NSLocalizedString("Cancel", comment: "Title of button for dismissing attribution action sheet")
XCTAssertEqual(firstAlert.actions[1].title, cancelTitle)
XCTAssertEqual(firstAlert.actions[2].title, cancelTitle)
}

func testTelemetryOptOut() throws {
Expand Down
16 changes: 9 additions & 7 deletions Tests/MapboxMapsTests/Style/AttributionDialogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class AttributionDialogTests: XCTestCase {
XCTAssertEqual(alert.title, alertTitle)
XCTAssertNil(alert.message)

guard alert.actions.count == 2 else {
XCTFail("Telemetry alert should have 2 actions")
guard alert.actions.count == 3 else {
XCTFail("Telemetry alert should have 3 actions")
return
}

Expand All @@ -147,12 +147,14 @@ class AttributionDialogTests: XCTestCase {
comment: "")
XCTAssertEqual(alert.actions[0].title, telemetryTitle)

XCTAssertEqual(alert.actions[1].title, Attribution.makePrivacyPolicyAttribution().title)

let cancelTitle = NSLocalizedString("CANCEL",
tableName: Ornaments.localizableTableName,
bundle: bundle,
value: "Cancel",
comment: "")
XCTAssertEqual(alert.actions[1].title, cancelTitle)
XCTAssertEqual(alert.actions[2].title, cancelTitle)
}

func testShowAttributionDialogSingleNonActionableAttribution() throws {
Expand All @@ -179,8 +181,8 @@ class AttributionDialogTests: XCTestCase {
XCTAssertEqual(alert.title, alertTitle)
XCTAssertEqual(alert.message, attribution.title)

guard alert.actions.count == 2 else {
XCTFail("Telemetry alert should have 2 actions")
guard alert.actions.count == 3 else {
XCTFail("Telemetry alert should have 3 actions")
return
}
}
Expand Down Expand Up @@ -210,8 +212,8 @@ class AttributionDialogTests: XCTestCase {
XCTAssertNil(alert.message)

// Single, non-actionable attributions should be displayed as alert's actions along the telemetry and cancel actions
guard alert.actions.count == 4 else {
XCTFail("Telemetry alert should have 4 actions")
guard alert.actions.count == 5 else {
XCTFail("Telemetry alert should have 5 actions")
return
}

Expand Down

0 comments on commit 7a5dbcb

Please sign in to comment.