Use UIAlertController when available

This commit is contained in:
Andreas Linde
2015-07-22 15:37:51 +02:00
parent 29acf3ef05
commit cb00038222
9 changed files with 681 additions and 168 deletions

View File

@@ -291,12 +291,33 @@
if(succeeded) { if(succeeded) {
//controller should dismiss us shortly.. //controller should dismiss us shortly..
} else { } else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:error.localizedDescription // requires iOS 8
delegate:nil id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
cancelButtonTitle:BITHockeyLocalizedString(@"OK") if (uialertcontrollerClass) {
otherButtonTitles:nil]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
[alertView show]; message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"OK")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:error.localizedDescription
delegate:nil
cancelButtonTitle:BITHockeyLocalizedString(@"OK")
otherButtonTitles:nil];
[alertView show];
#pragma clang diagnostic pop
}
typeof(self) strongSelf = weakSelf; typeof(self) strongSelf = weakSelf;
[strongSelf setLoginUIEnabled:YES]; [strongSelf setLoginUIEnabled:YES];
} }

View File

@@ -256,13 +256,38 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
} else { } else {
BITHockeyLog(@"Validation failed with error: %@", error); BITHockeyLog(@"Validation failed with error: %@", error);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil // requires iOS 8
message:error.localizedDescription id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") __weak typeof(self) weakSelf = self;
otherButtonTitles:nil];
[alertView setTag:0]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
[alertView show]; message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf validate];
}];
[alertController addAction:okAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:error.localizedDescription
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alertView setTag:0];
[alertView show];
#pragma clang diagnostic pop
}
} }
}]; }];
} }
@@ -906,11 +931,16 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
} }
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (alertView.tag == 0) { if (alertView.tag == 0) {
[self validate]; [self validate];
} }
} }
#pragma clang diagnostic pop
@end @end
#endif #endif

View File

@@ -1045,17 +1045,63 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
if (_alertViewHandler) { if (_alertViewHandler) {
_alertViewHandler(); _alertViewHandler();
} else { } else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName] // requires iOS 8
message:alertDescription id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"CrashDontSendReport") __weak typeof(self) weakSelf = self;
otherButtonTitles:BITHockeyLocalizedString(@"CrashSendReport"), nil];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName]
if (self.shouldShowAlwaysButton) { message:alertDescription
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways")]; preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashDontSendReport")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf handleUserInput:BITCrashManagerUserInputDontSend withUserProvidedMetaData:nil];
}];
[alertController addAction:cancelAction];
UIAlertAction *sendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReport")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf handleUserInput:BITCrashManagerUserInputSend withUserProvidedMetaData:nil];
}];
[alertController addAction:sendAction];
if (self.shouldShowAlwaysButton) {
UIAlertAction *alwaysSendAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf handleUserInput:BITCrashManagerUserInputAlwaysSend withUserProvidedMetaData:nil];
}];
[alertController addAction:alwaysSendAction];
}
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName]
message:alertDescription
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"CrashDontSendReport")
otherButtonTitles:BITHockeyLocalizedString(@"CrashSendReport"), nil];
if (self.shouldShowAlwaysButton) {
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"CrashSendReportAlways")];
}
[alertView show];
#pragma clang diagnostic pop
} }
[alertView show];
} }
} else { } else {
[self approveLatestCrashReport]; [self approveLatestCrashReport];
@@ -1451,6 +1497,8 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
#pragma mark - UIAlertView Delegate #pragma mark - UIAlertView Delegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
switch (buttonIndex) { switch (buttonIndex) {
case 0: case 0:
@@ -1464,8 +1512,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
break; break;
} }
} }
#pragma clang diagnostic pop
#pragma mark - Networking #pragma mark - Networking

View File

