From 866338fba67b56943c95e7c8ad4c1b8d6a896ec4 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 16 Oct 2018 11:29:48 -0400 Subject: [PATCH 1/2] Refine debug logs UI. --- Signal/src/util/Pastelog.m | 56 +++++++++++++------ .../translations/en.lproj/Localizable.strings | 2 +- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Signal/src/util/Pastelog.m b/Signal/src/util/Pastelog.m index 1360b3a5c..ee69b0784 100644 --- a/Signal/src/util/Pastelog.m +++ b/Signal/src/util/Pastelog.m @@ -297,7 +297,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error } }; - [self uploadLogsWithSuccess:^(NSURL *url) { + [[self sharedManager] uploadLogsWithUIWithSuccess:^(NSURL *url) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_TITLE", @"Title of the debug log alert.") message:NSLocalizedString(@"DEBUG_LOG_ALERT_MESSAGE", @"Message of the debug log alert.") @@ -357,28 +357,52 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error }]; } -+ (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)success -{ - OWSAssertDebug(success); - - [[self sharedManager] uploadLogsWithSuccess:success - failure:^(NSString *localizedErrorMessage) { - [Pastelog showFailureAlertWithMessage:localizedErrorMessage]; - }]; +- (void)uploadLogsWithUIWithSuccess:(UploadDebugLogsSuccess)successParam { + OWSAssertIsOnMainThread(); + + [ModalActivityIndicatorViewController + presentFromViewController:UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts + canCancel:YES + backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { + [self + uploadLogsWithSuccess:^(NSURL *url) { + OWSAssertIsOnMainThread(); + + if (modalActivityIndicator.wasCancelled) { + return; + } + + [modalActivityIndicator dismissWithCompletion:^{ + OWSAssertIsOnMainThread(); + + successParam(url); + }]; + } + failure:^(NSString *localizedErrorMessage) { + OWSAssertIsOnMainThread(); + + if (modalActivityIndicator.wasCancelled) { + return; + } + + [modalActivityIndicator dismissWithCompletion:^{ + OWSAssertIsOnMainThread(); + + [Pastelog showFailureAlertWithMessage:localizedErrorMessage]; + }]; + }]; + }]; } -- (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)successParam failure:(UploadDebugLogsFailure)failureParam -{ +- (void)uploadLogsWithSuccess:(UploadDebugLogsSuccess)successParam failure:(UploadDebugLogsFailure)failureParam { OWSAssertDebug(successParam); OWSAssertDebug(failureParam); // Ensure that we call the completions on the main thread. UploadDebugLogsSuccess success = ^(NSURL *url) { - if (successParam) { - DispatchMainThreadSafe(^{ - successParam(url); - }); - } + DispatchMainThreadSafe(^{ + successParam(url); + }); }; UploadDebugLogsFailure failure = ^(NSString *localizedErrorMessage) { DispatchMainThreadSafe(^{ diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 263dbcd7b..5e4fb088c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1911,7 +1911,7 @@ "SETTINGS_ADVANCED_DEBUGLOG" = "Enable Debug Log"; /* No comment provided by engineer. */ -"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Submit Debug Log"; +"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Create Debug Log"; /* No comment provided by engineer. */ "SETTINGS_ADVANCED_TITLE" = "Advanced"; From 92b55b945b2e7b7efbe355b076b1afb99c1e9032 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 16 Oct 2018 16:46:55 -0400 Subject: [PATCH 2/2] Revert copy change. --- Signal/translations/en.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 5e4fb088c..263dbcd7b 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1911,7 +1911,7 @@ "SETTINGS_ADVANCED_DEBUGLOG" = "Enable Debug Log"; /* No comment provided by engineer. */ -"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Create Debug Log"; +"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG" = "Submit Debug Log"; /* No comment provided by engineer. */ "SETTINGS_ADVANCED_TITLE" = "Advanced";