Add handoff to various user activities
This commit is contained in:
parent
6ca5bb0c74
commit
d74be9d81d
|
@ -227,6 +227,10 @@ class ConversationViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func mainStatusLoaded(_ mainStatus: StatusMO) {
|
||||
if let accountID = mastodonController.accountInfo?.id {
|
||||
userActivity = UserActivityManager.showConversationActivity(mainStatusID: mainStatus.id, accountID: accountID)
|
||||
}
|
||||
|
||||
let vc = ConversationCollectionViewController(for: mainStatus.id, state: mainStatusState, conversationViewController: self)
|
||||
vc.statusIDToScrollToOnLoad = statusIDToScrollToOnLoad ?? mainStatus.id
|
||||
vc.showStatusesAutomatically = showStatusesAutomatically
|
||||
|
|
|
@ -38,7 +38,9 @@ class MyProfileViewController: ProfileViewController {
|
|||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Preferences", style: .plain, target: self, action: #selector(preferencesPressed))
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||
|
||||
}
|
||||
|
||||
override func updateUserActivity() {
|
||||
userActivity = UserActivityManager.myProfileActivity(accountID: mastodonController.accountInfo!.id)
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,13 @@ class ProfileViewController: UIViewController, StateRestorableViewController {
|
|||
}
|
||||
}
|
||||
|
||||
func updateUserActivity() {
|
||||
if let accountID,
|
||||
let currentAccountID = mastodonController.accountInfo?.id {
|
||||
userActivity = UserActivityManager.showProfileActivity(id: accountID, accountID: currentAccountID)
|
||||
}
|
||||
}
|
||||
|
||||
private func loadAccount() async {
|
||||
guard let accountID else {
|
||||
return
|
||||
|
@ -136,10 +143,7 @@ class ProfileViewController: UIViewController, StateRestorableViewController {
|
|||
}
|
||||
|
||||
private func updateAccountUI(account: AccountMO) {
|
||||
if let currentAccountID = mastodonController.accountInfo?.id {
|
||||
userActivity = UserActivityManager.showProfileActivity(id: account.id, accountID: currentAccountID)
|
||||
}
|
||||
|
||||
updateUserActivity()
|
||||
navigationItem.title = account.displayNameWithoutCustomEmoji
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private var contentOffsetObservation: NSKeyValueObservation?
|
||||
private var activityToRestore: NSUserActivity?
|
||||
// the last time this VC disappeared or the scene was backgrounded while it was active, used to decide if we want to check for present when reappearing
|
||||
private var disappearedAt: Date?
|
||||
|
||||
|
@ -69,6 +68,10 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
|
||||
self.navigationItem.title = timeline.title
|
||||
addKeyCommand(MenuController.refreshCommand(discoverabilityTitle: "Refresh Timeline"))
|
||||
|
||||
if let accountID = mastodonController.accountInfo?.id {
|
||||
self.userActivity = UserActivityManager.showTimelineActivity(timeline: timeline, accountID: accountID)
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
|
@ -124,6 +124,7 @@ class UserActivityManager {
|
|||
static func checkNotificationsActivity(mode: NotificationsMode = .allNotifications, accountID: String) -> NSUserActivity {
|
||||
let activity = NSUserActivity(type: .checkNotifications, accountID: accountID)
|
||||
activity.isEligibleForPrediction = true
|
||||
activity.isEligibleForHandoff = true
|
||||
activity.addUserInfoEntries(from: [
|
||||
"notificationsMode": mode.rawValue
|
||||
])
|
||||
|
@ -160,6 +161,7 @@ class UserActivityManager {
|
|||
|
||||
let activity = NSUserActivity(type: .showTimeline, accountID: accountID)
|
||||
activity.isEligibleForPrediction = true
|
||||
activity.isEligibleForHandoff = true
|
||||
activity.addUserInfoEntries(from: [
|
||||
"timelineData": timelineData,
|
||||
])
|
||||
|
@ -221,6 +223,7 @@ class UserActivityManager {
|
|||
"mainStatusID": mainStatusID,
|
||||
])
|
||||
activity.isEligibleForPrediction = isEligibleForPrediction
|
||||
activity.isEligibleForHandoff = true
|
||||
return activity
|
||||
}
|
||||
|
||||
|
@ -298,6 +301,7 @@ class UserActivityManager {
|
|||
static func myProfileActivity(accountID: String) -> NSUserActivity {
|
||||
let activity = NSUserActivity(type: .myProfile, accountID: accountID)
|
||||
activity.isEligibleForPrediction = true
|
||||
activity.isEligibleForHandoff = true
|
||||
activity.title = NSLocalizedString("My Profile", comment: "my profile shortcut title")
|
||||
activity.suggestedInvocationPhrase = NSLocalizedString("Show my Mastodon profile", comment: "my profile shortuct invocation phrase")
|
||||
return activity
|
||||
|
|
Loading…
Reference in New Issue