Apply presentAlert() throughout codebase.

This commit is contained in:
Matthew Chen 2019-03-21 10:55:04 -04:00
parent c9d62f47cc
commit 882dd16d7c
37 changed files with 280 additions and 287 deletions

View File

@ -420,22 +420,22 @@ static NSTimeInterval launchStartedAt;
[self.window makeKeyAndVisible];
UIAlertController *controller =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"APP_LAUNCH_FAILURE_ALERT_TITLE",
@"Title for the 'app launch failed' alert.")
message:NSLocalizedString(@"APP_LAUNCH_FAILURE_ALERT_MESSAGE",
@"Message for the 'app launch failed' alert.")
preferredStyle:UIAlertControllerStyleAlert];
[controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog submitLogsWithCompletion:^{
OWSFail(@"exiting after sharing debug logs.");
}];
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[Pastelog submitLogsWithCompletion:^{
OWSFail(@"exiting after sharing debug logs.");
}];
}]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:controller animated:YES completion:nil];
[fromViewController presentAlert:alert];
}
- (nullable NSError *)convertDatabaseIfNecessary

View File

@ -429,19 +429,19 @@
- (void)showDeleteAccountUI:(BOOL)isRegistered
{
__weak AppSettingsViewController *weakSelf = self;
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TITLE", @"")
message:NSLocalizedString(@"CONFIRM_ACCOUNT_DESTRUCTION_TEXT", @"")
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"PROCEED_BUTTON", @"")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[weakSelf deleteAccount:isRegistered];
}]];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"PROCEED_BUTTON", @"")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[weakSelf deleteAccount:isRegistered];
}]];
[alert addAction:[OWSAlerts cancelAction]];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
- (void)deleteAccount:(BOOL)isRegistered

View File

@ -133,7 +133,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *title = NSLocalizedString(@"LINK_DEVICE_INVALID_CODE_TITLE", @"report an invalid linking code");
NSString *body = NSLocalizedString(@"LINK_DEVICE_INVALID_CODE_BODY", @"report an invalid linking code");
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:title message:body preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
@ -143,7 +143,7 @@ NS_ASSUME_NONNULL_BEGIN
[self popToLinkedDeviceList];
});
}];
[alertController addAction:cancelAction];
[alert addAction:cancelAction];
UIAlertAction *proceedAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"LINK_DEVICE_RESTART", @"attempt another linking")
@ -151,18 +151,18 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *action) {
[self.qrScanningController startCapture];
}];
[alertController addAction:proceedAction];
[alert addAction:proceedAction];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
} else {
NSString *title = NSLocalizedString(
@"LINK_DEVICE_PERMISSION_ALERT_TITLE", @"confirm the users intent to link a new device");
NSString *linkingDescription
= NSLocalizedString(@"LINK_DEVICE_PERMISSION_ALERT_BODY", @"confirm the users intent to link a new device");
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:linkingDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title
message:linkingDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
style:UIAlertActionStyleCancel
@ -171,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
[self popToLinkedDeviceList];
});
}];
[alertController addAction:cancelAction];
[alert addAction:cancelAction];
UIAlertAction *proceedAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"CONFIRM_LINK_NEW_DEVICE_ACTION", @"Button text")
@ -179,9 +179,9 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *action) {
[self provisionWithParser:parser];
}];
[alertController addAction:proceedAction];
[alert addAction:proceedAction];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
}
@ -225,12 +225,10 @@ NS_ASSUME_NONNULL_BEGIN
failure:^(NSError *error) {
OWSLogError(@"Failed to provision device with error: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:[self retryAlertControllerWithError:error
retryBlock:^{
[self provisionWithParser:parser];
}]
animated:YES
completion:nil];
[self presentAlert:[self retryAlertControllerWithError:error
retryBlock:^{
[self provisionWithParser:parser];
}]];
});
}];
}

View File

@ -174,23 +174,23 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
NSString *alertTitle = NSLocalizedString(
@"DEVICE_LIST_UPDATE_FAILED_TITLE", @"Alert title that can occur when viewing device manager.");
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:alertTitle
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *retryAction = [UIAlertAction actionWithTitle:[CommonStrings retryButton]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self refreshDevices];
}];
[alertController addAction:retryAction];
[alert addAction:retryAction];
UIAlertAction *dismissAction =
[UIAlertAction actionWithTitle:CommonStrings.dismissButton style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:dismissAction];
[alert addAction:dismissAction];
[self.refreshControl endRefreshing];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
- (void)deviceListUpdateModifiedDeviceList:(NSNotification *)notification
@ -390,11 +390,11 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
NSString *confirmationTitle = [NSString stringWithFormat:confirmationTitleFormat, device.displayName];
NSString *confirmationMessage
= NSLocalizedString(@"UNLINK_CONFIRMATION_ALERT_BODY", @"Alert message to confirm unlinking a device");
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:confirmationTitle
message:confirmationMessage
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:confirmationTitle
message:confirmationMessage
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[OWSAlerts cancelAction]];
UIAlertAction *unlinkAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"UNLINK_ACTION", "button title for unlinking a device")
@ -404,10 +404,10 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
[self unlinkDevice:device success:successCallback];
});
}];
[alertController addAction:unlinkAction];
[alert addAction:unlinkAction];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
});
}
@ -418,7 +418,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
failure:^(NSError *error) {
NSString *title = NSLocalizedString(
@"UNLINKING_FAILED_ALERT_TITLE", @"Alert title when unlinking device fails");
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:title
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
@ -429,11 +429,11 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
handler:^(UIAlertAction *aaction) {
[self unlinkDevice:device success:successCallback];
}];
[alertController addAction:retryAction];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:retryAction];
[alert addAction:[OWSAlerts cancelAction]];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
});
}];
}

