diff --git a/Tusker/Info.plist b/Tusker/Info.plist
index 46b8b212..5c93739c 100644
--- a/Tusker/Info.plist
+++ b/Tusker/Info.plist
@@ -8,6 +8,7 @@
$(PRODUCT_BUNDLE_IDENTIFIER).activity.check-notifications
$(PRODUCT_BUNDLE_IDENTIFIER).activity.check-mentions
$(PRODUCT_BUNDLE_IDENTIFIER).activity.new-post
+ $(PRODUCT_BUNDLE_IDENTIFIER).activity.search
CFBundleDevelopmentRegion
$(DEVELOPMENT_LANGUAGE)
diff --git a/Tusker/Screens/Search/SearchTableViewController.swift b/Tusker/Screens/Search/SearchTableViewController.swift
index 5f51d292..7280f090 100644
--- a/Tusker/Screens/Search/SearchTableViewController.swift
+++ b/Tusker/Screens/Search/SearchTableViewController.swift
@@ -83,6 +83,8 @@ class SearchTableViewController: EnhancedTableViewController {
.map { $0?.trimmingCharacters(in: .whitespacesAndNewlines) }
.filter { $0 != self.currentQuery }
.sink(receiveValue: performSearch(query:))
+
+ userActivity = UserActivityManager.searchActivity()
}
func performSearch(query: String?) {
diff --git a/Tusker/Shortcuts/UserActivityManager.swift b/Tusker/Shortcuts/UserActivityManager.swift
index e534d9cd..f1ee542f 100644
--- a/Tusker/Shortcuts/UserActivityManager.swift
+++ b/Tusker/Shortcuts/UserActivityManager.swift
@@ -57,9 +57,9 @@ class UserActivityManager {
static func handleCheckNotifications(activity: NSUserActivity) {
let tabBarController = getMainTabBarController()
tabBarController.select(tab: .notifications)
- if let navController = tabBarController.getTabController(tab: .notifications) as? UINavigationController,
- let notificationsPageController = navController.viewControllers.first as? NotificationsPageViewController {
- navController.popToRootViewController(animated: false)
+ if let navigationController = tabBarController.getTabController(tab: .notifications) as? UINavigationController,
+ let notificationsPageController = navigationController.viewControllers.first as? NotificationsPageViewController {
+ navigationController.popToRootViewController(animated: false)
notificationsPageController.selectMode(.allNotifications)
}
}
@@ -145,4 +145,22 @@ class UserActivityManager {
}
}
+ // MARK: - Search
+
+ static func searchActivity() -> NSUserActivity {
+ let activity = NSUserActivity(type: .search)
+ activity.isEligibleForPrediction = true
+ activity.title = NSLocalizedString("Search", comment: "search shortcut title")
+ activity.suggestedInvocationPhrase = NSLocalizedString("Search the fediverse", comment: "search shortcut invocation phrase")
+ return activity
+ }
+
+ static func handleSearch(activity: NSUserActivity) {
+ let tabBarController = getMainTabBarController()
+ tabBarController.select(tab: .search)
+ if let navigationController = tabBarController.getTabController(tab: .search) as? UINavigationController {
+ navigationController.popToRootViewController(animated: false)
+ }
+ }
+
}
diff --git a/Tusker/Shortcuts/UserActivityType.swift b/Tusker/Shortcuts/UserActivityType.swift
index c3ecdea9..86b7a2d2 100644
--- a/Tusker/Shortcuts/UserActivityType.swift
+++ b/Tusker/Shortcuts/UserActivityType.swift
@@ -13,6 +13,7 @@ enum UserActivityType: String {
case checkNotifications = "net.shadowfacts.Tusker.activity.check-notifications"
case checkMentions = "net.shadowfacts.Tusker.activity.check-mentions"
case showTimeline = "net.shadowfacts.Tusker.activity.show-timeline"
+ case search = "net.shadowfacts.Tusker.activity.search"
}
extension UserActivityType {
@@ -26,6 +27,8 @@ extension UserActivityType {
return UserActivityManager.handleCheckMentions
case .showTimeline:
return UserActivityManager.handleShowTimeline
+ case .search:
+ return UserActivityManager.handleSearch
}
}
}