Add NSUserActivity for reading articles

This commit is contained in:
Maurice Parker
2019-08-24 14:57:51 -05:00
parent 1ba60e2846
commit 5b1c0485c5
7 changed files with 130 additions and 31 deletions

View File

@@ -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()
}
}

View File

@@ -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? {

View File

@@ -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>