Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically clear data upon quitting #2600

Merged
merged 26 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c7eb278
Settings model
tomasstrba Mar 25, 2024
30a50f0
Disabling restorePreviousSession in case burn data on quit is enabled
tomasstrba Mar 25, 2024
6298998
Label: Disable the Automatically Clear Data setting to enable session…
tomasstrba Mar 25, 2024
b0e1c7f
Burn on Quit functionality
tomasstrba Mar 27, 2024
2198747
Delay for testing
tomasstrba Mar 27, 2024
b657c44
Edge case: unexpected app termination
tomasstrba Mar 29, 2024
d75afc1
Additional button removed
tomasstrba Apr 2, 2024
00631e4
Added clearing data options and warn on burn option
tomasstrba Apr 8, 2024
20efae9
Burn after
tomasstrba Apr 10, 2024
ce50bc0
Changes based on Ship Review
tomasstrba Apr 11, 2024
da7202f
Copy fixed
tomasstrba Apr 11, 2024
857e7ed
Refactoring
tomasstrba Apr 11, 2024
1d8bfff
Unit Tests
tomasstrba Apr 11, 2024
f997036
Merge branch 'main' into tom/automatically-clear-data
tomasstrba Apr 12, 2024
4aa5d52
Copy changed
tomasstrba Apr 12, 2024
c631833
Alert improved based on the ship review
tomasstrba Apr 12, 2024
0a29cbb
Quit without clearing
tomasstrba Apr 12, 2024
2791d02
Changes based on PR and ship review
tomasstrba Apr 18, 2024
1a9317b
Merge branch 'main' into tom/automatically-clear-data
tomasstrba Apr 18, 2024
3cf32e4
Icon replaced
tomasstrba Apr 19, 2024
4f62710
Copy changed
tomasstrba Apr 22, 2024
9761105
More copy changed
tomasstrba Apr 23, 2024
6ca9033
Merge branch 'main' into tom/automatically-clear-data
tomasstrba Apr 23, 2024
2e79aa4
Design review
tomasstrba Apr 25, 2024
b19a275
Translations
tomasstrba Apr 28, 2024
964cbe9
Merge branch 'main' into tom/automatically-clear-data
tomasstrba Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
1D01A3DA2B88DF8B00FE8150 /* PreferencesSyncView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D01A3D72B88DF8B00FE8150 /* PreferencesSyncView.swift */; };
1D02633628D8A9A9005CBB41 /* BWEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D02633528D8A9A9005CBB41 /* BWEncryption.m */; settings = {COMPILER_FLAGS = "-Wno-deprecated -Wno-strict-prototypes"; }; };
1D074B272909A433006E4AC3 /* PasswordManagerCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D074B262909A433006E4AC3 /* PasswordManagerCoordinator.swift */; };
1D0E4F562BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; };
1D0E4F572BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; };
1D0E4F582BB419ED00670CFE /* AutoClearHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */; };
1D12F2E2298BC660009A65FD /* InternalUserDeciderStoreMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D12F2E1298BC660009A65FD /* InternalUserDeciderStoreMock.swift */; };
1D1A33492A6FEB170080ACED /* BurnerMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1A33482A6FEB170080ACED /* BurnerMode.swift */; };
1D1A334A2A6FEB170080ACED /* BurnerMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D1A33482A6FEB170080ACED /* BurnerMode.swift */; };
Expand Down Expand Up @@ -69,6 +72,8 @@
1D43EB38292B636E0065E5D6 /* BWCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB37292B636E0065E5D6 /* BWCommand.swift */; };
1D43EB3A292B63B00065E5D6 /* BWRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB39292B63B00065E5D6 /* BWRequest.swift */; };
1D43EB3C292B664A0065E5D6 /* BWMessageIdGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D43EB3B292B664A0065E5D6 /* BWMessageIdGenerator.swift */; };
1D5FADA22BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */; };
1D5FADA32BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */; };
1D6216B229069BBF00386B2C /* BWKeyStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6216B129069BBF00386B2C /* BWKeyStorage.swift */; };
1D69C553291302F200B75945 /* BWVault.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D69C552291302F200B75945 /* BWVault.swift */; };
1D6A492029CF7A490011DF74 /* NSPopoverExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D6A491F29CF7A490011DF74 /* NSPopoverExtension.swift */; };
Expand Down Expand Up @@ -3568,6 +3573,7 @@
1D02633428D8A9A9005CBB41 /* BWEncryption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BWEncryption.h; sourceTree = "<group>"; };
1D02633528D8A9A9005CBB41 /* BWEncryption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BWEncryption.m; sourceTree = "<group>"; };
1D074B262909A433006E4AC3 /* PasswordManagerCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordManagerCoordinator.swift; sourceTree = "<group>"; };
1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearHandler.swift; sourceTree = "<group>"; };
1D12F2E1298BC660009A65FD /* InternalUserDeciderStoreMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalUserDeciderStoreMock.swift; sourceTree = "<group>"; };
1D1A33482A6FEB170080ACED /* BurnerMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BurnerMode.swift; sourceTree = "<group>"; };
1D1C36E229FAE8DA001FA40C /* FaviconManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconManagerTests.swift; sourceTree = "<group>"; };
Expand All @@ -3591,6 +3597,7 @@
1D43EB37292B636E0065E5D6 /* BWCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWCommand.swift; sourceTree = "<group>"; };
1D43EB39292B63B00065E5D6 /* BWRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWRequest.swift; sourceTree = "<group>"; };
1D43EB3B292B664A0065E5D6 /* BWMessageIdGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWMessageIdGenerator.swift; sourceTree = "<group>"; };
1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoClearHandlerTests.swift; sourceTree = "<group>"; };
1D6216B129069BBF00386B2C /* BWKeyStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWKeyStorage.swift; sourceTree = "<group>"; };
1D69C552291302F200B75945 /* BWVault.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BWVault.swift; sourceTree = "<group>"; };
1D6A491F29CF7A490011DF74 /* NSPopoverExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSPopoverExtension.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6968,6 +6975,7 @@
isa = PBXGroup;
children = (
85F1B0C825EF9759004792B6 /* URLEventHandlerTests.swift */,
1D5FADA12BC7E734005D6EB1 /* AutoClearHandlerTests.swift */,
0289041E2A7B23CE0028369C /* AppConfigurationURLProviderTests.swift */,
);
path = AppDelegate;
Expand Down Expand Up @@ -7171,6 +7179,7 @@
858A798226A8B75F00A75A42 /* CopyHandler.swift */,
1D36E65A298ACD2900AA485D /* AppIconChanger.swift */,
CB24F70B29A3D9CB006DCC58 /* AppConfigurationURLProvider.swift */,
1D0E4F552BB419ED00670CFE /* AutoClearHandler.swift */,
);
path = Application;
sourceTree = "<group>";
Expand Down Expand Up @@ -10940,6 +10949,7 @@
3706FC52293F65D500E42796 /* MouseOverAnimationButton.swift in Sources */,
B60293E72BA19ECD0033186B /* NetPPopoverManagerMock.swift in Sources */,
3706FC53293F65D500E42796 /* TabBarScrollView.swift in Sources */,
1D0E4F572BB419ED00670CFE /* AutoClearHandler.swift in Sources */,
B6104E9C2BA9C173008636B2 /* DownloadResumeData.swift in Sources */,
3706FC54293F65D500E42796 /* BookmarkListTreeControllerDataSource.swift in Sources */,
3706FC55293F65D500E42796 /* AddressBarViewController.swift in Sources */,
Expand Down Expand Up @@ -11213,6 +11223,7 @@
3706FE46293F661700E42796 /* EncryptedValueTransformerTests.swift in Sources */,
9F3910632B68C35600CB5112 /* DownloadsTabExtensionTests.swift in Sources */,
3706FE47293F661700E42796 /* URLExtensionTests.swift in Sources */,
1D5FADA32BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */,
1DB9617B29F1D06D00CF5568 /* InternalUserDeciderMock.swift in Sources */,
317295D52AF058D3002C3206 /* MockWaitlistFeatureSetupHandler.swift in Sources */,
3706FE48293F661700E42796 /* PixelTests.swift in Sources */,
Expand Down Expand Up @@ -12032,6 +12043,7 @@
4B957AF12AC7AE700062CA31 /* AppStateRestorationManager.swift in Sources */,
4B957AF22AC7AE700062CA31 /* DailyPixel.swift in Sources */,
9FDA6C232B79A59D00E099A9 /* BookmarkFavoriteView.swift in Sources */,
1D0E4F582BB419ED00670CFE /* AutoClearHandler.swift in Sources */,
4B957AF32AC7AE700062CA31 /* NavigationHotkeyHandler.swift in Sources */,
B6CC266E2BAD9CD800F53F8D /* FileProgressPresenter.swift in Sources */,
4B957AF42AC7AE700062CA31 /* ClickToLoadUserScript.swift in Sources */,
Expand Down Expand Up @@ -12459,6 +12471,7 @@
B6A9E48426146AAB0067D1B9 /* PixelParameters.swift in Sources */,
AA5FA697275F90C400DCE9C9 /* FaviconImageCache.swift in Sources */,
1430DFF524D0580F00B8978C /* TabBarViewController.swift in Sources */,
1D0E4F562BB419ED00670CFE /* AutoClearHandler.swift in Sources */,
B62B483E2ADE48DE000DECE5 /* ArrayBuilder.swift in Sources */,
4B92929B26670D2A00AD2C21 /* BookmarkOutlineViewDataSource.swift in Sources */,
56D145EB29E6C99B00E3488A /* DataImportStatusProviding.swift in Sources */,
Expand Down Expand Up @@ -13321,6 +13334,7 @@
85F487B5276A8F2E003CE668 /* OnboardingTests.swift in Sources */,
B626A7642992506A00053070 /* SerpHeadersNavigationResponderTests.swift in Sources */,
AA652CCE25DD9071009059CC /* BookmarkListTests.swift in Sources */,
1D5FADA22BC7E734005D6EB1 /* AutoClearHandlerTests.swift in Sources */,
859E7D6D274548F2009C2B69 /* BookmarksExporterTests.swift in Sources */,
B6A5A2A825BAA35500AA7ADA /* WindowManagerStateRestorationTests.swift in Sources */,
B6AE39F129373AF200C37AA4 /* EmptyAttributionRulesProver.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
tomasstrba marked this conversation as resolved.
Show resolved Hide resolved
"state" : {
"revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff",
"version" : "1.2.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1530"
version = "1.8">
version = "1.7">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Xcode 15.3 artifact, roll back please

<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
Expand Down
17 changes: 17 additions & 0 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
let internalUserDecider: InternalUserDecider
let featureFlagger: FeatureFlagger
private var appIconChanger: AppIconChanger!
private var autoClearHandler: AutoClearHandler!

private(set) var syncDataProviders: SyncDataProviders!
private(set) var syncService: DDGSyncing?
Expand Down Expand Up @@ -311,6 +312,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
#if SUBSCRIPTION

#endif

setUpAutoClearHandler()
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand Down Expand Up @@ -348,6 +351,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
stateRestorationManager?.applicationWillTerminate()

// Handling of "Burn on quit"
if let terminationReply = autoClearHandler.handleAppTermination() {
return terminationReply
}

return .terminateNow
}

Expand Down Expand Up @@ -548,6 +556,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
}
}

private func setUpAutoClearHandler() {
autoClearHandler = AutoClearHandler(preferences: .shared, fireViewModel: FireCoordinator.fireViewModel)
autoClearHandler.burnOnStartIfNeeded()
autoClearHandler.resetTheFlag()
tomasstrba marked this conversation as resolved.
Show resolved Hide resolved
autoClearHandler.onAutoClearCompleted = {
NSApplication.shared.reply(toApplicationShouldTerminate: true)
}
}

}

func updateSubscriptionStatus() {
Expand Down
91 changes: 91 additions & 0 deletions DuckDuckGo/Application/AutoClearHandler.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// AutoClearHandler.swift
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import Combine

final class AutoClearHandler {

private let preferences: DataClearingPreferences
private let fireViewModel: FireViewModel

init(preferences: DataClearingPreferences, fireViewModel: FireViewModel) {
self.preferences = preferences
self.fireViewModel = fireViewModel
}

var onAutoClearCompleted: (() -> Void)?

@MainActor
func handleAppTermination() -> NSApplication.TerminateReply? {
guard preferences.isAutoClearEnabled else { return nil }

if preferences.isWarnBeforeClearingEnabled {
switch confirmAutoClear() {
case .alertFirstButtonReturn:
tomasstrba marked this conversation as resolved.
Show resolved Hide resolved
performAutoClear()
return .terminateLater
case .alertSecondButtonReturn:
appTerminationHandledCorrectly = true
return .terminateNow
default:
return .terminateCancel
}
}

performAutoClear()
return .terminateLater
}

func resetTheFlag() {
appTerminationHandledCorrectly = false
}

// MARK: - Private

private func confirmAutoClear() -> NSApplication.ModalResponse {
let alert = NSAlert.autoClearAlert()
let response = alert.runModal()
return response
}

@MainActor
private func performAutoClear() {
fireViewModel.fire.burnAll { [weak self] in
self?.appTerminationHandledCorrectly = true
self?.onAutoClearCompleted?()
}
}

// MARK: - Burn On Start
// Burning on quit wasn't successful

@UserDefaultsWrapper(key: .appTerminationHandledCorrectly, defaultValue: false)
private var appTerminationHandledCorrectly: Bool

@MainActor
@discardableResult
func burnOnStartIfNeeded() -> Bool {
let shouldBurnOnStart = preferences.isAutoClearEnabled && !appTerminationHandledCorrectly
guard shouldBurnOnStart else { return false }

fireViewModel.fire.burnAll()
return true
}

}
29 changes: 29 additions & 0 deletions DuckDuckGo/Common/Extensions/NSAlertExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,35 @@ extension NSAlert {
return alert
}

static func autoClearAlert() -> NSAlert {
let alert = NSAlert()
alert.messageText = UserText.warnBeforeQuitDialogHeader
alert.alertStyle = .warning
alert.icon = .burnAlert
alert.addButton(withTitle: UserText.clearAndQuit)
alert.addButton(withTitle: UserText.quitWithoutClearing)
alert.addButton(withTitle: UserText.cancel)

let checkbox = NSButton(checkboxWithTitle: UserText.warnBeforeQuitDialogCheckboxMessage,
target: DataClearingPreferences.shared,
action: #selector(DataClearingPreferences.toggleWarnBeforeClearing))
checkbox.state = DataClearingPreferences.shared.isWarnBeforeClearingEnabled ? .on : .off
checkbox.translatesAutoresizingMaskIntoConstraints = false

// Create a container view for the checkbox with custom padding
let containerView = NSView(frame: NSRect(x: 0, y: 0, width: 224, height: 25))
containerView.addSubview(checkbox)

NSLayoutConstraint.activate([
checkbox.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
tomasstrba marked this conversation as resolved.
Show resolved Hide resolved
checkbox.centerYAnchor.constraint(equalTo: containerView.centerYAnchor, constant: -10) // Slightly up for better visual alignment
])

alert.accessoryView = containerView

return alert
}

@discardableResult
func runModal() async -> NSApplication.ModalResponse {
await withCheckedContinuation { continuation in
Expand Down
20 changes: 20 additions & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct UserText {
static let pasteAndGo = NSLocalizedString("paste.and.go", value: "Paste & Go", comment: "Paste & Go button")
static let pasteAndSearch = NSLocalizedString("paste.and.search", value: "Paste & Search", comment: "Paste & Search button")
static let clear = NSLocalizedString("clear", value: "Clear", comment: "Clear button")
static let clearAndQuit = NSLocalizedString("clear.and.quit", value: "Clear and Quit", comment: "Button to clear data and quit the application")
static let quitWithoutClearing = NSLocalizedString("quit.without.clearing", value: "Quit without Clearing", comment: "Button to quit the application without clearing data")
static let `continue` = NSLocalizedString("`continue`", value: "Continue", comment: "Continue button")
static let bookmarkDialogAdd = NSLocalizedString("bookmark.dialog.add", value: "Add", comment: "Button to confim a bookmark creation")
static let newFolderDialogAdd = NSLocalizedString("folder.dialog.add", value: "Add", comment: "Button to confim a bookmark folder creation")
Expand Down Expand Up @@ -1045,6 +1047,24 @@ struct UserText {
static let fireproofCheckboxTitle = NSLocalizedString("fireproof.checkbox.title", value: "Ask to Fireproof websites when signing in", comment: "Fireproof settings checkbox title")
static let fireproofExplanation = NSLocalizedString("fireproof.explanation", value: "When you Fireproof a site, cookies won't be erased and you'll stay signed in, even after using the Fire Button.", comment: "Fireproofing mechanism explanation")
static let manageFireproofSites = NSLocalizedString("fireproof.manage-sites", value: "Manage Fireproof Sites…", comment: "Fireproof settings button caption")
static let autoClear = NSLocalizedString("auto.clear", value: "Auto-Clear", comment: "Header of a section in Settings. The setting configures clearing data automatically after quitting the app.")
static let automaticallyClearData = NSLocalizedString("automatically.clear.data", value: "Automatically clear browsing data when DuckDuckGo quits", comment: "Label after the checkbox in Settings which configures clearing data automatically after quitting the app.")
static let warnBeforeQuit = NSLocalizedString("warn.before.quit", value: "Warn me that data will be cleared when quitting", comment: "Label after the checkbox in Settings which configures a warning before clearing data on the application termination.")
static let warnBeforeQuitDialogHeader = NSLocalizedString("warn.before.quit.dialog.header", value: "Clear browsing data and quit\nDuckDuckGo?", comment: "A header of warning before clearing data on the application termination.")
static let warnBeforeQuitDialogCheckboxMessage = NSLocalizedString("warn.before.quit.dialog.checkbox.message", value: "Warn me every time", comment: "A label after checkbox to configure the warning before clearing data on the application termination.")

static func disableAutoClearToEnableSessionRestore() -> String {
let localized = NSLocalizedString("disable.auto.clear.to.enable.session.restore",
value: "Disable the %@ setting to enable session restore on startup.",
comment: "Information label in Settings. It tells user that to enable session restoration setting they have to disable burn on quit")
Copy link
Collaborator

@mallexxx mallexxx Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment for translator that %@ will be replaced with the "Auto-Clear" setting name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed %@ and used the same approach you suggested for showDataClearingSettings

return String(format: localized, autoClear)
}
static func showDataClearingSettings() -> String {
let localized = NSLocalizedString("show.data.clearing.settings",
value: "Show %@ Settings.",
comment: "Button in Settings. It navigates user to Data Clearing Settings.")
return String(format: localized, dataClearing)
Copy link
Collaborator

@mallexxx mallexxx Apr 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the string format seems misaligned here as it doesn‘t consider declension of nouns ("Очистка данных" -> "Открыть настройки очистк-и- данных"), I think it‘s better to set the whole string for locatizations.

}

// MARK: Crash Report
static let crashReportTitle = NSLocalizedString("crash-report.title", value: "DuckDuckGo Privacy Browser quit unexpectedly.", comment: "Title of the dialog where the user can send a crash report")
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public struct UserDefaultsWrapper<T> {
case grammarCheckEnabledOnce = "grammar.check.enabled.once"

case loginDetectionEnabled = "fireproofing.login-detection-enabled"
case autoClearEnabled = "preferences.auto-clear-enabled"
case warnBeforeClearingEnabled = "preferences.warn-before-clearing-enabled"
case clearDataAfter = "preferences.clear-data-after"
tomasstrba marked this conversation as resolved.
Show resolved Hide resolved
case gpcEnabled = "preferences.gpc-enabled"
case selectedDownloadLocationKey = "preferences.download-location"
case lastUsedCustomDownloadLocation = "preferences.custom-last-used-download-location"
Expand All @@ -78,6 +81,7 @@ public struct UserDefaultsWrapper<T> {
case lastCrashReportCheckDate = "last.crash.report.check.date"

case fireInfoPresentedOnce = "fire.info.presented.once"
case appTerminationHandledCorrectly = "app.termination.handled.correctly"

case restorePreviousSession = "preferences.startup.restore-previous-session"
case launchToCustomHomePage = "preferences.startup.launch-to-custom-home-page"
Expand Down
Loading
Loading