mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add NSUserActivity for reading articles
This commit is contained in:
@@ -210,6 +210,8 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private(set) var readActivity: NSUserActivity? = nil
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
@@ -508,7 +510,8 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
|
||||
func selectArticle(_ indexPath: IndexPath?) {
|
||||
currentArticleIndexPath = indexPath
|
||||
|
||||
updateReadArticleUserActivity()
|
||||
|
||||
if indexPath == nil {
|
||||
if !rootSplitViewController.isCollapsed {
|
||||
let systemMessageViewController = UIStoryboard.main.instantiateController(ofType: SystemMessageViewController.self)
|
||||
@@ -1168,4 +1171,16 @@ private extension AppCoordinator {
|
||||
|
||||
}
|
||||
|
||||
// MARK: NSUserActivity
|
||||
|
||||
func updateReadArticleUserActivity() {
|
||||
readActivity?.invalidate()
|
||||
readActivity = nil
|
||||
|
||||
guard let article = currentArticle else { return }
|
||||
|
||||
readActivity = ActivityFactory.make(article)
|
||||
readActivity?.becomeCurrent()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -463,39 +463,11 @@ private extension MasterTimelineViewController {
|
||||
|
||||
}
|
||||
|
||||
func avatarFor(_ article: Article) -> UIImage? {
|
||||
|
||||
func avatarFor(_ article: Article) -> RSImage? {
|
||||
if !coordinator.showAvatars {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let authors = article.authors {
|
||||
for author in authors {
|
||||
if let image = avatarForAuthor(author) {
|
||||
return image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard let feed = article.feed else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let feedIconImage = appDelegate.feedIconDownloader.icon(for: feed)
|
||||
if feedIconImage != nil {
|
||||
return feedIconImage
|
||||
}
|
||||
|
||||
if let feed = article.feed, let faviconImage = appDelegate.faviconDownloader.faviconAsAvatar(for: feed) {
|
||||
return faviconImage
|
||||
}
|
||||
|
||||
return FaviconGenerator.favicon(feed)
|
||||
|
||||
}
|
||||
|
||||
func avatarForAuthor(_ author: Author) -> UIImage? {
|
||||
return appDelegate.authorAvatarDownloader.image(for: author)
|
||||
return article.avatarImage()
|
||||
}
|
||||
|
||||
func featuredImageFor(_ article: Article) -> UIImage? {
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>com.ranchero.NetNewsWire.ReadArticle</string>
|
||||
</array>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
|
||||
Reference in New Issue
Block a user