mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-20 14:33:04 +01:00
Add Activities for viewing Feeds and Folders
This commit is contained in:
parent
2b206e098a
commit
d641223536
@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import CoreSpotlight
|
||||
import CoreServices
|
||||
import Account
|
||||
import Articles
|
||||
import Intents
|
||||
|
||||
@ -21,19 +22,34 @@ class ActivityManager {
|
||||
|
||||
func selectingToday() {
|
||||
let title = NSLocalizedString("See articles for Today", comment: "Today")
|
||||
selectingActivity = makeSmartFeedActivity(type: ActivityType.selectToday, title: title, identifier: "smartfeed.today")
|
||||
selectingActivity = makeSelectingActivity(type: ActivityType.selectToday, title: title, identifier: "smartfeed.today")
|
||||
selectingActivity!.becomeCurrent()
|
||||
}
|
||||
|
||||
func selectingAllUnread() {
|
||||
let title = NSLocalizedString("See articles in All Unread", comment: "All Unread")
|
||||
selectingActivity = makeSmartFeedActivity(type: ActivityType.selectAllUnread, title: title, identifier: "smartfeed.allUnread")
|
||||
selectingActivity = makeSelectingActivity(type: ActivityType.selectAllUnread, title: title, identifier: "smartfeed.allUnread")
|
||||
selectingActivity!.becomeCurrent()
|
||||
}
|
||||
|
||||
func selectingStarred() {
|
||||
let title = NSLocalizedString("See articles in Starred", comment: "Starred")
|
||||
selectingActivity = makeSmartFeedActivity(type: ActivityType.selectStarred, title: title, identifier: "smartfeed.starred")
|
||||
selectingActivity = makeSelectingActivity(type: ActivityType.selectStarred, title: title, identifier: "smartfeed.starred")
|
||||
selectingActivity!.becomeCurrent()
|
||||
}
|
||||
|
||||
func selectingFolder(_ folder: Folder) {
|
||||
let localizedText = NSLocalizedString("See articles in “%@”", comment: "See articles in Folder")
|
||||
let title = NSString.localizedStringWithFormat(localizedText as NSString, folder.nameForDisplay) as String
|
||||
selectingActivity = makeSelectingActivity(type: ActivityType.selectFolder, title: title, identifier: "folder.\(folder.nameForDisplay)")
|
||||
selectingActivity!.becomeCurrent()
|
||||
|
||||
}
|
||||
|
||||
func selectingFeed(_ feed: Feed) {
|
||||
let localizedText = NSLocalizedString("See articles in “%@”", comment: "See articles in Feed")
|
||||
let title = NSString.localizedStringWithFormat(localizedText as NSString, feed.nameForDisplay) as String
|
||||
selectingActivity = makeSelectingActivity(type: ActivityType.selectFeed, title: title, identifier: feed.url)
|
||||
selectingActivity!.becomeCurrent()
|
||||
}
|
||||
|
||||
@ -51,7 +67,7 @@ class ActivityManager {
|
||||
|
||||
private extension ActivityManager {
|
||||
|
||||
func makeSmartFeedActivity(type: ActivityType, title: String, identifier: String) -> NSUserActivity {
|
||||
func makeSelectingActivity(type: ActivityType, title: String, identifier: String) -> NSUserActivity {
|
||||
let activity = NSUserActivity(activityType: type.rawValue)
|
||||
activity.title = title
|
||||
activity.suggestedInvocationPhrase = title
|
||||
|
@ -12,5 +12,7 @@ enum ActivityType: String {
|
||||
case selectToday = "com.ranchero.NetNewsWire.SelectToday"
|
||||
case selectAllUnread = "com.ranchero.NetNewsWire.SelectAllUnread"
|
||||
case selectStarred = "com.ranchero.NetNewsWire.SelectStarred"
|
||||
case selectFolder = "com.ranchero.NetNewsWire.SelectFolder"
|
||||
case selectFeed = "com.ranchero.NetNewsWire.SelectFeed"
|
||||
case readArticle = "com.ranchero.NetNewsWire.ReadArticle"
|
||||
}
|
||||
|
@ -253,6 +253,10 @@ class AppCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
handleSelectAllUnread()
|
||||
case .selectStarred:
|
||||
handleSelectStarred()
|
||||
case .selectFolder:
|
||||
print("folder selected")
|
||||
case .selectFeed:
|
||||
print("feed selected")
|
||||
case .readArticle:
|
||||
handleReadArticle(activity)
|
||||
}
|
||||
@ -1193,6 +1197,10 @@ private extension AppCoordinator {
|
||||
ActivityManager.shared.selectingAllUnread()
|
||||
case node.representedObject === SmartFeedsController.shared.starredFeed:
|
||||
ActivityManager.shared.selectingStarred()
|
||||
case node.representedObject is Folder:
|
||||
ActivityManager.shared.selectingFolder(node.representedObject as! Folder)
|
||||
case node.representedObject is Feed:
|
||||
ActivityManager.shared.selectingFeed(node.representedObject as! Feed)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -49,6 +49,8 @@
|
||||
<true/>
|
||||
<key>NSUserActivityTypes</key>
|
||||
<array>
|
||||
<string>com.ranchero.NetNewsWire.SelectFeed</string>
|
||||
<string>com.ranchero.NetNewsWire.SelectFolder</string>
|
||||
<string>com.ranchero.NetNewsWire.SelectAllUnread</string>
|
||||
<string>com.ranchero.NetNewsWire.SelectStarred</string>
|
||||
<string>com.ranchero.NetNewsWire.SelectToday</string>
|
||||
|
Loading…
Reference in New Issue
Block a user