View File

@ -430,7 +430,7 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
}];
[alert addAction:deleteAction];
[self presentAlert:alert animated:YES];
[self presentAlert:alert];
}
- (void)deleteThreadsAndMessages
@ -568,7 +568,7 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
}
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentAlert:alert animated:YES];
[fromViewController presentAlert:alert];
}
- (NSString *)formatScreenLockTimeout:(NSInteger)value useShortFormat:(BOOL)useShortFormat

View File

@ -30,11 +30,10 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssertIsOnMainThread();
OWSAssertDebug(self.delegate);
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:self.delegate.avatarActionSheetTitle
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[OWSAlerts cancelAction]];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:self.delegate.avatarActionSheetTitle
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[OWSAlerts cancelAction]];
UIAlertAction *takePictureAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"MEDIA_FROM_CAMERA_BUTTON", @"media picker option to take photo or video")
@ -42,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *_Nonnull action) {
[self takePicture];
}];
[actionSheetController addAction:takePictureAction];
[actionSheet addAction:takePictureAction];
UIAlertAction *choosePictureAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"MEDIA_FROM_LIBRARY_BUTTON", @"media picker option to choose from library")
@ -50,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *_Nonnull action) {
[self chooseFromLibrary];
}];
[actionSheetController addAction:choosePictureAction];
[actionSheet addAction:choosePictureAction];
if (self.delegate.hasClearAvatarAction) {
UIAlertAction *clearAction = [UIAlertAction actionWithTitle:self.delegate.clearAvatarActionLabel
@ -58,10 +57,10 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *_Nonnull action) {
[self.delegate clearAvatar];
}];
[actionSheetController addAction:clearAction];
[actionSheet addAction:clearAction];
}
[self.delegate.fromViewController presentViewController:actionSheetController animated:true completion:nil];
[self.delegate.fromViewController presentAlert:actionSheet];
}
- (void)takePicture

View File

@ -458,7 +458,7 @@ class CallViewController: OWSViewController, CallObserver, CallServiceObserver,
// Note: It's critical that we present from this view and
// not the "frontmost view controller" since this view may
// reside on a separate window.
self.present(actionSheetController, animated: true)
presentAlert(actionSheetController)
}
func updateAvatarImage() {

View File

@ -108,7 +108,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
})
actionSheet.addAction(OWSAlerts.cancelAction)
fromViewController.present(actionSheet, animated: true)
fromViewController.presentAlert(actionSheet)
}
private func showPhoneNumberPicker(phoneNumbers: [String], fromViewController: UIViewController, completion :@escaping ((String) -> Void)) {
@ -123,7 +123,7 @@ public class ContactShareViewHelper: NSObject, CNContactViewControllerDelegate {
}
actionSheet.addAction(OWSAlerts.cancelAction)
fromViewController.present(actionSheet, animated: true)
fromViewController.presentAlert(actionSheet)
}
func didPressCreateNewContact(contactShare: ContactShareViewModel, fromViewController: UIViewController) {

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -566,7 +566,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
UIPasteboard.general.string = phoneNumber.phoneNumber
})
actionSheet.addAction(OWSAlerts.cancelAction)
present(actionSheet, animated: true)
presentAlert(actionSheet)
}
func callPhoneNumberWithSystemCall(phoneNumber: OWSContactPhoneNumber) {
@ -594,7 +594,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
UIPasteboard.general.string = email.email
})
actionSheet.addAction(OWSAlerts.cancelAction)
present(actionSheet, animated: true)
presentAlert(actionSheet)
}
func openEmailInEmailApp(email: OWSContactEmail) {
@ -624,7 +624,7 @@ class ContactViewController: OWSViewController, ContactShareViewHelperDelegate {
UIPasteboard.general.string = strongSelf.formatAddressForQuery(address: address)
})
actionSheet.addAction(OWSAlerts.cancelAction)
present(actionSheet, animated: true)
presentAlert(actionSheet)
}
func openAddressInMaps(address: OWSContactAddress) {

View File

@ -189,7 +189,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView
})
alert.addAction(openSettingsAction)
self.present(alert, animated: true, completion: nil)
self.presentAlert(alert)
case CNAuthorizationStatus.notDetermined:
//This case means the user is prompted for the first time for allowing contacts

View File

