Skip to content

Commit

Permalink
update for @available
Browse files Browse the repository at this point in the history
  • Loading branch information
BailingIOS committed Oct 10, 2019
1 parent b198154 commit 8018021
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ @implementation UICollectionView (BackgroundView)

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (self.tag != 202) {
return [super hitTest:point withEvent:event];
}

NSInteger userCellCount = [self.callVideoMultiCallViewController.subUserModelList count];
UIView *touchView = self;
if ([self pointInside:point withEvent:event] && self.alpha >= 0.01 && !self.hidden && self.isUserInteractionEnabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ - (void)inviteNewUser {
success:^(NSArray *addUserIdList) {
[weakSelf.callSession inviteRemoteUsers:addUserIdList mediaType:weakSelf.mediaType];
}];
selectViewController.modalPresentationStyle = UIModalPresentationFullScreen;
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:selectViewController];
nav.modalPresentationStyle = UIModalPresentationFullScreen;

dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:nav animated:YES completion:nil];
Expand All @@ -386,9 +386,8 @@ - (void)inviteNewUserWithClickEvent {
success:^(NSArray *addUserIdList) {
[weakSelf.callSession inviteRemoteUsers:addUserIdList mediaType:weakSelf.mediaType];
}];

selectViewController.modalPresentationStyle = UIModalPresentationFullScreen;
UINavigationController *rootVC = [[UINavigationController alloc] initWithRootViewController:selectViewController];
rootVC.modalPresentationStyle = UIModalPresentationFullScreen;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:rootVC animated:YES completion:nil];
});
Expand Down
129 changes: 84 additions & 45 deletions ios-rongcallkit/RongCallKit/Controller/RCCallBaseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (instancetype)initWithIncomingCall:(RCCallSession *)callSession {
sem = dispatch_semaphore_create(1);
queue = dispatch_queue_create("AnswerQueue", DISPATCH_QUEUE_SERIAL);
[self registerForegroundNotification];
[_callSession setDelegate:self];
[_callSession addDelegate:self];
[RCCallKitUtility setScreenForceOn];
[_callSession setMinimized:NO];
self.needPlayingRingAfterForeground = YES;
Expand Down Expand Up @@ -107,7 +107,7 @@ - (instancetype)initWithActiveCall:(RCCallSession *)callSession {
sem = dispatch_semaphore_create(1);
queue = dispatch_queue_create("AnswerQueue", DISPATCH_QUEUE_SERIAL);
[self registerForegroundNotification];
[_callSession setDelegate:self];
[_callSession addDelegate:self];
[_callSession setMinimized:YES];
hangupButtonClick = NO;
}
Expand All @@ -119,6 +119,7 @@ - (void)registerForegroundNotification {
selector:@selector(appDidBecomeActive)
name:UIApplicationDidBecomeActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioRouteChange:) name:AVAudioSessionRouteChangeNotification object:nil];
}

