From 8779984a00a5486e41ca64be274ed1a17dc23c94 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 1 May 2024 12:35:38 +0100 Subject: [PATCH 1/3] fix address bar weirdness use less intrusive mechanism to detect user tap on field --- DuckDuckGo/OmniBar.swift | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/DuckDuckGo/OmniBar.swift b/DuckDuckGo/OmniBar.swift index 751a15283d..abae43ffc7 100644 --- a/DuckDuckGo/OmniBar.swift +++ b/DuckDuckGo/OmniBar.swift @@ -174,17 +174,9 @@ class OmniBar: UIView { guard let range = field.selectedTextRange else { return } UIPasteboard.general.string = field.text(in: range) } - - textField.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector( onTextFieldTapped ))) } - var textFieldTapped = false - - @objc - private func onTextFieldTapped() { - textFieldTapped = true - textField.becomeFirstResponder() - } + var textFieldTapped = true private func configureSeparator() { separatorHeightConstraint.constant = 1.0 / UIScreen.main.scale @@ -374,6 +366,10 @@ class OmniBar: UIView { } @discardableResult override func becomeFirstResponder() -> Bool { + textFieldTapped = false + defer { + textFieldTapped = true + } return textField.becomeFirstResponder() } From aee610686a4fc655e82115f466a902cc9420f8c4 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 1 May 2024 12:41:22 +0100 Subject: [PATCH 2/3] tweak for web page clicking --- DuckDuckGo/OmniBar.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/DuckDuckGo/OmniBar.swift b/DuckDuckGo/OmniBar.swift index abae43ffc7..1991df9c4f 100644 --- a/DuckDuckGo/OmniBar.swift +++ b/DuckDuckGo/OmniBar.swift @@ -497,7 +497,6 @@ extension OmniBar: UITextFieldDelegate { func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { omniDelegate?.onTextFieldWillBeginEditing(self, tapped: textFieldTapped) - textFieldTapped = false return true } From 7892aa6b4453de10448fe48bcb5cba2635811f52 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 1 May 2024 16:10:49 +0100 Subject: [PATCH 3/3] disable post clear if launching as should be in fresh state anyway --- DuckDuckGo/AppDelegate.swift | 2 +- DuckDuckGo/AutoClear.swift | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 05ee8b1793..a95494f062 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -288,7 +288,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { autoClear = AutoClear(worker: main) Task { - await autoClear?.clearDataIfEnabled() + await autoClear?.clearDataIfEnabled(launching: true) } AppDependencyProvider.shared.voiceSearchHelper.migrateSettingsFlagIfNecessary() diff --git a/DuckDuckGo/AutoClear.swift b/DuckDuckGo/AutoClear.swift index 7abb856b6a..d1bcb84e68 100644 --- a/DuckDuckGo/AutoClear.swift +++ b/DuckDuckGo/AutoClear.swift @@ -45,7 +45,7 @@ class AutoClear { } @MainActor - func clearDataIfEnabled() async { + func clearDataIfEnabled(launching: Bool = false) async { guard let settings = AutoClearSettingsModel(settings: appSettings) else { return } if settings.action.contains(.clearTabs) { @@ -56,7 +56,9 @@ class AutoClear { await worker.forgetData() } - worker.clearDataFinished(self) + if !launching { + worker.clearDataFinished(self) + } } /// Note: function is parametrised because of tests.