diff --git a/Vector/AppDelegate.h b/Vector/AppDelegate.h index 8049b5f11..f08818876 100644 --- a/Vector/AppDelegate.h +++ b/Vector/AppDelegate.h @@ -25,7 +25,7 @@ */ extern NSString *const kAppDelegateDidTapStatusBarNotification; -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder { BOOL isAPNSRegistered; diff --git a/Vector/AppDelegate.m b/Vector/AppDelegate.m index c0bf327a0..c0aa1a6e0 100644 --- a/Vector/AppDelegate.m +++ b/Vector/AppDelegate.m @@ -1697,13 +1697,6 @@ NSString *const kAppDelegateDidTapStatusBarNotification = @"kAppDelegateDidTapSt [self startPrivateOneToOneRoomWithUserId:matrixId completion:completion]; } -#pragma mark - MXKRoomMemberDetailsViewControllerDelegate - -- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion -{ - [self startPrivateOneToOneRoomWithUserId:matrixId completion:completion]; -} - #pragma mark - Call status handling - (void)addCallStatusBar diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 934c11357..19da99a8e 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -143,6 +143,7 @@ "room_participants_action_start_chat" = "Start chat"; "room_participants_action_start_voice_call" = "Start voice call"; "room_participants_action_start_video_call" = "Start video call"; +"room_participants_action_mention" = "Mention"; // Chat "room_one_user_is_typing" = "%@ is typing..."; diff --git a/Vector/ViewController/RoomMemberDetailsViewController.m b/Vector/ViewController/RoomMemberDetailsViewController.m index becb6a66c..71cc524d2 100644 --- a/Vector/ViewController/RoomMemberDetailsViewController.m +++ b/Vector/ViewController/RoomMemberDetailsViewController.m @@ -68,9 +68,6 @@ self.enableBarTintColorStatusChange = NO; self.rageShakeManager = [RageShakeManager sharedManager]; - // Set delegate to handle start chat option - self.delegate = [AppDelegate theDelegate]; - self.memberHeaderView.backgroundColor = kVectorColorLightGrey; self.roomMemberNameLabel.textColor = kVectorTextColorBlack; self.roomMemberStatusLabel.textColor = kVectorColorGreen; @@ -404,6 +401,12 @@ } } + if (self.enableMention) + { + // Add mention option + [actionsArray addObject:@(MXKRoomMemberDetailsActionMention)]; + } + return actionsArray.count; } @@ -452,6 +455,9 @@ case MXKRoomMemberDetailsActionStartVideoCall: title = NSLocalizedStringFromTable(@"room_participants_action_start_video_call", @"Vector", nil); break; + case MXKRoomMemberDetailsActionMention: + title = NSLocalizedStringFromTable(@"room_participants_action_mention", @"Vector", nil); + break; default: break; } diff --git a/Vector/ViewController/RoomParticipantsViewController.h b/Vector/ViewController/RoomParticipantsViewController.h index a705695dc..6f84299c9 100644 --- a/Vector/ViewController/RoomParticipantsViewController.h +++ b/Vector/ViewController/RoomParticipantsViewController.h @@ -21,12 +21,30 @@ #import "SegmentedViewController.h" @class Contact; +@class RoomParticipantsViewController; + +/** + `RoomParticipantsViewController` delegate. + */ +@protocol RoomParticipantsViewControllerDelegate + +/** + Tells the delegate that the user wants to mention a room member. + + @discussion the `RoomParticipantsViewController` instance is withdrawn automatically. + + @param roomParticipantsViewController the `RoomParticipantsViewController` instance. + @param member the room member to mention. + */ +- (void)roomParticipantsViewController:(RoomParticipantsViewController *)roomParticipantsViewController mention:(MXRoomMember*)member; + +@end /** 'RoomParticipantsViewController' instance is used to edit members of the room defined by the property 'mxRoom'. When this property is nil, the view controller is empty. */ -@interface RoomParticipantsViewController : MXKViewController +@interface RoomParticipantsViewController : MXKViewController { @protected /** @@ -72,5 +90,15 @@ */ @property (nonatomic) SegmentedViewController *segmentedViewController; +/** + Enable mention option in member details view. NO by default + */ +@property (nonatomic) BOOL enableMention; + +/** + The delegate for the view controller. + */ +@property (nonatomic) id delegate; + @end diff --git a/Vector/ViewController/RoomParticipantsViewController.m b/Vector/ViewController/RoomParticipantsViewController.m index 8e17f1f67..b35014e84 100644 --- a/Vector/ViewController/RoomParticipantsViewController.m +++ b/Vector/ViewController/RoomParticipantsViewController.m @@ -314,6 +314,19 @@ } } +- (void)setEnableMention:(BOOL)enableMention +{ + if (_enableMention != enableMention) + { + _enableMention = enableMention; + + if (detailsViewController) + { + detailsViewController.enableMention = enableMention; + } + } +} + #pragma mark - Internals - (void)setNavBarButtons @@ -1020,6 +1033,11 @@ if (contact.mxMember) { detailsViewController = [RoomMemberDetailsViewController roomMemberDetailsViewController]; + + // Set delegate to handle action on member (start chat, mention) + detailsViewController.delegate = self; + detailsViewController.enableMention = _enableMention; + [detailsViewController displayRoomMember:contact.mxMember withMatrixRoom:self.mxRoom]; // Check whether the view controller is displayed inside a segmented one. @@ -1065,6 +1083,30 @@ return actions; } +#pragma mark - MXKRoomMemberDetailsViewControllerDelegate + +- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion +{ + [[AppDelegate theDelegate] startPrivateOneToOneRoomWithUserId:matrixId completion:completion]; +} + +- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController mention:(MXRoomMember*)member +{ + if (_delegate) + { + id delegate = _delegate; + + // Check whether the current view controller is displayed inside a segmented view controller in order to withdraw the right item + MXKViewController *viewController = _segmentedViewController ? _segmentedViewController : self; + + // Withdraw the current view controller, and let the delegate mention the member + [viewController withdrawViewControllerAnimated:YES completion:^{ + + [delegate roomParticipantsViewController:self mention:member]; + + }]; + } +} #pragma mark - Actions diff --git a/Vector/ViewController/RoomViewController.h b/Vector/ViewController/RoomViewController.h index 35c958dba..ba189e172 100644 --- a/Vector/ViewController/RoomViewController.h +++ b/Vector/ViewController/RoomViewController.h @@ -20,9 +20,11 @@ #import "RoomPreviewData.h" +#import "RoomParticipantsViewController.h" + #import "UIViewController+VectorSearch.h" -@interface RoomViewController : MXKRoomViewController +@interface RoomViewController : MXKRoomViewController // The expanded header @property (weak, nonatomic) IBOutlet UIView *expandedHeaderContainer; diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index 0bb2f031e..39b2c5283 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -33,7 +33,6 @@ #import "SimpleRoomTitleView.h" #import "PreviewRoomTitleView.h" -#import "RoomParticipantsViewController.h" #import "RoomMemberDetailsViewController.h" #import "SegmentedViewController.h" @@ -1539,6 +1538,8 @@ [titles addObject: NSLocalizedStringFromTable(@"room_details_people", @"Vector", nil)]; RoomParticipantsViewController* participantsViewController = [[RoomParticipantsViewController alloc] init]; + participantsViewController.delegate = self; + participantsViewController.enableMention = YES; participantsViewController.mxRoom = [session roomWithRoomId:roomid]; participantsViewController.segmentedViewController = segmentedViewController; [viewControllers addObject:participantsViewController]; @@ -1576,10 +1577,10 @@ if (selectedRoomMember) { RoomMemberDetailsViewController *memberViewController = pushedViewController; - // Set rageShake handler - memberViewController.rageShakeManager = [RageShakeManager sharedManager]; - // Set delegate to handle start chat option - memberViewController.delegate = [AppDelegate theDelegate]; + + // Set delegate to handle action on member (start chat, memtion) + memberViewController.delegate = self; + memberViewController.enableMention = YES; [memberViewController displayRoomMember:selectedRoomMember withMatrixRoom:self.roomDataSource.room]; @@ -1640,6 +1641,25 @@ } } +#pragma mark - RoomParticipantsViewControllerDelegate + +- (void)roomParticipantsViewController:(RoomParticipantsViewController *)roomParticipantsViewController mention:(MXRoomMember*)member +{ + [self mention:member]; +} + +#pragma mark - MXKRoomMemberDetailsViewControllerDelegate + +- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion +{ + [[AppDelegate theDelegate] startPrivateOneToOneRoomWithUserId:matrixId completion:completion]; +} + +- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController mention:(MXRoomMember*)member +{ + [self mention:member]; +} + #pragma mark - Action - (IBAction)onButtonPressed:(id)sender