diff --git a/Classes/CallView.m b/Classes/CallView.m index 5c0b0de98..621743eef 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -107,11 +107,6 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - // Set observer - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(callUpdateEvent:) - name:kLinphoneCallUpdate - object:nil]; // Update on show LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]); @@ -669,47 +664,37 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { if (linphone_core_get_video_policy([LinphoneManager getLc])->automatically_accept) return; - const char *lUserNameChars = linphone_address_get_username(linphone_call_get_remote_address(call)); - NSString *lUserName = - lUserNameChars ? [[NSString alloc] initWithUTF8String:lUserNameChars] : NSLocalizedString(@"Unknown", nil); - const char *lDisplayNameChars = linphone_address_get_display_name(linphone_call_get_remote_address(call)); - NSString *lDisplayName = lDisplayNameChars ? [[NSString alloc] initWithUTF8String:lDisplayNameChars] : @""; - - NSString *title = [NSString stringWithFormat:NSLocalizedString(@"'%@' would like to enable video", nil), - ([lDisplayName length] > 0) ? lDisplayName : lUserName]; - DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:title]; - NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:30 - target:self - selector:@selector(dismissVideoActionSheet:) - userInfo:sheet - repeats:NO]; - [sheet addButtonWithTitle:NSLocalizedString(@"Accept", nil) - block:^() { - LOGI(@"User accept video proposal"); - LinphoneCallParams *paramsCopy = - linphone_call_params_copy(linphone_call_get_current_params(call)); - linphone_call_params_enable_video(paramsCopy, TRUE); - linphone_core_accept_call_update([LinphoneManager getLc], call, paramsCopy); - linphone_call_params_destroy(paramsCopy); - [timer invalidate]; - }]; - DTActionSheetBlock cancelBlock = ^() { - LOGI(@"User declined video proposal"); - LinphoneCallParams *paramsCopy = linphone_call_params_copy(linphone_call_get_current_params(call)); - linphone_core_accept_call_update([LinphoneManager getLc], call, paramsCopy); - linphone_call_params_destroy(paramsCopy); - [timer invalidate]; - }; - [sheet addDestructiveButtonWithTitle:NSLocalizedString(@"Decline", nil) block:cancelBlock]; - if (LinphoneManager.runningOnIpad) { - [sheet addCancelButtonWithTitle:NSLocalizedString(@"Decline", nil) block:cancelBlock]; - } - [sheet showInView:PhoneMainView.instance.view]; + NSString *username = [FastAddressBook displayNameForAddress:linphone_call_get_remote_address(call)]; + NSString *title = [NSString stringWithFormat:NSLocalizedString(@"%@ would like to enable video", nil), username]; + NSTimer *timer; + UIConfirmationDialog *sheet = [UIConfirmationDialog ShowWithMessage:title + cancelMessage:nil + confirmMessage:NSLocalizedString(@"ACCEPT", nil) + onCancelClick:^() { + LOGI(@"User declined video proposal"); + LinphoneCallParams *paramsCopy = linphone_call_params_copy(linphone_call_get_current_params(call)); + linphone_core_accept_call_update([LinphoneManager getLc], call, paramsCopy); + linphone_call_params_destroy(paramsCopy); + [timer invalidate]; + } + onConfirmationClick:^() { + LOGI(@"User accept video proposal"); + LinphoneCallParams *paramsCopy = linphone_call_params_copy(linphone_call_get_current_params(call)); + linphone_call_params_enable_video(paramsCopy, TRUE); + linphone_core_accept_call_update([LinphoneManager getLc], call, paramsCopy); + linphone_call_params_destroy(paramsCopy); + [timer invalidate]; + }]; + timer = [NSTimer scheduledTimerWithTimeInterval:30 + target:self + selector:@selector(dismissVideoActionSheet:) + userInfo:sheet + repeats:NO]; } - (void)dismissVideoActionSheet:(NSTimer *)timer { - DTActionSheet *sheet = (DTActionSheet *)timer.userInfo; - [sheet dismissWithClickedButtonIndex:sheet.destructiveButtonIndex animated:TRUE]; + UIConfirmationDialog *sheet = (UIConfirmationDialog *)timer.userInfo; + [sheet dismiss]; } #pragma mark VideoPreviewMoving diff --git a/Classes/LinphoneUI/StatusBarView.m b/Classes/LinphoneUI/StatusBarView.m index 668729b7a..747f694e2 100644 --- a/Classes/LinphoneUI/StatusBarView.m +++ b/Classes/LinphoneUI/StatusBarView.m @@ -302,7 +302,7 @@ linphone_call_get_authentication_token(call)]; if (securityDialog == nil) { __block __strong StatusBarView *weakSelf = self; - [UIConfirmationDialog ShowWithMessage:message + securityDialog = [UIConfirmationDialog ShowWithMessage:message cancelMessage:NSLocalizedString(@"DENY", nil) confirmMessage:NSLocalizedString(@"ACCEPT", nil) onCancelClick:^() { diff --git a/Classes/LinphoneUI/UIConfirmationDialog.h b/Classes/LinphoneUI/UIConfirmationDialog.h index fe8abc591..eef81217d 100644 --- a/Classes/LinphoneUI/UIConfirmationDialog.h +++ b/Classes/LinphoneUI/UIConfirmationDialog.h @@ -15,11 +15,11 @@ typedef void (^UIConfirmationBlock)(void); UIConfirmationBlock onConfirmCb; } -+ (void)ShowWithMessage:(NSString *)message - cancelMessage:(NSString *)cancel - confirmMessage:(NSString *)confirm - onCancelClick:(UIConfirmationBlock)onCancel - onConfirmationClick:(UIConfirmationBlock)onConfirm; ++ (UIConfirmationDialog *)ShowWithMessage:(NSString *)message + cancelMessage:(NSString *)cancel + confirmMessage:(NSString *)confirm + onCancelClick:(UIConfirmationBlock)onCancel + onConfirmationClick:(UIConfirmationBlock)onConfirm; @property(weak, nonatomic) IBOutlet UIRoundBorderedButton *cancelButton; @property(weak, nonatomic) IBOutlet UIRoundBorderedButton *confirmationButton; diff --git a/Classes/LinphoneUI/UIConfirmationDialog.m b/Classes/LinphoneUI/UIConfirmationDialog.m index f61ffffef..1e9246d10 100644 --- a/Classes/LinphoneUI/UIConfirmationDialog.m +++ b/Classes/LinphoneUI/UIConfirmationDialog.m @@ -11,11 +11,11 @@ @implementation UIConfirmationDialog -+ (void)ShowWithMessage:(NSString *)message - cancelMessage:(NSString *)cancel - confirmMessage:(NSString *)confirm - onCancelClick:(UIConfirmationBlock)onCancel - onConfirmationClick:(UIConfirmationBlock)onConfirm { ++ (UIConfirmationDialog *)ShowWithMessage:(NSString *)message + cancelMessage:(NSString *)cancel + confirmMessage:(NSString *)confirm + onCancelClick:(UIConfirmationBlock)onCancel + onConfirmationClick:(UIConfirmationBlock)onConfirm { UIConfirmationDialog *dialog = [[UIConfirmationDialog alloc] initWithNibName:NSStringFromClass(self.class) bundle:NSBundle.mainBundle]; @@ -37,6 +37,7 @@ [[UIColor colorWithPatternImage:[UIImage imageNamed:@"color_A.png"]] CGColor]; dialog.cancelButton.layer.borderColor = [[UIColor colorWithPatternImage:[UIImage imageNamed:@"color_F.png"]] CGColor]; + return dialog; } - (IBAction)onCancelClick:(id)sender { diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 278b16b7a..a6f1d9944 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -570,8 +570,9 @@ static UICompositeViewDescription *compositeDescription = nil; [hiddenKeys addObject:@"quit_button"]; // Hide for the moment [hiddenKeys addObject:@"about_button"]; // Hide for the moment - if (!linphone_core_video_supported([LinphoneManager getLc])) + if (!linphone_core_video_supported([LinphoneManager getLc])) { [hiddenKeys addObject:@"video_menu"]; + } if (![LinphoneManager isCodecSupported:"h264"]) { [hiddenKeys addObject:@"h264_preference"];