mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 23:58:36 +01:00
Merge pull request #2073 from rizwankce/open-in-safari-shortcut
Keyboard shortcuts for "Open in App Browser"
This commit is contained in:
commit
225c98a70e
@ -106,11 +106,11 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>title</key>
|
||||
<string>Open in Browser</string>
|
||||
<string>Open in App Browser</string>
|
||||
<key>key</key>
|
||||
<string>[return]</string>
|
||||
<key>action</key>
|
||||
<string>openInBrowser:</string>
|
||||
<string>openFeedInAppBrowser:</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>key</key>
|
||||
|
@ -256,6 +256,7 @@ class ArticleViewController: UIViewController {
|
||||
}
|
||||
|
||||
// MARK: Keyboard Shortcuts
|
||||
|
||||
@objc func navigateToTimeline(_ sender: Any?) {
|
||||
coordinator.navigateToTimeline()
|
||||
}
|
||||
@ -277,7 +278,10 @@ class ArticleViewController: UIViewController {
|
||||
func stopArticleExtractorIfProcessing() {
|
||||
currentWebViewController?.stopArticleExtractorIfProcessing()
|
||||
}
|
||||
|
||||
|
||||
func openInAppBrowser() {
|
||||
currentWebViewController?.openInAppBrowser()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: WebViewControllerDelegate
|
||||
|
@ -227,7 +227,15 @@ class WebViewController: UIViewController {
|
||||
activityViewController.popoverPresentationController?.barButtonItem = popOverBarButtonItem
|
||||
present(activityViewController, animated: true)
|
||||
}
|
||||
|
||||
|
||||
func openInAppBrowser() {
|
||||
guard let preferredLink = article?.preferredLink, let url = URL(string: preferredLink) else {
|
||||
return
|
||||
}
|
||||
|
||||
let vc = SFSafariViewController(url: url)
|
||||
present(vc, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: ArticleExtractorDelegate
|
||||
|
@ -177,6 +177,9 @@ 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: "openInAppBrowser:", 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]))
|
||||
|
||||
|
@ -11,6 +11,7 @@ import Account
|
||||
import Articles
|
||||
import RSCore
|
||||
import RSTree
|
||||
import SafariServices
|
||||
|
||||
class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
|
||||
@ -514,7 +515,14 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
func focus() {
|
||||
becomeFirstResponder()
|
||||
}
|
||||
|
||||
|
||||
func openInAppBrowser() {
|
||||
if let indexPath = coordinator.currentFeedIndexPath,
|
||||
let url = coordinator.homePageURLForFeed(indexPath) {
|
||||
let vc = SFSafariViewController(url: url)
|
||||
present(vc, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: UIContextMenuInteractionDelegate
|
||||
|
@ -81,6 +81,14 @@ class RootSplitViewController: UISplitViewController {
|
||||
@objc func openInBrowser(_ sender: Any?) {
|
||||
coordinator.showBrowserForCurrentArticle()
|
||||
}
|
||||
|
||||
@objc func openInAppBrowser(_ sender: Any?) {
|
||||
coordinator.showInAppBrowserForCurrentArticle()
|
||||
}
|
||||
|
||||
@objc func openFeedInAppBrowser(_ sender: Any?) {
|
||||
coordinator.showInAppBrowserForCurrentFeed()
|
||||
}
|
||||
|
||||
@objc func articleSearch(_ sender: Any?) {
|
||||
coordinator.showSearch()
|
||||
|
@ -12,6 +12,7 @@ import Account
|
||||
import Articles
|
||||
import RSCore
|
||||
import RSTree
|
||||
import SafariServices
|
||||
|
||||
enum PanelMode {
|
||||
case unset
|
||||
@ -1183,6 +1184,14 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
}
|
||||
UIApplication.shared.open(url, options: [:])
|
||||
}
|
||||
|
||||
func showInAppBrowserForCurrentArticle() {
|
||||
articleViewController?.openInAppBrowser()
|
||||
}
|
||||
|
||||
func showInAppBrowserForCurrentFeed() {
|
||||
masterFeedViewController.openInAppBrowser()
|
||||
}
|
||||
|
||||
func navigateToFeeds() {
|
||||
masterFeedViewController?.focus()
|
||||
|
Loading…
Reference in New Issue
Block a user