Add share option for debug logs.

pull/1/head
Matthew Chen 7 years ago
parent 256a300297
commit 4834a85fb5

@ -8,6 +8,7 @@
#import "zlib.h"
#import <AFNetworking/AFNetworking.h>
#import <SSZipArchive/SSZipArchive.h>
#import <SignalMessaging/AttachmentSharing.h>
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalServiceKit/AppContext.h>
@ -326,10 +327,18 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_BUG_REPORT",
@"Label for the 'Open a Bug Report' option of the the debug log alert.")
style:UIAlertActionStyleCancel
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager prepareRedirection:url completion:completion];
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SHARE",
@"Label for the 'Share' option of the the debug log alert.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[AttachmentSharing showShareUIForText:url.absoluteString
completion:completion];
}]];
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *presentingViewController
= UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert animated:NO completion:nil];

@ -529,6 +529,9 @@
/* Label for the 'send to self' option of the the debug log alert. */
"DEBUG_LOG_ALERT_OPTION_SEND_TO_SELF" = "Send to Self";
/* Label for the 'Share' option of the the debug log alert. */
"DEBUG_LOG_ALERT_OPTION_SHARE" = "Share";
/* Title of the alert shown for failures while uploading debug logs.
Title of the debug log alert. */
"DEBUG_LOG_ALERT_TITLE" = "One More Step";

@ -2,18 +2,28 @@
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@class TSAttachmentStream;
typedef void (^AttachmentSharingCompletion)(void);
@interface AttachmentSharing : NSObject
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream;
+ (void)showShareUIForURL:(NSURL *)url;
+ (void)showShareUIForURL:(NSURL *)url completion:(nullable AttachmentSharingCompletion)completion;
+ (void)showShareUIForText:(NSString *)text;
+ (void)showShareUIForText:(NSString *)text completion:(nullable AttachmentSharingCompletion)completion;
#ifdef DEBUG
+ (void)showShareUIForUIImage:(UIImage *)image;
#endif
@end
NS_ASSUME_NONNULL_END

@ -8,6 +8,8 @@
#import <SignalServiceKit/TSAttachmentStream.h>
#import <SignalServiceKit/Threading.h>
NS_ASSUME_NONNULL_BEGIN
@implementation AttachmentSharing
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream
@ -18,21 +20,33 @@
}
+ (void)showShareUIForURL:(NSURL *)url
{
[self showShareUIForURL:url completion:nil];
}
+ (void)showShareUIForURL:(NSURL *)url completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(url);
[AttachmentSharing showShareUIForActivityItems:@[
url,
]];
]
completion:completion];
}
+ (void)showShareUIForText:(NSString *)text
{
[self showShareUIForText:text completion:nil];
}
+ (void)showShareUIForText:(NSString *)text completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(text);
[AttachmentSharing showShareUIForActivityItems:@[
text,
]];
]
completion:completion];
}
#ifdef DEBUG
@ -42,11 +56,12 @@
[AttachmentSharing showShareUIForActivityItems:@[
image,
]];
]
completion:nil];
}
#endif
+ (void)showShareUIForActivityItems:(NSArray *)activityItems
+ (void)showShareUIForActivityItems:(NSArray *)activityItems completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(activityItems);
@ -67,6 +82,10 @@
} else if (completed) {
DDLogInfo(@"%@ Did share with activityType: %@", self.logTag, activityType);
}
if (completion) {
DispatchMainThreadSafe(completion);
}
}];
UIViewController *fromViewController = CurrentAppContext().frontmostViewController;
@ -84,3 +103,5 @@
}
@end
NS_ASSUME_NONNULL_END

Loading…
Cancel
Save