From 3dc474fba8f2aa2445ba945cc4bbeb4e2eeef8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20=C5=9Apiewak?= Date: Tue, 6 Aug 2024 11:16:54 +0200 Subject: [PATCH] Open keyboard on New Tab Page based on Settings (#3187) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task/Issue URL: https://app.asana.com/0/72649045549333/1207840822110802/f Tech Design URL: CC: **Description**: When opening New Tab Page keyboard needs to open according to setting in General → Keyboard → New Tab. --- DuckDuckGo/HomeCollectionView.swift | 4 ---- DuckDuckGo/HomeViewController.swift | 4 ---- DuckDuckGo/HomeViewSectionRenderers.swift | 8 -------- DuckDuckGo/HomeViewSectionRenderersExtension.swift | 2 -- DuckDuckGo/MainViewController.swift | 2 +- .../NavigationSearchHomeViewSectionRenderer.swift | 2 +- DuckDuckGo/NewTabPage.swift | 1 - DuckDuckGo/NewTabPageViewController.swift | 12 +++++++----- 8 files changed, 9 insertions(+), 26 deletions(-) diff --git a/DuckDuckGo/HomeCollectionView.swift b/DuckDuckGo/HomeCollectionView.swift index 7c1627d54e..7368530dc3 100644 --- a/DuckDuckGo/HomeCollectionView.swift +++ b/DuckDuckGo/HomeCollectionView.swift @@ -150,10 +150,6 @@ class HomeCollectionView: UICollectionView { menuController.showMenu(from: self, rect: menuView.frame) } - func omniBarCancelPressed() { - renderers.omniBarCancelPressed() - } - func openedAsNewTab(allowingKeyboard: Bool) { renderers.openedAsNewTab(allowingKeyboard: allowingKeyboard) } diff --git a/DuckDuckGo/HomeViewController.swift b/DuckDuckGo/HomeViewController.swift index b51a65401b..a65c20507e 100644 --- a/DuckDuckGo/HomeViewController.swift +++ b/DuckDuckGo/HomeViewController.swift @@ -216,10 +216,6 @@ class HomeViewController: UIViewController, NewTabPage { collectionView.reloadData() } - func omniBarCancelPressed() { - collectionView.omniBarCancelPressed() - } - func openedAsNewTab(allowingKeyboard: Bool) { collectionView.openedAsNewTab(allowingKeyboard: allowingKeyboard) if !variantManager.isSupported(feature: .newOnboardingIntro) { diff --git a/DuckDuckGo/HomeViewSectionRenderers.swift b/DuckDuckGo/HomeViewSectionRenderers.swift index f9518f3674..191f323c53 100644 --- a/DuckDuckGo/HomeViewSectionRenderers.swift +++ b/DuckDuckGo/HomeViewSectionRenderers.swift @@ -38,8 +38,6 @@ protocol HomeViewSectionRenderer: AnyObject { func remove(from controller: HomeViewController) - func omniBarCancelPressed() - func openedAsNewTab(allowingKeyboard: Bool) func launchNewSearch() @@ -136,12 +134,6 @@ class HomeViewSectionRenderers: NSObject, return renderers[section] } - func omniBarCancelPressed() { - renderers.forEach { renderer in - renderer.omniBarCancelPressed() - } - } - func openedAsNewTab(allowingKeyboard: Bool) { renderers.forEach { renderer in renderer.openedAsNewTab(allowingKeyboard: allowingKeyboard) diff --git a/DuckDuckGo/HomeViewSectionRenderersExtension.swift b/DuckDuckGo/HomeViewSectionRenderersExtension.swift index 9e8888953b..6c101e702a 100644 --- a/DuckDuckGo/HomeViewSectionRenderersExtension.swift +++ b/DuckDuckGo/HomeViewSectionRenderersExtension.swift @@ -26,8 +26,6 @@ extension HomeViewSectionRenderer { func remove(from controller: HomeViewController) { } - func omniBarCancelPressed() { } - func openedAsNewTab(allowingKeyboard: Bool) { } func menuItemsFor(itemAt: Int) -> [UIMenuItem]? { diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index db7ef718a7..51192e1955 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -775,6 +775,7 @@ class MainViewController: UIViewController { controller.delegate = self controller.shortcutsDelegate = self + controller.chromeDelegate = self newTabPageViewController = controller addToContentContainer(controller: controller) @@ -1866,7 +1867,6 @@ extension MainViewController: OmniBarDelegate { dismissOmniBar() omniBar.cancel() hideSuggestionTray() - homeController?.omniBarCancelPressed() self.showMenuHighlighterIfNeeded() } diff --git a/DuckDuckGo/NavigationSearchHomeViewSectionRenderer.swift b/DuckDuckGo/NavigationSearchHomeViewSectionRenderer.swift index 34f23fb686..d55c41e0ce 100644 --- a/DuckDuckGo/NavigationSearchHomeViewSectionRenderer.swift +++ b/DuckDuckGo/NavigationSearchHomeViewSectionRenderer.swift @@ -48,7 +48,7 @@ class NavigationSearchHomeViewSectionRenderer: HomeViewSectionRenderer { func openedAsNewTab(allowingKeyboard: Bool) { guard allowingKeyboard && KeyboardSettings().onNewTab else { return } // The omnibar is inside a collection view so this needs to chance to do its thing - // which might also be async. Not great. + // which might also be async. Not great. DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { self.launchNewSearch() } diff --git a/DuckDuckGo/NewTabPage.swift b/DuckDuckGo/NewTabPage.swift index 5ae09b931b..7be2446e29 100644 --- a/DuckDuckGo/NewTabPage.swift +++ b/DuckDuckGo/NewTabPage.swift @@ -26,7 +26,6 @@ protocol NewTabPage: UIViewController { func launchNewSearch() func openedAsNewTab(allowingKeyboard: Bool) - func omniBarCancelPressed() func dismiss() diff --git a/DuckDuckGo/NewTabPageViewController.swift b/DuckDuckGo/NewTabPageViewController.swift index 5476a4c19e..772ebf2faa 100644 --- a/DuckDuckGo/NewTabPageViewController.swift +++ b/DuckDuckGo/NewTabPageViewController.swift @@ -128,15 +128,17 @@ final class NewTabPageViewController: UIHostingController