Show alert if we fail to build the attachment

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 89b9887f1d
commit 3eceb86371

@ -359,12 +359,6 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
[self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]]; [self presentViewController:navigationController animated:YES completion:[UIUtil modalCompletionBlock]];
} }
- (void)presentInvalidCountryCodeError {
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTER_CC_ERR_ALERT_VIEW_TITLE", @"")
message:NSLocalizedString(@"REGISTER_CC_ERR_ALERT_VIEW_MESSAGE", @"")
buttonTitle:CommonStrings.dismissButton];
}
- (void)backgroundTapped:(UIGestureRecognizer *)sender - (void)backgroundTapped:(UIGestureRecognizer *)sender
{ {
if (sender.state == UIGestureRecognizerStateRecognized) { if (sender.state == UIGestureRecognizerStateRecognized) {

@ -1273,12 +1273,6 @@
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"RATING_TITLE" = "Support Signal!"; "RATING_TITLE" = "Support Signal!";
/* No comment provided by engineer. */
"REGISTER_CC_ERR_ALERT_VIEW_MESSAGE" = "Please enter a valid country code";
/* No comment provided by engineer. */
"REGISTER_CC_ERR_ALERT_VIEW_TITLE" = "Country Code Error";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"REGISTER_CONTACTS_WELCOME" = "Welcome!"; "REGISTER_CONTACTS_WELCOME" = "Welcome!";
@ -1570,6 +1564,9 @@
/* Title indicating that the share extension cannot be used until the main app has been launched at least once. */ /* Title indicating that the share extension cannot be used until the main app has been launched at least once. */
"SHARE_EXTENSION_NOT_YET_MIGRATED_TITLE" = "Not Ready"; "SHARE_EXTENSION_NOT_YET_MIGRATED_TITLE" = "Not Ready";
/* Shown when trying to share content to a Signal user for the share extension. Followed by failure details. */
"SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE" = "Unable to Prepare Attachment";
/* Action sheet item */ /* Action sheet item */
"SHOW_SAFETY_NUMBER_ACTION" = "Show New Safety Number"; "SHOW_SAFETY_NUMBER_ACTION" = "Show New Safety Number";

@ -200,7 +200,7 @@ NS_ASSUME_NONNULL_BEGIN
[ThreadUtil sendMessageWithAttachment:self.attachment inThread:self.thread messageSender:self.messageSender]; [ThreadUtil sendMessageWithAttachment:self.attachment inThread:self.thread messageSender:self.messageSender];
// FIXME SHARINGEXTENSION // FIXME SHARINGEXTENSION
// Show loading screen and dismiss entire share extnesion once entirely complete // Show loading screen and dismiss entire share extension once entirely complete
[self.navigationController popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES];
} }

@ -34,13 +34,13 @@ import Foundation
} }
@objc @objc
public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil) { public class func showAlert(withTitle title: String, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil) {
assert(title.count > 0) assert(title.count > 0)
let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "") let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "")
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: nil)) alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: buttonAction))
CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil) CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil)
} }

@ -242,9 +242,8 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
AssertIsOnMainThread(); AssertIsOnMainThread();
// Should only be sent once per operation // Should only be sent once per operation
// FIXME SHARINGEXTENSION OWSAssert(!CurrentAppContext().isMainApp || _backgroundTaskIdentifier == UIBackgroundTaskInvalid);
// OWSAssert(_backgroundTaskIdentifier == UIBackgroundTaskInvalid); OWSAssert(!CurrentAppContext().isMainApp || backgroundTaskIdentifier != UIBackgroundTaskInvalid);
// OWSAssert(backgroundTaskIdentifier != UIBackgroundTaskInvalid);
_backgroundTaskIdentifier = backgroundTaskIdentifier; _backgroundTaskIdentifier = backgroundTaskIdentifier;
} }

@ -362,6 +362,11 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate, S
self.pushViewController(conversationPicker, animated: false) self.pushViewController(conversationPicker, animated: false)
Logger.info("presented conversation picker with attachment") Logger.info("presented conversation picker with attachment")
}.catch { error in }.catch { error in
OWSAlerts.showAlert(withTitle: NSLocalizedString("SHARE_EXTENSION_UNABLE_TO_BUILD_ATTACHMENT_ALERT_TITLE", comment: "Shown when trying to share content to a Signal user for the share extension. Followed by failure details."),
message: error.localizedDescription,
buttonTitle: CommonStrings.cancelButton) { _ in
self.shareExtensionWasCancelled()
}
owsFail("\(self.logTag) building attachment failed with error: \(error)") owsFail("\(self.logTag) building attachment failed with error: \(error)")
}.retainUntilComplete() }.retainUntilComplete()
} }

Loading…
Cancel
Save