@ -1060,10 +1060,9 @@ typedef enum : NSUInteger {
}
BOOL hasMultiple = noLongerVerifiedRecipientIds.count > 1;
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
__weak ConversationViewController *weakSelf = self;
UIAlertAction *verifyAction = [UIAlertAction
@ -1077,17 +1076,17 @@ typedef enum : NSUInteger {
handler:^(UIAlertAction *action) {
[weakSelf showNoLongerVerifiedUI];
}];
[actionSheetController addAction:verifyAction];
[actionSheet addAction:verifyAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.dismissButton
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *action) {
[weakSelf resetVerificationStateToDefault];
}];
[actionSheetController addAction:dismissAction];
[actionSheet addAction:dismissAction];
[self dismissKeyBoard];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
}
@ -1777,19 +1776,18 @@ typedef enum : NSUInteger {
- (void)handleUnsentMessageTap:(TSOutgoingMessage *)message
{
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:message.mostRecentFailureText
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:message.mostRecentFailureText
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
UIAlertAction *deleteMessageAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_DELETE_TITLE", @"")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[message remove];
}];
[actionSheetController addAction:deleteMessageAction];
[actionSheet addAction:deleteMessageAction];
UIAlertAction *resendMessageAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"SEND_AGAIN_BUTTON", @"")
@ -1801,10 +1799,10 @@ typedef enum : NSUInteger {
}];
}];
[actionSheetController addAction:resendMessageAction];
[actionSheet addAction:resendMessageAction];
[self dismissKeyBoard];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)tappedNonBlockingIdentityChangeForRecipientId:(nullable NSString *)signalIdParam
@ -1832,11 +1830,11 @@ typedef enum : NSUInteger {
NSString *alertMessage = [NSString
stringWithFormat:NSLocalizedString(@"CORRUPTED_SESSION_DESCRIPTION", @"ActionSheet title"), self.thread.name];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:alertMessage
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil
message:alertMessage
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[OWSAlerts cancelAction]];
UIAlertAction *resetSessionAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON", @"")
@ -1853,10 +1851,10 @@ typedef enum : NSUInteger {
[self.sessionResetJobQueue addContactThread:contactThread transaction:transaction];
}];
}];
[alertController addAction:resetSessionAction];
[alert addAction:resetSessionAction];
[self dismissKeyBoard];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
- (void)tappedInvalidIdentityKeyErrorMessage:(TSInvalidIdentityKeyErrorMessage *)errorMessage
@ -1865,12 +1863,11 @@ typedef enum : NSUInteger {
NSString *titleFormat = NSLocalizedString(@"SAFETY_NUMBERS_ACTIONSHEET_TITLE", @"Action sheet heading");
NSString *titleText = [NSString stringWithFormat:titleFormat, keyOwner];
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:titleText
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:titleText
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
UIAlertAction *showSafteyNumberAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"SHOW_SAFETY_NUMBER_ACTION", @"Action sheet item")
@ -1879,7 +1876,7 @@ typedef enum : NSUInteger {
OWSLogInfo(@"Remote Key Changed actions: Show fingerprint display");
[self showFingerprintWithRecipientId:errorMessage.theirSignalId];
}];
[actionSheetController addAction:showSafteyNumberAction];
[actionSheet addAction:showSafteyNumberAction];
UIAlertAction *acceptSafetyNumberAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"ACCEPT_NEW_IDENTITY_ACTION", @"Action sheet item")
@ -1900,10 +1897,10 @@ typedef enum : NSUInteger {
}
}];
[actionSheetController addAction:acceptSafetyNumberAction];
[actionSheet addAction:acceptSafetyNumberAction];
[self dismissKeyBoard];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)handleCallTap:(TSCall *)call
@ -1918,7 +1915,7 @@ typedef enum : NSUInteger {
TSContactThread *contactThread = (TSContactThread *)self.thread;
NSString *displayName = [self.contactsManager displayNameForPhoneIdentifier:contactThread.contactIdentifier];
UIAlertController *alertController = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:[CallStrings callBackAlertTitle]
message:[NSString stringWithFormat:[CallStrings callBackAlertMessageFormat], displayName]
preferredStyle:UIAlertControllerStyleAlert];
@ -1929,11 +1926,11 @@ typedef enum : NSUInteger {
handler:^(UIAlertAction *action) {
[weakSelf startAudioCall];
}];
[alertController addAction:callAction];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:callAction];
[alert addAction:[OWSAlerts cancelAction]];
[self dismissKeyBoard];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
#pragma mark - MessageActionsDelegate
@ -2191,10 +2188,10 @@ typedef enum : NSUInteger {
@"Embeds {{the unknown user's name or phone number}}."),
[BlockListUIUtils formatDisplayNameForAlertTitle:displayName]];
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
UIAlertAction *blockAction = [UIAlertAction
actionWithTitle:NSLocalizedString(
@ -2210,10 +2207,10 @@ typedef enum : NSUInteger {
[interaction removeWithTransaction:transaction];
}];
}];
[actionSheetController addAction:blockAction];
[actionSheet addAction:blockAction];
[self dismissKeyBoard];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)tappedAddToContactsOfferMessage:(OWSContactOffersInteraction *)interaction
@ -3393,10 +3390,10 @@ typedef enum : NSUInteger {
}
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
UIAlertAction *takeMediaAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"MEDIA_FROM_CAMERA_BUTTON", @"media picker option to take photo or video")
@ -3407,7 +3404,7 @@ typedef enum : NSUInteger {
UIImage *takeMediaImage = [UIImage imageNamed:@"actionsheet_camera_black"];
OWSAssertDebug(takeMediaImage);
[takeMediaAction setValue:takeMediaImage forKey:@"image"];
[actionSheetController addAction:takeMediaAction];
[actionSheet addAction:takeMediaAction];
UIAlertAction *chooseMediaAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"MEDIA_FROM_LIBRARY_BUTTON", @"media picker option to choose from library")
@ -3418,7 +3415,7 @@ typedef enum : NSUInteger {
UIImage *chooseMediaImage = [UIImage imageNamed:@"actionsheet_camera_roll_black"];
OWSAssertDebug(chooseMediaImage);
[chooseMediaAction setValue:chooseMediaImage forKey:@"image"];
[actionSheetController addAction:chooseMediaAction];
[actionSheet addAction:chooseMediaAction];
UIAlertAction *gifAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"SELECT_GIF_BUTTON", @"Label for 'select GIF to attach' action sheet button")
@ -3429,7 +3426,7 @@ typedef enum : NSUInteger {
UIImage *gifImage = [UIImage imageNamed:@"actionsheet_gif_black"];
OWSAssertDebug(gifImage);
[gifAction setValue:gifImage forKey:@"image"];
[actionSheetController addAction:gifAction];
[actionSheet addAction:gifAction];
UIAlertAction *chooseDocumentAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"MEDIA_FROM_DOCUMENT_PICKER_BUTTON",
@ -3441,7 +3438,7 @@ typedef enum : NSUInteger {
UIImage *chooseDocumentImage = [UIImage imageNamed:@"actionsheet_document_black"];
OWSAssertDebug(chooseDocumentImage);
[chooseDocumentAction setValue:chooseDocumentImage forKey:@"image"];
[actionSheetController addAction:chooseDocumentAction];
[actionSheet addAction:chooseDocumentAction];
if (kIsSendingContactSharesEnabled) {
UIAlertAction *chooseContactAction =
@ -3454,11 +3451,11 @@ typedef enum : NSUInteger {
UIImage *chooseContactImage = [UIImage imageNamed:@"actionsheet_contact"];
OWSAssertDebug(takeMediaImage);
[chooseContactAction setValue:chooseContactImage forKey:@"image"];
[actionSheetController addAction:chooseContactAction];
[actionSheet addAction:chooseContactAction];
}
[self dismissKeyBoard];
[self presentViewController:actionSheetController animated:true completion:nil];
[self presentAlert:actionSheet];
}
- (nullable NSIndexPath *)lastVisibleIndexPath

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "DebugUIBackup.h"
@ -153,19 +153,19 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSLogInfo(@"tryToImportBackup.");
UIAlertController *controller =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:@"Restore CloudKit Backup"
message:@"This will delete all of your database contents."
preferredStyle:UIAlertControllerStyleAlert];
[controller addAction:[UIAlertAction actionWithTitle:@"Restore"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[OWSBackup.sharedManager tryToImportBackup];
}]];
[controller addAction:[OWSAlerts cancelAction]];
[alert addAction:[UIAlertAction actionWithTitle:@"Restore"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[OWSBackup.sharedManager tryToImportBackup];
}]];
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:controller animated:YES completion:nil];
[fromViewController presentAlert:alert];
}
+ (void)logDatabaseSizeStats

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
@objc class DebugUIFileBrowser: OWSTableViewController {
@ -153,7 +153,7 @@
textField.text = strongSelf.fileURL.lastPathComponent
}
strongSelf.present(alert, animated: true)
strongSelf.presentAlert(alert)
},
OWSTableItem.disclosureItem(withText: "➡ Move") { [weak self] in
@ -198,7 +198,7 @@
textField.text = oldDirectory.path
}
strongSelf.present(alert, animated: true)
strongSelf.presentAlert(alert)
},
OWSTableItem.disclosureItem(withText: "❌ Delete") { [weak self] in
@ -233,7 +233,7 @@
alert.addAction(UIAlertAction(title: "Dismiss", style: .default))
strongSelf.present(alert, animated: true)
strongSelf.presentAlert(alert)
},
OWSTableItem.disclosureItem(withText: "🔒 Set File Protection") { [weak self] in
@ -273,7 +273,7 @@
}
actionSheet.addAction(OWSAlerts.cancelAction)
strongSelf.present(actionSheet, animated: true)
strongSelf.presentAlert(actionSheet)
}
]
@ -311,7 +311,7 @@
textField.placeholder = "File Name"
}
strongSelf.present(alert, animated: true)
strongSelf.presentAlert(alert)
}
managementItems.append(createFileItem)
@ -352,7 +352,7 @@
textField.placeholder = "Dir Name"
}
strongSelf.present(alert, animated: true)
strongSelf.presentAlert(alert)
}
managementItems.append(createDirItem)

