merged element 1.8.10

This commit is contained in:
Arnfried Griesert
2022-05-03 12:48:01 +02:00
1235 changed files with 50869 additions and 23132 deletions
@@ -31,12 +31,13 @@
#import "DirectoryRecentTableViewCell.h"
#import "RoomIdOrAliasTableViewCell.h"
#import "TableViewCellWithCollectionView.h"
#import "SectionHeaderView.h"
#import "GeneratedInterface-Swift.h"
NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewControllerDataReadyNotification";
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate>
@interface RecentsViewController () <CreateRoomCoordinatorBridgePresenterDelegate, RoomsDirectoryCoordinatorBridgePresenterDelegate, RoomNotificationSettingsCoordinatorBridgePresenterDelegate, DialpadViewControllerDelegate, ExploreRoomCoordinatorBridgePresenterDelegate, SpaceChildRoomDetailBridgePresenterDelegate>
{
// Tell whether a recents refresh is pending (suspended during editing mode).
BOOL isRefreshPending;
@@ -64,6 +65,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// when the user selects it.
UISearchBar *tableSearchBar;
// Flag indicating whether the view controller is (at least partially) visible and not dissapearing
BOOL isViewVisible;
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
__weak id kThemeServiceDidChangeThemeNotificationObserver;
}
@@ -80,6 +84,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
@property (nonatomic, strong) RoomNotificationSettingsCoordinatorBridgePresenter *roomNotificationSettingsCoordinatorBridgePresenter;
@property (nonatomic, strong) SpaceChildRoomDetailBridgePresenter *spaceChildPresenter;
@end
@implementation RecentsViewController
@@ -121,7 +127,11 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
tableSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 600, 44)];
tableSearchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
tableSearchBar.showsCancelButton = NO;
tableSearchBar.placeholder = [VectorL10n searchDefaultPlaceholder];
tableSearchBar.placeholder = [VectorL10n searchFilterPlaceholder];
[tableSearchBar setImage:AssetImages.filterOff.image
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
tableSearchBar.delegate = self;
displayedSectionHeaders = [NSMutableArray array];
@@ -146,6 +156,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// Register key verification banner cells
[self.recentsTableView registerNib:CrossSigningSetupBannerCell.nib forCellReuseIdentifier:CrossSigningSetupBannerCell.defaultReuseIdentifier];
[self.recentsTableView registerClass:SectionHeaderView.class
forHeaderFooterViewReuseIdentifier:SectionHeaderView.defaultReuseIdentifier];
// Hide line separators of empty cells
self.recentsTableView.tableFooterView = [[UIView alloc] init];
@@ -166,8 +179,11 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
self.recentsSearchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.recentsSearchBar.placeholder = [VectorL10n searchDefaultPlaceholder];
self.recentsSearchBar.placeholder = [VectorL10n searchFilterPlaceholder];
[self.recentsSearchBar setImage:AssetImages.filterOff.image
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
// Observe user interface theme change.
kThemeServiceDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kThemeServiceDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
@@ -253,6 +269,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
isViewVisible = YES;
[self.screenTracker trackScreen];
// Reset back user interactions
self.userInteractionEnabled = YES;
@@ -288,6 +307,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
isViewVisible = NO;
// Leave potential editing mode
[self cancelEditionMode:NO];
@@ -303,6 +323,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[[NSNotificationCenter defaultCenter] removeObserver:kMXNotificationCenterDidUpdateRulesObserver];
kMXNotificationCenterDidUpdateRulesObserver = nil;
}
[self stopActivityIndicator];
}
- (void)viewDidAppear:(BOOL)animated
@@ -323,14 +345,6 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// the selected room (if any) is highlighted.
[self refreshCurrentSelectedCell:YES];
}
[self.screenTimer start];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.screenTimer stop];
}
- (void)viewDidLayoutSubviews
@@ -529,16 +543,16 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
{
// minging kludge until https://matrix.org/jira/browse/SYN-678 is fixed
// 'Error when trying to join an empty room should be more explicit'
msg = [MatrixKitL10n roomErrorJoinFailedEmptyRoom];
msg = [VectorL10n roomErrorJoinFailedEmptyRoom];
}
[self->currentAlert dismissViewControllerAnimated:NO completion:nil];
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n roomErrorJoinFailedTitle]
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomErrorJoinFailedTitle]
message:msg
preferredStyle:UIAlertControllerStyleAlert];
[errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok]
[errorAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n ok]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
@@ -872,6 +886,12 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)showRoomWithRoomId:(NSString*)roomId inMatrixSession:(MXSession*)matrixSession
{
MXRoom *room = [matrixSession roomWithRoomId:roomId];
if (room.summary.membership == MXMembershipInvite)
{
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerInvite;
}
// Avoid multiple openings of rooms
self.userInteractionEnabled = NO;
@@ -891,6 +911,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)showRoomPreviewWithData:(RoomPreviewData*)roomPreviewData
{
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerRoomDirectory;
// Do not stack views when showing room
ScreenPresentationParameters *presentationParameters = [[ScreenPresentationParameters alloc] initWithRestoreInitialDisplay:NO stackAboveVisibleViews:NO sender:nil sourceView:nil];
@@ -987,6 +1009,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}
// Accept invitation
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerInvite;
[self joinRoom:invitedRoom completion:nil];
}
else if ([actionIdentifier isEqualToString:kInviteRecentTableViewCellDeclineButtonPressed])
@@ -1024,6 +1047,19 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
TableViewCellWithCollectionView *collectionViewCell = (TableViewCellWithCollectionView *)cell;
[collectionViewCell.collectionView reloadData];
cellReloaded = YES;
CGRect headerFrame = [self.recentsTableView rectForHeaderInSection:update.sectionIndex];
UIView *headerView = [self.recentsTableView headerViewForSection:update.sectionIndex];
UIView *updatedHeaderView = [self.dataSource viewForHeaderInSection:update.sectionIndex withFrame:headerFrame inTableView:self.recentsTableView];
if ([headerView isKindOfClass:SectionHeaderView.class]
&& [updatedHeaderView isKindOfClass:SectionHeaderView.class])
{
SectionHeaderView *sectionHeaderView = (SectionHeaderView *)headerView;
SectionHeaderView *updatedSectionHeaderView = (SectionHeaderView *)updatedHeaderView;
sectionHeaderView.headerLabel = updatedSectionHeaderView.headerLabel;
sectionHeaderView.accessoryView = updatedSectionHeaderView.accessoryView;
sectionHeaderView.rightAccessoryView = updatedSectionHeaderView.rightAccessoryView;
}
}
}
}
@@ -1039,10 +1075,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[[AppDelegate theDelegate].masterTabBarController refreshTabBarBadges];
}
if (changes == nil)
{
[self showEmptyViewIfNeeded];
}
[self showEmptyViewIfNeeded];
if (dataSource.state == MXKDataSourceStateReady)
{
@@ -1100,7 +1133,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
directChatAction.backgroundColor = actionBackgroundColor;
UIImage *directChatImage = [UIImage imageNamed:@"room_action_direct_chat"];
UIImage *directChatImage = AssetImages.roomActionDirectChat.image;
directChatImage = [directChatImage vc_tintedImageUsingColor:isDirect ? selectedColor : unselectedColor];
directChatAction.image = [directChatImage vc_notRenderedImage];
@@ -1141,6 +1174,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
notificationImage = [UIImage imageNamed:@"room_action_notification"];
}
// $$$
notificationImage = [notificationImage vc_tintedImageUsingColor:isMuted ? unselectedColor : selectedColor];
muteAction.image = [notificationImage vc_notRenderedImage];
}
@@ -1170,7 +1204,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
favouriteAction.backgroundColor = actionBackgroundColor;
UIImage *favouriteImage = [UIImage imageNamed:@"room_action_favourite"];
UIImage *favouriteImage = AssetImages.roomActionFavourite.image;
favouriteImage = [favouriteImage vc_tintedImageUsingColor:isFavourite ? selectedColor : unselectedColor];
favouriteAction.image = [favouriteImage vc_notRenderedImage];
@@ -1187,7 +1221,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
priorityAction.backgroundColor = actionBackgroundColor;
UIImage *priorityImage = isInLowPriority ? [UIImage imageNamed:@"room_action_priority_high"] : [UIImage imageNamed:@"room_action_priority_low"];
UIImage *priorityImage = isInLowPriority ? AssetImages.roomActionPriorityHigh.image : AssetImages.roomActionPriorityLow.image;
priorityImage = [priorityImage vc_tintedImageUsingColor:unselectedColor];
priorityAction.image = [priorityImage vc_notRenderedImage];
@@ -1201,7 +1235,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
leaveAction.backgroundColor = actionBackgroundColor;
UIImage *leaveImage = [UIImage imageNamed:@"room_action_leave"];
UIImage *leaveImage = AssetImages.roomActionLeave.image;
leaveImage = [leaveImage vc_tintedImageUsingColor:selectedWarningColor];
leaveAction.image = [leaveImage vc_notRenderedImage];
@@ -1255,7 +1289,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
message:message
preferredStyle:UIAlertControllerStyleAlert];
[leavePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[leavePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1280,8 +1314,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
MXRoom *room = [self.mainSession roomWithRoomId:currentRoomId];
if (room)
{
[self startActivityIndicator];
[self startActivityIndicatorWithLabel:[VectorL10n roomParticipantsLeaveProcessing]];
// cancel pending uploads/downloads
// they are useless by now
[MXMediaManager cancelDownloadsInCacheFolder:room.roomId];
@@ -1296,6 +1329,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
{
typeof(self) self = weakSelf;
[self stopActivityIndicator];
[self.indicatorPresenter presentSuccessWithLabel:[VectorL10n roomParticipantsLeaveSuccess]];
// Force table refresh
[self cancelEditionMode:YES];
}
@@ -1315,7 +1349,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
[self cancelEditionMode:self->isRefreshPending];
}
}];
@@ -1323,7 +1357,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
else
{
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
[self cancelEditionMode:self->isRefreshPending];
}
}
@@ -1381,7 +1415,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[self stopActivityIndicator];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
[self cancelEditionMode:self->isRefreshPending];
} failure:^(NSError *error) {
@@ -1389,7 +1423,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[self stopActivityIndicator];
MXLogDebug(@"[RecentsViewController] Failed to update direct tag of the room (%@)", editedRoomId);
MXLogDebug(@"[RecentsViewController] Failed to update direct tag of the room (%@)", self->editedRoomId);
// Notify the end user
NSString *userId = self.mainSession.myUser.userId; // TODO: handle multi-account
@@ -1398,7 +1432,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
userInfo:userId ? @{kMXKErrorUserIdKey: userId} : nil];
// Leave editing mode
[self cancelEditionMode:isRefreshPending];
[self cancelEditionMode:self->isRefreshPending];
}];
}
@@ -1893,7 +1927,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
typeof(self) self = weakSelf;
self->currentAlert = nil;
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
[self startChat];
}
}]];
@@ -1943,7 +1977,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}]];
}
[actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -2003,12 +2037,17 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
self.customSizedPresentationController = nil;
}
- (void)startChat {
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
}
- (void)createNewRoom
{
// Sanity check
if (self.mainSession)
{
self.createRoomCoordinatorBridgePresenter = [[CreateRoomCoordinatorBridgePresenter alloc] initWithSession:self.mainSession];
CreateRoomCoordinatorParameter *parameters = [[CreateRoomCoordinatorParameter alloc] initWithSession:self.mainSession parentSpace: self.dataSource.currentSpace];
self.createRoomCoordinatorBridgePresenter = [[CreateRoomCoordinatorBridgePresenter alloc] initWithParameters:parameters];
self.createRoomCoordinatorBridgePresenter.delegate = self;
[self.createRoomCoordinatorBridgePresenter presentFrom:self animated:YES];
}
@@ -2056,6 +2095,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
// Check whether the user has already joined the selected public room
if ([self.recentsDataSource.publicRoomsDirectoryDataSource.mxSession isJoinedOnRoom:publicRoom.roomId])
{
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerRoomDirectory;
// Open the public room
[self showRoomWithRoomId:publicRoom.roomId
inMatrixSession:self.recentsDataSource.publicRoomsDirectoryDataSource.mxSession];
@@ -2151,19 +2192,17 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
- (void)recentListViewController:(MXKRecentListViewController *)recentListViewController didSelectRoom:(NSString *)roomId inMatrixSession:(MXSession *)matrixSession
{
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerRoomList;
[self showRoomWithRoomId:roomId inMatrixSession:matrixSession];
}
- (void)recentListViewController:(MXKRecentListViewController *)recentListViewController didSelectSuggestedRoom:(MXSpaceChildInfo *)childInfo
- (void)recentListViewController:(MXKRecentListViewController *)recentListViewController didSelectSuggestedRoom:(MXSpaceChildInfo *)childInfo from:(UIView* _Nullable)sourceView
{
RoomPreviewData *previewData = [[RoomPreviewData alloc] initWithSpaceChildInfo:childInfo andSession:self.mainSession];
[self startActivityIndicator];
MXWeakify(self);
[previewData peekInRoom:^(BOOL succeeded) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
[self showRoomPreviewWithData:previewData];
}];
Analytics.shared.joinedRoomTrigger = AnalyticsJoinedRoomTriggerSpaceHierarchy;
self.spaceChildPresenter = [[SpaceChildRoomDetailBridgePresenter alloc] initWithSession:self.mainSession childInfo:childInfo];
self.spaceChildPresenter.delegate = self;
[self.spaceChildPresenter presentFrom:self sourceView:sourceView animated:YES];
}
#pragma mark - UISearchBarDelegate
@@ -2200,11 +2239,22 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[self.recentsSearchBar setShowsCancelButton:NO animated:NO];
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
[super searchBar:searchBar textDidChange:searchText];
UIImage *filterIcon = searchText.length > 0 ? AssetImages.filterOn.image : AssetImages.filterOff.image;
[self.recentsSearchBar setImage:filterIcon
forSearchBarIcon:UISearchBarIconSearch
state:UIControlStateNormal];
}
#pragma mark - CreateRoomCoordinatorBridgePresenterDelegate
- (void)createRoomCoordinatorBridgePresenterDelegate:(CreateRoomCoordinatorBridgePresenter *)coordinatorBridgePresenter didCreateNewRoom:(MXRoom *)room
{
[coordinatorBridgePresenter dismissWithAnimated:YES completion:^{
Analytics.shared.viewRoomTrigger = AnalyticsViewRoomTriggerCreated;
[self showRoomWithRoomId:room.roomId inMatrixSession:self.mainSession];
}];
coordinatorBridgePresenter = nil;
@@ -2216,6 +2266,12 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
coordinatorBridgePresenter = nil;
}
- (void)createRoomCoordinatorBridgePresenterDelegate:(CreateRoomCoordinatorBridgePresenter *)coordinatorBridgePresenter didAddRoomsWithIds:(NSArray<NSString *> *)roomIds
{
[coordinatorBridgePresenter dismissWithAnimated:YES completion:nil];
coordinatorBridgePresenter = nil;
}
#pragma mark - Empty view management
- (void)showEmptyViewIfNeeded
@@ -2348,7 +2404,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
else if ([MXTools isMatrixRoomAlias:roomIdOrAlias])
{
// Room preview doesn't support room alias
[[AppDelegate theDelegate] showAlertWithTitle:[MatrixKitL10n error] message:[VectorL10n roomRecentsUnknownRoomErrorMessage]];
[[AppDelegate theDelegate] showAlertWithTitle:[VectorL10n error] message:[VectorL10n roomRecentsUnknownRoomErrorMessage]];
}
else
{
@@ -2374,7 +2430,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
}];
self.roomsDirectoryCoordinatorBridgePresenter = nil;
} else {
[[AppDelegate theDelegate] showAlertWithTitle:[MatrixKitL10n error] message:[VectorL10n roomRecentsUnknownRoomErrorMessage]];
[[AppDelegate theDelegate] showAlertWithTitle:[VectorL10n error] message:[VectorL10n roomRecentsUnknownRoomErrorMessage]];
}
}];
}
@@ -2538,4 +2594,51 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink] options:@{} completionHandler:nil];
}
#pragma mark - SpaceChildRoomDetailBridgePresenterDelegate
- (void)spaceChildRoomDetailBridgePresenterDidCancel:(SpaceChildRoomDetailBridgePresenter *)coordinator
{
[self.spaceChildPresenter dismissWithAnimated:YES completion:^{
self.spaceChildPresenter = nil;
}];
}
- (void)spaceChildRoomDetailBridgePresenter:(SpaceChildRoomDetailBridgePresenter *)coordinator didOpenRoomWith:(NSString *)roomId
{
[self showRoomWithRoomId:roomId inMatrixSession:self.mainSession];
[self.spaceChildPresenter dismissWithAnimated:YES completion:^{
self.spaceChildPresenter = nil;
}];
}
#pragma mark - Activity Indicator
- (BOOL)providesCustomActivityIndicator {
return self.indicatorPresenter != nil;
}
- (void)startActivityIndicatorWithLabel:(NSString *)label {
if (self.indicatorPresenter && isViewVisible) {
[self.indicatorPresenter presentLoadingIndicatorWithLabel:label];
} else {
[super startActivityIndicator];
}
}
- (void)startActivityIndicator {
if (self.indicatorPresenter && isViewVisible) {
[self.indicatorPresenter presentLoadingIndicator];
} else {
[super startActivityIndicator];
}
}
- (void)stopActivityIndicator {
if (self.indicatorPresenter) {
[self.indicatorPresenter dismissLoadingIndicator];
} else {
[super stopActivityIndicator];
}
}
@end