merged from element 1.8.13

This commit is contained in:
Arnfried Griesert
2022-05-05 06:57:45 +02:00
328 changed files with 11854 additions and 2365 deletions
+135 -80
View File
@@ -100,7 +100,7 @@ static CGSize kThreadListBarButtonItemImageSize;
@interface RoomViewController () <UISearchBarDelegate, UIGestureRecognizerDelegate, UIScrollViewAccessibilityDelegate, RoomTitleViewTapGestureDelegate, MXKRoomMemberDetailsViewControllerDelegate, ContactsTableViewControllerDelegate, MXServerNoticesDelegate, RoomContextualMenuViewControllerDelegate,
ReactionsMenuViewModelCoordinatorDelegate, EditHistoryCoordinatorBridgePresenterDelegate, MXKDocumentPickerPresenterDelegate, EmojiPickerCoordinatorBridgePresenterDelegate,
ReactionHistoryCoordinatorBridgePresenterDelegate, CameraPresenterDelegate, MediaPickerCoordinatorBridgePresenterDelegate,
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, UserSuggestionCoordinatorBridgeDelegate, ThreadsCoordinatorBridgePresenterDelegate, MXThreadingServiceDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate>
RoomDataSourceDelegate, RoomCreationModalCoordinatorBridgePresenterDelegate, RoomInfoCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, RemoveJitsiWidgetViewDelegate, VoiceMessageControllerDelegate, SpaceDetailPresenterDelegate, UserSuggestionCoordinatorBridgeDelegate, ThreadsCoordinatorBridgePresenterDelegate, ThreadsBetaCoordinatorBridgePresenterDelegate, MXThreadingServiceDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate>
{
// The preview header
@@ -213,6 +213,8 @@ static CGSize kThreadListBarButtonItemImageSize;
@property (nonatomic, strong) CustomSizedPresentationController *customSizedPresentationController;
@property (nonatomic, strong) RoomParticipantsInviteCoordinatorBridgePresenter *participantsInvitePresenter;
@property (nonatomic, strong) ThreadsCoordinatorBridgePresenter *threadsBridgePresenter;
@property (nonatomic, strong) ThreadsBetaCoordinatorBridgePresenter *threadsBetaBridgePresenter;
@property (nonatomic, strong) SlidingModalPresenter *threadsNoticeModalPresenter;
@property (nonatomic, getter=isActivitiesViewExpanded) BOOL activitiesViewExpanded;
@property (nonatomic, getter=isScrollToBottomHidden) BOOL scrollToBottomHidden;
@property (nonatomic, getter=isMissedDiscussionsBadgeHidden) BOOL missedDiscussionsBadgeHidden;
@@ -233,15 +235,6 @@ static CGSize kThreadListBarButtonItemImageSize;
// scroll state just before the layout change, and restore it after the layout.
@property (nonatomic) BOOL wasScrollAtBottomBeforeLayout;
/// Handles all banners that should be displayed at the top of the timeline but that should not scroll with the timeline
@property (weak, nonatomic, nullable) IBOutlet UIStackView *topBannersStackView;
@property (nonatomic) BOOL shouldShowLiveLocationSharingBannerView;
#if LOCATION
@property (nonatomic, weak) LiveLocationSharingBannerView *liveLocationSharingBannerView;
#endif
@end
@implementation RoomViewController
@@ -419,6 +412,8 @@ static CGSize kThreadListBarButtonItemImageSize;
[self setupActions];
[self setupUserSuggestionViewIfNeeded];
[self.topBannersStackView vc_removeAllSubviews];
}
- (void)userInterfaceThemeDidChange
@@ -560,6 +555,8 @@ static CGSize kThreadListBarButtonItemImageSize;
notificationTaskProfile = [MXSDKOptions.sharedInstance.profiler startMeasuringTaskWithName:MXTaskProfileNameNotificationsOpenEvent];
}
[self updateTopBanners];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -671,6 +668,11 @@ static CGSize kThreadListBarButtonItemImageSize;
}
self.showSettingsInitially = NO;
if (!RiotSettings.shared.threadsNoticeDisplayed && RiotSettings.shared.enableThreads)
{
[self showThreadsNotice];
}
}
- (void)viewDidDisappear:(BOOL)animated
@@ -982,17 +984,13 @@ static CGSize kThreadListBarButtonItemImageSize;
#pragma mark - Loading indicators
- (BOOL)providesCustomActivityIndicator {
return [self.delegate roomViewControllerCanDelegateUserIndicators:self];
return YES;
}
// Override of a legacy method to determine whether to use a newer implementation instead.
// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608
- (void)startActivityIndicator {
if ([self providesCustomActivityIndicator]) {
[self.delegate roomViewControllerDidStartLoading:self];
} else {
[super startActivityIndicator];
}
[self.delegate roomViewControllerDidStartLoading:self];
}
// Override of a legacy method to determine whether to use a newer implementation instead.
@@ -1005,15 +1003,11 @@ static CGSize kThreadListBarButtonItemImageSize;
[MXSDKOptions.sharedInstance.profiler stopMeasuringTaskWithProfile:notificationTaskProfile];
notificationTaskProfile = nil;
}
if ([self providesCustomActivityIndicator]) {
// The legacy super implementation of `stopActivityIndicator` contains a number of checks grouped under `canStopActivityIndicator`
// to determine whether the indicator can be stopped or not (and the method should thus rather be called `stopActivityIndicatorIfPossible`).
// Since the newer indicators are not calling super implementation, the check for `canStopActivityIndicator` has to be performed manually.
if ([self canStopActivityIndicator]) {
[self stopLoadingUserIndicator];
}
} else {
[super stopActivityIndicator];
// The legacy super implementation of `stopActivityIndicator` contains a number of checks grouped under `canStopActivityIndicator`
// to determine whether the indicator can be stopped or not (and the method should thus rather be called `stopActivityIndicatorIfPossible`).
// Since the newer indicators are not calling super implementation, the check for `canStopActivityIndicator` has to be performed manually.
if ([self canStopActivityIndicator]) {
[self stopLoadingUserIndicator];
}
}
@@ -1069,6 +1063,8 @@ static CGSize kThreadListBarButtonItemImageSize;
_userSuggestionCoordinator.delegate = self;
[self setupUserSuggestionViewIfNeeded];
[self updateTopBanners];
}
- (void)onRoomDataSourceReady
@@ -1081,10 +1077,8 @@ static CGSize kThreadListBarButtonItemImageSize;
// Show preview header
[self showPreviewHeader:YES];
}
else
{
[super onRoomDataSourceReady];
}
[super onRoomDataSourceReady];
}
- (void)updateViewControllerAppearanceOnRoomDataSourceState
@@ -1585,6 +1579,11 @@ static CGSize kThreadListBarButtonItemImageSize;
missedDiscussionsDotView.hidden = missedDiscussionsBadgeHidden;
}
- (BOOL)shouldShowLiveLocationSharingBannerView
{
return customizedRoomDataSource.isCurrentUserSharingIsLocation;
}
#pragma mark - Internals
- (UIBarButtonItem *)videoCallBarButtonItem
@@ -1654,6 +1653,11 @@ static CGSize kThreadListBarButtonItemImageSize;
- (BOOL)isRoomPreview
{
if (self.isContextPreview)
{
return YES;
}
// Check first whether some preview data are defined.
if (roomPreviewData)
{
@@ -2478,12 +2482,7 @@ static CGSize kThreadListBarButtonItemImageSize;
{
[self.view bringSubviewToFront:self.topBannersStackView];
[self.topBannersStackView vc_removeAllSubviews];
if (self.shouldShowLiveLocationSharingBannerView)
{
[self showLiveLocationBannerView];
}
[self updateLiveLocationBannerViewVisibility];
}
#pragma mark - Jitsi
@@ -3555,9 +3554,7 @@ static CGSize kThreadListBarButtonItemImageSize;
MXWeakify(self);
BOOL showThreadOption = RiotSettings.shared.enableThreads
&& !self.roomDataSource.threadId
&& !selectedEvent.threadId;
BOOL showThreadOption = [self showThreadOptionForEvent:selectedEvent];
if (showThreadOption && [self canCopyEvent:selectedEvent andCell:cell])
{
[self.eventMenuBuilder addItemWithType:EventMenuItemTypeCopy
@@ -3715,7 +3712,7 @@ static CGSize kThreadListBarButtonItemImageSize;
activityViewController = [self.delegate roomViewController:self locationShareActivityViewControllerForEvent:selectedEvent];
}
if (activityViewController == nil) {
if (activityViewController == nil && selectedComponent.textMessage) {
NSArray *activityItems = @[selectedComponent.textMessage];
activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
}
@@ -4486,6 +4483,11 @@ static CGSize kThreadListBarButtonItemImageSize;
[Analytics.shared trackInteraction:AnalyticsUIElementRoomThreadSummaryItem];
}
- (void)roomDataSourceDidUpdateCurrentUserSharingLocationStatus:(RoomDataSource *)roomDataSource
{
[self updateLiveLocationBannerViewVisibility];
}
#pragma mark - Segues
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
@@ -4804,9 +4806,7 @@ static CGSize kThreadListBarButtonItemImageSize;
- (IBAction)onThreadListTapped:(id)sender
{
self.threadsBridgePresenter = [[ThreadsCoordinatorBridgePresenter alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId
threadId:nil];
self.threadsBridgePresenter = [self.delegate threadsCoordinatorForRoomViewController:self threadId:nil];
self.threadsBridgePresenter.delegate = self;
[self.threadsBridgePresenter pushFrom:self.navigationController animated:YES];
@@ -5634,6 +5634,15 @@ static CGSize kThreadListBarButtonItemImageSize;
continueBlock(threadDataSource, YES);
}];
}
else if (self.isContextPreview)
{
[RoomPreviewDataSource loadRoomDataSourceWithRoomId:self.roomDataSource.roomId
andMatrixSession:self.mainSession
onComplete:^(RoomPreviewDataSource *roomDataSource)
{
continueBlock(roomDataSource, YES);
}];
}
else
{
// Switch back to the room live timeline managed by MXKRoomDataSourceManager
@@ -6475,7 +6484,7 @@ static CGSize kThreadListBarButtonItemImageSize;
BOOL showMoreOption = (event.isState && RiotSettings.shared.roomContextualMenuShowMoreOptionForStates)
|| (!event.isState && RiotSettings.shared.roomContextualMenuShowMoreOptionForMessages);
BOOL showThreadOption = RiotSettings.shared.enableThreads && !self.roomDataSource.threadId && !event.threadId;
BOOL showThreadOption = [self showThreadOptionForEvent:event];
NSMutableArray<RoomContextualMenuItem*> *items = [NSMutableArray arrayWithCapacity:5];
@@ -6838,7 +6847,14 @@ static CGSize kThreadListBarButtonItemImageSize;
[self hideContextualMenuAnimated:YES cancelEventSelection:NO completion:nil];
[self openThreadWithId:event.eventId];
if (RiotSettings.shared.enableThreads)
{
[self openThreadWithId:event.eventId];
}
else
{
[self showThreadsBetaForEvent:event];
}
};
return item;
@@ -6860,6 +6876,58 @@ static CGSize kThreadListBarButtonItemImageSize;
#pragma mark - Threads
- (BOOL)showThreadOptionForEvent:(MXEvent*)event
{
return !self.roomDataSource.threadId
&& !event.threadId
&& (RiotSettings.shared.enableThreads || self.mainSession.store.supportedMatrixVersions.supportsThreads);
}
- (void)showThreadsNotice
{
if (!self.threadsNoticeModalPresenter)
{
self.threadsNoticeModalPresenter = [SlidingModalPresenter new];
}
[self.threadsNoticeModalPresenter dismissWithAnimated:NO completion:nil];
ThreadsNoticeViewController *threadsNoticeVC = [ThreadsNoticeViewController instantiate];
MXWeakify(self);
threadsNoticeVC.didTapDoneButton = ^{
MXStrongifyAndReturnIfNil(self);
[self.threadsNoticeModalPresenter dismissWithAnimated:YES completion:^{
RiotSettings.shared.threadsNoticeDisplayed = YES;
}];
};
[self.threadsNoticeModalPresenter present:threadsNoticeVC
from:self.presentedViewController?:self
animated:YES
options:SlidingModalPresenter.SpanningOption
completion:nil];
}
- (void)showThreadsBetaForEvent:(MXEvent *)event
{
if (self.threadsBetaBridgePresenter)
{
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:nil];
self.threadsBetaBridgePresenter = nil;
}
self.threadsBetaBridgePresenter = [[ThreadsBetaCoordinatorBridgePresenter alloc] initWithThreadId:event.eventId
infoText:VectorL10n.threadsBetaInformation
additionalText:nil];
self.threadsBetaBridgePresenter.delegate = self;
[self.threadsBetaBridgePresenter presentFrom:self.presentedViewController?:self animated:YES];
}
- (void)openThreadWithId:(NSString *)threadId
{
if (self.threadsBridgePresenter)
@@ -6868,9 +6936,7 @@ static CGSize kThreadListBarButtonItemImageSize;
self.threadsBridgePresenter = nil;
}
self.threadsBridgePresenter = [[ThreadsCoordinatorBridgePresenter alloc] initWithSession:self.mainSession
roomId:self.roomDataSource.roomId
threadId:threadId];
self.threadsBridgePresenter = [self.delegate threadsCoordinatorForRoomViewController:self threadId:threadId];
self.threadsBridgePresenter.delegate = self;
[self.threadsBridgePresenter pushFrom:self.navigationController animated:YES];
}
@@ -7489,6 +7555,28 @@ static CGSize kThreadListBarButtonItemImageSize;
self.threadsBridgePresenter = nil;
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
MXWeakify(self);
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
[self cancelEventSelection];
[self.roomDataSource reload];
[self openThreadWithId:coordinatorBridgePresenter.threadId];
}];
}
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapCancel:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
MXWeakify(self);
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
[self cancelEventSelection];
}];
}
#pragma mark - MXThreadingServiceDelegate
- (void)threadingServiceDidUpdateThreads:(MXThreadingService *)service
@@ -7513,37 +7601,4 @@ static CGSize kThreadListBarButtonItemImageSize;
[self stopActivityIndicator];
}
#pragma mark - Live location sharing
- (void)showLiveLocationBannerView
{
#if LOCATION
if (self.liveLocationSharingBannerView)
{
return;
}
LiveLocationSharingBannerView *bannerView = [LiveLocationSharingBannerView instantiate];
[bannerView updateWithTheme:ThemeService.shared.theme];
MXWeakify(self);
bannerView.didTapBackground = ^{
MXStrongifyAndReturnIfNil(self);
[self.delegate roomViewControllerDidTapLiveLocationSharingBanner:self];
};
bannerView.didTapStopButton = ^{
MXStrongifyAndReturnIfNil(self);
[self.delegate roomViewControllerDidStopLiveLocationSharing:self];
};
[self.topBannersStackView addArrangedSubview:bannerView];
self.liveLocationSharingBannerView = bannerView;
#endif
}
@end