Merge branch 'develop' into maximee/PSF-986_lls_fix_live_banner_visibility

This commit is contained in:
MaximeE
2022-05-12 11:49:58 +02:00
35 changed files with 1576 additions and 345 deletions
+109 -66
View File
@@ -103,9 +103,6 @@ static CGSize kThreadListBarButtonItemImageSize;
// The preview header
__weak PreviewRoomTitleView *previewHeader;
// The customized room data source for Vector
RoomDataSource *customizedRoomDataSource;
// The user taps on a user id contained in a message
MXKContact *selectedContact;
@@ -197,7 +194,7 @@ static CGSize kThreadListBarButtonItemImageSize;
@property (nonatomic, strong) RoomContextualMenuViewController *roomContextualMenuViewController;
@property (nonatomic, strong) RoomContextualMenuPresenter *roomContextualMenuPresenter;
@property (nonatomic, strong) MXKErrorAlertPresentation *errorPresenter;
@property (nonatomic, strong) NSString *textMessageBeforeEditing;
@property (nonatomic, strong) NSAttributedString *textMessageBeforeEditing;
@property (nonatomic, strong) EditHistoryCoordinatorBridgePresenter *editHistoryPresenter;
@property (nonatomic, strong) MXKDocumentPickerPresenter *documentPickerPresenter;
@property (nonatomic, strong) EmojiPickerCoordinatorBridgePresenter *emojiPickerCoordinatorBridgePresenter;
@@ -316,7 +313,8 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)finalizeInit
{
[super finalizeInit];
[self registerPillAttachmentViewProviderIfNeeded];
self.resizeComposerAnimationDuration = kResizeComposerAnimationDuration;
// Setup `MXKViewControllerHandling` properties
@@ -561,10 +559,10 @@ static CGSize kThreadListBarButtonItemImageSize;
[self removeTypingNotificationsListener];
if (customizedRoomDataSource)
if (self.customizedRoomDataSource)
{
// Cancel potential selected event (to leave edition mode)
if (customizedRoomDataSource.selectedEventId)
if (self.customizedRoomDataSource.selectedEventId)
{
[self cancelEventSelection];
}
@@ -662,6 +660,15 @@ static CGSize kThreadListBarButtonItemImageSize;
{
[self showThreadsNotice];
}
if (self.saveProgressTextInput && self.roomDataSource)
{
// Retrieve the potential message partially typed during last room display.
// Note: We have to wait for viewDidAppear before updating growingTextView (viewWillAppear is too early)
RoomInputToolbarView *inputToolbar = (RoomInputToolbarView *)self.inputToolbarView;
inputToolbar.attributedTextMessage = self.roomDataSource.partialAttributedTextMessage;
}
}
- (void)viewDidDisappear:(BOOL)animated
@@ -1020,7 +1027,7 @@ static CGSize kThreadListBarButtonItemImageSize;
[super displayRoom:dataSource];
customizedRoomDataSource = nil;
self.customizedRoomDataSource = nil;
if (self.roomDataSource)
{
@@ -1031,7 +1038,7 @@ static CGSize kThreadListBarButtonItemImageSize;
// Store ref on customized room data source
if ([dataSource isKindOfClass:RoomDataSource.class])
{
customizedRoomDataSource = (RoomDataSource*)dataSource;
self.customizedRoomDataSource = (RoomDataSource*)dataSource;
}
// Set room title view
@@ -1312,7 +1319,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)sendTextMessage:(NSString*)msgTxt
{
// The event modified is always fetch from the actual data source
MXEvent *eventModified = [self.roomDataSource eventWithEventId:customizedRoomDataSource.selectedEventId];
MXEvent *eventModified = [self.roomDataSource eventWithEventId:self.customizedRoomDataSource.selectedEventId];
// In the case the event is a reply or and edit, and it's done on a non-live timeline
// we have to fetch live timeline in order to display the event properly
@@ -1341,7 +1348,7 @@ static CGSize kThreadListBarButtonItemImageSize;
}];
}
if (self->customizedRoomDataSource.selectedEventId)
if (self.customizedRoomDataSource.selectedEventId)
{
[self cancelEventSelection];
}
@@ -1413,10 +1420,10 @@ static CGSize kThreadListBarButtonItemImageSize;
currentAlert = nil;
}
if (customizedRoomDataSource)
if (self.customizedRoomDataSource)
{
customizedRoomDataSource.selectedEventId = nil;
customizedRoomDataSource = nil;
self.customizedRoomDataSource.selectedEventId = nil;
self.customizedRoomDataSource = nil;
}
[self removeTypingNotificationsListener];
@@ -1524,7 +1531,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (BOOL)shouldShowLiveLocationSharingBannerView
{
return customizedRoomDataSource.isCurrentUserSharingActiveLocation;
return self.customizedRoomDataSource.isCurrentUserSharingActiveLocation;
}
#pragma mark - Internals
@@ -1635,7 +1642,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXCall *callInRoom = [self.roomDataSource.mxSession.callManager callInRoom:self.roomDataSource.roomId];
return (callInRoom && callInRoom.state != MXCallStateEnded)
|| customizedRoomDataSource.jitsiWidget;
|| self.customizedRoomDataSource.jitsiWidget;
}
/**
@@ -1973,7 +1980,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)handleLongPressFromCell:(id<MXKCellRendering>)cell withTappedEvent:(MXEvent*)event
{
if (event && !customizedRoomDataSource.selectedEventId)
if (event && !self.customizedRoomDataSource.selectedEventId)
{
[self showContextualMenuForEvent:event fromSingleTapGesture:NO cell:cell animated:YES];
}
@@ -2749,7 +2756,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
{
RoomTimelineCellIdentifier cellIdentifier = [self cellIdentifierForCellData:cellData andRoomDataSource:customizedRoomDataSource];
RoomTimelineCellIdentifier cellIdentifier = [self cellIdentifierForCellData:cellData andRoomDataSource:self.customizedRoomDataSource];
RoomTimelineConfiguration *timelineConfiguration = [RoomTimelineConfiguration shared];
@@ -3131,7 +3138,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)actionIdentifier inCell:(id<MXKCellRendering>)cell userInfo:(NSDictionary *)userInfo
{
// Handle here user actions on bubbles for Vector app
if (customizedRoomDataSource)
if (self.customizedRoomDataSource)
{
id<MXKRoomBubbleCellDataStoring> bubbleData;
@@ -3182,7 +3189,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXEvent *tappedEvent = userInfo[kMXKRoomBubbleCellEventKey];
// Check whether a selection already exist or not
if (customizedRoomDataSource.selectedEventId)
if (self.customizedRoomDataSource.selectedEventId)
{
[self cancelEventSelection];
}
@@ -3320,7 +3327,7 @@ static CGSize kThreadListBarButtonItemImageSize;
// We consider this tap like a selection.
// Check whether a selection already exist or not
if (customizedRoomDataSource.selectedEventId)
if (self.customizedRoomDataSource.selectedEventId)
{
[self cancelEventSelection];
}
@@ -3354,7 +3361,7 @@ static CGSize kThreadListBarButtonItemImageSize;
else if ([actionIdentifier isEqualToString:kRoomMembershipExpandedBubbleCellTapOnCollapseButton])
{
// Reset the selection before collapsing
customizedRoomDataSource.selectedEventId = nil;
self.customizedRoomDataSource.selectedEventId = nil;
[self.roomDataSource collapseRoomBubble:((MXKRoomBubbleTableViewCell*)cell).bubbleData collapsed:YES];
}
@@ -3421,7 +3428,7 @@ static CGSize kThreadListBarButtonItemImageSize;
if (granted)
{
// Present the Jitsi view controller
Widget *jitsiWidget = [self->customizedRoomDataSource jitsiWidget];
Widget *jitsiWidget = [self.customizedRoomDataSource jitsiWidget];
if (jitsiWidget)
{
[self showJitsiCallWithWidget:jitsiWidget];
@@ -3435,7 +3442,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXEvent *widgetEvent = userInfo[kMXKRoomBubbleCellEventKey];
Widget *widget = [[Widget alloc] initWithWidgetEvent:widgetEvent
inMatrixSession:customizedRoomDataSource.mxSession];
inMatrixSession:self.customizedRoomDataSource.mxSession];
[[JitsiService shared] resetDeclineForWidgetWithId:widget.widgetId];
}
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusCell.leaveAction])
@@ -3447,7 +3454,7 @@ static CGSize kThreadListBarButtonItemImageSize;
{
MXEvent *widgetEvent = userInfo[kMXKRoomBubbleCellEventKey];
Widget *widget = [[Widget alloc] initWithWidgetEvent:widgetEvent
inMatrixSession:customizedRoomDataSource.mxSession];
inMatrixSession:self.customizedRoomDataSource.mxSession];
[[JitsiService shared] declineWidgetWithId:widget.widgetId];
[self reloadBubblesTable:YES];
}
@@ -4351,8 +4358,8 @@ static CGSize kThreadListBarButtonItemImageSize;
{
[self setInputToolBarSendMode:inputToolBarSendMode forEventWithId:eventId];
customizedRoomDataSource.showBubbleDateTimeOnSelection = showTimestamp;
customizedRoomDataSource.selectedEventId = eventId;
self.customizedRoomDataSource.showBubbleDateTimeOnSelection = showTimestamp;
self.customizedRoomDataSource.selectedEventId = eventId;
// Force table refresh
[self dataSource:self.roomDataSource didCellChange:nil];
@@ -4368,9 +4375,9 @@ static CGSize kThreadListBarButtonItemImageSize;
currentAlert = nil;
}
customizedRoomDataSource.showBubbleDateTimeOnSelection = YES;
customizedRoomDataSource.selectedEventId = nil;
customizedRoomDataSource.highlightedEventId = nil;
self.customizedRoomDataSource.showBubbleDateTimeOnSelection = YES;
self.customizedRoomDataSource.selectedEventId = nil;
self.customizedRoomDataSource.highlightedEventId = nil;
[self restoreTextMessageBeforeEditing];
@@ -4392,8 +4399,8 @@ static CGSize kThreadListBarButtonItemImageSize;
if (roomInputToolbarView)
{
self.textMessageBeforeEditing = roomInputToolbarView.textMessage;
roomInputToolbarView.textMessage = [self.roomDataSource editableTextMessageForEvent:event];
self.textMessageBeforeEditing = roomInputToolbarView.attributedTextMessage;
roomInputToolbarView.attributedTextMessage = [self.customizedRoomDataSource editableAttributedTextMessageFor:event];
}
[self selectEventWithId:eventId inputToolBarSendMode:RoomInputToolbarViewSendModeEdit showTimestamp:YES];
@@ -4405,7 +4412,7 @@ static CGSize kThreadListBarButtonItemImageSize;
if (self.textMessageBeforeEditing)
{
roomInputToolbarView.textMessage = self.textMessageBeforeEditing;
roomInputToolbarView.attributedTextMessage = self.textMessageBeforeEditing;
}
self.textMessageBeforeEditing = nil;
@@ -4582,7 +4589,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)placeCallWithVideo2:(BOOL)video
{
Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget];
Widget *jitsiWidget = [self.customizedRoomDataSource jitsiWidget];
if (jitsiWidget)
{
// If there is already a Jitsi call, join it
@@ -4671,9 +4678,18 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)roomInputToolbarView:(MXKRoomInputToolbarView*)toolbarView isTyping:(BOOL)typing
{
[super roomInputToolbarView:toolbarView isTyping:typing];
// TODO: Improve so we don't save partial message twice.
RoomInputToolbarView *inputToolbar = (RoomInputToolbarView *)toolbarView;
if (self.saveProgressTextInput && self.roomDataSource && inputToolbar)
{
// Store the potential message partially typed in text input
self.roomDataSource.partialAttributedTextMessage = inputToolbar.attributedTextMessage;
}
// Cancel potential selected event (to leave edition mode)
NSString *selectedEventId = customizedRoomDataSource.selectedEventId;
NSString *selectedEventId = self.customizedRoomDataSource.selectedEventId;
if (typing && selectedEventId && ![self.roomDataSource canReplyToEventWithId:selectedEventId])
{
[self cancelEventSelection];
@@ -4709,17 +4725,17 @@ static CGSize kThreadListBarButtonItemImageSize;
}
}
- (void)roomInputToolbarViewDidTapCancel:(MXKRoomInputToolbarView*)toolbarView
- (void)roomInputToolbarViewDidTapCancel:(RoomInputToolbarView*)toolbarView
{
[self cancelEventSelection];
}
- (void)roomInputToolbarViewDidChangeTextMessage:(MXKRoomInputToolbarView *)toolbarView
- (void)roomInputToolbarViewDidChangeTextMessage:(RoomInputToolbarView *)toolbarView
{
[self.userSuggestionCoordinator processTextMessage:toolbarView.textMessage];
}
- (void)roomInputToolbarViewDidOpenActionMenu:(MXKRoomInputToolbarView*)toolbarView
- (void)roomInputToolbarViewDidOpenActionMenu:(RoomInputToolbarView*)toolbarView
{
// Consider opening the action menu as beginning to type and share encryption keys if requested.
if ([MXKAppSettings standardAppSettings].outboundGroupSessionKeyPreSharingStrategy == MXKKeyPreSharingWhenTyping)
@@ -4728,6 +4744,11 @@ static CGSize kThreadListBarButtonItemImageSize;
}
}
- (void)roomInputToolbarView:(RoomInputToolbarView *)toolbarView sendAttributedTextMessage:(NSAttributedString *)attributedTextMessage
{
[self sendAttributedTextMessage:attributedTextMessage];
}
#pragma mark - MXKRoomMemberDetailsViewControllerDelegate
- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion
@@ -5283,7 +5304,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXStrongifyAndReturnIfNil(self);
MXCall *call = notif.object;
if ([call.room.roomId isEqualToString:self->customizedRoomDataSource.roomId])
if ([call.room.roomId isEqualToString:self.customizedRoomDataSource.roomId])
{
[self refreshActivitiesViewDisplay];
[self refreshRoomInputToolbar];
@@ -5294,7 +5315,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXStrongifyAndReturnIfNil(self);
NSString *roomId = notif.object;
if ([roomId isEqualToString:self->customizedRoomDataSource.roomId])
if ([roomId isEqualToString:self.customizedRoomDataSource.roomId])
{
[self refreshActivitiesViewDisplay];
}
@@ -5304,7 +5325,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXStrongifyAndReturnIfNil(self);
NSString *roomId = notif.object;
if ([roomId isEqualToString:self->customizedRoomDataSource.roomId])
if ([roomId isEqualToString:self.customizedRoomDataSource.roomId])
{
[self refreshActivitiesViewDisplay];
[self refreshRoomInputToolbar];
@@ -5364,7 +5385,7 @@ static CGSize kThreadListBarButtonItemImageSize;
Widget *widget = notif.object;
if (widget.mxSession == self.roomDataSource.mxSession
&& [widget.roomId isEqualToString:self->customizedRoomDataSource.roomId])
&& [widget.roomId isEqualToString:self.customizedRoomDataSource.roomId])
{
// Call button update
[self refreshRoomTitle];
@@ -5439,16 +5460,16 @@ static CGSize kThreadListBarButtonItemImageSize;
self.activitiesViewExpanded = YES;
[roomActivitiesView displayNetworkErrorNotification:[VectorL10n roomOfflineNotification]];
}
else if (customizedRoomDataSource.roomState.isObsolete)
else if (self.customizedRoomDataSource.roomState.isObsolete)
{
self.activitiesViewExpanded = YES;
MXWeakify(self);
[roomActivitiesView displayRoomReplacementWithRoomLinkTappedHandler:^{
MXStrongifyAndReturnIfNil(self);
MXEvent *stoneTombEvent = [self->customizedRoomDataSource.roomState stateEventsWithType:kMXEventTypeStringRoomTombStone].lastObject;
MXEvent *stoneTombEvent = [self.customizedRoomDataSource.roomState stateEventsWithType:kMXEventTypeStringRoomTombStone].lastObject;
NSString *replacementRoomId = self->customizedRoomDataSource.roomState.tombStoneContent.replacementRoomId;
NSString *replacementRoomId = self.customizedRoomDataSource.roomState.tombStoneContent.replacementRoomId;
if ([self.roomDataSource.mxSession roomWithRoomId:replacementRoomId])
{
// Open the room if it is already joined
@@ -5457,7 +5478,7 @@ static CGSize kThreadListBarButtonItemImageSize;
else
{
// Else auto join it via the server that sent the event
MXLogDebug(@"[RoomVC] Auto join an upgraded room: %@ -> %@. Sender: %@", self->customizedRoomDataSource.roomState.roomId,
MXLogDebug(@"[RoomVC] Auto join an upgraded room: %@ -> %@. Sender: %@", self.customizedRoomDataSource.roomState.roomId,
replacementRoomId, stoneTombEvent.sender);
NSString *viaSenderServer = [MXTools serverNameInMatrixIdentifier:stoneTombEvent.sender];
@@ -5846,10 +5867,10 @@ static CGSize kThreadListBarButtonItemImageSize;
MXEvent *event = notif.object;
NSString *previousId = notif.userInfo[kMXEventIdentifierKey];
if ([customizedRoomDataSource.selectedEventId isEqualToString:previousId])
if ([self.customizedRoomDataSource.selectedEventId isEqualToString:previousId])
{
MXLogDebug(@"[RoomVC] eventDidChangeIdentifier: Update selectedEventId");
customizedRoomDataSource.selectedEventId = event.eventId;
self.customizedRoomDataSource.selectedEventId = event.eventId;
}
}
@@ -6059,7 +6080,7 @@ static CGSize kThreadListBarButtonItemImageSize;
if (self.roomDataSource.isLive && !self.roomDataSource.isPeeking)
{
Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget];
Widget *jitsiWidget = [self.customizedRoomDataSource jitsiWidget];
if (jitsiWidget && self.canEditJitsiWidget)
{
@@ -6735,11 +6756,19 @@ static CGSize kThreadListBarButtonItemImageSize;
}
selectedComponent = nil;
}
NSString *textMessage = selectedComponent.textMessage;
NSAttributedString *attributedTextMessage = selectedComponent.attributedTextMessage;
if (textMessage)
if (attributedTextMessage)
{
MXKPasteboardManager.shared.pasteboard.string = textMessage;
if (@available(iOS 15.0, *))
{
MXKPasteboardManager.shared.pasteboard.string = [PillsFormatter stringByReplacingPillsIn:attributedTextMessage asMarkdown:YES];
}
else
{
MXKPasteboardManager.shared.pasteboard.string = attributedTextMessage.string;
}
}
else
{
@@ -6923,7 +6952,7 @@ static CGSize kThreadListBarButtonItemImageSize;
return;
}
self->customizedRoomDataSource.highlightedEventId = eventId;
self.customizedRoomDataSource.highlightedEventId = eventId;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
@@ -6949,19 +6978,19 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)cancelEventHighlight
{
// if data source is highlighting an event, dismiss the highlight when user dragges the table view
if (customizedRoomDataSource.highlightedEventId)
if (self.customizedRoomDataSource.highlightedEventId)
{
NSInteger row = [self.roomDataSource indexOfCellDataWithEventId:customizedRoomDataSource.highlightedEventId];
NSInteger row = [self.roomDataSource indexOfCellDataWithEventId:self.customizedRoomDataSource.highlightedEventId];
if (row == NSNotFound)
{
customizedRoomDataSource.highlightedEventId = nil;
self.customizedRoomDataSource.highlightedEventId = nil;
return;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
if ([[self.bubblesTableView indexPathsForVisibleRows] containsObject:indexPath])
{
customizedRoomDataSource.highlightedEventId = nil;
self.customizedRoomDataSource.highlightedEventId = nil;
[self.bubblesTableView reloadRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
@@ -7362,7 +7391,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (void)removeJitsiWidgetViewDidCompleteSliding:(RemoveJitsiWidgetView *)view
{
view.delegate = nil;
Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget];
Widget *jitsiWidget = [self.customizedRoomDataSource jitsiWidget];
[self startActivityIndicator];
@@ -7443,13 +7472,14 @@ static CGSize kThreadListBarButtonItemImageSize;
didRequestMentionForMember:(MXRoomMember *)member
textTrigger:(NSString *)textTrigger
{
if (textTrigger.length) {
NSString *textMessage = [self.inputToolbarView textMessage];
textMessage = [textMessage stringByReplacingOccurrencesOfString:textTrigger
withString:@""
options:NSBackwardsSearch | NSAnchoredSearch
range:NSMakeRange(0, textMessage.length)];
[self.inputToolbarView setTextMessage:textMessage];
RoomInputToolbarView *toolbar = (RoomInputToolbarView *)self.inputToolbarView;
if (toolbar && textTrigger.length) {
NSMutableAttributedString *attributedTextMessage = [[NSMutableAttributedString alloc] initWithAttributedString:toolbar.attributedTextMessage];
[[attributedTextMessage mutableString] replaceOccurrencesOfString:textTrigger
withString:@""
options:NSBackwardsSearch | NSAnchoredSearch
range:NSMakeRange(0, attributedTextMessage.length)];
[toolbar setAttributedTextMessage:attributedTextMessage];
}
[self mention:member];
@@ -7526,4 +7556,17 @@ static CGSize kThreadListBarButtonItemImageSize;
[self stopActivityIndicator];
}
#pragma mark - Pills
/// Register provider for Pills.
- (void)registerPillAttachmentViewProviderIfNeeded
{
if (@available(iOS 15.0, *))
{
if (![NSTextAttachment textAttachmentViewProviderClassForFileType:PillsFormatter.pillUTType])
{
[NSTextAttachment registerTextAttachmentViewProviderClass:PillAttachmentViewProvider.class forFileType:PillsFormatter.pillUTType];
}
}
}
@end