diff --git a/Classes/BITFeedbackComposeViewController.m b/Classes/BITFeedbackComposeViewController.m index f22b0237c5..d492f39314 100644 --- a/Classes/BITFeedbackComposeViewController.m +++ b/Classes/BITFeedbackComposeViewController.m @@ -50,12 +50,12 @@ @property (nonatomic, weak) BITFeedbackManager *manager; @property (nonatomic, strong) UITextView *textView; @property (nonatomic, strong) UIView *contentViewContainer; -@property (nonatomic, strong) UIScrollView *photoScrollView; -@property (nonatomic, strong) NSMutableArray *photoScrollViewImageViews; +@property (nonatomic, strong) UIScrollView *attachmentScrollView; +@property (nonatomic, strong) NSMutableArray *attachmentScrollViewImageViews; @property (nonatomic, strong) NSString *text; -@property (nonatomic, strong) NSMutableArray *photos; +@property (nonatomic, strong) NSMutableArray *attachments; @property (nonatomic, strong) UIView *textAccessoryView; @@ -76,8 +76,8 @@ _blockUserDataScreen = NO; _delegate = nil; _manager = [BITHockeyManager sharedHockeyManager].feedbackManager; - _photos = [NSMutableArray new]; - _photoScrollViewImageViews = [NSMutableArray new]; + _attachments = [NSMutableArray new]; + _attachmentScrollViewImageViews = [NSMutableArray new]; _text = nil; } @@ -185,12 +185,12 @@ self.textView.inputAccessoryView = self.textAccessoryView; // This could be a subclass, yet - self.photoScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; - self.photoScrollView.scrollEnabled = YES; - self.photoScrollView.bounces = YES; - self.photoScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + self.attachmentScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; + self.attachmentScrollView.scrollEnabled = YES; + self.attachmentScrollView.bounces = YES; + self.attachmentScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; - [self.contentViewContainer addSubview:self.photoScrollView]; + [self.contentViewContainer addSubview:self.attachmentScrollView]; } - (void)viewWillAppear:(BOOL)animated { @@ -256,13 +256,13 @@ -(void)refreshPhotoScrollview { CGFloat scrollViewWidth = 0; - if (self.photos.count){ + if (self.attachments.count){ scrollViewWidth = 100; } CGRect textViewFrame = self.textView.frame; - CGRect scrollViewFrame = self.photoScrollView.frame; + CGRect scrollViewFrame = self.attachmentScrollView.frame; BOOL alreadySetup = CGRectGetWidth(scrollViewFrame) == scrollViewWidth; @@ -270,19 +270,19 @@ textViewFrame.size.width -= scrollViewWidth; scrollViewFrame = CGRectMake(CGRectGetMaxX(textViewFrame), self.view.frame.origin.y, scrollViewWidth, CGRectGetHeight(textViewFrame)); self.textView.frame = textViewFrame; - self.photoScrollView.frame = scrollViewFrame; - self.photoScrollView.contentInset = self.textView.contentInset; + self.attachmentScrollView.frame = scrollViewFrame; + self.attachmentScrollView.contentInset = self.textView.contentInset; } - for (UIView *subview in self.photoScrollView.subviews){ + for (UIView *subview in self.attachmentScrollView.subviews){ [subview removeFromSuperview]; } - if (self.photos.count > self.photoScrollViewImageViews.count){ - NSInteger numberOfViewsToCreate = self.photos.count - self.photoScrollViewImageViews.count; + if (self.attachments.count > self.attachmentScrollViewImageViews.count){ + NSInteger numberOfViewsToCreate = self.attachments.count - self.attachmentScrollViewImageViews.count; for (int i = 0;i -@property (nonatomic, copy) NSString *filename; @property (nonatomic, copy) NSNumber *id; +@property (nonatomic, copy) NSString *originalFilename; @property (nonatomic, copy) NSString *contentType; @property (nonatomic, readonly) NSData *data; diff --git a/Classes/BITFeedbackMessageAttachment.m b/Classes/BITFeedbackMessageAttachment.m index 95a6e31272..99865897f9 100644 --- a/Classes/BITFeedbackMessageAttachment.m +++ b/Classes/BITFeedbackMessageAttachment.m @@ -37,6 +37,8 @@ @property (nonatomic, strong) NSMutableDictionary *thumbnailRepresentations; @property (nonatomic, strong) NSData *internalData; +@property (nonatomic, copy) NSString *filename; + @end @implementation BITFeedbackMessageAttachment @@ -79,6 +81,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder { [aCoder encodeObject:self.contentType forKey:@"contentType"]; [aCoder encodeObject:self.filename forKey:@"filename"]; + [aCoder encodeObject:self.originalFilename forKey:@"originalFilename"]; } @@ -89,6 +92,7 @@ self.contentType = [aDecoder decodeObjectForKey:@"contentType"]; self.filename = [aDecoder decodeObjectForKey:@"filename"]; self.thumbnailRepresentations = [NSMutableDictionary new]; + self.originalFilename = [aDecoder decodeObjectForKey:@"originalFilename"]; } return self; diff --git a/Classes/BITHockeyAppClient.h b/Classes/BITHockeyAppClient.h index 617b9b392d..8d2fce15e1 100644 --- a/Classes/BITHockeyAppClient.h +++ b/Classes/BITHockeyAppClient.h @@ -138,6 +138,5 @@ * * @return NSData instance configured to be attached on a (post) URLRequest */ -+ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary; - ++ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary filename:(NSString *)filename; @end diff --git a/Classes/BITHockeyAppClient.m b/Classes/BITHockeyAppClient.m index c3db96ae75..39944284d8 100644 --- a/Classes/BITHockeyAppClient.m +++ b/Classes/BITHockeyAppClient.m @@ -85,23 +85,24 @@ } + (NSData *)dataWithPostValue:(NSString *)value forKey:(NSString *)key boundary:(NSString *) boundary { - return [self dataWithPostValue:[value dataUsingEncoding:NSUTF8StringEncoding] forKey:key contentType:@"text" boundary:boundary]; + return [self dataWithPostValue:[value dataUsingEncoding:NSUTF8StringEncoding] forKey:key contentType:@"text" boundary:boundary filename:nil]; } -+ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary { ++ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary filename:(NSString *)filename { NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; // There's certainly a better way to check if we are supposed to send binary data here. - if ([contentType rangeOfString:@"text"].location == NSNotFound){ - [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"image.jpg\"\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]]; + if (filename){ + [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", key, filename] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", contentType] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; } else { [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", contentType] dataUsingEncoding:NSUTF8StringEncoding]]; } + [postBody appendData:value]; [postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];