View File

@ -462,7 +462,7 @@ NS_ASSUME_NONNULL_BEGIN
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:alert animated:YES completion:nil];
[fromViewController presentAlert:alert];
}
#pragma mark - Send Media
@ -2753,7 +2753,7 @@ NS_ASSUME_NONNULL_BEGIN
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:alert animated:YES completion:nil];
[fromViewController presentAlert:alert];
}
#pragma mark - Sequences

View File

@ -404,7 +404,7 @@ class GifPickerViewController: OWSViewController, UISearchBarDelegate, UICollect
strongSelf.dismiss(animated: true, completion: nil)
})
strongSelf.present(alert, animated: true, completion: nil)
strongSelf.presentAlert(alert)
}.retainUntilComplete()
}

View File

@ -1354,7 +1354,7 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) {
}]];
[alert addAction:[OWSAlerts cancelAction]];
[self presentViewController:alert animated:YES completion:nil];
[self presentAlert:alert];
}
- (void)deleteThread:(TSThread *)thread

View File

@ -177,7 +177,7 @@ class InviteFlow: NSObject, MFMessageComposeViewControllerDelegate, MFMailCompos
self.sendSMSTo(phoneNumbers: phoneNumbers)
}))
warning.addAction(OWSAlerts.cancelAction)
self.presentingViewController.present(warning, animated: true, completion: nil)
self.presentingViewController.presentAlert(warning)
} else {
self.sendSMSTo(phoneNumbers: phoneNumbers)
}

View File

@ -396,7 +396,7 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
actionSheet.addAction(OWSAlerts.cancelAction)
actionSheet.addAction(deleteAction)
self.present(actionSheet, animated: true)
self.presentAlert(actionSheet)
}
// MARK: MediaGalleryDataSourceDelegate