@@ -536,6 +536,47 @@
self.selectedAttachmentIndex = (self.attachmentScrollViewImageViews.count - index - 1); self.selectedAttachmentIndex = (self.attachmentScrollViewImageViews.count - index - 1);
// requires iOS 8
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
if (uialertcontrollerClass) {
__weak typeof(self) weakSelf = self;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentCancel")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf cancelAction];
}];
[alertController addAction:cancelAction];
UIAlertAction *editAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentEdit")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf editAction];
}];
[alertController addAction:editAction];
UIAlertAction *deleteAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentDelete")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf deleteAction];
}];
[alertController addAction:deleteAction];
[self presentViewController:alertController animated:YES completion:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle: nil UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle: nil
delegate: self delegate: self
cancelButtonTitle: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentCancel") cancelButtonTitle: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentCancel")
@@ -543,7 +584,9 @@
otherButtonTitles: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentEdit"), nil]; otherButtonTitles: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentEdit"), nil];
[actionSheet showFromRect: sender.frame inView: self.attachmentScrollView animated: YES]; [actionSheet showFromRect: sender.frame inView: self.attachmentScrollView animated: YES];
#pragma clang diagnostic push
}
_actionSheetVisible = YES; _actionSheetVisible = YES;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.textView resignFirstResponder]; [self.textView resignFirstResponder];
@@ -587,38 +630,49 @@
#pragma mark - UIActionSheet Delegate #pragma mark - UIActionSheet Delegate
- (void)deleteAction {
if (self.selectedAttachmentIndex != NSNotFound){
UIButton *imageButton = self.attachmentScrollViewImageViews[self.selectedAttachmentIndex];
BITFeedbackMessageAttachment *attachment = self.imageAttachments[self.selectedAttachmentIndex];
[attachment deleteContents]; // mandatory call to delete the files associated.
[self.imageAttachments removeObject:attachment];
[self.attachments removeObject:attachment];
[imageButton removeFromSuperview];
[self.attachmentScrollViewImageViews removeObject:imageButton];
}
self.selectedAttachmentIndex = NSNotFound;
[self refreshAttachmentScrollview];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.textView becomeFirstResponder];
}
}
- (void)editAction {
if (self.selectedAttachmentIndex != NSNotFound){
BITFeedbackMessageAttachment *attachment = self.imageAttachments[self.selectedAttachmentIndex];
BITImageAnnotationViewController *annotationEditor = [[BITImageAnnotationViewController alloc ] init];
annotationEditor.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:annotationEditor];
annotationEditor.image = attachment.imageRepresentation;
[self presentViewController:navController animated:YES completion:nil];
}
}
- (void)cancelAction {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.textView becomeFirstResponder];
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == [actionSheet destructiveButtonIndex]) { if (buttonIndex == [actionSheet destructiveButtonIndex]) {
[self deleteAction];
if (self.selectedAttachmentIndex != NSNotFound){
UIButton *imageButton = self.attachmentScrollViewImageViews[self.selectedAttachmentIndex];
BITFeedbackMessageAttachment *attachment = self.imageAttachments[self.selectedAttachmentIndex];
[attachment deleteContents]; // mandatory call to delete the files associated.
[self.imageAttachments removeObject:attachment];
[self.attachments removeObject:attachment];
[imageButton removeFromSuperview];
[self.attachmentScrollViewImageViews removeObject:imageButton];
}
self.selectedAttachmentIndex = NSNotFound;
[self refreshAttachmentScrollview];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.textView becomeFirstResponder];
}
} else if (buttonIndex != [actionSheet cancelButtonIndex]) { } else if (buttonIndex != [actionSheet cancelButtonIndex]) {
if (self.selectedAttachmentIndex != NSNotFound){ [self editAction];
BITFeedbackMessageAttachment *attachment = self.imageAttachments[self.selectedAttachmentIndex];
BITImageAnnotationViewController *annotationEditor = [[BITImageAnnotationViewController alloc ] init];
annotationEditor.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:annotationEditor];
annotationEditor.image = attachment.imageRepresentation;
[self presentViewController:navController animated:YES completion:nil];
}
} else { } else {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [self cancelAction];
[self.textView becomeFirstResponder];
}
} }
_actionSheetVisible = NO; _actionSheetVisible = NO;
} }

View File

