mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
+ Finalized preliminary feedback support. Now comes the polish.
This commit is contained in:
@@ -351,7 +351,7 @@
|
|||||||
|
|
||||||
NSString *text = self.textView.text;
|
NSString *text = self.textView.text;
|
||||||
|
|
||||||
[self.manager submitMessageWithText:text];
|
[self.manager submitMessageWithText:text andPhotos:self.photos];
|
||||||
|
|
||||||
[self dismissWithResult:BITFeedbackComposeResultSubmitted];
|
[self dismissWithResult:BITFeedbackComposeResultSubmitted];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -837,6 +837,15 @@
|
|||||||
|
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
|
||||||
|
NSInteger photoIndex = 0;
|
||||||
|
|
||||||
|
for (UIImage *image in message.photos){
|
||||||
|
NSString *contentType = @"image/png";
|
||||||
|
NSData* imageData = UIImagePNGRepresentation(image);
|
||||||
|
[postBody appendData:[BITHockeyAppClient dataWithPostValue:imageData forKey:[NSString stringWithFormat:@"attachment%ld", (long)photoIndex] contentType:contentType boundary:boundary]];
|
||||||
|
photoIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
[request setHTTPBody:postBody];
|
[request setHTTPBody:postBody];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -971,11 +980,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)submitMessageWithText:(NSString *)text {
|
- (void)submitMessageWithText:(NSString *)text andPhotos:(NSArray *)photos {
|
||||||
BITFeedbackMessage *message = [[BITFeedbackMessage alloc] init];
|
BITFeedbackMessage *message = [[BITFeedbackMessage alloc] init];
|
||||||
message.text = text;
|
message.text = text;
|
||||||
[message setStatus:BITFeedbackMessageStatusSendPending];
|
[message setStatus:BITFeedbackMessageStatusSendPending];
|
||||||
[message setToken:[self uuidAsLowerCaseAndShortened]];
|
[message setToken:[self uuidAsLowerCaseAndShortened]];
|
||||||
|
[message setPhotos:photos];
|
||||||
[message setUserMessage:YES];
|
[message setUserMessage:YES];
|
||||||
|
|
||||||
[_feedbackList addObject:message];
|
[_feedbackList addObject:message];
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
- (NSUInteger)numberOfMessages;
|
- (NSUInteger)numberOfMessages;
|
||||||
- (BITFeedbackMessage *)messageAtIndex:(NSUInteger)index;
|
- (BITFeedbackMessage *)messageAtIndex:(NSUInteger)index;
|
||||||
|
|
||||||
- (void)submitMessageWithText:(NSString *)text;
|
- (void)submitMessageWithText:(NSString *)text andPhotos:(NSArray *)photos;
|
||||||
- (void)submitPendingMessages;
|
- (void)submitPendingMessages;
|
||||||
|
|
||||||
// Returns YES if manual user data can be entered, required or optional
|
// Returns YES if manual user data can be entered, required or optional
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ typedef NS_ENUM(NSInteger, BITFeedbackMessageStatus) {
|
|||||||
@property (nonatomic, copy) NSDate *date;
|
@property (nonatomic, copy) NSDate *date;
|
||||||
@property (nonatomic, copy) NSNumber *id;
|
@property (nonatomic, copy) NSNumber *id;
|
||||||
@property (nonatomic, copy) NSString *token;
|
@property (nonatomic, copy) NSString *token;
|
||||||
|
@property (nonatomic, strong) NSArray *photos;
|
||||||
@property (nonatomic) BITFeedbackMessageStatus status;
|
@property (nonatomic) BITFeedbackMessageStatus status;
|
||||||
@property (nonatomic) BOOL userMessage;
|
@property (nonatomic) BOOL userMessage;
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
_email = nil;
|
_email = nil;
|
||||||
_date = [[NSDate alloc] init];
|
_date = [[NSDate alloc] init];
|
||||||
_token = nil;
|
_token = nil;
|
||||||
|
_photos = nil;
|
||||||
_id = [[NSNumber alloc] initWithInteger:0];
|
_id = [[NSNumber alloc] initWithInteger:0];
|
||||||
_status = BITFeedbackMessageStatusSendPending;
|
_status = BITFeedbackMessageStatusSendPending;
|
||||||
_userMessage = NO;
|
_userMessage = NO;
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
[encoder encodeObject:self.email forKey:@"email"];
|
[encoder encodeObject:self.email forKey:@"email"];
|
||||||
[encoder encodeObject:self.date forKey:@"date"];
|
[encoder encodeObject:self.date forKey:@"date"];
|
||||||
[encoder encodeObject:self.id forKey:@"id"];
|
[encoder encodeObject:self.id forKey:@"id"];
|
||||||
|
[encoder encodeObject:self.photos forKey:@"photos"];
|
||||||
[encoder encodeInteger:self.status forKey:@"status"];
|
[encoder encodeInteger:self.status forKey:@"status"];
|
||||||
[encoder encodeBool:self.userMessage forKey:@"userMessage"];
|
[encoder encodeBool:self.userMessage forKey:@"userMessage"];
|
||||||
[encoder encodeObject:self.token forKey:@"token"];
|
[encoder encodeObject:self.token forKey:@"token"];
|
||||||
@@ -72,6 +74,7 @@
|
|||||||
self.email = [decoder decodeObjectForKey:@"email"];
|
self.email = [decoder decodeObjectForKey:@"email"];
|
||||||
self.date = [decoder decodeObjectForKey:@"date"];
|
self.date = [decoder decodeObjectForKey:@"date"];
|
||||||
self.id = [decoder decodeObjectForKey:@"id"];
|
self.id = [decoder decodeObjectForKey:@"id"];
|
||||||
|
self.photos = [decoder decodeObjectForKey:@"photos"];
|
||||||
self.status = (BITFeedbackMessageStatus)[decoder decodeIntegerForKey:@"status"];
|
self.status = (BITFeedbackMessageStatus)[decoder decodeIntegerForKey:@"status"];
|
||||||
self.userMessage = [decoder decodeBoolForKey:@"userMessage"];
|
self.userMessage = [decoder decodeBoolForKey:@"userMessage"];
|
||||||
self.token = [decoder decodeObjectForKey:@"token"];
|
self.token = [decoder decodeObjectForKey:@"token"];
|
||||||
|
|||||||
@@ -118,8 +118,8 @@
|
|||||||
|
|
||||||
#pragma mark - Helpers
|
#pragma mark - Helpers
|
||||||
/**
|
/**
|
||||||
* create a post body from the given value, key and boundary
|
* create a post body from the given value, key and boundary. This is a convenience call to
|
||||||
* c/p from HockeyBaseManager
|
* dataWithPostValue:forKey:contentType:boundary and aimed at NSString-content.
|
||||||
*
|
*
|
||||||
* @param value -
|
* @param value -
|
||||||
* @param key -
|
* @param key -
|
||||||
@@ -128,4 +128,16 @@
|
|||||||
* @return NSData instance configured to be attached on a (post) URLRequest
|
* @return NSData instance configured to be attached on a (post) URLRequest
|
||||||
*/
|
*/
|
||||||
+ (NSData *)dataWithPostValue:(NSString *)value forKey:(NSString *)key boundary:(NSString *) boundary;
|
+ (NSData *)dataWithPostValue:(NSString *)value forKey:(NSString *)key boundary:(NSString *) boundary;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a post body from the given value, key and boundary and content type.
|
||||||
|
*
|
||||||
|
* @param value -
|
||||||
|
* @param key -
|
||||||
|
* @param boundary -
|
||||||
|
*
|
||||||
|
* @return NSData instance configured to be attached on a (post) URLRequest
|
||||||
|
*/
|
||||||
|
+ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -85,12 +85,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (NSData *)dataWithPostValue:(NSString *)value forKey:(NSString *)key boundary:(NSString *) boundary {
|
+ (NSData *)dataWithPostValue:(NSString *)value forKey:(NSString *)key boundary:(NSString *) boundary {
|
||||||
|
return [self dataWithPostValue:[value dataUsingEncoding:NSUTF8StringEncoding] forKey:key contentType:@"text" boundary:boundary];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSData *)dataWithPostValue:(NSData *)value forKey:(NSString *)key contentType:(NSString *)contentType boundary:(NSString *) boundary {
|
||||||
NSMutableData *postBody = [NSMutableData data];
|
NSMutableData *postBody = [NSMutableData data];
|
||||||
|
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\";\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\";\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
[postBody appendData:[[NSString stringWithFormat:@"Content-Type: text\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", contentType] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
[postBody appendData:[value dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:value];
|
||||||
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
[postBody appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
|
||||||
|
|
||||||
return postBody;
|
return postBody;
|
||||||
|
|||||||
Reference in New Issue
Block a user