- (void)dealloc {
Expand Down Expand Up @@ -156,8 +157,8 @@ - (void)triggerVibrate {

- (void)triggerVibrateAction
{
NSString *version = [UIDevice currentDevice].systemVersion;
if (version.doubleValue >= 9.0) {
NSInteger checker = [RCCallKitUtility compareVersion:[UIDevice currentDevice].systemVersion toVersion:@"9.0"];
if (checker >= 0) {
AudioServicesPlaySystemSoundWithCompletion(kSystemSoundID_Vibrate, ^{});
}
else{
Expand Down Expand Up @@ -224,8 +225,7 @@ - (void)viewDidLoad {
[self registerTelephonyEvent];
[self addProximityMonitoringObserver];

UIVisualEffect *blurEffect = [UIBlurEffect
effectWithStyle:UIBlurEffectStyleDark];
// UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
// self.blurView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
self.blurView = [[UIView alloc] init];
self.blurView.frame = self.view.frame;
Expand Down Expand Up @@ -364,6 +364,8 @@ - (UILabel *)timeLabel {
}

- (void)startActiveTimer {
[_activeTimer invalidate];
_activeTimer = nil;
self.activeTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateActiveTimer)
Expand Down Expand Up @@ -466,24 +468,12 @@ - (void)addButtonClicked

NSMutableArray *menuItems = [NSMutableArray new];
[menuItems addObject:addMemberItem];
// [menuItems addObject:whiteBoardItem];
// if (self.callSession.blinkUserType == 2)
// [menuItems addObject:handupItem];

UIBarButtonItem *rightBarButton = self.navigationItem.rightBarButtonItems[1];
CGRect targetFrame = rightBarButton.customView.frame;
targetFrame.origin.y = targetFrame.origin.y + 15;
// if (IOS_FSystenVersion >= 11.0) {
// targetFrame.origin.x = self.view.bounds.size.width - targetFrame.size.width - 17;
// targetFrame.origin.y += 11;
// }
// if([UIDevice isX])
// {
// targetFrame.origin.y = targetFrame.origin.y + 24;
// }
[KxCallMenu setTintColor:[UIColor blackColor]];
[KxCallMenu setTitleFont:[UIFont systemFontOfSize:16]];
// [KxCallMenu showMenuInView:self.navigationController.navigationBar.superview fromRect:targetFrame menuItems:menuItems];
[KxCallMenu showMenuInView:_addButton.superview fromRect:CGRectMake([UIScreen mainScreen].bounds.size.width - 80, 48, 0, 0) menuItems:menuItems];
}

Expand Down Expand Up @@ -874,13 +864,17 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
[self layoutTextUnderImageButton:self.speakerButton];
self.speakerButton.hidden = NO;
[self.speakerButton setSelected:self.callSession.speakerEnabled];
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
} else if (callStatus == RCCallDialing) {
self.speakerButton.frame =
CGRectMake(self.view.frame.size.width - RCCallHorizontalMiddleMargin - RCCallCustomButtonLength,
self.view.frame.size.height - (RCCallButtonBottomMargin * 2 - RCCallInsideMargin * 2) - RCCallCustomButtonLength - RCCallExtraSpace, RCCallCustomButtonLength,
RCCallCustomButtonLength);
[self layoutTextUnderImageButton:self.speakerButton];
self.speakerButton.hidden = NO;
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
} else if (callStatus != RCCallHangup) {
self.speakerButton.hidden = YES;
}
Expand Down Expand Up @@ -1005,6 +999,8 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
[self layoutTextUnderImageButton:self.speakerButton];
self.speakerButton.hidden = NO;
[self setSpeakerEnable:NO];
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
}else if (callStatus != RCCallHangup) {
self.speakerButton.hidden = YES;
}
Expand Down Expand Up @@ -1147,12 +1143,16 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
RCCallCustomButtonLength);
[self layoutTextUnderImageButton:self.speakerButton];
self.speakerButton.hidden = NO;
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
} else if (callStatus != RCCallHangup) {
self.speakerButton.hidden = YES;
}

if (callStatus == RCCallActive) {
[self.speakerButton setSelected:self.callSession.speakerEnabled];
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
}

if (callStatus == RCCallDialing) {
Expand Down Expand Up @@ -1227,6 +1227,8 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
[self layoutTextUnderImageButton:self.speakerButton];
self.speakerButton.hidden = YES;
[self setSpeakerEnable:NO];
if ([self isHeadsetPluggedIn])
[self reloadSpeakerRoute:NO];
} else if (callStatus != RCCallHangup) {
self.speakerButton.hidden = YES;
}
Expand All @@ -1241,25 +1243,6 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
} else if (callStatus != RCCallHangup) {
self.minimizeButton.hidden = YES;
}
/*
//举手
if (callStatus == RCCallActive && self.callSession.blinkUserType == 2) {
self.handUpButton.frame = CGRectMake(self.view.frame.size.width - RCCallHorizontalMargin / 2 - RCCallButtonLength - RCCallButtonLength / 2 - RCCallButtonLength / 2 - RCCallInsideMargin * 3,
RCCallVerticalMargin, RCCallButtonLength / 2, RCCallButtonLength / 2);
self.handUpButton.hidden = NO;
} else if (callStatus != RCCallHangup) {
self.handUpButton.hidden = YES;
}
//白板
if (callStatus == RCCallActive) {
self.whiteBoardButton.frame = CGRectMake(self.view.frame.size.width - RCCallHorizontalMargin / 2 - RCCallButtonLength - RCCallButtonLength / 2 - RCCallInsideMargin * 2,
RCCallVerticalMargin, RCCallButtonLength / 2, RCCallButtonLength / 2);
self.whiteBoardButton.hidden = NO;
} else if (callStatus != RCCallHangup) {
self.whiteBoardButton.hidden = YES;
}
*/

