mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Call: use confirmation dialog for Video acceptance popup
This commit is contained in:
parent
620200be2f
commit
5b47846d76
5 changed files with 42 additions and 55 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:^() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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"];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue