|
16 | 16 | limitations under the License. |
17 | 17 | */ |
18 | 18 |
|
| 19 | +@import CoreSpotlight; |
| 20 | + |
19 | 21 | #import "RoomViewController.h" |
20 | 22 |
|
21 | 23 | #import "RoomDataSource.h" |
|
128 | 130 |
|
129 | 131 | #import "MXSDKOptions.h" |
130 | 132 |
|
| 133 | +#import "UserActivities.h" |
| 134 | + |
131 | 135 | #import "Riot-Swift.h" |
132 | 136 |
|
133 | 137 | NSNotificationName const RoomCallTileTappedNotification = @"RoomCallTileTappedNotification"; |
@@ -588,6 +592,8 @@ - (void)viewWillAppear:(BOOL)animated |
588 | 592 | notificationTaskProfile = [MXSDKOptions.sharedInstance.profiler startMeasuringTaskWithName:AnalyticsNoficationsTimeToDisplayContent |
589 | 593 | category:AnalyticsNoficationsCategory]; |
590 | 594 | } |
| 595 | + |
| 596 | + [self becomeCurrentActivity]; |
591 | 597 | } |
592 | 598 |
|
593 | 599 | - (void)viewWillDisappear:(BOOL)animated |
@@ -1991,6 +1997,50 @@ - (void)setupActions { |
1991 | 1997 | roomInputView.actionsBar.actionItems = actionItems; |
1992 | 1998 | } |
1993 | 1999 |
|
| 2000 | +- (void)becomeCurrentActivity |
| 2001 | +{ |
| 2002 | + if (!self.userActivity) { |
| 2003 | + self.userActivity = [[NSUserActivity alloc] initWithActivityType:kUserActivityTypeMatrixRoom]; |
| 2004 | + } |
| 2005 | + |
| 2006 | + self.userActivity.title = self.roomDataSource.room.summary.displayname; |
| 2007 | + self.userActivity.requiredUserInfoKeys = [[NSSet alloc] initWithObjects:kUserActivityInfoRoomId, nil]; |
| 2008 | + |
| 2009 | + // user info |
| 2010 | + NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init]; |
| 2011 | + [userInfo setObject:self.roomDataSource.roomId forKey:kUserActivityInfoRoomId]; |
| 2012 | + if ([self.roomDataSource.room isDirect]) { |
| 2013 | + [userInfo setObject:self.roomDataSource.room.directUserId forKey:kUserActivityInfoUserId]; |
| 2014 | + } |
| 2015 | + self.userActivity.userInfo = userInfo; |
| 2016 | + |
| 2017 | + // TODO: add a NSUserActivityDelegate to save the current text in the userinfo of the activity |
| 2018 | + // self.userActivity.delegate = self; |
| 2019 | + // self.userActivity.needsSave = true; |
| 2020 | + self.userActivity.persistentIdentifier = self.roomDataSource.roomId; |
| 2021 | + |
| 2022 | + self.userActivity.eligibleForHandoff = true; |
| 2023 | + self.userActivity.eligibleForSearch = true; |
| 2024 | + self.userActivity.eligibleForPrediction = true; |
| 2025 | + |
| 2026 | + CSSearchableItemAttributeSet *contentAttribute; |
| 2027 | + if (@available(iOS 14.0, *)) { |
| 2028 | + contentAttribute = [[CSSearchableItemAttributeSet alloc] initWithContentType:UTTypeItem]; |
| 2029 | + } else { |
| 2030 | + contentAttribute = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:@"public.item"]; |
| 2031 | + } |
| 2032 | + |
| 2033 | + contentAttribute.title = self.roomDataSource.room.summary.displayname; |
| 2034 | + contentAttribute.displayName = self.roomDataSource.room.summary.displayname; |
| 2035 | + contentAttribute.contentDescription = self.roomDataSource.room.summary.lastMessage.text; |
| 2036 | + |
| 2037 | + // TODO: contentAttribute.thumbnailURL = |
| 2038 | + // TODO: accountHandles of everyone in the room |
| 2039 | + contentAttribute.instantMessageAddresses = [[NSArray alloc] initWithObjects:self.roomDataSource.roomId, nil]; |
| 2040 | + |
| 2041 | + self.userActivity.contentAttributeSet = contentAttribute; |
| 2042 | +} |
| 2043 | + |
1994 | 2044 | - (void)roomInputToolbarViewPresentStickerPicker |
1995 | 2045 | { |
1996 | 2046 | // Search for the sticker picker widget in the user account |
|
0 commit comments