+ Changing machines..

This commit is contained in:
moritz haarmann 2014-02-17 21:04:03 +01:00
parent 4b359e7771
commit 38af43bdb5
10 changed files with 266 additions and 25 deletions

View File

@ -34,6 +34,7 @@
#import "HockeySDKPrivate.h"
#import "BITFeedbackManagerPrivate.h"
#import "BITFeedbackMessageAttachment.h"
#import "BITFeedbackComposeViewController.h"
#import "BITFeedbackUserDataViewController.h"
@ -160,8 +161,6 @@
self.contentViewContainer = [[UIView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:self.contentViewContainer];
// message input textfield
self.textView = [[UITextView alloc] initWithFrame:self.view.bounds];
self.textView.font = [UIFont systemFontOfSize:17];
@ -185,15 +184,13 @@
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.contentViewContainer addSubview:self.photoScrollView];
}
- (void)viewWillAppear:(BOOL)animated {
@ -271,9 +268,6 @@
if (!alreadySetup){
textViewFrame.size.width -= scrollViewWidth;
// status bar?
scrollViewFrame = CGRectMake(CGRectGetMaxX(textViewFrame), self.view.frame.origin.y, scrollViewWidth, CGRectGetHeight(textViewFrame));
self.textView.frame = textViewFrame;
self.photoScrollView.frame = scrollViewFrame;
@ -315,8 +309,6 @@
}
[self.photoScrollView setContentSize:CGSizeMake(CGRectGetWidth(self.photoScrollView.frame), currentYOffset)];
}
@ -351,7 +343,16 @@
NSString *text = self.textView.text;
[self.manager submitMessageWithText:text andPhotos:self.photos];
// Create attachments from the photos.
NSMutableArray *attachments = [NSMutableArray new];
for (UIImage *photo in self.photos){
BITFeedbackMessageAttachment *attachment = [BITFeedbackMessageAttachment attachmentWithData:UIImageJPEGRepresentation(photo, 0.7f) contentType:@"image/jpeg"];
[attachments addObject:attachment];
}
[self.manager submitMessageWithText:text andAttachments:attachments];
[self dismissWithResult:BITFeedbackComposeResultSubmitted];
}
@ -392,7 +393,7 @@
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}
#pragma mark - BITFeedbackUserDataDelegate

View File