@@ -287,25 +287,66 @@
} }
- (void)deleteAllMessagesAction:(id)sender { - (void)deleteAllMessagesAction:(id)sender {
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { // requires iOS 8
UIActionSheet *deleteAction = [[UIActionSheet alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle") id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel")
destructiveButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete")
otherButtonTitles:nil
];
[deleteAction setTag:0];
[deleteAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[deleteAction showInView:[self viewForShowingActionSheetOnPhone]];
} else {
UIAlertView *deleteAction = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages")
message:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle")
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel")
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete"), nil];
[deleteAction setTag:0]; NSString *title = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages");
[deleteAction show]; NSString *message = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle");
UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert;
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
controllerStyle = UIAlertControllerStyleActionSheet;
title = BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle");
message = nil;
}
__weak typeof(self) weakSelf = self;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message
preferredStyle:controllerStyle];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {}];
[alertController addAction:cancelAction];
UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf deleteAllMessages];
}];
[alertController addAction:deleteAction];
[self presentViewController:alertController animated:YES completion:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
UIActionSheet *deleteAction = [[UIActionSheet alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle")
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel")
destructiveButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete")
otherButtonTitles:nil
];
[deleteAction setTag:0];
[deleteAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[deleteAction showInView:[self viewForShowingActionSheetOnPhone]];
} else {
UIAlertView *deleteAction = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages")
message:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllTitle")
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllCancel")
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListDeleteAllDelete"), nil];
[deleteAction setTag:0];
[deleteAction show];
}
#pragma clang diagnostic pop
} }
} }
@@ -767,32 +808,77 @@
#pragma mark - BITAttributedLabelDelegate #pragma mark - BITAttributedLabelDelegate
- (void)attributedLabel:(BITAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url { - (void)attributedLabel:(BITAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) { // requires iOS 8
UIActionSheet *linkAction = [[UIActionSheet alloc] initWithTitle:[url absoluteString] id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel") UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert;
destructiveButtonTitle:nil if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil controllerStyle = UIAlertControllerStyleActionSheet;
]; }
[linkAction setTag:1];
[linkAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[linkAction showInView:[self viewForShowingActionSheetOnPhone]];
} else {
UIAlertView *linkAction = [[UIAlertView alloc] initWithTitle:[url absoluteString]
message:nil
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel")
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil
];
[linkAction setTag:1]; UIAlertController *linkAction = [UIAlertController alertControllerWithTitle:[url absoluteString]
[linkAction show]; message:nil
preferredStyle:controllerStyle];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {}];
[linkAction addAction:cancelAction];
UIAlertAction* openAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[url absoluteString]]];
}];
[linkAction addAction:openAction];
UIAlertAction* copyAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.URL = [NSURL URLWithString:[url absoluteString]];
}];
[linkAction addAction:copyAction];
[self presentViewController:linkAction animated:YES completion:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
UIActionSheet *linkAction = [[UIActionSheet alloc] initWithTitle:[url absoluteString]
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel")
destructiveButtonTitle:nil
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil
];
[linkAction setTag:1];
[linkAction setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[linkAction showInView:[self viewForShowingActionSheetOnPhone]];
} else {
UIAlertView *linkAction = [[UIAlertView alloc] initWithTitle:[url absoluteString]
message:nil
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCancel")
otherButtonTitles:BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionOpen"), BITHockeyLocalizedString(@"HockeyFeedbackListLinkActionCopy"), nil
];
[linkAction setTag:1];
[linkAction show];
}
#pragma clang diagnostic pop
} }
} }
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == alertView.cancelButtonIndex) { if (buttonIndex == alertView.cancelButtonIndex) {
return; return;
@@ -811,7 +897,7 @@
} }
} }
} }
#pragma clang diagnostic pop
#pragma mark - UIActionSheetDelegate #pragma mark - UIActionSheetDelegate

View File

@@ -1070,6 +1070,8 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// invoke the selected action from the action sheet for a location element // invoke the selected action from the action sheet for a location element
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
@@ -1079,6 +1081,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
[self showFeedbackListView]; [self showFeedbackListView];
} }
} }
#pragma clang diagnostic pop
#pragma mark - Observation Handling #pragma mark - Observation Handling

View File

