mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Add option to Feedback compose UI to be pre filled with data
Accepts an array with data to fill it up with, much like UIActivity. Allows easier option to expand with more content types in the future
This commit is contained in:
parent
423bc7ece7
commit
34bb4cb758
@ -12,7 +12,4 @@
|
||||
|
||||
@interface BITFeedbackActivity : UIActivity <BITFeedbackComposeViewControllerDelegate>
|
||||
|
||||
@property (nonatomic, retain) UIImage *shareImage;
|
||||
@property (nonatomic, retain) NSString *shareString;
|
||||
|
||||
@end
|
||||
|
@ -13,8 +13,35 @@
|
||||
#import "BITHockeyHelper.h"
|
||||
#import "BITFeedbackManagerPrivate.h"
|
||||
|
||||
|
||||
@interface BITFeedbackActivity()
|
||||
|
||||
@property (nonatomic, retain) NSMutableArray *items;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation BITFeedbackActivity
|
||||
|
||||
#pragma mark - NSObject
|
||||
|
||||
- (id)init {
|
||||
if ((self = [super init])) {
|
||||
self.items = [NSMutableArray array];;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_items release]; _items = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UIActivity
|
||||
|
||||
- (NSString *)activityType {
|
||||
return @"UIActivityTypePostToHockeySDKFeedback";
|
||||
}
|
||||
@ -36,9 +63,7 @@
|
||||
if ([BITHockeyManager sharedHockeyManager].disableFeedbackManager) return NO;
|
||||
|
||||
for (UIActivityItemProvider *item in activityItems) {
|
||||
if ([item isKindOfClass:[UIImage class]]) {
|
||||
return YES;
|
||||
} else if ([item isKindOfClass:[NSString class]]) {
|
||||
if ([item isKindOfClass:[NSString class]]) {
|
||||
return YES;
|
||||
} else if ([item isKindOfClass:[NSURL class]]) {
|
||||
return YES;
|
||||
@ -49,12 +74,9 @@
|
||||
|
||||
- (void)prepareWithActivityItems:(NSArray *)activityItems {
|
||||
for (id item in activityItems) {
|
||||
if ([item isKindOfClass:[UIImage class]]) {
|
||||
self.shareImage = item;
|
||||
} else if ([item isKindOfClass:[NSString class]]) {
|
||||
self.shareString = [(self.shareString ? self.shareString : @"") stringByAppendingFormat:@"%@%@",(self.shareString ? @" " : @""),item];
|
||||
} else if ([item isKindOfClass:[NSURL class]]) {
|
||||
self.shareString = [(self.shareString ? self.shareString : @"") stringByAppendingFormat:@"%@%@",(self.shareString ? @" " : @""),[(NSURL *)item absoluteString]];
|
||||
if ([item isKindOfClass:[NSString class]] ||
|
||||
[item isKindOfClass:[NSURL class]]) {
|
||||
[_items addObject:item];
|
||||
} else {
|
||||
BITHockeyLog(@"Unknown item type %@", item);
|
||||
}
|
||||
@ -63,7 +85,9 @@
|
||||
|
||||
- (UIViewController *)activityViewController {
|
||||
// TODO: return compose controller with activity content added
|
||||
BITFeedbackComposeViewController *composeViewController = [[BITHockeyManager sharedHockeyManager].feedbackManager feedbackComposeViewControllerWithScreenshot:NO delegate:self];
|
||||
BITFeedbackComposeViewController *composeViewController = [[BITHockeyManager sharedHockeyManager].feedbackManager feedbackComposeViewController];
|
||||
composeViewController.delegate = self;
|
||||
[composeViewController prepareWithItems:_items];
|
||||
|
||||
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController: composeViewController] autorelease];
|
||||
navController.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||
|
@ -37,6 +37,7 @@
|
||||
@property (nonatomic, assign) id<BITFeedbackComposeViewControllerDelegate> delegate;
|
||||
|
||||
- (id)init;
|
||||
- (id)initWithDelegate:(id<BITFeedbackComposeViewControllerDelegate>)delegate;
|
||||
|
||||
- (void)prepareWithItems:(NSArray *)items;
|
||||
|
||||
@end
|
@ -37,39 +37,59 @@
|
||||
#import "BITHockeyHelper.h"
|
||||
|
||||
|
||||
@interface BITFeedbackComposeViewController () <BITFeedbackUserDataDelegate> {
|
||||
BOOL blockUserDataScreen;
|
||||
}
|
||||
@interface BITFeedbackComposeViewController () <BITFeedbackUserDataDelegate>
|
||||
|
||||
@property (nonatomic, assign) BITFeedbackManager *manager;
|
||||
@property (nonatomic, retain) UITextView *textView;
|
||||
|
||||
@property (nonatomic, retain) NSString *text;
|
||||
|
||||
- (void)setUserDataAction;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation BITFeedbackComposeViewController {
|
||||
BOOL _blockUserDataScreen;
|
||||
}
|
||||
|
||||
@implementation BITFeedbackComposeViewController
|
||||
|
||||
#pragma mark - NSObject
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.title = BITHockeyLocalizedString(@"HockeyFeedbackComposeTitle");
|
||||
blockUserDataScreen = NO;
|
||||
_blockUserDataScreen = NO;
|
||||
_delegate = nil;
|
||||
_manager = [BITHockeyManager sharedHockeyManager].feedbackManager;
|
||||
|
||||
_text = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_text release];
|
||||
[_textView release], _textView = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id)initWithDelegate:(id<BITFeedbackComposeViewControllerDelegate>)delegate {
|
||||
self = [self init];
|
||||
if (self) {
|
||||
_delegate = delegate;
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (void)prepareWithItems:(NSArray *)items {
|
||||
for (id item in items) {
|
||||
if ([item isKindOfClass:[NSString class]]) {
|
||||
self.text = [(self.text ? self.text : @"") stringByAppendingFormat:@"%@%@", (self.text ? @" " : @""), item];
|
||||
} else if ([item isKindOfClass:[NSURL class]]) {
|
||||
self.text = [(self.text ? self.text : @"") stringByAppendingFormat:@"%@%@", (self.text ? @" " : @""), [(NSURL *)item absoluteString]];
|
||||
} else {
|
||||
BITHockeyLog(@"Unknown item type %@", item);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +132,14 @@
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:(self.navigationController.navigationBar.barStyle == UIBarStyleDefault) ? UIStatusBarStyleDefault : UIStatusBarStyleBlackOpaque];
|
||||
|
||||
if (_text) {
|
||||
self.textView.text = _text;
|
||||
self.navigationItem.rightBarButtonItem.enabled = YES;
|
||||
} else {
|
||||
self.navigationItem.rightBarButtonItem.enabled = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
@ -124,7 +149,7 @@
|
||||
([self.manager requireManualUserDataMissing] ||
|
||||
![self.manager didAskUserData])
|
||||
) {
|
||||
if (!blockUserDataScreen)
|
||||
if (!_blockUserDataScreen)
|
||||
[self setUserDataAction];
|
||||
} else {
|
||||
[self.textView becomeFirstResponder];
|
||||
@ -180,7 +205,7 @@
|
||||
#pragma mark - CNSFeedbackUserDataDelegate
|
||||
|
||||
- (void)userDataUpdateCancelled {
|
||||
blockUserDataScreen = YES;
|
||||
_blockUserDataScreen = YES;
|
||||
|
||||
if ([self.manager requireManualUserDataMissing]) {
|
||||
if ([self.navigationController respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) {
|
||||
|
@ -87,10 +87,9 @@ typedef enum {
|
||||
/**
|
||||
Create an feedback compose view
|
||||
|
||||
@param modal Return a view ready for modal presentation with integrated navigation bar
|
||||
@return `BITFeedbackComposeViewController` The compose feedback view controller,
|
||||
e.g. to push it onto a navigation stack.
|
||||
*/
|
||||
- (BITFeedbackComposeViewController *)feedbackComposeViewControllerWithDelegate:(id<BITFeedbackComposeViewControllerDelegate>)delegate;
|
||||
- (BITFeedbackComposeViewController *)feedbackComposeViewController;
|
||||
|
||||
@end
|
||||
|
@ -177,8 +177,8 @@
|
||||
}
|
||||
|
||||
|
||||
- (BITFeedbackComposeViewController *)feedbackComposeViewControllerWithDelegate:(id<BITFeedbackComposeViewControllerDelegate>)delegate {
|
||||
return [[[BITFeedbackComposeViewController alloc] initWithDelegate:delegate] autorelease];
|
||||
- (BITFeedbackComposeViewController *)feedbackComposeViewController {
|
||||
return [[[BITFeedbackComposeViewController alloc] init] autorelease];
|
||||
}
|
||||
|
||||
- (void)showFeedbackComposeView {
|
||||
@ -187,7 +187,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
[self showView:[self feedbackComposeViewControllerWithDelegate:nil]];
|
||||
[self showView:[self feedbackComposeViewController]];
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user