From f2cd09aae33b338506e42a69739125eebbeffcce Mon Sep 17 00:00:00 2001 From: Rizwan Mohamed Ibrahim Date: Fri, 29 May 2020 20:39:04 +0530 Subject: [PATCH] refactor open in app browser with global shortcuts --- Shared/Resources/GlobalKeyboardShortcuts.plist | 2 +- iOS/KeyboardManager.swift | 3 --- iOS/RootSplitViewController.swift | 6 +----- iOS/SceneCoordinator.swift | 17 +++++++++-------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Shared/Resources/GlobalKeyboardShortcuts.plist b/Shared/Resources/GlobalKeyboardShortcuts.plist index c72a56917..c6288be02 100644 --- a/Shared/Resources/GlobalKeyboardShortcuts.plist +++ b/Shared/Resources/GlobalKeyboardShortcuts.plist @@ -106,7 +106,7 @@ title - Open in Browser + Open In App Browser key [return] action diff --git a/iOS/KeyboardManager.swift b/iOS/KeyboardManager.swift index 9fcbff108..a79dcd834 100644 --- a/iOS/KeyboardManager.swift +++ b/iOS/KeyboardManager.swift @@ -177,9 +177,6 @@ private extension KeyboardManager { let openInBrowserTitle = NSLocalizedString("Open In Browser", comment: "Open In Browser") keys.append(KeyboardManager.createKeyCommand(title: openInBrowserTitle, action: "openInBrowser:", input: UIKeyCommand.inputRightArrow, modifiers: [.command])) - let openInAppBrowserTitle = NSLocalizedString("Open In App Browser", comment: "Open In App Browser") - keys.append(KeyboardManager.createKeyCommand(title: openInAppBrowserTitle, action: "openArticleInAppBrowser:", input: "\r", modifiers: [])) - let toggleReadTitle = NSLocalizedString("Toggle Read Status", comment: "Toggle Read Status") keys.append(KeyboardManager.createKeyCommand(title: toggleReadTitle, action: "toggleRead:", input: "u", modifiers: [.command, .shift])) diff --git a/iOS/RootSplitViewController.swift b/iOS/RootSplitViewController.swift index 18c53c305..248436129 100644 --- a/iOS/RootSplitViewController.swift +++ b/iOS/RootSplitViewController.swift @@ -83,11 +83,7 @@ class RootSplitViewController: UISplitViewController { } @objc func openInAppBrowser(_ sender: Any?) { - coordinator.showInAppBrowserForCurrentFeed() - } - - @objc func openArticleInAppBrowser(_ sender: Any?) { - coordinator.showInAppBrowserForCurrentArticle() + coordinator.showInAppBrowser() } @objc func articleSearch(_ sender: Any?) { diff --git a/iOS/SceneCoordinator.swift b/iOS/SceneCoordinator.swift index 8d087a51c..6d976f567 100644 --- a/iOS/SceneCoordinator.swift +++ b/iOS/SceneCoordinator.swift @@ -1185,15 +1185,16 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider { } UIApplication.shared.open(url, options: [:]) } - - func showInAppBrowserForCurrentArticle() { - articleViewController?.openInAppBrowser() - } - - func showInAppBrowserForCurrentFeed() { - masterFeedViewController.openInAppBrowser() - } + func showInAppBrowser() { + if currentArticle != nil { + articleViewController?.openInAppBrowser() + } + else { + masterFeedViewController.openInAppBrowser() + } + } + func navigateToFeeds() { masterFeedViewController?.focus() selectArticle(nil)