@@ -97,7 +97,7 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
self.imageView.image = self.image; self.imageView.image = self.image;
self.imageView.contentMode = UIViewContentModeScaleToFill; self.imageView.contentMode = UIViewContentModeScaleToFill;
self.view.frame = UIScreen.mainScreen.applicationFrame; self.view.frame = UIScreen.mainScreen.bounds;
[self.view addSubview:self.imageView]; [self.view addSubview:self.imageView];
// Erm. // Erm.
@@ -113,13 +113,8 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
self.imageView.userInteractionEnabled = YES; self.imageView.userInteractionEnabled = YES;
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(discard:)]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(discard:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(save:)]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
#else
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Cancel.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(discard:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithImage:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) landscapeImagePhone:bit_imageNamed(@"Ok.png", BITHOCKEYSDK_BUNDLE) style:UIBarButtonItemStyleBordered target:self action:@selector(save:)];
#endif
self.view.autoresizesSubviews = NO; self.view.autoresizesSubviews = NO;
} }
@@ -364,7 +359,14 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
self.navigationController.navigationBar.alpha = 1.0; self.navigationController.navigationBar.alpha = 1.0;
} }
[[UIApplication sharedApplication] setStatusBarHidden:NO]; if ([self respondsToSelector:@selector(prefersStatusBarHidden)]) {
[self setNeedsStatusBarAppearanceUpdate];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] setStatusBarHidden:NO];
#pragma clang diagnostic pop
}
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
[self fitImageViewFrame]; [self fitImageViewFrame];
@@ -379,7 +381,14 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
self.navigationController.navigationBar.alpha = 0.0; self.navigationController.navigationBar.alpha = 0.0;
} }
[[UIApplication sharedApplication] setStatusBarHidden:YES]; if ([self respondsToSelector:@selector(prefersStatusBarHidden)]) {
[self setNeedsStatusBarAppearanceUpdate];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[[UIApplication sharedApplication] setStatusBarHidden:YES];
#pragma clang diagnostic pop
}
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
[self fitImageViewFrame]; [self fitImageViewFrame];

View File

@@ -417,13 +417,57 @@
if (!_updateAlertShowing) { if (!_updateAlertShowing) {
NSString *versionString = [NSString stringWithFormat:@"%@ %@", BITHockeyLocalizedString(@"UpdateVersion"), _newStoreVersion]; NSString *versionString = [NSString stringWithFormat:@"%@ %@", BITHockeyLocalizedString(@"UpdateVersion"), _newStoreVersion];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") // requires iOS 8
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString] id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore") __weak typeof(self) weakSelf = self;
otherButtonTitles:BITHockeyLocalizedString(@"UpdateRemindMe"), BITHockeyLocalizedString(@"UpdateShow"), nil
]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateAvailable")
[alertView show]; message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf ignoreAction];
}];
[alertController addAction:ignoreAction];
UIAlertAction *remindAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateRemindMe")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf remindAction];
}];
[alertController addAction:remindAction];
UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf showAction];
}];
[alertController addAction:showAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable")
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), versionString]
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore")
otherButtonTitles:BITHockeyLocalizedString(@"UpdateRemindMe"), BITHockeyLocalizedString(@"UpdateShow"), nil
];
[alertView show];
#pragma clang diagnostic pop
}
_updateAlertShowing = YES; _updateAlertShowing = YES;
} }
} }
@@ -442,28 +486,44 @@
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
// invoke the selected action from the action sheet for a location element - (void)ignoreAction {
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
_updateAlertShowing = NO; _updateAlertShowing = NO;
if (buttonIndex == [alertView cancelButtonIndex]) { [self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
// Ignore [self.userDefaults synchronize];
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion]; }
[self.userDefaults synchronize];
} else if (buttonIndex == [alertView firstOtherButtonIndex]) { - (void)remindAction {
// Remind button _updateAlertShowing = NO;
} else if (buttonIndex == [alertView firstOtherButtonIndex] + 1) { }
// Show button
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion]; - (void)showAction {
[self.userDefaults synchronize]; _updateAlertShowing = NO;
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
if (_appStoreURLString) { [self.userDefaults synchronize];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:_appStoreURLString]];
} else { if (_appStoreURLString) {
BITHockeyLog(@"WARNING: The app store page couldn't be opened, since we did not get a valid URL from the store API."); [[UIApplication sharedApplication] openURL:[NSURL URLWithString:_appStoreURLString]];
} } else {
BITHockeyLog(@"WARNING: The app store page couldn't be opened, since we did not get a valid URL from the store API.");
} }
} }
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// invoke the selected action from the action sheet for a location element
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == [alertView cancelButtonIndex]) {
[self ignoreAction];
} else if (buttonIndex == [alertView firstOtherButtonIndex]) {
// Remind button
[self remindAction];
} else if (buttonIndex == [alertView firstOtherButtonIndex] + 1) {
// Show button
[self showAction];
}
}
#pragma clang diagnostic pop
@end @end
#endif /* HOCKEYSDK_FEATURE_STORE_UPDATES */ #endif /* HOCKEYSDK_FEATURE_STORE_UPDATES */

