From f6ab161960d1a3052c40cdea28f39322a485d9b1 Mon Sep 17 00:00:00 2001 From: REIS Benjamin Date: Tue, 4 Oct 2016 11:59:55 +0200 Subject: [PATCH] Migration from UiAlertView to UiAlertController for simple UiAlert --- Classes/AssistantLinkView.m | 46 +++++---- Classes/AssistantView.m | 98 +++++++++++-------- Classes/CallView.m | 21 ++-- Classes/ChatConversationCreateTableView.m | 17 ++-- Classes/ChatConversationView.m | 41 ++++---- Classes/ContactsListView.m | 21 ++-- Classes/DialerView.m | 18 ++-- Classes/FirstLoginView.m | 21 ++-- Classes/LinphoneAppDelegate.h | 3 +- Classes/LinphoneAppDelegate.m | 34 ++++--- Classes/LinphoneCoreSettingsStore.m | 33 ++++--- Classes/LinphoneManager.m | 75 +++++++------- Classes/LinphoneUI/UIShopTableCell.m | 17 ++-- Classes/PhoneMainView.m | 32 +++--- Classes/SettingsView.m | 16 +-- Classes/Utils/FileTransferDelegate.m | 19 ++-- .../IASKAppSettingsViewController.m | 19 ++-- 17 files changed, 313 insertions(+), 218 deletions(-) diff --git a/Classes/AssistantLinkView.m b/Classes/AssistantLinkView.m index 7411d2cc7..d2ac46d9d 100644 --- a/Classes/AssistantLinkView.m +++ b/Classes/AssistantLinkView.m @@ -114,12 +114,16 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - popup - (void)showErrorPopup:(const char *)err { - UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Account configuration issue", nil) - message:[AssistantView StringForXMLRPCError:err] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil, nil]; - [errorView show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) + message:[AssistantView StringForXMLRPCError:err] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } #pragma mark - cbs @@ -201,20 +205,22 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph } - (IBAction)onPhoneNumberDisclosureClick:(id)sender { - UIAlertView *errorView = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"What will my phone number be used for?", nil) - message:NSLocalizedString(@"Your friends will find your more easily if you link your account to your " - @"phone number. \n\nYou will see in your address book who is using " - @"Linphone and your friends will know that they can reach you on Linphone " - @"as well. \n\nYou can use your phone number with only one Linphone " - @"account. If you had already linked your number to an other account but " - @"you prefer to use this one, simply link it now and your number will " - @"automatically be moved to this account.", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil, nil]; - [errorView show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"What will my phone number be used for?", nil) + message:NSLocalizedString(@"Your friends will find your more easily if you link your account to your " + @"phone number. \n\nYou will see in your address book who is using " + @"Linphone and your friends will know that they can reach you on Linphone " + @"as well. \n\nYou can use your phone number with only one Linphone " + @"account. If you had already linked your number to an other account but " + @"you prefer to use this one, simply link it now and your number will " + @"automatically be moved to this account.", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } #pragma mark - select country delegate diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index adbfb6163..3bd43c7b4 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -224,15 +224,18 @@ static UICompositeViewDescription *compositeDescription = nil; LinphoneManager *lm = LinphoneManager.instance; if (!linphone_core_is_network_reachable(LC)) { - UIAlertView *error = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Network Error", nil) - message:NSLocalizedString(@"There is no network connection available, enable " - @"WIFI or WWAN prior to configure an account", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Network Error", nil) + message:NSLocalizedString(@"There is no network connection available, enable " + @"WIFI or WWAN prior to configure an account", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; _waitView.hidden = YES; return; } @@ -265,14 +268,17 @@ static UICompositeViewDescription *compositeDescription = nil; // todo: STOP doing that! [[LinphoneManager.instance fastAddressBook] reload]; } else { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Assistant error", nil) - message:NSLocalizedString( - @"Could not configure your account, please check parameters or try again later", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Assistant error", nil) + message:NSLocalizedString(@"Could not configure your account, please check parameters or try again later", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; _waitView.hidden = YES; return; } @@ -673,12 +679,16 @@ static UICompositeViewDescription *compositeDescription = nil; break; case LinphoneConfiguringFailed: { NSString *error_message = [notif.userInfo valueForKey:@"message"]; - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Provisioning Load error", nil) - message:error_message - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Provisioning Load error", nil) + message:error_message + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; break; } @@ -741,13 +751,15 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)showErrorPopup:(const char *)err { - UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Account configuration issue", nil) - message:[self.class StringForXMLRPCError:err] - //message:[NSString stringWithUTF8String:err] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil, nil]; - [errorView show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) + message:[AssistantView StringForXMLRPCError:err] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } - (void)isAccountUsed:(LinphoneAccountCreatorStatus)status withResp:(const char *)resp { @@ -1104,16 +1116,22 @@ void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAcc } - (IBAction)onPhoneNumberDisclosureClick:(id)sender { - UIAlertView *errorView = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"What will my phone number be used for?", nil) - message:NSLocalizedString(@"Thanks to your phone number, your friends will find you more easily. " - @"\n\nYou will see in your address book who is using Linphone and your " - @"friends will know that they can reach you on Linphone as well.", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil, nil]; - [errorView show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"What will my phone number be used for?", nil) + message:NSLocalizedString(@"Your friends will find your more easily if you link your account to your " + @"phone number. \n\nYou will see in your address book who is using " + @"Linphone and your friends will know that they can reach you on Linphone " + @"as well. \n\nYou can use your phone number with only one Linphone " + @"account. If you had already linked your number to an other account but " + @"you prefer to use this one, simply link it now and your number will " + @"automatically be moved to this account.", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } - (IBAction)onBackClick:(id)sender { diff --git a/Classes/CallView.m b/Classes/CallView.m index 6bcc3e939..ee8008076 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -541,15 +541,18 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { if (state == LinphoneCallStreamsRunning && callAppData->videoRequested && linphone_call_params_low_bandwidth_enabled(param)) { // too bad video was not enabled because low bandwidth - UIAlertView *alert = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Low bandwidth", nil) - message:NSLocalizedString(@"Video cannot be activated because of low bandwidth " - @"condition, only audio is available", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Low bandwidth", nil) + message:NSLocalizedString(@"Video cannot be activated because of low bandwidth " + @"condition, only audio is available", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Continue" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; callAppData->videoRequested = FALSE; /*reset field*/ } } diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index 06c292608..3f307122f 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -83,12 +83,17 @@ LC, ((NSString *)[_contacts.allKeys objectAtIndex:indexPath.row]).UTF8String); if (!room) { [PhoneMainView.instance popCurrentView]; - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid address", nil) - message:@"Please specify the entire SIP address for the chat" - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid address", nil) + message:NSLocalizedString(@"Please specify the entire SIP address for the chat", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } else { ChatConversationView *view = VIEW(ChatConversationView); [view setChatRoom:room]; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index f7e941385..f31d5aa5d 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -194,15 +194,18 @@ static UICompositeViewDescription *compositeDescription = nil; const LinphoneAddress *addr = linphone_chat_room_get_peer_address(_chatRoom); if (addr == NULL) { [PhoneMainView.instance popCurrentView]; - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Invalid SIP address", nil) - message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to send a " - @"message or use a valid SIP address (I.E sip:john@example.net)", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid SIP address", nil) + message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to send a " + @"message or use a valid SIP address (I.E sip:john@example.net)", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Continue" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; return; } [ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr]; @@ -245,14 +248,18 @@ static UICompositeViewDescription *compositeDescription = nil; completionBlock:^(NSURL *assetURL, NSError *error) { if (error) { LOGE(@"Cannot save image data downloaded [%@]", [error localizedDescription]); - - UIAlertView *errorAlert = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Transfer error", nil) - message:NSLocalizedString(@"Cannot write image to photo library", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Ok", nil) - otherButtonTitles:nil, nil]; - [errorAlert show]; + + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Transfer error", nil) + message:NSLocalizedString(@"Cannot write image to photo library", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } else { LOGI(@"Image saved to [%@]", [assetURL absoluteString]); [self startImageUpload:image url:assetURL]; diff --git a/Classes/ContactsListView.m b/Classes/ContactsListView.m index 081a59ee0..cedd07fdc 100644 --- a/Classes/ContactsListView.m +++ b/Classes/ContactsListView.m @@ -126,15 +126,18 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if (![FastAddressBook isAuthorized]) { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Address book", nil) - message:NSLocalizedString(@"You must authorize the application to have access to address book.\n" - "Toggle the application in Settings > Privacy > Contacts", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Address book", nil) + message:NSLocalizedString(@"You must authorize the application to have access to address book.\n" + "Toggle the application in Settings > Privacy > Contacts", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Continue" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; [PhoneMainView.instance popCurrentView]; } } diff --git a/Classes/DialerView.m b/Classes/DialerView.m index 4da747c72..8dca7c12b 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -234,13 +234,17 @@ static UICompositeViewDescription *compositeDescription = nil; } } else { - UIAlertView *alert = - [[UIAlertView alloc] initWithTitle:subject - message:NSLocalizedString(@"Error: no mail account configured", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:subject + message:NSLocalizedString(@"Error: no mail account configured", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } } diff --git a/Classes/FirstLoginView.m b/Classes/FirstLoginView.m index 081b0f926..ca424766b 100644 --- a/Classes/FirstLoginView.m +++ b/Classes/FirstLoginView.m @@ -245,15 +245,18 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)onLoginClick:(id)sender { if (!linphone_core_is_network_reachable(LC)) { - UIAlertView *error = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Network Error", nil) - message:NSLocalizedString(@"There is no network connection available, enable " - @"WIFI or WWAN prior to configure an account", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Network Error", nil) + message:NSLocalizedString(@"There is no network connection available, enable " + @"WIFI or WWAN prior to configure an account", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; return; } diff --git a/Classes/LinphoneAppDelegate.h b/Classes/LinphoneAppDelegate.h index f639083f4..90469f8da 100644 --- a/Classes/LinphoneAppDelegate.h +++ b/Classes/LinphoneAppDelegate.h @@ -25,8 +25,7 @@ #import #import -//@interface LinphoneAppDelegate : NSObject { -@interface LinphoneAppDelegate : NSObject { +@interface LinphoneAppDelegate : NSObject { @private UIBackgroundTaskIdentifier bgStartId; BOOL startedInBackground; diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 3d5126a75..c5fa2ae14 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -681,26 +681,32 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (state == LinphoneConfiguringSuccessful) { [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; [_waitingIndicator dismissWithClickedButtonIndex:0 animated:true]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Success", nil) + message:NSLocalizedString(@"Remote configuration successfully fetched and applied.", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Success", nil) - message:NSLocalizedString(@"Remote configuration successfully fetched and applied.", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [error show]; [PhoneMainView.instance startUp]; } if (state == LinphoneConfiguringFailed) { [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil]; [_waitingIndicator dismissWithClickedButtonIndex:0 animated:true]; - UIAlertView *error = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Failure", nil) - message:NSLocalizedString(@"Failed configuring from the specified URL.", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Failure", nil) + message:NSLocalizedString(@"Failed configuring from the specified URL.", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 6f436e9e2..388c9bcff 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -19,6 +19,7 @@ #import "LinphoneCoreSettingsStore.h" #import "Utils.h" +#import "PhoneMainView.h" #include "linphone/lpconfig.h" #include "linphone/linphone_tunnel.h" @@ -395,12 +396,16 @@ } - (void)alertAccountError:(NSString *)error { - UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) - message:error - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil]; - [alertview show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", nil) + message:error + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } - (void)synchronizeAccounts { @@ -570,12 +575,16 @@ // in case of error, show an alert to the user if (error != nil) { linphone_proxy_config_done(proxyCfg); - - [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) - message:error - delegate:nil - cancelButtonTitle:NSLocalizedString(@"OK", nil) - otherButtonTitles:nil] show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Error", nil) + message:error + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } } // reload address book to prepend proxy config domain to contacts' phone number diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 809bd3368..e434b3afe 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1688,14 +1688,16 @@ static BOOL libStarted = FALSE; LOGE(@"audioSession setActive failed: %@", [err description]); } if (!bAudioInputAvailable) { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"No microphone", nil) - message:NSLocalizedString( - @"You need to plug a microphone to your device to use this application.", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Ok", nil) - otherButtonTitles:nil, nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"No microphone", nil) + message:NSLocalizedString(@"You need to plug a microphone to your device to use the application.", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { @@ -2271,16 +2273,16 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (BOOL)call:(const LinphoneAddress *)iaddr { // First verify that network is available, abort otherwise. if (!linphone_core_is_network_reachable(theLinphoneCore)) { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Network Error", nil) - message: - NSLocalizedString( - @"There is no network connection available, enable WIFI or WWAN prior to place a call", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Network Error", nil) + message:NSLocalizedString(@"There is no network connection available, enable WIFI or WWAN prior to place a call", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; return FALSE; } @@ -2288,27 +2290,32 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { CTCallCenter *callCenter = [[CTCallCenter alloc] init]; if ([callCenter currentCalls] != nil) { LOGE(@"GSM call in progress, cancelling outgoing SIP call request"); - UIAlertView *error = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Cannot make call", nil) - message:NSLocalizedString(@"Please terminate GSM call first.", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot make call", nil) + message:NSLocalizedString(@"Please terminate GSM call first.", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; return FALSE; } // Then check that the supplied address is valid if (!iaddr) { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Invalid SIP address", nil) - message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " - @"call or use a valid SIP address (I.E sip:john@example.net)", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid SIP address", nil) + message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " + @"call or use a valid SIP address (I.E sip:john@example.net)", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; return FALSE; } LinphoneAddress *addr = linphone_address_clone(iaddr); diff --git a/Classes/LinphoneUI/UIShopTableCell.m b/Classes/LinphoneUI/UIShopTableCell.m index 7c69470fb..13e7a51c6 100644 --- a/Classes/LinphoneUI/UIShopTableCell.m +++ b/Classes/LinphoneUI/UIShopTableCell.m @@ -20,6 +20,7 @@ #import "UIShopTableCell.h" #import "Utils.h" #import "UILabel+Boldify.h" +#import "PhoneMainView.h" @implementation UIShopTableCell @@ -55,12 +56,16 @@ UIImageView *infoImage; - (IBAction)onDetails:(id)event { NSString *msg = [NSString stringWithFormat:@"Product - %@", self.nameLabel.text]; - UIAlertView *descriptionAlertView = [[UIAlertView alloc] initWithTitle:msg - message:self.descriptionLabel.text - delegate:nil - cancelButtonTitle:@"OK" - otherButtonTitles:nil]; - [descriptionAlertView show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:msg + message:self.descriptionLabel.text + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } - (void)touchUp:(id)sender { diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index cca27f268..812e5c7e1 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -287,12 +287,16 @@ static RootViewManager *rootViewManagerInstance = nil; LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue]; if (state == LinphoneRegistrationFailed && ![currentView equal:AssistantView.compositeViewDescription] && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - UIAlertView *error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure", nil) - message:[notif.userInfo objectForKey:@"message"] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil, nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Registration failure", nil) + message:[notif.userInfo objectForKey:@"message"] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Continue", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } } @@ -633,12 +637,16 @@ static RootViewManager *rootViewManagerInstance = nil; } lTitle = NSLocalizedString(@"Call failed", nil); - UIAlertView *error = [[UIAlertView alloc] initWithTitle:lTitle - message:lMessage - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:lTitle + message:lMessage + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } - (void)addInhibitedEvent:(id)event { diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 7f47280fd..89743a017 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -808,12 +808,16 @@ static UICompositeViewDescription *compositeDescription = nil; #endif if (error != nil) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Cannot send email", nil) - message:error - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot send email", nil) + message:error + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Continue", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } else { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index fc18b2fe6..dc63afed5 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -8,6 +8,7 @@ #import "FileTransferDelegate.h" #import "Utils.h" +#import "PhoneMainView.h" @interface FileTransferDelegate () @property(strong) NSMutableData *data; @@ -60,13 +61,17 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con if (error) { LOGE(@"Cannot save image data downloaded [%@]", [error localizedDescription]); [LinphoneManager setValueInMessageAppData:nil forKey:@"localimage" inMessage:message]; - UIAlertView *errorAlert = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Transfer error", nil) - message:NSLocalizedString(@"Cannot write image to photo library", nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Ok", nil) - otherButtonTitles:nil, nil]; - [errorAlert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Transfer error", nil) + message:NSLocalizedString(@"Cannot write image to photo library", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; } else { LOGI(@"Image saved to [%@]", [assetURL absoluteString]); [LinphoneManager setValueInMessageAppData:[assetURL absoluteString] diff --git a/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m b/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m index f077e1264..9fe942583 100755 --- a/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m +++ b/Classes/Utils/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m @@ -800,13 +800,16 @@ CGRect IASKCGRectSwap(CGRect rect); mailViewController.mailComposeDelegate = vc; [vc presentModalViewController:mailViewController animated:YES]; } else { - UIAlertView *alert = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Mail not configured", @"InAppSettingsKit") - message:NSLocalizedString(@"This device is not configured for sending Email. Please configure the Mail settings in the Settings app.", @"InAppSettingsKit") - delegate: nil - cancelButtonTitle:NSLocalizedString(@"OK", @"InAppSettingsKit") - otherButtonTitles:nil]; - [alert show]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Mail not configured", @"InAppSettingKit") + message:NSLocalizedString(@"This device is not configured for sending Email. Please configure the Mail settings in the Settings app.", @"InAppSettingsKit") + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"InAppSettingsKit") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } } else if ([[specifier type] isEqualToString:kIASKCustomViewSpecifier] && [self.delegate respondsToSelector:@selector(settingsViewController:tableView:didSelectCustomViewSpecifier:)]) { @@ -907,4 +910,4 @@ CGRect IASKCGRectSwap(CGRect rect) { } @end -#pragma deploymate pop \ No newline at end of file +#pragma deploymate pop