Add support for incoming calls view
MODIFY
MatrixKit/Controllers/MXKCallViewController.h
MatrixKit/Controllers/MXKCallViewController.h
@@ -163,6 +163,16 @@ extern NSString *const kMXKCallViewControllerBackToAppNotification;
*/
- (void)updateProximityAndSleep;
+/**
+ Return a view that is used for informing about incoming call.
+
+ @return a view that stands for informing about incoming call or nil
+
+ @discussion Subclasses must override this method to provide appropriate for their app view.
+ When this method is called peer and mxCall are valid so you can use them.
+ */
+- (UIView *)createIncomingCallView;
+
/**
Action registered on the event 'UIControlEventTouchUpInside' for each UIButton instance.
*/

MODIFY
MatrixKit/Controllers/MXKCallViewController.m
MatrixKit/Controllers/MXKCallViewController.m
@@ -54,6 +54,8 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
@property (nonatomic, assign) Boolean isRinging;
+@property (nonatomic, nullable) UIView *incomingCallView;
+
@end
@implementation MXKCallViewController
@@ -524,6 +526,54 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
case MXCallStateWaitLocalMedia:
self.isRinging = NO;
[localPreviewActivityView startAnimating];
+
+ // Try to show a special view for incoming view
+ if (call.isIncoming && !self.incomingCallView)
+ {
+ UIView *incomingCallView = [self createIncomingCallView];
+ if (incomingCallView)
+ {
+ self.incomingCallView = incomingCallView;
+ [self.view addSubview:incomingCallView];
+
+ incomingCallView.translatesAutoresizingMaskIntoConstraints = NO;
+
+ [NSLayoutConstraint activateConstraints:@[
+ [NSLayoutConstraint constraintWithItem:incomingCallView
+ attribute:NSLayoutAttributeTop
+ relatedBy:NSLayoutRelationEqual
+ toItem:self.view
+ attribute:NSLayoutAttributeTop
+ multiplier:1.0
+ constant:0.0],
+
+ [NSLayoutConstraint constraintWithItem:incomingCallView
+ attribute:NSLayoutAttributeLeading
+ relatedBy:NSLayoutRelationEqual
+ toItem:self.view
+ attribute:NSLayoutAttributeLeading
+ multiplier:1.0
+ constant:0.0],
+
+ [NSLayoutConstraint constraintWithItem:incomingCallView
+ attribute:NSLayoutAttributeBottom
+ relatedBy:NSLayoutRelationEqual
+ toItem:self.view
+ attribute:NSLayoutAttributeBottom
+ multiplier:1.0
+ constant:0.0],
+
+ [NSLayoutConstraint constraintWithItem:incomingCallView
+ attribute:NSLayoutAttributeTrailing
+ relatedBy:NSLayoutRelationEqual
+ toItem:self.view
+ attribute:NSLayoutAttributeTrailing
+ multiplier:1.0
+ constant:0.0]
+ ]];
+ }
+ }
+
break;
case MXCallStateCreateOffer:
self.isRinging = YES;
@@ -547,6 +597,21 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
case MXCallStateConnecting:
self.isRinging = NO;
callStatusLabel.text = [NSBundle mxk_localizedStringForKey:@"call_connecting"];
+
+ // User has accepted the call and we can remove incomingCallView
+ if (self.incomingCallView)
+ {
+ [UIView transitionWithView:self.view
+ duration:0.33
+ options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionCurveEaseOut
+ animations:^{
+ [self.incomingCallView removeFromSuperview];
+ }
+ completion:^(BOOL finished) {
+ self.incomingCallView = nil;
+ }];
+ }
+
break;
case MXCallStateConnected:
self.isRinging = NO;
@@ -840,6 +905,11 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
}
}
+- (UIView *)createIncomingCallView
+{
+ return nil;
+}
+
#pragma mark - UIResponder Touch Events
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event

Add support for incoming calls view