if (callStatus == RCCallActive) {
self.cameraSwitchButton.frame = CGRectMake(
Expand Down Expand Up @@ -1593,30 +1576,29 @@ - (void)errorDidOccur:(RCCallErrorCode)error {
@param rxQuality 下行网络质量
*/
- (void)networkTxQuality:(RCCallQuality)txQuality rxQuality:(RCCallQuality)rxQuality {
// NSLog(@"networkTxQuality, %zd, %zd", txQuality, rxQuality);
dispatch_async(dispatch_get_main_queue(), ^{
switch (txQuality)
{
case RCCall_Quality_Unknown:
self.signalImageView.image = signalImage0;
self.signalImageView.image = self->signalImage0;
break;
case RCCall_Quality_Excellent:
self.signalImageView.image = signalImage5;
self.signalImageView.image = self->signalImage5;
break;
case RCCall_Quality_Good:
self.signalImageView.image = signalImage4;
self.signalImageView.image = self->signalImage4;
break;
case RCCall_Quality_Poor:
self.signalImageView.image = signalImage3;
self.signalImageView.image = self->signalImage3;
break;
case RCCall_Quality_Bad:
self.signalImageView.image = signalImage2;
self.signalImageView.image = self->signalImage2;
break;
case RCCall_Quality_VBad:
self.signalImageView.image = signalImage1;
self.signalImageView.image = self->signalImage1;
break;
case RCCall_Quality_Down:
self.signalImageView.image = signalImage0;
self.signalImageView.image = self->signalImage0;
break;
default:
break;
Expand Down Expand Up @@ -1713,6 +1695,63 @@ - (void)proximityStatueChanged:(NSNotificationCenter *)notification {
}
}

- (void)handleAudioRouteChange:(NSNotification*)notification
{
NSInteger reason = [[[notification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
AVAudioSessionRouteDescription *route = [AVAudioSession sharedInstance].currentRoute;
AVAudioSessionPortDescription *port = route.outputs.firstObject;
switch (reason)
{
case AVAudioSessionRouteChangeReasonUnknown:
break;
case AVAudioSessionRouteChangeReasonNewDeviceAvailable : //1
[self reloadSpeakerRoute:NO];
break;
case AVAudioSessionRouteChangeReasonOldDeviceUnavailable : //2
[self reloadSpeakerRoute:YES];
break;
case AVAudioSessionRouteChangeReasonCategoryChange : //3
break;
case AVAudioSessionRouteChangeReasonOverride : //4
{
if ([port.portType isEqualToString:AVAudioSessionPortBuiltInReceiver] || [port.portType isEqualToString: AVAudioSessionPortBuiltInSpeaker]){
[self reloadSpeakerRoute:YES];
}
else{
[self reloadSpeakerRoute:NO];
}
}
break;
case AVAudioSessionRouteChangeReasonWakeFromSleep : //6
break;
case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory : //7
break;
case AVAudioSessionRouteChangeReasonRouteConfigurationChange : //8
break;
default:
break;
}
}

- (void)reloadSpeakerRoute:(BOOL)enable
{
dispatch_async(dispatch_get_main_queue(), ^{
self.speakerButton.enabled = enable;
});
}

- (BOOL)isHeadsetPluggedIn
{
AVAudioSessionRouteDescription *route = [[AVAudioSession sharedInstance] currentRoute];
for (AVAudioSessionPortDescription* desc in [route outputs])
{
NSString *outputer = desc.portType;
if ([outputer isEqualToString:AVAudioSessionPortHeadphones] || [outputer isEqualToString:AVAudioSessionPortBluetoothLE] || [outputer isEqualToString:AVAudioSessionPortBluetoothHFP] || [outputer isEqualToString:AVAudioSessionPortBluetoothA2DP])
return YES;
}
return NO;
}

#pragma mark - outside callback
- (void)callWillConnect {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ - (void)viewDidLoad {
self.searchController.searchResultsUpdater = self;
self.searchController.delegate = self;
self.searchController.dimsBackgroundDuringPresentation = YES;
if (@available(iOS 9.1, *)) {

NSInteger checker = [RCCallKitUtility compareVersion:[UIDevice currentDevice].systemVersion toVersion:@"9.1"];
if (checker >= 0) {
self.searchController.obscuresBackgroundDuringPresentation = YES;
}
self.searchController.hidesNavigationBarDuringPresentation = NO;
Expand Down Expand Up @@ -378,7 +380,8 @@ - (UITableViewController *)resultController {
_resultController.tableView.contentInset = UIEdgeInsetsMake(20, 0, 49, 0);
_resultController.tableView.allowsSelection = YES;
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_10_3
if (@available(iOS 11.0, *)) {
NSInteger checker = [RCCallKitUtility compareVersion:[UIDevice currentDevice].systemVersion toVersion:@"11.0"];
if (checker >= 0) {
_resultController.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ - (void)inviteUserButtonClicked {
if (self.callSession.isMultiCall) {
[self inviteNewUser];
} else {
NSLog(@"not support add user for conversation type %zd", self.callSession.conversationType);
RCLogI(@"not support add user for conversation type %zd", self.callSession.conversationType);
}
}

Expand All @@ -411,8 +411,8 @@ - (void)inviteNewUser {
success:^(NSArray *addUserIdList) {
[weakSelf.callSession inviteRemoteUsers:addUserIdList mediaType:weakSelf.mediaType];
}];
selectViewController.modalPresentationStyle = UIModalPresentationFullScreen;
UINavigationController* nav = [[UINavigationController alloc] initWithRootViewController:selectViewController];
nav.modalPresentationStyle = UIModalPresentationFullScreen;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:nav animated:YES completion:nil];
});
Expand All @@ -435,8 +435,8 @@ - (void)inviteNewUserWithClickEvent {
success:^(NSArray *addUserIdList) {
[weakSelf.callSession inviteRemoteUsers:addUserIdList mediaType:weakSelf.mediaType];
}];
selectViewController.modalPresentationStyle = UIModalPresentationFullScreen;
UINavigationController *rootVC = [[UINavigationController alloc] initWithRootViewController:selectViewController];
rootVC.modalPresentationStyle = UIModalPresentationFullScreen;
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf presentViewController:rootVC animated:YES completion:nil];
});
Expand Down Expand Up @@ -472,7 +472,6 @@ - (void)resetLayout:(BOOL)isMultiCall mediaType:(RCCallMediaType)mediaType callS
CGRectMake(RCCallHorizontalMargin, RCCallMiniButtonTopMargin + RCCallStatusBarHeight,
(self.view.frame.size.width - RCCallHorizontalMargin * 2), RCCallLabelHeight);
self.mainNameLabel.hidden = NO;

} else if (callStatus == RCCallActive) {
self.mainNameLabel.frame =
CGRectMake(RCCallHorizontalMargin, RCCallMiniButtonTopMargin + RCCallStatusBarHeight,
Expand Down
2 changes: 1 addition & 1 deletion ios-rongcallkit/RongCallKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.9.22</string>
<string>2.9.25</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit 8018021

Please sign in to comment.