View File

@ -602,7 +602,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
actionSheet.addAction(deleteAction)
actionSheet.addAction(OWSAlerts.cancelAction)
present(actionSheet, animated: true)
presentAlert(actionSheet)
}
var footerBarBottomConstraint: NSLayoutConstraint!

View File

@ -748,10 +748,9 @@ NS_ASSUME_NONNULL_BEGIN
stringByAppendingString:NSLocalizedString(@"QUESTIONMARK_PUNCTUATION", @"")];
}
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRMATION_TITLE", @"")
message:confirmMessage
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRMATION_TITLE", @"")
message:confirmMessage
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"")
@ -765,8 +764,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}];
[alertController addAction:[OWSAlerts cancelAction]];
[alertController addAction:okAction];
[alert addAction:[OWSAlerts cancelAction]];
[alert addAction:okAction];
self.searchBar.text = @"";
[self searchTextDidChange];
@ -774,10 +773,10 @@ NS_ASSUME_NONNULL_BEGIN
if ([self presentedViewController]) {
[self dismissViewControllerAnimated:YES
completion:^{
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}];
} else {
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
}

View File

@ -559,7 +559,7 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
UIAlertController *controller = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:
NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_TITLE",
@"The alert title if user tries to exit the new group view without saving changes.")
@ -567,15 +567,15 @@ NS_ASSUME_NONNULL_BEGIN
NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE",
@"The alert message if user tries to exit the new group view without saving changes.")
preferredStyle:UIAlertControllerStyleAlert];
[controller
[alert
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON",
@"The label for the 'discard' button in alerts and action sheets.")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[self.navigationController popViewControllerAnimated:YES];
}]];
[controller addAction:[OWSAlerts cancelAction]];
[self presentViewController:controller animated:YES completion:nil];
[alert addAction:[OWSAlerts cancelAction]];
[self presentAlert:alert];
}
- (void)groupNameDidChange:(id)sender

View File

@ -316,7 +316,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
[alert addAction:discardAction];
[alert addAction:[OWSAlerts cancelAction]];
[self presentAlert:alert animated:YES];
[self presentAlert:alert];
}
- (void)avatarTapped

View File

@ -245,7 +245,7 @@ public class OnboardingController: NSObject {
style: .destructive) { (_) in
self.showProfileView(fromView: view)
})
view.present(alert, animated: true)
view.presentAlert(alert)
}
public func onboardingDidRequire2FAPin(viewController: UIViewController) {

View File

@ -490,7 +490,7 @@ public class OnboardingVerificationViewController: OnboardingBaseViewController
})
actionSheet.addAction(OWSAlerts.cancelAction)
self.present(actionSheet, animated: true)
self.presentAlert(actionSheet)
}
private func tryToVerify() {

View File

@ -76,6 +76,6 @@ public class RegistrationController: NSObject {
// style: .destructive) { (_) in
// self.showProfileView(fromView: view)
// })
// view.present(alert, animated: true)
// view.presentAlert(alert)
// }
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -62,7 +62,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
comment: "Action sheet body presented when a user's SN has recently changed. Embeds {{contact's name or phone number}}")
let body = String(format: bodyFormat, displayName)
let actionSheetController = UIAlertController(title: title, message: body, preferredStyle: .actionSheet)
let actionSheet = UIAlertController(title: title, message: body, preferredStyle: .actionSheet)
let confirmAction = UIAlertAction(title: confirmationText, style: .default) { _ in
Logger.info("Confirmed identity: \(untrustedIdentity)")
@ -74,7 +74,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
}
}
}
actionSheetController.addAction(confirmAction)
actionSheet.addAction(confirmAction)
let showSafetyNumberAction = UIAlertAction(title: NSLocalizedString("VERIFY_PRIVACY", comment: "Label for button or row which allows users to verify the safety number of another user."), style: .default) { _ in
Logger.info("Opted to show Safety Number for identity: \(untrustedIdentity)")
@ -85,7 +85,7 @@ public class SafetyNumberConfirmationAlert: NSObject {
completion: { completion(false) })
}
actionSheetController.addAction(showSafetyNumberAction)
actionSheet.addAction(showSafetyNumberAction)
// We can't use the default `OWSAlerts.cancelAction` because we need to specify that the completion
// handler is called.
@ -93,11 +93,11 @@ public class SafetyNumberConfirmationAlert: NSObject {
Logger.info("user canceled.")
completion(false)
}
actionSheetController.addAction(cancelAction)
actionSheet.addAction(cancelAction)
beforePresentationHandler?()
UIApplication.shared.frontmostViewController?.present(actionSheetController, animated: true)
UIApplication.shared.frontmostViewController?.presentAlert(actionSheet)
return true
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "FingerprintViewScanController.h"
@ -177,10 +177,10 @@ NS_ASSUME_NONNULL_BEGIN
NSString *descriptionFormat = NSLocalizedString(
@"SUCCESSFUL_VERIFICATION_DESCRIPTION", @"Alert body after verifying privacy with {{other user's name}}");
NSString *successDescription = [NSString stringWithFormat:descriptionFormat, contactName];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:successTitle
message:successDescription
preferredStyle:UIAlertControllerStyleAlert];
[alertController
UIAlertController *alert = [UIAlertController alertControllerWithTitle:successTitle
message:successDescription
preferredStyle:UIAlertControllerStyleAlert];
[alert
addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"FINGERPRINT_SCAN_VERIFY_BUTTON",
@"Button that marks user as verified after a successful fingerprint scan.")
@ -198,9 +198,9 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *action) {
[viewController dismissViewControllerAnimated:true completion:nil];
}];
[alertController addAction:dismissAction];
[alert addAction:dismissAction];
[viewController presentViewController:alertController animated:YES completion:nil];
[viewController presentAlert:alert];
}
+ (void)showVerificationFailedWithError:(NSError *)error
@ -220,21 +220,21 @@ NS_ASSUME_NONNULL_BEGIN
failureTitle = NSLocalizedString(@"FAILED_VERIFICATION_TITLE", @"alert title");
} // else no title. We don't want to show a big scary "VERIFICATION FAILED" when it's just user error.
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:failureTitle
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:failureTitle
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
if (retryBlock) {
[alertController addAction:[UIAlertAction actionWithTitle:[CommonStrings retryButton]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
retryBlock();
}]];
[alert addAction:[UIAlertAction actionWithTitle:[CommonStrings retryButton]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
retryBlock();
}]];
}
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[OWSAlerts cancelAction]];
[viewController presentViewController:alertController animated:YES completion:nil];
[viewController presentAlert:alert];
OWSLogWarn(@"%@ Identity verification failed with error: %@", tag, error);
}

