mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Jitsi widget: RoomVC: Show it in the banner when there is an active jitsi conference in a room.
This commit is contained in:
parent
87835ad749
commit
094886fab1
5 changed files with 102 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
|||
|
||||
#import <MatrixKit/MatrixKit.h>
|
||||
|
||||
#import "WidgetManager.h"
|
||||
|
||||
/**
|
||||
The data source for `RoomViewController` in Vector.
|
||||
*/
|
||||
|
@ -32,4 +34,11 @@
|
|||
*/
|
||||
@property(nonatomic) BOOL markTimelineInitialEvent;
|
||||
|
||||
/**
|
||||
Check if there is an active jitsi widget in the room and return it.
|
||||
|
||||
@return a widget representating the active jitsi conference in the room. Else, nil.
|
||||
*/
|
||||
- (Widget *)jitsiWidget;
|
||||
|
||||
@end
|
||||
|
|
|
@ -390,4 +390,21 @@
|
|||
_selectedEventId = selectedEventId;
|
||||
}
|
||||
|
||||
- (Widget *)jitsiWidget
|
||||
{
|
||||
Widget *jitsiWidget;
|
||||
|
||||
NSArray<Widget*> *widgets = [[WidgetManager sharedManager] widgetsInRoom:self.room];
|
||||
for (Widget *widget in widgets)
|
||||
{
|
||||
if ([widget.type isEqualToString:kWidgetTypeJitsi])
|
||||
{
|
||||
jitsiWidget = widget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return jitsiWidget;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
#import "ReadReceiptsViewController.h"
|
||||
|
||||
#import "JitsiViewController.h"
|
||||
|
||||
#import "RoomEmptyBubbleCell.h"
|
||||
|
||||
#import "RoomIncomingTextMsgBubbleCell.h"
|
||||
|
@ -96,6 +98,7 @@
|
|||
|
||||
#import "AvatarGenerator.h"
|
||||
#import "Tools.h"
|
||||
#import "WidgetManager.h"
|
||||
|
||||
#import "GBDeviceInfo_iOS.h"
|
||||
|
||||
|
@ -3275,6 +3278,8 @@
|
|||
{
|
||||
[roomActivitiesView removeGestureRecognizer:roomActivitiesView.gestureRecognizers[0]];
|
||||
}
|
||||
|
||||
Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget];
|
||||
|
||||
if ([AppDelegate theDelegate].isOffline)
|
||||
{
|
||||
|
@ -3305,6 +3310,26 @@
|
|||
}];
|
||||
}
|
||||
}
|
||||
else if (jitsiWidget)
|
||||
{
|
||||
// The room has an active jitsi widget, show it in the banner
|
||||
[roomActivitiesView displayOngoingJitsiConference:^{
|
||||
|
||||
// Present the Jitsi view controller
|
||||
AppDelegate *appDelegate = [AppDelegate theDelegate];
|
||||
JitsiViewController *jitsiViewController = [JitsiViewController jitsiViewControllerForWidget:jitsiWidget];
|
||||
|
||||
if (appDelegate.window.rootViewController.presentedViewController)
|
||||
{
|
||||
[appDelegate.window.rootViewController.presentedViewController presentViewController:jitsiViewController animated:YES completion:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[appDelegate.window.rootViewController presentViewController:jitsiViewController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
else if ([self checkUnsentMessages] == NO)
|
||||
{
|
||||
// Show "scroll to bottom" icon when the most recent message is not visible,
|
||||
|
|
|
@ -66,6 +66,13 @@
|
|||
*/
|
||||
- (void)displayOngoingConferenceCall:(void (^)(BOOL video))ongoingConferenceCallPressed;
|
||||
|
||||
/**
|
||||
Display an ongoing jitsi conference call.
|
||||
Replace the current notification if any.
|
||||
|
||||
@param ongoingJitsiConferencePressed the block called when the user clicks on the banner.
|
||||
*/
|
||||
- (void)displayOngoingJitsiConference:(void (^)())ongoingJitsiConferencePressed;
|
||||
|
||||
/**
|
||||
Display a "scroll to bottom" icon.
|
||||
|
|
|
@ -242,6 +242,50 @@
|
|||
[self checkHeight:YES];
|
||||
}
|
||||
|
||||
- (void)displayOngoingJitsiConference:(void (^)())ongoingJitsiConferencePressed
|
||||
{
|
||||
[self reset];
|
||||
|
||||
// @TODO: use dedicated strings
|
||||
objc_setAssociatedObject(self.messageTextView, "onOngoingConferenceCallPressed", [ongoingJitsiConferencePressed copy], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
|
||||
// Build the string to display in the banner
|
||||
NSString *onGoingConferenceCall =
|
||||
[NSString stringWithFormat:NSLocalizedStringFromTable(@"room_ongoing_conference_call", @"Vector", nil),
|
||||
NSLocalizedStringFromTable(@"voice", @"Vector", nil),
|
||||
NSLocalizedStringFromTable(@"video", @"Vector", nil)];
|
||||
|
||||
NSMutableAttributedString *onGoingConferenceCallAttibutedString = [[NSMutableAttributedString alloc] initWithString:onGoingConferenceCall];
|
||||
|
||||
// Add a link on the "voice" string
|
||||
NSRange voiceRange = [onGoingConferenceCall rangeOfString:NSLocalizedStringFromTable(@"voice", @"Vector", nil)];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:voiceRange];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSLinkAttributeName value:@"onOngoingConferenceCallWithVoicePressed" range:voiceRange];
|
||||
|
||||
// Add a link on the "video" string
|
||||
NSRange videoRange = [onGoingConferenceCall rangeOfString:NSLocalizedStringFromTable(@"video", @"Vector", nil)];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:videoRange];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSLinkAttributeName value:@"onOngoingConferenceCallWithVideoPressed" range:videoRange];
|
||||
|
||||
// Display the string in white on pink red
|
||||
NSRange wholeString = NSMakeRange(0, onGoingConferenceCallAttibutedString.length);
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:wholeString];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSBackgroundColorAttributeName value:kRiotColorPinkRed range:wholeString];
|
||||
[onGoingConferenceCallAttibutedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:wholeString];
|
||||
|
||||
self.messageTextView.attributedText = onGoingConferenceCallAttibutedString;
|
||||
self.messageTextView.tintColor = UIColor.whiteColor;
|
||||
self.messageTextView.hidden = NO;
|
||||
|
||||
self.backgroundColor = kRiotColorPinkRed;
|
||||
self.messageTextView.backgroundColor = kRiotColorPinkRed;
|
||||
|
||||
// Hide the separator to display correctly the red pink conf call banner
|
||||
self.separatorView.hidden = YES;
|
||||
|
||||
[self checkHeight:YES];
|
||||
}
|
||||
|
||||
- (void)displayScrollToBottomIcon:(NSUInteger)newMessagesCount onIconTapGesture:(void (^)(void))onIconTapGesture
|
||||
{
|
||||
if (newMessagesCount)
|
||||
|
|
Loading…
Reference in a new issue