View File

@@ -89,11 +89,32 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
// only show error if we enable that // only show error if we enable that
if (_showFeedback) { if (_showFeedback) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateError") // requires iOS 8
message:[error localizedDescription] id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:nil if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"OK") otherButtonTitles:nil]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateError")
[alert show]; message:[error localizedDescription]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[alertController addAction:okAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateError")
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alert show];
#pragma clang diagnostic pop
}
_showFeedback = NO; _showFeedback = NO;
} }
} }
@@ -520,28 +541,122 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
if ([self isUpdateManagerDisabled]) return; if ([self isUpdateManagerDisabled]) return;
if (!_updateAlertShowing) { if (!_updateAlertShowing) {
NSString *title = BITHockeyLocalizedString(@"UpdateAvailable");
NSString *message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]];
if ([self hasNewerMandatoryVersion]) { if ([self hasNewerMandatoryVersion]) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") // requires iOS 8
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]] id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:nil __weak typeof(self) weakSelf = self;
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), BITHockeyLocalizedString(@"UpdateInstall"), nil UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
]; message:message
[alertView setTag:BITUpdateAlertViewTagMandatoryUpdate]; preferredStyle:UIAlertControllerStyleAlert];
[alertView show];
UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
if (strongSelf.blockingView) {
[strongSelf.blockingView removeFromSuperview];
}
[strongSelf showUpdateView];
}];
[alertController addAction:showAction];
UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
(void)[strongSelf initiateAppDownload];
}];
[alertController addAction:installAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:self
cancelButtonTitle:nil
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), BITHockeyLocalizedString(@"UpdateInstall"), nil
];
[alertView setTag:BITUpdateAlertViewTagMandatoryUpdate];
[alertView show];
#pragma clang diagnostic pop
}
_updateAlertShowing = YES; _updateAlertShowing = YES;
} else { } else {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable") message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]];
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]]
delegate:self // requires iOS 8
cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore") id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), nil if (uialertcontrollerClass) {
]; __weak typeof(self) weakSelf = self;
if (self.isShowingDirectInstallOption) { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateInstall")]; message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ignoreAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateIgnore")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
if ([strongSelf expiryDateReached] && !strongSelf.blockingView) {
[strongSelf alertFallback:_blockingScreenMessage];
}
}];
[alertController addAction:ignoreAction];
UIAlertAction *showAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateShow")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
if (strongSelf.blockingView) {
[strongSelf.blockingView removeFromSuperview];
}
[strongSelf showUpdateView];
}];
[alertController addAction:showAction];
if (self.isShowingDirectInstallOption) {
UIAlertAction *installAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateInstall")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
(void)[strongSelf initiateAppDownload];
}];
[alertController addAction:installAction];
}
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore")
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), nil
];
if (self.isShowingDirectInstallOption) {
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateInstall")];
}
[alertView setTag:BITUpdateAlertViewTagDefaultUpdate];
[alertView show];
#pragma clang diagnostic pop
} }
[alertView setTag:BITUpdateAlertViewTagDefaultUpdate];
[alertView show];
_updateAlertShowing = YES; _updateAlertShowing = YES;
} }
} }
@@ -615,19 +730,53 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
// nag the user with neverending alerts if we cannot find out the window for presenting the covering sheet // nag the user with neverending alerts if we cannot find out the window for presenting the covering sheet
- (void)alertFallback:(NSString *)message { - (void)alertFallback:(NSString *)message {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil // requires iOS 8
message:message id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
delegate:self if (uialertcontrollerClass) {
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") __weak typeof(self) weakSelf = self;
otherButtonTitles:nil UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
]; message:message
preferredStyle:UIAlertControllerStyleAlert];
if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:_blockingScreenMessage]) {
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck")];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf alertFallback:_blockingScreenMessage];
}];
[alertController addAction:okAction];
if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:_blockingScreenMessage]) {
UIAlertAction *checkAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
[strongSelf checkForUpdateForExpiredVersion];
}];
[alertController addAction:checkAction];
}
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:self
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil
];
if (!self.disableUpdateCheckOptionWhenExpired && [message isEqualToString:_blockingScreenMessage]) {
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateButtonCheck")];
}
[alertView setTag:BITUpdateAlertViewTagNeverEndingAlertView];
[alertView show];
} }
[alertView setTag:BITUpdateAlertViewTagNeverEndingAlertView];
[alertView show];
} }
#pragma mark - RequestComments #pragma mark - RequestComments
@@ -741,8 +890,31 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
} }
#if TARGET_IPHONE_SIMULATOR #if TARGET_IPHONE_SIMULATOR
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateWarning") message:BITHockeyLocalizedString(@"UpdateSimulatorMessage") delegate:nil cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") otherButtonTitles:nil]; // requires iOS 8
[alert show]; id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
if (uialertcontrollerClass) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateWarning")
message:BITHockeyLocalizedString(@"UpdateSimulatorMessage")
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[alertController addAction:okAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateWarning")
message:BITHockeyLocalizedString(@"UpdateSimulatorMessage")
delegate:nil
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alert show];
#pragma clang diagnostic pop
}
return NO; return NO;
#else #else
@@ -921,12 +1093,40 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
versionString = [shortVersionString length] ? [NSString stringWithFormat:@"(%@)", versionString] : versionString; versionString = [shortVersionString length] ? [NSString stringWithFormat:@"(%@)", versionString] : versionString;
NSString *currentVersionString = [NSString stringWithFormat:@"%@ %@ %@%@", self.newestAppVersion.name, BITHockeyLocalizedString(@"UpdateVersion"), shortVersionString, versionString]; NSString *currentVersionString = [NSString stringWithFormat:@"%@ %@ %@%@", self.newestAppVersion.name, BITHockeyLocalizedString(@"UpdateVersion"), shortVersionString, versionString];
NSString *alertMsg = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableMessage"), currentVersionString]; NSString *alertMsg = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableMessage"), currentVersionString];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle")
message:alertMsg // requires iOS 8
delegate:nil id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") if (uialertcontrollerClass) {
otherButtonTitles:nil]; __weak typeof(self) weakSelf = self;
[alert show]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle")
message:alertMsg
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:BITHockeyLocalizedString(@"HockeyOK")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
typeof(self) strongSelf = weakSelf;
_updateAlertShowing = NO;
if ([strongSelf expiryDateReached] && !strongSelf.blockingView) {
[strongSelf alertFallback:_blockingScreenMessage];
}
}];
[alertController addAction:okAction];
[self showView:alertController];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle")
message:alertMsg
delegate:nil
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
otherButtonTitles:nil];
[alert show];
#pragma clang diagnostic pop
}
} }
if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self hasNewerMandatoryVersion])) { if (self.isUpdateAvailable && (self.alwaysShowUpdateReminder || newVersionDiffersFromCachedVersion || [self hasNewerMandatoryVersion])) {
@@ -1049,6 +1249,8 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
#pragma mark - UIAlertViewDelegate #pragma mark - UIAlertViewDelegate
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// invoke the selected action from the action sheet for a location element // invoke the selected action from the action sheet for a location element
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if ([alertView tag] == BITUpdateAlertViewTagNeverEndingAlertView) { if ([alertView tag] == BITUpdateAlertViewTagNeverEndingAlertView) {
@@ -1076,6 +1278,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
} }
} }
} }
#pragma clang diagnostic pop
@end @end