@ -34,6 +34,7 @@
#import "HockeySDKPrivate.h"
#import "BITFeedbackManager.h"
#import "BITFeedbackMessageAttachment.h"
#import "BITFeedbackManagerPrivate.h"
#import "BITHockeyBaseManagerPrivate.h"
@ -697,6 +698,14 @@
matchingSendInProgressOrInConflictMessage.date = [self parseRFC3339Date:[(NSDictionary *)objMessage objectForKey:@"created_at"]];
matchingSendInProgressOrInConflictMessage.id = messageID;
matchingSendInProgressOrInConflictMessage.status = BITFeedbackMessageStatusRead;
NSArray *feedbackAttachments =[(NSDictionary *)objMessage objectForKey:@"attachments"];
if (matchingSendInProgressOrInConflictMessage.attachments.count == feedbackAttachments.count) {
int attachmentIndex = 0;
for (BITFeedbackMessageAttachment* attachment in matchingSendInProgressOrInConflictMessage.attachments){
attachment.id =feedbackAttachments[attachmentIndex][@"id"];
attachmentIndex++;
}
}
} else {
if ([(NSDictionary *)objMessage objectForKey:@"clean_text"] || [(NSDictionary *)objMessage objectForKey:@"text"]) {
BITFeedbackMessage *message = [[BITFeedbackMessage alloc] init];
@ -835,17 +844,18 @@
[postBody appendData:[BITHockeyAppClient dataWithPostValue:self.userEmail forKey:@"email" boundary:boundary]];
}
[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]];
for (BITFeedbackMessageAttachment *attachment in message.attachments){
NSString *key = [NSString stringWithFormat:@"attachment%ld", (long)photoIndex];
[postBody appendData:[BITHockeyAppClient dataWithPostValue:attachment.data forKey:key contentType:attachment.contentType boundary:boundary]];
photoIndex++;
}
[postBody appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postBody];
}
@ -980,12 +990,12 @@
}
}
- (void)submitMessageWithText:(NSString *)text andPhotos:(NSArray *)photos {
- (void)submitMessageWithText:(NSString *)text andAttachments:(NSArray *)attachments {
BITFeedbackMessage *message = [[BITFeedbackMessage alloc] init];
message.text = text;
[message setStatus:BITFeedbackMessageStatusSendPending];
[message setToken:[self uuidAsLowerCaseAndShortened]];
[message setPhotos:photos];
[message setAttachments:attachments];
[message setUserMessage:YES];
[_feedbackList addObject:message];

View File

@ -65,7 +65,7 @@
- (NSUInteger)numberOfMessages;
- (BITFeedbackMessage *)messageAtIndex:(NSUInteger)index;
- (void)submitMessageWithText:(NSString *)text andPhotos:(NSArray *)photos;
- (void)submitMessageWithText:(NSString *)text andAttachments:(NSArray *)photos;
- (void)submitPendingMessages;
// Returns YES if manual user data can be entered, required or optional

View File

@ -69,7 +69,7 @@ typedef NS_ENUM(NSInteger, BITFeedbackMessageStatus) {
@property (nonatomic, copy) NSDate *date;
@property (nonatomic, copy) NSNumber *id;
@property (nonatomic, copy) NSString *token;
@property (nonatomic, strong) NSArray *photos;
@property (nonatomic, strong) NSArray *attachments;
@property (nonatomic) BITFeedbackMessageStatus status;
@property (nonatomic) BOOL userMessage;

View File

@ -42,7 +42,7 @@
_email = nil;
_date = [[NSDate alloc] init];
_token = nil;
_photos = nil;
_attachments = nil;
_id = [[NSNumber alloc] initWithInteger:0];
_status = BITFeedbackMessageStatusSendPending;
_userMessage = NO;
@ -60,7 +60,7 @@
[encoder encodeObject:self.email forKey:@"email"];
[encoder encodeObject:self.date forKey:@"date"];
[encoder encodeObject:self.id forKey:@"id"];
[encoder encodeObject:self.photos forKey:@"photos"];
[encoder encodeObject:self.attachments forKey:@"attachments"];
[encoder encodeInteger:self.status forKey:@"status"];
[encoder encodeBool:self.userMessage forKey:@"userMessage"];
[encoder encodeObject:self.token forKey:@"token"];
@ -74,7 +74,7 @@
self.email = [decoder decodeObjectForKey:@"email"];
self.date = [decoder decodeObjectForKey:@"date"];
self.id = [decoder decodeObjectForKey:@"id"];
self.photos = [decoder decodeObjectForKey:@"photos"];
self.attachments = [decoder decodeObjectForKey:@"attachments"];
self.status = (BITFeedbackMessageStatus)[decoder decodeIntegerForKey:@"status"];
self.userMessage = [decoder decodeBoolForKey:@"userMessage"];
self.token = [decoder decodeObjectForKey:@"token"];

View File

@ -0,0 +1,47 @@
/*
* Author: Moritz Haarmann <post@moritzhaarmann.de>
*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* Copyright (c) 2011 Andreas Linde & Kent Sutherland.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface BITFeedbackMessageAttachment : NSObject<NSCoding>
@property (nonatomic, copy) NSString *filename;
@property (nonatomic, copy) NSNumber *id;
@property (nonatomic, copy) NSString *contentType;
@property (readonly) UIImage *imageRepresentation;
@property (readonly) NSData *data;
+ (BITFeedbackMessageAttachment *)attachmentWithData:(NSData *)data contentType:(NSString *)contentType;
- (UIImage *)thumbnailWithSize:(CGSize)size;
@end

View File

@ -0,0 +1,97 @@
/*
* Author: Moritz Haarmann <post@moritzhaarmann.de>
*
* Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#import "BITFeedbackMessageAttachment.h"
#import "BITHockeyHelper.h"
#import "HockeySDKPrivate.h"
@interface BITFeedbackMessageAttachment()
@property (nonatomic, strong) NSData *data;
@property (nonatomic, strong) NSMutableDictionary *thumbnailRepresentations;
@end
@implementation BITFeedbackMessageAttachment
+ (BITFeedbackMessageAttachment *)attachmentWithData:(NSData *)data contentType:(NSString *)contentType {
BITFeedbackMessageAttachment *newAttachment = [BITFeedbackMessageAttachment new];
newAttachment.contentType = contentType;
newAttachment.data = data;
return newAttachment;
}
-(id)init {
self = [super init];
if (self){
self.thumbnailRepresentations = [NSMutableDictionary new];
}
return self;
}
#pragma mark NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.contentType forKey:@"contentType"];
[aCoder encodeObject:self.filename forKey:@"filename"];
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super init];
if (self){
self.contentType = [aDecoder decodeObjectForKey:@"contentType"];
self.filename = [aDecoder decodeObjectForKey:@"filename"];
self.thumbnailRepresentations = [NSMutableDictionary new];
}
return self;
}
- (UIImage *)imageRepresentation {
if ([self.contentType rangeOfString:@"image"].location != NSNotFound){
return [UIImage imageWithData:self.data];
} else {
// return bit_imageNamed(@"feedbackActiviy.png", BITHOCKEYSDK_BUNDLE);
}
}
- (UIImage *)thumbnailWithSize:(CGSize)size {
id<NSCopying> cacheKey = [NSValue valueWithCGSize:size];
// if (!self.thumbnailRepresentations[cacheKey]){
// UIImage *thumbnail =bit_imageToFitSize(self.imageRepresentation, size, YES);
// [self.thumbnailRepresentations setObject:thumbnail forKey:cacheKey];
// }
return self.thumbnailRepresentations[cacheKey];
}
@end

View File

@ -0,0 +1,15 @@
//
// BITImageAnnotationViewController.h
// HockeySDK
//
// Created by Moritz Haarmann on 14.02.14.
//
//
#import <UIKit/UIKit.h>
@interface BITImageAnnotationViewController : UIViewController
@property (nonatomic, strong) UIImage *image;
@end

View File

@ -0,0 +1,57 @@
//
// BITImageAnnotationViewController.m
// HockeySDK
//
// Created by Moritz Haarmann on 14.02.14.
//
//
#import "BITImageAnnotationViewController.h"
@interface BITImageAnnotationViewController ()
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UISegmentedControl *editingControls;
@property (nonatomic, strong) NSMutableArray *layers;
@end
@implementation BITImageAnnotationViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.editingControls = [[UISegmentedControl alloc] initWithItems:@[@"Arrow", @"Rect", @"Blur"]];
self.navigationItem.titleView = self.editingControls;
[self.editingControls addTarget:self action:@selector(editingAction:) forControlEvents:UIControlEventTouchUpInside];
self.imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
self.imageView.image = self.image;
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
// Do any additional setup after loading the view.
}
-(void)editingAction:(id)sender {
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end

View File

@ -133,6 +133,9 @@
1EFF03E517F2485500A5F13C /* BITCrashManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EFF03E417F2485500A5F13C /* BITCrashManagerTests.m */; };
97F0F9FD18ABAECD00EF50AA /* iconCamera.png in Resources */ = {isa = PBXBuildFile; fileRef = 97F0F9FB18ABAECD00EF50AA /* iconCamera.png */; };
97F0F9FE18ABAECD00EF50AA /* iconCamera@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 97F0F9FC18ABAECD00EF50AA /* iconCamera@2x.png */; };
97F0FA0118AE375E00EF50AA /* BITImageAnnotationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 97F0FA0018AE375E00EF50AA /* BITImageAnnotationViewController.m */; };
97F0FA0418AE5AED00EF50AA /* BITFeedbackMessageAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 97F0FA0318AE5AED00EF50AA /* BITFeedbackMessageAttachment.m */; };
97F0FA0518B2294D00EF50AA /* BITFeedbackMessageAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 97F0FA0318AE5AED00EF50AA /* BITFeedbackMessageAttachment.m */; };
E405266217A2AD300096359C /* BITFeedbackManagerDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = E405266117A2AD300096359C /* BITFeedbackManagerDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
E40E0B0917DA19DC005E38C1 /* BITHockeyAppClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E40E0B0817DA19DC005E38C1 /* BITHockeyAppClientTests.m */; };
E40E0B0C17DA1AFF005E38C1 /* BITHockeyAppClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E40E0B0A17DA1AFF005E38C1 /* BITHockeyAppClient.h */; };
@ -293,6 +296,10 @@
1EFF03E417F2485500A5F13C /* BITCrashManagerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITCrashManagerTests.m; sourceTree = "<group>"; };
97F0F9FB18ABAECD00EF50AA /* iconCamera.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = iconCamera.png; sourceTree = "<group>"; };
97F0F9FC18ABAECD00EF50AA /* iconCamera@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "iconCamera@2x.png"; sourceTree = "<group>"; };
97F0F9FF18AE375E00EF50AA /* BITImageAnnotationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITImageAnnotationViewController.h; sourceTree = "<group>"; };
97F0FA0018AE375E00EF50AA /* BITImageAnnotationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITImageAnnotationViewController.m; sourceTree = "<group>"; };
97F0FA0218AE5AED00EF50AA /* BITFeedbackMessageAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITFeedbackMessageAttachment.h; sourceTree = "<group>"; };
97F0FA0318AE5AED00EF50AA /* BITFeedbackMessageAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITFeedbackMessageAttachment.m; sourceTree = "<group>"; };
BEE0207C16C5107E004426EA /* hu */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/HockeySDK.strings; sourceTree = "<group>"; };
E400561D148D79B500EB22B9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
E405266117A2AD300096359C /* BITFeedbackManagerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITFeedbackManagerDelegate.h; sourceTree = "<group>"; };
@ -444,6 +451,8 @@
children = (
1E49A4361612223B00463151 /* BITFeedbackMessage.h */,
1E49A4371612223B00463151 /* BITFeedbackMessage.m */,
97F0FA0218AE5AED00EF50AA /* BITFeedbackMessageAttachment.h */,
97F0FA0318AE5AED00EF50AA /* BITFeedbackMessageAttachment.m */,
1E49A42D1612223B00463151 /* BITFeedbackComposeViewController.h */,
1E49A42E1612223B00463151 /* BITFeedbackComposeViewController.m */,
1EF95CA9162CB313000AE3AD /* BITFeedbackComposeViewControllerDelegate.h */,
@ -459,6 +468,8 @@
1E49A4341612223B00463151 /* BITFeedbackManager.m */,
E405266117A2AD300096359C /* BITFeedbackManagerDelegate.h */,
1E49A4351612223B00463151 /* BITFeedbackManagerPrivate.h */,
97F0F9FF18AE375E00EF50AA /* BITImageAnnotationViewController.h */,
97F0FA0018AE375E00EF50AA /* BITImageAnnotationViewController.m */,
);
name = Feedback;
sourceTree = "<group>";
@ -887,11 +898,12 @@
1E49A4601612223B00463151 /* BITFeedbackUserDataViewController.m in Sources */,
1E49A4701612226D00463151 /* BITAppVersionMetaInfo.m in Sources */,
1E49A4761612226D00463151 /* BITUpdateManager.m in Sources */,
1E49A4C1161222B900463151 /* BITHockeyHelper.m in Sources */,
1E49A4821612226D00463151 /* BITUpdateViewController.m in Sources */,
E4B4DB7E17B435550099C67F /* BITAuthenticationViewController.m in Sources */,
1E49A4B2161222B900463151 /* BITHockeyBaseManager.m in Sources */,
1E49A4BB161222B900463151 /* BITHockeyBaseViewController.m in Sources */,
1E49A4C1161222B900463151 /* BITHockeyHelper.m in Sources */,
97F0FA0518B2294D00EF50AA /* BITFeedbackMessageAttachment.m in Sources */,
1E49A4C7161222B900463151 /* BITAppStoreHeader.m in Sources */,
1E49A4CD161222B900463151 /* BITStoreButton.m in Sources */,
1E49A4D3161222B900463151 /* BITWebTableViewCell.m in Sources */,
@ -910,6 +922,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
97F0FA0118AE375E00EF50AA /* BITImageAnnotationViewController.m in Sources */,
97F0FA0418AE5AED00EF50AA /* BITFeedbackMessageAttachment.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};