mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Use UIAlertController when available
This commit is contained in:
@@ -291,12 +291,33 @@
|
||||
if(succeeded) {
|
||||
//controller should dismiss us shortly..
|
||||
} else {
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
|
||||
message:error.localizedDescription
|
||||
delegate:nil
|
||||
cancelButtonTitle:BITHockeyLocalizedString(@"OK")
|
||||
otherButtonTitles:nil];
|
||||
[alertView show];
|
||||
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
|
||||
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;
|
||||
[strongSelf setLoginUIEnabled:YES];
|
||||
}
|
||||
|
||||
@@ -256,13 +256,38 @@ static unsigned char kBITPNGEndChunk[4] = {0x49, 0x45, 0x4e, 0x44};
|
||||
} else {
|
||||
BITHockeyLog(@"Validation failed with error: %@", error);
|
||||
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil
|
||||
message:error.localizedDescription
|
||||
delegate:self
|
||||
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
|
||||
otherButtonTitles:nil];
|
||||
[alertView setTag:0];
|
||||
[alertView show];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
|
||||
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 clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
if (alertView.tag == 0) {
|
||||
[self validate];
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1045,17 +1045,63 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
if (_alertViewHandler) {
|
||||
_alertViewHandler();
|
||||
} else {
|
||||
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")];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundTitle"), appName]
|
||||
message:alertDescription
|
||||
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 {
|
||||
[self approveLatestCrashReport];
|
||||
@@ -1451,6 +1497,8 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
|
||||
#pragma mark - UIAlertView Delegate
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
switch (buttonIndex) {
|
||||
case 0:
|
||||
@@ -1464,8 +1512,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
|
||||
#pragma mark - Networking
|
||||
|
||||
@@ -536,6 +536,47 @@
|
||||
|
||||
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
|
||||
delegate: self
|
||||
cancelButtonTitle: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentCancel")
|
||||
@@ -543,7 +584,9 @@
|
||||
otherButtonTitles: BITHockeyLocalizedString(@"HockeyFeedbackComposeAttachmentEdit"), nil];
|
||||
|
||||
[actionSheet showFromRect: sender.frame inView: self.attachmentScrollView animated: YES];
|
||||
|
||||
#pragma clang diagnostic push
|
||||
}
|
||||
|
||||
_actionSheetVisible = YES;
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[self.textView resignFirstResponder];
|
||||
@@ -587,38 +630,49 @@
|
||||
|
||||
#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 {
|
||||
if (buttonIndex == [actionSheet destructiveButtonIndex]) {
|
||||
|
||||
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];
|
||||
}
|
||||
[self deleteAction];
|
||||
} else if (buttonIndex != [actionSheet cancelButtonIndex]) {
|
||||
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];
|
||||
}
|
||||
[self editAction];
|
||||
} else {
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[self.textView becomeFirstResponder];
|
||||
}
|
||||
[self cancelAction];
|
||||
}
|
||||
_actionSheetVisible = NO;
|
||||
}
|
||||
|
||||
@@ -287,25 +287,66 @@
|
||||
}
|
||||
|
||||
- (void)deleteAllMessagesAction:(id)sender {
|
||||
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];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
|
||||
[deleteAction setTag:0];
|
||||
[deleteAction show];
|
||||
NSString *title = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages");
|
||||
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
|
||||
|
||||
- (void)attributedLabel:(BITAttributedLabel *)label didSelectLinkWithURL:(NSURL *)url {
|
||||
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
|
||||
];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
UIAlertControllerStyle controllerStyle = UIAlertControllerStyleAlert;
|
||||
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
|
||||
controllerStyle = UIAlertControllerStyleActionSheet;
|
||||
}
|
||||
|
||||
[linkAction setTag:1];
|
||||
[linkAction show];
|
||||
UIAlertController *linkAction = [UIAlertController alertControllerWithTitle:[url absoluteString]
|
||||
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 clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
if (buttonIndex == alertView.cancelButtonIndex) {
|
||||
return;
|
||||
@@ -811,7 +897,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma mark - UIActionSheetDelegate
|
||||
|
||||
|
||||
@@ -1070,6 +1070,8 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
|
||||
#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
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
|
||||
@@ -1079,6 +1081,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
[self showFeedbackListView];
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma mark - Observation Handling
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
self.imageView.image = self.image;
|
||||
self.imageView.contentMode = UIViewContentModeScaleToFill;
|
||||
|
||||
self.view.frame = UIScreen.mainScreen.applicationFrame;
|
||||
self.view.frame = UIScreen.mainScreen.bounds;
|
||||
|
||||
[self.view addSubview:self.imageView];
|
||||
// Erm.
|
||||
@@ -113,13 +113,8 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
|
||||
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.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;
|
||||
}
|
||||
@@ -364,7 +359,14 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
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) {
|
||||
[self fitImageViewFrame];
|
||||
@@ -379,7 +381,14 @@ typedef NS_ENUM(NSInteger, BITImageAnnotationViewControllerInteractionMode) {
|
||||
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) {
|
||||
[self fitImageViewFrame];
|
||||
|
||||
@@ -417,13 +417,57 @@
|
||||
if (!_updateAlertShowing) {
|
||||
NSString *versionString = [NSString stringWithFormat:@"%@ %@", BITHockeyLocalizedString(@"UpdateVersion"), _newStoreVersion];
|
||||
|
||||
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];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateAvailable")
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -442,28 +486,44 @@
|
||||
|
||||
#pragma mark - UIAlertViewDelegate
|
||||
|
||||
// invoke the selected action from the action sheet for a location element
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
- (void)ignoreAction {
|
||||
_updateAlertShowing = NO;
|
||||
if (buttonIndex == [alertView cancelButtonIndex]) {
|
||||
// Ignore
|
||||
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
|
||||
[self.userDefaults synchronize];
|
||||
} else if (buttonIndex == [alertView firstOtherButtonIndex]) {
|
||||
// Remind button
|
||||
} else if (buttonIndex == [alertView firstOtherButtonIndex] + 1) {
|
||||
// Show button
|
||||
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
|
||||
[self.userDefaults synchronize];
|
||||
|
||||
if (_appStoreURLString) {
|
||||
[[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.");
|
||||
}
|
||||
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
|
||||
[self.userDefaults synchronize];
|
||||
}
|
||||
|
||||
- (void)remindAction {
|
||||
_updateAlertShowing = NO;
|
||||
}
|
||||
|
||||
- (void)showAction {
|
||||
_updateAlertShowing = NO;
|
||||
[self.userDefaults setObject:_newStoreVersion forKey:kBITStoreUpdateIgnoreVersion];
|
||||
[self.userDefaults synchronize];
|
||||
|
||||
if (_appStoreURLString) {
|
||||
[[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
|
||||
|
||||
#endif /* HOCKEYSDK_FEATURE_STORE_UPDATES */
|
||||
|
||||
@@ -89,11 +89,32 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
|
||||
// only show error if we enable that
|
||||
if (_showFeedback) {
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateError")
|
||||
message:[error localizedDescription]
|
||||
delegate:nil
|
||||
cancelButtonTitle:BITHockeyLocalizedString(@"OK") otherButtonTitles:nil];
|
||||
[alert show];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:BITHockeyLocalizedString(@"UpdateError")
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -520,28 +541,122 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
if ([self isUpdateManagerDisabled]) return;
|
||||
|
||||
if (!_updateAlertShowing) {
|
||||
NSString *title = BITHockeyLocalizedString(@"UpdateAvailable");
|
||||
NSString *message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]];
|
||||
if ([self hasNewerMandatoryVersion]) {
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable")
|
||||
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertMandatoryTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]]
|
||||
delegate:self
|
||||
cancelButtonTitle:nil
|
||||
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), BITHockeyLocalizedString(@"UpdateInstall"), nil
|
||||
];
|
||||
[alertView setTag:BITUpdateAlertViewTagMandatoryUpdate];
|
||||
[alertView show];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
|
||||
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;
|
||||
} else {
|
||||
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateAvailable")
|
||||
message:[NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]]
|
||||
delegate:self
|
||||
cancelButtonTitle:BITHockeyLocalizedString(@"UpdateIgnore")
|
||||
otherButtonTitles:BITHockeyLocalizedString(@"UpdateShow"), nil
|
||||
];
|
||||
if (self.isShowingDirectInstallOption) {
|
||||
[alertView addButtonWithTitle:BITHockeyLocalizedString(@"UpdateInstall")];
|
||||
message = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateAlertTextWithAppVersion"), [self.newestAppVersion nameAndVersionString]];
|
||||
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
- (void)alertFallback:(NSString *)message {
|
||||
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")];
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
|
||||
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
|
||||
@@ -741,8 +890,31 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
}
|
||||
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateWarning") message:BITHockeyLocalizedString(@"UpdateSimulatorMessage") delegate:nil cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK") otherButtonTitles:nil];
|
||||
[alert show];
|
||||
// requires iOS 8
|
||||
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;
|
||||
|
||||
#else
|
||||
@@ -921,12 +1093,40 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
versionString = [shortVersionString length] ? [NSString stringWithFormat:@"(%@)", versionString] : versionString;
|
||||
NSString *currentVersionString = [NSString stringWithFormat:@"%@ %@ %@%@", self.newestAppVersion.name, BITHockeyLocalizedString(@"UpdateVersion"), shortVersionString, versionString];
|
||||
NSString *alertMsg = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableMessage"), currentVersionString];
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:BITHockeyLocalizedString(@"UpdateNoUpdateAvailableTitle")
|
||||
message:alertMsg
|
||||
delegate:nil
|
||||
cancelButtonTitle:BITHockeyLocalizedString(@"HockeyOK")
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
|
||||
// requires iOS 8
|
||||
id uialertcontrollerClass = NSClassFromString(@"UIAlertController");
|
||||
if (uialertcontrollerClass) {
|
||||
__weak typeof(self) weakSelf = self;
|
||||
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])) {
|
||||
@@ -1049,6 +1249,8 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
|
||||
#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
|
||||
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
|
||||
if ([alertView tag] == BITUpdateAlertViewTagNeverEndingAlertView) {
|
||||
@@ -1076,6 +1278,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user