-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add delegate for implementing custom prompting behavior #65
Changes from 2 commits
f84ce1c
afe2c79
d412dbb
7ebd7c6
0cb6208
74403e4
df47e3d
b17bc05
de292f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// ARKEmailBugReportConfiguration.h | ||
// Aardvark | ||
// | ||
// Created by Nick Entin on 4/14/18. | ||
// Copyright 2018 Square, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@class ARKLogStore; | ||
@class ARKEmailAttachment; | ||
|
||
|
||
/// Configuration object describing the contents of an email bug report. | ||
@interface ARKEmailBugReportConfiguration : NSObject | ||
|
||
/// The email subject that will be prefilled when the email dialog is presented to the user. Defaults to an empty string. | ||
@property (nonnull, nonatomic, copy) NSString *prefilledEmailSubject; | ||
|
||
/// The log stores that will be included as attachments on the email. Defaults to an empty array. | ||
@property (nonnull, nonatomic, copy) NSArray<ARKLogStore *> *logStores; | ||
|
||
/// Controls whether or not a screenshot should be attached to the email, when available. Defaults to NO. | ||
@property (nonatomic) BOOL includesScreenshot; | ||
|
||
/// Controls whether or not a view hierarchy description should be attached to the email, when available. Defaults to NO. | ||
@property (nonatomic) BOOL includesViewHierarchyDescription; | ||
|
||
/// Additional attachments to include on the email. Defaults to nil. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be a little more convenient to make it |
||
@property (nullable, nonatomic, copy) NSArray<ARKEmailAttachment *> *additionalAttachments; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// ARKEmailBugReportConfiguration.m | ||
// Aardvark | ||
// | ||
// Created by Nick Entin on 4/14/18. | ||
// Copyright 2018 Square, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
#import "ARKEmailBugReportConfiguration.h" | ||
|
||
|
||
@implementation ARKEmailBugReportConfiguration | ||
|
||
- (instancetype)init; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice 😄 |
||
{ | ||
self = [super init]; | ||
|
||
_prefilledEmailSubject = @""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it may be worth having a quick comment here stating: "If any of the below default values change, remember to update the header file" That may also be overkill. I leave it up to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like making behavioral changes like changing default values should imply needing to update the header docs, and if it doesn't then you don't have enough header docs. Maybe that's just optimistic thinking, but adding comments saying that things are documented feels backwards. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Works for me! |
||
_logStores = @[]; | ||
_includesScreenshot = NO; | ||
_includesViewHierarchyDescription = NO; | ||
_additionalAttachments = nil; | ||
|
||
return self; | ||
} | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
|
||
|
||
@class ARKEmailAttachment; | ||
@class ARKEmailBugReportConfiguration; | ||
@class ARKEmailBugReporter; | ||
@class ARKLogStore; | ||
@protocol ARKLogFormatter; | ||
|
@@ -53,6 +54,20 @@ | |
@end | ||
|
||
|
||
typedef void (^ARKEmailBugReporterCustomPromptCompletionBlock)(ARKEmailBugReportConfiguration *_Nullable configuration); | ||
|
||
@protocol ARKEmailBugReporterPromptingDelegate <NSObject> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like every other protocol in Aardvark does this, so just as well to match. |
||
|
||
@required | ||
|
||
/// Called on the main thread when a bug is filed to signal that a bug report prompt should be presented to the user. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👏 for calling out what thread this is called on |
||
/// The `completion` should be called with either an updated configuration to present the email dialog, or `nil` to signal that the prompt was cancelled. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on what thread should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. main 👍 |
||
/// When the initial `configuration` has `includesScreenshot` or `includesViewHierarchyDescription` false, setting the field to true will have no effect. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "set to false"? But also: I'm not sure I get this comment. Why does changing some fields work, and some other fields not? Where should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically it's a one-way door. If there is a screenshot, the initial configuration will have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So then, why are these fields mutable at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still want the prompt to be able to remove the screenshot and view hierarchy. If we want to make the API more explicit here, we could do something like: /// Whether or not there is a screenshot attached to the bug report.
@property (nonatomic, readonly) BOOL includesScreenshot;
/// Removes the screenshot from the bug report if one is attached.
- (void)removeScreenshot;
/// Whether or not there is a view hierarchy description attached to the bug report.
@property (nonatomic, readonly) BOOL includesViewHierarchyDescription;
/// Removes the view hierarchy description from the bug report if one is attached.
- (void)removeViewHierarchyDescription; Alternatively, we could just attach the screenshot data, which would have the added advantage of allowing the custom prompt to modify the image. Although this would probably be dependent on #67 (and maybe #66). @property (nullable, nonatomic, copy) UIImage *screenshot;
@property (nullable, nonatomic, copy) NSString *viewHierarchyDescription; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked about this offline with @efirestone and landed on going to |
||
- (void)showBugReportingPromptForConfiguration:(ARKEmailBugReportConfiguration *_Nonnull)configuration completion:(ARKEmailBugReporterCustomPromptCompletionBlock _Nonnull)completion; | ||
|
||
@end | ||
|
||
|
||
/// Composes a bug report that is sent via email. | ||
@interface ARKEmailBugReporter : NSObject <ARKBugReporter> | ||
|
||
|
@@ -73,6 +88,9 @@ | |
/// The email attachment delegate, responsible for providing additional attachments and filtering which log stores to include in the bug report at the time the bug is filed. | ||
@property (nullable, nonatomic, weak) id <ARKEmailBugReporterEmailAttachmentAdditionsDelegate> emailAttachmentAdditionsDelegate; | ||
|
||
/// The prompting delegate, responsible for showing a prompt to file a bug report. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a default behavior if/when this is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, default behavior is the existing behavior (showing an alert asking for the bug title). Added to comment. |
||
@property (nullable, nonatomic, weak) id <ARKEmailBugReporterPromptingDelegate> promptingDelegate; | ||
|
||
/// The formatter used to prepare the log for entry into an email. Defaults to a vanilla instance of ARKDefaultLogFormatter. | ||
@property (nonnull, nonatomic) id <ARKLogFormatter> logFormatter; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triple-slash comment explaining what this object is?