View File

@ -1078,7 +1078,7 @@ const CGFloat kIconViewLength = 24;
- (void)didTapLeaveGroup
{
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRM_LEAVE_GROUP_TITLE", @"Alert title")
message:NSLocalizedString(@"CONFIRM_LEAVE_GROUP_DESCRIPTION", @"Alert body")
preferredStyle:UIAlertControllerStyleAlert];
@ -1089,10 +1089,10 @@ const CGFloat kIconViewLength = 24;
handler:^(UIAlertAction *_Nonnull action) {
[self leaveGroup];
}];
[alertController addAction:leaveAction];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:leaveAction];
[alert addAction:[OWSAlerts cancelAction]];
[self presentViewController:alertController animated:YES completion:nil];
[self presentAlert:alert];
}
- (BOOL)hasLeftGroup
@ -1220,10 +1220,9 @@ const CGFloat kIconViewLength = 24;
@"MUTE_BEHAVIOR_EXPLANATION", @"An explanation of the consequences of muting a thread.");
}
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
__weak OWSConversationSettingsViewController *weakSelf = self;
if (self.thread.isMuted) {
@ -1233,10 +1232,10 @@ const CGFloat kIconViewLength = 24;
handler:^(UIAlertAction *_Nonnull ignore) {
[weakSelf setThreadMutedUntilDate:nil];
}];
[actionSheetController addAction:action];
[actionSheet addAction:action];
} else {
#ifdef DEBUG
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_MINUTE_ACTION",
@"Label for button to mute a thread for a minute.")
style:UIAlertActionStyleDestructive
@ -1253,7 +1252,7 @@ const CGFloat kIconViewLength = 24;
[weakSelf setThreadMutedUntilDate:mutedUntilDate];
}]];
#endif
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_HOUR_ACTION",
@"Label for button to mute a thread for a hour.")
style:UIAlertActionStyleDestructive
@ -1269,7 +1268,7 @@ const CGFloat kIconViewLength = 24;
options:0];
[weakSelf setThreadMutedUntilDate:mutedUntilDate];
}]];
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_DAY_ACTION",
@"Label for button to mute a thread for a day.")
style:UIAlertActionStyleDestructive
@ -1285,7 +1284,7 @@ const CGFloat kIconViewLength = 24;
options:0];
[weakSelf setThreadMutedUntilDate:mutedUntilDate];
}]];
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_WEEK_ACTION",
@"Label for button to mute a thread for a week.")
style:UIAlertActionStyleDestructive
@ -1301,7 +1300,7 @@ const CGFloat kIconViewLength = 24;
options:0];
[weakSelf setThreadMutedUntilDate:mutedUntilDate];
}]];
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_YEAR_ACTION",
@"Label for button to mute a thread for a year.")
style:UIAlertActionStyleDestructive
@ -1319,9 +1318,9 @@ const CGFloat kIconViewLength = 24;
}]];
}
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)setThreadMutedUntilDate:(nullable NSDate *)value

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "ShowGroupMembersViewController.h"
@ -213,7 +213,7 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssertIsOnMainThread();
UIAlertController *actionSheetController = [UIAlertController
UIAlertController *actionSheet = [UIAlertController
alertControllerWithTitle:nil
message:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED_ALERT_MESSAGE",
@"Label for the 'reset all no-longer-verified group members' confirmation alert.")
@ -225,10 +225,10 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *_Nonnull action) {
[weakSelf resetAllNoLongerVerified];
}];
[actionSheetController addAction:verifyAction];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:verifyAction];
[actionSheet addAction:[OWSAlerts cancelAction]];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)resetAllNoLongerVerified
@ -275,7 +275,7 @@ NS_ASSUME_NONNULL_BEGIN
ContactsViewHelper *helper = self.contactsViewHelper;
SignalAccount *_Nullable signalAccount = [helper fetchSignalAccountForRecipientId:recipientId];
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
if (self.contactsViewHelper.contactsManager.supportsContactEditing) {
@ -283,19 +283,18 @@ NS_ASSUME_NONNULL_BEGIN
? NSLocalizedString(@"GROUP_MEMBERS_VIEW_CONTACT_INFO", @"Button label for the 'show contact info' button")
: NSLocalizedString(
@"GROUP_MEMBERS_ADD_CONTACT_INFO", @"Button label to add information to an unknown contact");
[actionSheetController addAction:[UIAlertAction actionWithTitle:contactInfoTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self
showContactInfoViewForRecipientId:recipientId];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:contactInfoTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self showContactInfoViewForRecipientId:recipientId];
}]];
}
BOOL isBlocked;
if (signalAccount) {
isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) {
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
@"Button label for the 'unblock' button")
style:UIAlertActionStyleDefault
@ -310,7 +309,7 @@ NS_ASSUME_NONNULL_BEGIN
}];
}]];
} else {
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
@"Button label for the 'block' button")
style:UIAlertActionStyleDestructive
@ -328,7 +327,7 @@ NS_ASSUME_NONNULL_BEGIN
} else {
isBlocked = [helper isRecipientIdBlocked:recipientId];
if (isBlocked) {
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
@"Button label for the 'unblock' button")
style:UIAlertActionStyleDefault
@ -343,7 +342,7 @@ NS_ASSUME_NONNULL_BEGIN
}];
}]];
} else {
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
@"Button label for the 'block' button")
style:UIAlertActionStyleDestructive
@ -361,21 +360,20 @@ NS_ASSUME_NONNULL_BEGIN
}
if (!isBlocked) {
[actionSheetController
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_SEND_MESSAGE",
@"Button label for the 'send message to group member' button")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self showConversationViewForRecipientId:recipientId];
}]];
[actionSheetController
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_CALL",
@"Button label for the 'call group member' button")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self callMember:recipientId];
}]];
[actionSheetController
[actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_CALL",
@"Button label for the 'call group member' button")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self callMember:recipientId];
}]];
[actionSheet
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"VERIFY_PRIVACY",
@"Label for button or row which allows users to verify the "
@"safety number of another user.")
@ -385,9 +383,9 @@ NS_ASSUME_NONNULL_BEGIN
}]];
}
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
[self presentViewController:actionSheetController animated:YES completion:nil];
[self presentAlert:actionSheet];
}
- (void)showContactInfoViewForRecipientId:(NSString *)recipientId

