From 3aae7ed17280ead4ac602d2596f0fd9f6274041f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Buczek?= Date: Mon, 9 Oct 2023 16:56:03 +0200 Subject: [PATCH] Fix #8209: Better message when tracking is disabled for the Privacy Hub. --- .../PrivacyHub/PrivacyHubLastWeekSection.swift | 17 ++++++++++++++--- .../Browser/PrivacyHub/PrivacyReportsView.swift | 12 ------------ Sources/BraveStrings/BraveStrings.swift | 5 +++++ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift b/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift index 9a29e4c82c5..eae8df1ab74 100644 --- a/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift +++ b/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift @@ -8,6 +8,7 @@ import Shared import BraveShared import BraveUI import Data +import Preferences extension PrivacyReportsView { struct PrivacyHubLastWeekSection: View { @@ -21,10 +22,14 @@ extension PrivacyReportsView { return mostFrequentTracker == nil && riskiestWebsite == nil } - private var noDataCalloutView: some View { + private var trackingDisabled: Bool { + !Preferences.PrivacyReports.captureShieldsData.value + } + + private func emptyCalloutView(text: String) -> some View { HStack { Image(systemName: "info.circle.fill") - Text(Strings.PrivacyHub.noDataCalloutBody) + Text(text) } .foregroundColor(Color.white) .frame(maxWidth: .infinity) @@ -36,7 +41,13 @@ extension PrivacyReportsView { var body: some View { VStack(alignment: .leading, spacing: 8) { if noData { - noDataCalloutView + if trackingDisabled { + emptyCalloutView(text: + String.localizedStringWithFormat(Strings.PrivacyHub.trackingDisabledCalloutBody, + Strings.PrivacyHub.settingsEnableShieldsTitle)) + } else { + emptyCalloutView(text: Strings.PrivacyHub.noDataCalloutBody) + } } Text(Strings.PrivacyHub.lastWeekHeader.uppercased()) diff --git a/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift b/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift index 0dade80a4b8..2590c77c9d1 100644 --- a/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift +++ b/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyReportsView.swift @@ -67,18 +67,6 @@ struct PrivacyReportsView: View { .foregroundColor(Color(.braveBlurpleTint)) } - private var noDataCalloutView: some View { - HStack { - Image(systemName: "info.circle.fill") - Text(Strings.PrivacyHub.noDataCalloutBody) - } - .foregroundColor(Color.white) - .frame(maxWidth: .infinity) - .padding() - .background(Color(.braveInfoLabel)) - .clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous)) - } - var body: some View { NavigationView { ScrollView(.vertical) { diff --git a/Sources/BraveStrings/BraveStrings.swift b/Sources/BraveStrings/BraveStrings.swift index bf3c843117d..b7477dbe54d 100644 --- a/Sources/BraveStrings/BraveStrings.swift +++ b/Sources/BraveStrings/BraveStrings.swift @@ -4365,6 +4365,11 @@ extension Strings { comment: "Text of a callout that tell user they need to browser some websites first in order to see privacy stats data" ) + public static let trackingDisabledCalloutBody = NSLocalizedString("privacyHub.trackingDisabledCalloutBody", tableName: "BraveShared", bundle: .module, + value: "Enable '%@' to see data here", + comment: "Text of a callout that tell user they need to browser some websites first in order to see privacy stats data" + ) + public static let lastWeekHeader = NSLocalizedString("privacyHub.lastWeekHeader", tableName: "BraveShared", bundle: .module, value: "Last week", comment: "Header text, under it we display blocked items from last week"