From afadcb43503de651af9352603f9fe6f67651bb3d Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Wed, 2 Nov 2022 12:46:24 -0400 Subject: [PATCH] Localization is included. --- .../Browser/BrowserViewController.swift | 22 +++++------ .../BrowserViewController+Callout.swift | 20 +++++----- Sources/BraveShared/BraveStrings.swift | 38 ++++++++++++++++--- .../Welcome/WelcomeViewController.swift | 10 ++--- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/Client/Frontend/Browser/BrowserViewController.swift b/Client/Frontend/Browser/BrowserViewController.swift index 71a27a4110e..75cff014c43 100644 --- a/Client/Frontend/Browser/BrowserViewController.swift +++ b/Client/Frontend/Browser/BrowserViewController.swift @@ -1112,22 +1112,22 @@ public class BrowserViewController: UIViewController { } override public func viewDidAppear(_ animated: Bool) { -// // Passcode Migration has highest priority, it should be presented over everything else -// presentPassCodeMigration() -// -// // Present Onboarding to new users, existing users will not see the onboarding -// presentOnboardingIntro() -// -// // Full Screen Callout Presentation -// // Priority: P3A - VPN - Default Browser - Rewards -// // TODO: Remove the dispatch after with a proper fix and fix calling present functions before super.viewDidAppear -// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { + // Passcode Migration has highest priority, it should be presented over everything else + presentPassCodeMigration() + + // Present Onboarding to new users, existing users will not see the onboarding + presentOnboardingIntro() + + // Full Screen Callout Presentation + // Priority: P3A - VPN - Default Browser - Rewards + // TODO: Remove the dispatch after with a proper fix and fix calling present functions before super.viewDidAppear + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { self.presentP3AScreenCallout() self.presentVPNAlertCallout() self.presentDefaultBrowserScreenCallout() self.presentBraveRewardsScreenCallout() self.presentCookieNotificationBlockingCalloutIfNeeded() -// } + } screenshotHelper.viewIsVisible = true screenshotHelper.takePendingScreenshots(tabManager.allTabs) diff --git a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift index ce7a5e8d9f3..23c167fb007 100644 --- a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift +++ b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Callout.swift @@ -31,13 +31,11 @@ extension BrowserViewController { } func presentP3AScreenCallout() { -// if Preferences.DebugFlag.skipNTPCallouts == true || isOnboardingOrFullScreenCalloutPresented { return } -// -// if presentedViewController != nil || !FullScreenCalloutManager.shouldShowDefaultBrowserCallout(calloutType: .p3a) { -// return -// } + if Preferences.DebugFlag.skipNTPCallouts == true || isOnboardingOrFullScreenCalloutPresented { return } -// let onboardingP3ACalloutController = WelcomeViewController(p3aUtilities: braveCore.p3aUtils) + if presentedViewController != nil || !FullScreenCalloutManager.shouldShowDefaultBrowserCallout(calloutType: .p3a) { + return + } let onboardingP3ACalloutController = Welcome3PAViewController().then { $0.isModalInPresentation = true @@ -46,11 +44,11 @@ extension BrowserViewController { let state = WelcomeViewCalloutState.p3a( info: WelcomeViewCalloutState.WelcomeViewDefaultBrowserDetails( - title: "Help make Brave better.", - toggleTitle: "Share anonymous, private product insights.", - details: "This helps us learn what Brave features are used most often. Change this at any time in Brave Settings under ‘Brave Shields and Privacy’.", - linkDescription: "Learn more about our Privacy Preserving Product Analytics (P3A).", - primaryButtonTitle: "Done", + title: Strings.Callout.p3aCalloutTitle, + toggleTitle: Strings.Callout.p3aCalloutToggleTitle, + details: Strings.Callout.p3aCalloutDescription, + linkDescription: Strings.Callout.p3aCalloutLinkTitle, + primaryButtonTitle: Strings.done, toggleAction: { [weak self] isOn in self?.braveCore.p3aUtils.isP3AEnabled = isOn }, diff --git a/Sources/BraveShared/BraveStrings.swift b/Sources/BraveShared/BraveStrings.swift index 1aae576568b..8454ba65bb9 100644 --- a/Sources/BraveShared/BraveStrings.swift +++ b/Sources/BraveShared/BraveStrings.swift @@ -266,6 +266,30 @@ extension Strings { tableName: "BraveShared", bundle: .module, value: "Tab Received", comment: "Title for 'Tab Received' Callout, This is shown in the message when a Tab information is received from another sync device. ") + public static let p3aCalloutTitle = + NSLocalizedString( + "callout.p3aCalloutTitle", + tableName: "BraveShared", bundle: .module, + value: "Help make Brave better.", + comment: "Title for p3a (Privacy Preserving Analytics) Full Screen Callout") + public static let p3aCalloutDescription = + NSLocalizedString( + "callout.p3aCalloutDescription", + tableName: "BraveShared", bundle: .module, + value: "This helps us learn what Brave features are used most often. Change this at any time in Brave Settings under ‘Brave Shields and Privacy’.", + comment: "Subtitle - Description for p3a (Privacy Preserving Analytics) Full Screen Callout") + public static let p3aCalloutToggleTitle = + NSLocalizedString( + "callout.p3aCalloutToggleTitle", + tableName: "BraveShared", bundle: .module, + value: "Share anonymous, private product insights. ", + comment: "Title for toggle for enabling p3a (Privacy Preserving Analytics) Full Screen Callout") + public static let p3aCalloutLinkTitle = + NSLocalizedString( + "callout.p3aCalloutLinkTitle", + tableName: "BraveShared", bundle: .module, + value: "Learn more about our Privacy Preserving Product Analytics (P3A).", + comment: "Title for the link that vaviagtes information about p3a (Privacy Preserving Analytics)") } } @@ -4096,13 +4120,15 @@ extension Strings { // P3A extension Strings { public struct P3A { - public static let settingTitle = NSLocalizedString("p3a.settingTitle", tableName: "BraveShared", bundle: .module, - value: "Allow Privacy-Preserving Product Analytics (P3A)", - comment: "The title for the setting that will allow a user to toggle sending privacy preserving analytics to Brave. P3A is the name of a Brave Product") + public static let settingTitle = NSLocalizedString( + "p3a.settingTitle", tableName: "BraveShared", bundle: .module, + value: "Product Analytics", + comment: "The title for the setting that will allow a user to toggle sending privacy preserving analytics to Brave.") - public static let settingSubtitle = NSLocalizedString("p3a.settingSubtitle", tableName: "BraveShared", bundle: .module, - value: "Anonymized P3A info helps Brave estimate overall usage and ensure we're improving popular features", - comment: "A subtitle shown on the setting that toggles analytics on Brave. P3A is the name of a Brave Product") + public static let settingSubtitle = NSLocalizedString( + "p3a.settingSubtitle", tableName: "BraveShared", bundle: .module, + value: "Share anonymous, private product insights. This helps us learn what Brave features are used most often.", + comment: "A subtitle shown on the setting that toggles analytics on Brave.") } } diff --git a/Sources/Onboarding/Welcome/WelcomeViewController.swift b/Sources/Onboarding/Welcome/WelcomeViewController.swift index c848a40d295..17106e3974e 100644 --- a/Sources/Onboarding/Welcome/WelcomeViewController.swift +++ b/Sources/Onboarding/Welcome/WelcomeViewController.swift @@ -359,11 +359,11 @@ public class WelcomeViewController: UIViewController { let nextController = WelcomeViewController(state: nil, p3aUtilities: self.p3aUtilities) let state = WelcomeViewCalloutState.p3a( info: WelcomeViewCalloutState.WelcomeViewDefaultBrowserDetails( - title: "Help make Brave better.", - toggleTitle: "Share anonymous, private product insights.", - details: "This helps us learn what Brave features are used most often. Change this at any time in Brave Settings under ‘Brave Shields and Privacy’.", - linkDescription: "Learn more about our Privacy Preserving Product Analytics (P3A).", - primaryButtonTitle: "Done", + title: Strings.Callout.p3aCalloutTitle, + toggleTitle: Strings.Callout.p3aCalloutToggleTitle, + details: Strings.Callout.p3aCalloutDescription, + linkDescription: Strings.Callout.p3aCalloutLinkTitle, + primaryButtonTitle: Strings.done, toggleAction: { [weak self] isOn in self?.p3aUtilities.isP3AEnabled = isOn },