View File

@ -415,32 +415,31 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
UIAlertController *controller = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:NSLocalizedString(@"EDIT_GROUP_VIEW_UNSAVED_CHANGES_TITLE",
@"The alert title if user tries to exit update group view without saving changes.")
message:
NSLocalizedString(@"EDIT_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE",
@"The alert message if user tries to exit update group view without saving changes.")
preferredStyle:UIAlertControllerStyleAlert];
[controller
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_SAVE",
@"The label for the 'save' button in action sheets.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
OWSAssertDebug(self.conversationSettingsViewDelegate);
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_SAVE",
@"The label for the 'save' button in action sheets.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
OWSAssertDebug(self.conversationSettingsViewDelegate);
[self updateGroup];
[self updateGroup];
[self.conversationSettingsViewDelegate
popAllConversationSettingsViewsWithCompletion:nil];
}]];
[controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DONT_SAVE",
@"The label for the 'don't save' button in action sheets.")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[self.navigationController popViewControllerAnimated:YES];
}]];
[self presentViewController:controller animated:YES completion:nil];
[self.conversationSettingsViewDelegate
popAllConversationSettingsViewsWithCompletion:nil];
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DONT_SAVE",
@"The label for the 'don't save' button in action sheets.")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[self.navigationController popViewControllerAnimated:YES];
}]];
[self presentAlert:alert];
}
- (void)updateGroupPressed

View File

@ -27,10 +27,10 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)showReregistrationUIFromViewController:(UIViewController *)fromViewController
{
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheetController
[actionSheet
addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEREGISTRATION_REREGISTER_WITH_SAME_PHONE_NUMBER",
@"Label for button that lets users re-register using the same phone number.")
@ -39,9 +39,9 @@ NS_ASSUME_NONNULL_BEGIN
[RegistrationUtils reregisterWithFromViewController:fromViewController];
}]];
[actionSheetController addAction:[OWSAlerts cancelAction]];
[actionSheet addAction:[OWSAlerts cancelAction]];
[fromViewController presentViewController:actionSheetController animated:YES completion:nil];
[fromViewController presentAlert:actionSheet];
}
+ (void)reregisterWithFromViewController:(UIViewController *)fromViewController

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "UIViewController+Permissions.h"
@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
}];
[alert addAction:dismissAction];
[self presentViewController:alert animated:YES completion:nil];
[self presentAlert:alert];
} else if (status == AVAuthorizationStatusAuthorized) {
callback(YES);
} else if (status == AVAuthorizationStatusNotDetermined) {
@ -107,7 +107,7 @@ NS_ASSUME_NONNULL_BEGIN
}];
[alert addAction:dismissAction];
[self presentViewController:alert animated:YES completion:nil];
[self presentAlert:alert];
});
};

View File

@ -321,7 +321,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)presentMissingContactAccessAlertControllerFromViewController:(UIViewController *)viewController
{
UIAlertController *alertController = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:NSLocalizedString(@"EDIT_CONTACT_WITHOUT_CONTACTS_PERMISSION_ALERT_TITLE", comment
: @"Alert title for when the user has just tried to edit a "
@"contacts after declining to give Signal contacts "
@ -332,18 +332,17 @@ NS_ASSUME_NONNULL_BEGIN
@"permissions")
preferredStyle:UIAlertControllerStyleAlert];
[alertController
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"AB_PERMISSION_MISSING_ACTION_NOT_NOW",
@"Button text to dismiss missing contacts permission alert")
style:UIAlertActionStyleCancel
handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"AB_PERMISSION_MISSING_ACTION_NOT_NOW",
@"Button text to dismiss missing contacts permission alert")
style:UIAlertActionStyleCancel
handler:nil]];
UIAlertAction *_Nullable openSystemSettingsAction = CurrentAppContext().openSystemSettingsAction;
if (openSystemSettingsAction) {
[alertController addAction:openSystemSettingsAction];
[alert addAction:openSystemSettingsAction];
}
[viewController presentViewController:alertController animated:YES completion:nil];
[viewController presentAlert:alert];
}
- (void)presentContactViewControllerForRecipientId:(NSString *)recipientId

