diff --git a/Client/Application/Shortcuts/ActivityShortcutManager.swift b/Client/Application/Shortcuts/ActivityShortcutManager.swift index 7a316ca69ab..170186b7036 100644 --- a/Client/Application/Shortcuts/ActivityShortcutManager.swift +++ b/Client/Application/Shortcuts/ActivityShortcutManager.swift @@ -114,20 +114,27 @@ class ActivityShortcutManager: NSObject { // MARK: Activity Action Methods public func performShortcutActivity(type: ActivityType, using bvc: BrowserViewController) { + // Adding a slight delay to overcome concurency issues with bvc setup + DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { + self.handleActivityDetails(type: type, using: bvc) + } + } + + private func handleActivityDetails(type: ActivityType, using bvc: BrowserViewController) { switch type { case .newTab: - bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: false) + bvc.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: false) case .newPrivateTab: - bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: true) + bvc.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: true) case .clearBrowsingHistory: bvc.clearHistoryAndOpenNewTab() case .enableBraveVPN: - bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: false) - + bvc.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: false) + switch BraveVPN.vpnState { case .notPurchased, .purchased, .expired: guard let enableVPNController = BraveVPN.vpnState.enableVPNDestinationVC else { return } - + bvc.openInsideSettingsNavigation(with: enableVPNController) case .installed(let connected): if !connected { @@ -135,10 +142,16 @@ class ActivityShortcutManager: NSObject { } } case .openBraveNews: - bvc.openBlankNewTab(attemptLocationFieldFocus: true, isPrivate: false) - - guard let newTabPageController = bvc.tabManager.selectedTab?.newTabPageViewController else { return } - newTabPageController.scrollToBraveNews() + if Preferences.BraveNews.isEnabled.value { + bvc.openBlankNewTab(attemptLocationFieldFocus: false, isPrivate: false) + + guard let newTabPageController = bvc.tabManager.selectedTab?.newTabPageViewController else { return } + newTabPageController.scrollToBraveNews() + } else { + let controller = BraveNewsSettingsViewController(dataSource: bvc.feedDataSource) + let container = UINavigationController(rootViewController: controller) + bvc.present(container, animated: true) + } case .openPlayList: let playlistController = (UIApplication.shared.delegate as? AppDelegate)?.playlistRestorationController ?? PlaylistViewController() playlistController.modalPresentationStyle = .fullScreen diff --git a/Client/Frontend/Browser/Tab Tray/TabTrayController.swift b/Client/Frontend/Browser/Tab Tray/TabTrayController.swift index 3a811389af7..a2512dd1e86 100644 --- a/Client/Frontend/Browser/Tab Tray/TabTrayController.swift +++ b/Client/Frontend/Browser/Tab Tray/TabTrayController.swift @@ -99,6 +99,8 @@ class TabTrayController: UIViewController { tabManager.addDelegate(self) Preferences.Privacy.privateBrowsingOnly.observe(from: self) + + setPrivateMode() } convenience init(tabManager: TabManager, profile: Profile, tabTrayDelegate: TabTrayDelegate) { @@ -152,9 +154,7 @@ class TabTrayController: UIViewController { make.bottom.equalTo(self.toolbar.snp.top) } - if let tab = tabManager.selectedTab, tab.isPrivate { - privateMode = true - } + setPrivateMode() // XXX: Bug 1447726 - Temporarily disable 3DT in tabs tray // register for previewing delegate to enable peek and pop if force touch feature available @@ -374,6 +374,12 @@ class TabTrayController: UIViewController { delegate.updateShortcutItems(UIApplication.shared) } } + + private func setPrivateMode() { + if let tab = tabManager.selectedTab, tab.isPrivate { + privateMode = true + } + } } extension TabTrayController: PreferencesObserver {