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
@@ -30,7 +30,7 @@
#import "RageShakeManager.h"
@interface RoomParticipantsViewController () <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UIGestureRecognizerDelegate, MXKRoomMemberDetailsViewControllerDelegate, ContactsTableViewControllerDelegate>
@interface RoomParticipantsViewController () <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate, UIGestureRecognizerDelegate, MXKRoomMemberDetailsViewControllerDelegate, RoomParticipantsInviteCoordinatorBridgePresenterDelegate>
{
// Add participant FAB image
UIImageView *inviteFabImageView;
@@ -53,12 +53,13 @@
id roomDidFlushDataNotificationObserver;
RoomMemberDetailsViewController *memberDetailsViewController;
ContactsTableViewController *contactsPickerViewController;
UIAlertController *currentAlert;
// Observe kThemeServiceDidChangeThemeNotification to handle user interface theme change.
id kThemeServiceDidChangeThemeNotificationObserver;
RoomParticipantsInviteCoordinatorBridgePresenter *invitePresenter;
}
@end
@@ -89,6 +90,7 @@
self.enableBarTintColorStatusChange = NO;
self.rageShakeManager = [RageShakeManager sharedManager];
self.showParticipantCustomAccessoryView = YES;
self.showInviteUserFab = YES;
}
- (void)viewDidLoad
@@ -106,6 +108,8 @@
// Adjust Top and Bottom constraints to take into account potential navBar and tabBar.
[NSLayoutConstraint deactivateConstraints:@[_searchBarTopConstraint]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
_searchBarTopConstraint = [NSLayoutConstraint constraintWithItem:self.topLayoutGuide
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
@@ -113,6 +117,7 @@
attribute:NSLayoutAttributeTop
multiplier:1.0f
constant:0.0f];
#pragma clang diagnostic pop
[NSLayoutConstraint activateConstraints:@[_searchBarTopConstraint]];
@@ -143,6 +148,15 @@
[self.tableView registerClass:ContactTableViewCell.class forCellReuseIdentifier:@"ParticipantTableViewCellId"];
if (_showInviteUserFab)
{
// Add invite members button programmatically
[self vc_addFABWithImage:AssetImages.addMemberFloatingAction.image
target:self
action:@selector(onAddParticipantButtonPressed)];
}
// Observe user interface theme change.
kThemeServiceDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kThemeServiceDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
@@ -245,6 +259,8 @@
// Refresh display
[self refreshTableView];
[self.screenTracker trackScreen];
}
- (void)viewDidAppear:(BOOL)animated
@@ -256,14 +272,6 @@
[memberDetailsViewController destroy];
memberDetailsViewController = nil;
}
if (contactsPickerViewController)
{
[contactsPickerViewController destroy];
contactsPickerViewController = nil;
}
[self.screenTimer start];
}
- (void)viewWillDisappear:(BOOL)animated
@@ -280,12 +288,6 @@
[self searchBarCancelButtonClicked:_searchBarView];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.screenTimer stop];
}
- (void)withdrawViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion
{
// Check whether the current view controller is displayed inside a segmented view controller in order to withdraw the right item
@@ -568,50 +570,9 @@
- (void)onAddParticipantButtonPressed
{
// Push the contacts picker.
contactsPickerViewController = [ContactsTableViewController contactsTableViewController];
// Set delegate to handle action on member (start chat, mention)
contactsPickerViewController.contactsTableViewControllerDelegate = self;
// Prepare its data source
ContactsDataSource *contactsDataSource = [[ContactsDataSource alloc] initWithMatrixSession:self.mxRoom.mxSession];
contactsDataSource.areSectionsShrinkable = YES;
contactsDataSource.displaySearchInputInContactsList = YES;
contactsDataSource.forceMatrixIdInDisplayName = YES;
// Add a plus icon to the contact cell in the contacts picker, in order to make it more understandable for the end user.
contactsDataSource.contactCellAccessoryImage = [[UIImage imageNamed:@"plus_icon"] vc_tintedImageUsingColor:ThemeService.shared.theme.textPrimaryColor];
// List all the participants matrix user id to ignore them during the contacts search.
for (Contact *contact in actualParticipants)
{
contactsDataSource.ignoredContactsByMatrixId[contact.mxMember.userId] = contact;
}
for (Contact *contact in invitedParticipants)
{
if (contact.mxMember)
{
contactsDataSource.ignoredContactsByMatrixId[contact.mxMember.userId] = contact;
}
}
if (userParticipant)
{
contactsDataSource.ignoredContactsByMatrixId[userParticipant.mxMember.userId] = userParticipant;
}
[contactsPickerViewController showSearch:YES];
contactsPickerViewController.searchBar.placeholder = [VectorL10n roomParticipantsInviteAnotherUser];
// Apply the search pattern if any
if (currentSearchText)
{
contactsPickerViewController.searchBar.text = currentSearchText;
[contactsDataSource searchWithPattern:currentSearchText forceReset:YES];
}
[contactsPickerViewController displayList:contactsDataSource];
[self pushViewController:contactsPickerViewController];
self->invitePresenter = [[RoomParticipantsInviteCoordinatorBridgePresenter alloc] initWithSession:self.mxRoom.mxSession room:self.mxRoom parentSpaceId:self.parentSpaceId currentSearchText:currentSearchText actualParticipants:actualParticipants invitedParticipants:invitedParticipants userParticipant:userParticipant];
self->invitePresenter.delegate = self;
[self->invitePresenter presentFrom:self animated:true];
}
- (void)refreshParticipantsFromRoomMembers
@@ -871,7 +832,7 @@
pendingMaskSpinnerView.alpha = 0;
[UIView animateWithDuration:0.3 delay:0.3 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
pendingMaskSpinnerView.alpha = 1;
self->pendingMaskSpinnerView.alpha = 1;
} completion:^(BOOL finished) {
}];
@@ -1316,13 +1277,6 @@
}
}
#pragma mark - ContactsTableViewControllerDelegate
- (void)contactsTableViewController:(ContactsTableViewController *)contactsTableViewController didSelectContact:(MXKContact*)contact
{
[self didSelectInvitableContact:contact];
}
#pragma mark - Actions
- (void)onDeleteAt:(NSIndexPath*)path
@@ -1359,7 +1313,7 @@
message:message
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1444,7 +1398,7 @@
message:promptMsg
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1493,7 +1447,7 @@
message:[VectorL10n roomParticipantsRemoveThirdPartyInvitePromptMsg]
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
@@ -1547,149 +1501,6 @@
[self withdrawViewControllerAnimated:YES completion:nil];
}
#pragma mark -
- (void)didSelectInvitableContact:(MXKContact*)contact
{
__weak typeof(self) weakSelf = self;
if (currentAlert)
{
[currentAlert dismissViewControllerAnimated:NO completion:nil];
currentAlert = nil;
}
// Invite ?
NSString *promptMsg = [VectorL10n roomParticipantsInvitePromptMsg:contact.displayName];
currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomParticipantsInvitePromptTitle]
message:promptMsg
preferredStyle:UIAlertControllerStyleAlert];
[currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
}]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n invite]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
NSArray *identifiers = contact.matrixIdentifiers;
NSString *participantId;
if (identifiers.count)
{
participantId = identifiers.firstObject;
// Invite this user if a room is defined
[self addPendingActionMask];
[self.mxRoom inviteUser:participantId success:^{
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
// Refresh display by removing the contacts picker
[self->contactsPickerViewController withdrawViewControllerAnimated:YES completion:nil];
} failure:^(NSError *error) {
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
MXLogDebug(@"[RoomParticipantsVC] Invite %@ failed", participantId);
// Alert user
[self processInviteError:error withContact:contact];
}];
}
else
{
if (contact.emailAddresses.count)
{
// This is a local contact, consider the first email by default.
// TODO: Prompt the user to select the right email.
MXKEmail *email = contact.emailAddresses.firstObject;
participantId = email.emailAddress;
}
else
{
// This is the text filled by the user.
participantId = contact.displayName;
}
// Is it an email or a Matrix user ID?
if ([MXTools isEmailAddress:participantId])
{
[self addPendingActionMask];
[self.mxRoom inviteUserByEmail:participantId success:^{
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
// Refresh display by removing the contacts picker
[self->contactsPickerViewController withdrawViewControllerAnimated:YES completion:nil];
} failure:^(NSError *error) {
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
MXLogDebug(@"[RoomParticipantsVC] Invite be email %@ failed", participantId);
// Alert user
if ([error.domain isEqualToString:kMXRestClientErrorDomain]
&& error.code == MXRestClientErrorMissingIdentityServer)
{
NSString *message = [VectorL10n errorInvite3pidWithNoIdentityServer];
[[AppDelegate theDelegate] showAlertWithTitle:message message:nil];
}
else
{
[[AppDelegate theDelegate] showErrorAsAlert:error];
}
}];
}
else //if ([MXTools isMatrixUserIdentifier:participantId])
{
[self addPendingActionMask];
[self.mxRoom inviteUser:participantId success:^{
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
// Refresh display by removing the contacts picker
[self->contactsPickerViewController withdrawViewControllerAnimated:YES completion:nil];
} failure:^(NSError *error) {
__strong __typeof(weakSelf)self = weakSelf;
[self removePendingActionMask];
MXLogDebug(@"[RoomParticipantsVC] Invite %@ failed", participantId);
// Alert user
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}
}
}
}]];
[currentAlert mxk_setAccessibilityIdentifier:@"RoomParticipantsVCInviteAlert"];
[self presentViewController:currentAlert animated:YES completion:nil];
}
#pragma mark - UISearchBar delegate
- (void)refreshSearchBarItemsColor:(UISearchBar *)searchBar
@@ -1819,4 +1630,21 @@
[searchBar resignFirstResponder];
}
#pragma mark - RoomParticipantsInviteCoordinatorBridgePresenterDelegate
- (void)roomParticipantsInviteCoordinatorBridgePresenterDidComplete:(RoomParticipantsInviteCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
self->invitePresenter = nil;
}
- (void)roomParticipantsInviteCoordinatorBridgePresenterDidStartLoading:(RoomParticipantsInviteCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[self addPendingActionMask];
}
- (void)roomParticipantsInviteCoordinatorBridgePresenterDidEndLoading:(RoomParticipantsInviteCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
[self removePendingActionMask];
}
@end