View File

@ -130,9 +130,14 @@ extension UIView {
// MARK: -
extension UIViewController {
public extension UIViewController {
@objc
public func presentAlert(_ alert: UIAlertController, animated: Bool = true) {
public func presentAlert(_ alert: UIAlertController) {
self.presentAlert(alert, animated: true)
}
@objc
public func presentAlert(_ alert: UIAlertController, animated: Bool) {
self.present(alert,
animated: animated,
completion: {

View File

@ -6,6 +6,7 @@
#import "Environment.h"
#import "OWSDatabaseMigrationRunner.h"
#import "SignalKeyingStorage.h"
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalServiceKit/AppContext.h>
#import <SignalServiceKit/AppVersion.h>
#import <SignalServiceKit/NSUserDefaults+OWS.h>
@ -67,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
if ([self isVersion:previousVersion atLeast:@"1.0.2" andLessThan:@"2.0"]) {
OWSLogError(@"Migrating from RedPhone no longer supported. Quitting.");
// Not translating these as so few are affected.
UIAlertController *alertController = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"You must reinstall Signal"
message:
@"Sorry, your installation is too old for us to update. You'll have to start fresh."
@ -78,9 +79,9 @@ NS_ASSUME_NONNULL_BEGIN
handler:^(UIAlertAction *_Nonnull action) {
OWSFail(@"Obsolete install.");
}];
[alertController addAction:quitAction];
[alert addAction:quitAction];
[CurrentAppContext().frontmostViewController presentViewController:alertController animated:YES completion:nil];
[CurrentAppContext().frontmostViewController presentAlert:alert];
}
if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [self.tsAccountManager isRegistered]) {

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "OWSProfileManager.h"
@ -1467,20 +1467,20 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error);
{
OWSAssertIsOnMainThread();
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
NSString *shareTitle = NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE",
@"Button to confirm that user wants to share their profile with a user or group.");
[alertController addAction:[UIAlertAction actionWithTitle:shareTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self userAddedThreadToProfileWhitelist:thread];
successHandler();
}]];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[UIAlertAction actionWithTitle:shareTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *_Nonnull action) {
[self userAddedThreadToProfileWhitelist:thread];
successHandler();
}]];
[alert addAction:[OWSAlerts cancelAction]];
[fromViewController presentViewController:alertController animated:YES completion:nil];
[fromViewController presentAlert:alert];
}
- (void)userAddedThreadToProfileWhitelist:(TSThread *)thread

View File

@ -110,7 +110,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
@"blocked user's name or phone number}}."),
[self formatDisplayNameForAlertTitle:displayName]];
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:title
message:NSLocalizedString(@"BLOCK_USER_BEHAVIOR_EXPLANATION",
@"An explanation of the consequences of blocking another user.")
@ -131,7 +131,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
}];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block");
[actionSheetController addAction:blockAction];
[actionSheet addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
style:UIAlertActionStyleCancel
@ -141,8 +141,8 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentAlert:actionSheetController animated:YES];
[actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet];
}
+ (void)showBlockGroupActionSheet:(TSGroupThread *)groupThread
@ -161,7 +161,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
@"A format for the 'block group' action sheet title. Embeds the {{group name}}."),
[self formatDisplayNameForAlertTitle:groupName]];
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:title
message:NSLocalizedString(@"BLOCK_GROUP_BEHAVIOR_EXPLANATION",
@"An explanation of the consequences of blocking a group.")
@ -182,7 +182,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
}];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block");
[actionSheetController addAction:blockAction];
[actionSheet addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
style:UIAlertActionStyleCancel
@ -192,8 +192,8 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentAlert:actionSheetController animated:YES];
[actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet];
}
+ (void)blockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -330,7 +330,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
@"A format for the 'unblock conversation' action sheet title. Embeds the {{conversation title}}."),
[self formatDisplayNameForAlertTitle:displayName]];
UIAlertController *actionSheetController =
UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *unblockAction = [UIAlertAction
@ -348,7 +348,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
}];
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock");
[actionSheetController addAction:unblockAction];
[actionSheet addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
style:UIAlertActionStyleCancel
@ -358,8 +358,8 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentAlert:actionSheetController animated:YES];
[actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet];
}
+ (void)unblockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -402,10 +402,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
NSString *message = NSLocalizedString(
@"BLOCK_LIST_UNBLOCK_GROUP_BODY", @"Action sheet body when confirming you want to unblock a group");
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *unblockAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button")
@ -422,7 +421,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
}];
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock");
[actionSheetController addAction:unblockAction];
[actionSheet addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
style:UIAlertActionStyleCancel
@ -432,8 +431,8 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentAlert:actionSheetController animated:YES];
[actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet];
}
+ (void)unblockGroup:(TSGroupModel *)groupModel
@ -478,7 +477,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
handler:completionBlock];
okAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok");
[alert addAction:okAction];
[fromViewController presentAlert:alert animated:YES];
[fromViewController presentAlert:alert];
}
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName