Minor code cleanup in Feedback component

This commit is contained in:
Andreas Linde 2014-06-20 16:43:58 +02:00
parent c5cee82954
commit c1d75806c7
10 changed files with 44 additions and 44 deletions

View File

@ -59,7 +59,7 @@
_customActivityImage = nil; _customActivityImage = nil;
_customActivityTitle = nil; _customActivityTitle = nil;
self.items = [NSMutableArray array];; _items = [NSMutableArray array];
} }
return self; return self;

View File

@ -79,7 +79,6 @@
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if (self) { if (self) {
self.title = BITHockeyLocalizedString(@"HockeyFeedbackComposeTitle");
_blockUserDataScreen = NO; _blockUserDataScreen = NO;
_actionSheetVisible = NO; _actionSheetVisible = NO;
_delegate = nil; _delegate = nil;
@ -87,8 +86,8 @@
_attachments = [NSMutableArray new]; _attachments = [NSMutableArray new];
_imageAttachments = [NSMutableArray new]; _imageAttachments = [NSMutableArray new];
_attachmentScrollViewImageViews = [NSMutableArray new]; _attachmentScrollViewImageViews = [NSMutableArray new];
self.tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewTapped:)]; _tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollViewTapped:)];
[self.attachmentScrollView addGestureRecognizer:self.tapRecognizer]; [_attachmentScrollView addGestureRecognizer:self.tapRecognizer];
_text = nil; _text = nil;
} }
@ -167,6 +166,7 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.title = BITHockeyLocalizedString(@"HockeyFeedbackComposeTitle");
self.view.backgroundColor = [UIColor whiteColor]; self.view.backgroundColor = [UIColor whiteColor];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.

View File

@ -85,28 +85,28 @@
_message = nil; _message = nil;
self.dateFormatter = [[NSDateFormatter alloc] init]; _dateFormatter = [[NSDateFormatter alloc] init];
[self.dateFormatter setTimeStyle:NSDateFormatterNoStyle]; [_dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[self.dateFormatter setDateStyle:NSDateFormatterMediumStyle]; [_dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[self.dateFormatter setLocale:[NSLocale currentLocale]]; [_dateFormatter setLocale:[NSLocale currentLocale]];
[self.dateFormatter setDoesRelativeDateFormatting:YES]; [_dateFormatter setDoesRelativeDateFormatting:YES];
self.timeFormatter = [[NSDateFormatter alloc] init]; _timeFormatter = [[NSDateFormatter alloc] init];
[self.timeFormatter setTimeStyle:NSDateFormatterShortStyle]; [_timeFormatter setTimeStyle:NSDateFormatterShortStyle];
[self.timeFormatter setDateStyle:NSDateFormatterNoStyle]; [_timeFormatter setDateStyle:NSDateFormatterNoStyle];
[self.timeFormatter setLocale:[NSLocale currentLocale]]; [_timeFormatter setLocale:[NSLocale currentLocale]];
[self.timeFormatter setDoesRelativeDateFormatting:YES]; [_timeFormatter setDoesRelativeDateFormatting:YES];
self.labelTitle = [[UILabel alloc] init]; _labelTitle = [[UILabel alloc] init];
self.labelTitle.font = [UIFont systemFontOfSize:TITLE_FONTSIZE]; _labelTitle.font = [UIFont systemFontOfSize:TITLE_FONTSIZE];
self.labelText = [[BITAttributedLabel alloc] init]; _labelText = [[BITAttributedLabel alloc] init];
self.labelText.font = [UIFont systemFontOfSize:TEXT_FONTSIZE]; _labelText.font = [UIFont systemFontOfSize:TEXT_FONTSIZE];
self.labelText.numberOfLines = 0; _labelText.numberOfLines = 0;
self.labelText.textAlignment = kBITTextLabelAlignmentLeft; _labelText.textAlignment = kBITTextLabelAlignmentLeft;
self.labelText.dataDetectorTypes = UIDataDetectorTypeAll; _labelText.dataDetectorTypes = UIDataDetectorTypeAll;
self.attachmentViews = [NSMutableArray new]; _attachmentViews = [NSMutableArray new];
} }
return self; return self;
} }

View File

@ -91,10 +91,10 @@
_userButtonSection = -1; _userButtonSection = -1;
_userDataComposeFlow = NO; _userDataComposeFlow = NO;
self.lastUpdateDateFormatter = [[NSDateFormatter alloc] init]; _lastUpdateDateFormatter = [[NSDateFormatter alloc] init];
[self.lastUpdateDateFormatter setDateStyle:NSDateFormatterShortStyle]; [_lastUpdateDateFormatter setDateStyle:NSDateFormatterShortStyle];
[self.lastUpdateDateFormatter setTimeStyle:NSDateFormatterShortStyle]; [_lastUpdateDateFormatter setTimeStyle:NSDateFormatterShortStyle];
self.lastUpdateDateFormatter.locale = [NSLocale currentLocale]; _lastUpdateDateFormatter.locale = [NSLocale currentLocale];
_thumbnailQueue = [NSOperationQueue new]; _thumbnailQueue = [NSOperationQueue new];
} }

View File

@ -95,7 +95,7 @@
_token = nil; _token = nil;
_lastMessageID = nil; _lastMessageID = nil;
self.feedbackList = [NSMutableArray array]; _feedbackList = [NSMutableArray array];
_fileManager = [[NSFileManager alloc] init]; _fileManager = [[NSFileManager alloc] init];
@ -537,7 +537,7 @@
__block BITFeedbackMessage *message = nil; __block BITFeedbackMessage *message = nil;
[_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) { [_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
if ([[objMessage id] isEqualToNumber:messageID]) { if ([[objMessage identifier] isEqualToNumber:messageID]) {
message = objMessage; message = objMessage;
*stop = YES; *stop = YES;
} }
@ -562,7 +562,7 @@
__block BITFeedbackMessage *message = nil; __block BITFeedbackMessage *message = nil;
[_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) { [_feedbackList enumerateObjectsUsingBlock:^(BITFeedbackMessage *objMessage, NSUInteger messagesIdx, BOOL *stop) {
if ([[objMessage id] integerValue] != 0) { if ([[objMessage identifier] integerValue] != 0) {
message = objMessage; message = objMessage;
*stop = YES; *stop = YES;
} }
@ -590,8 +590,8 @@
- (void)updateLastMessageID { - (void)updateLastMessageID {
BITFeedbackMessage *lastMessageHavingID = [self lastMessageHavingID]; BITFeedbackMessage *lastMessageHavingID = [self lastMessageHavingID];
if (lastMessageHavingID) { if (lastMessageHavingID) {
if (!self.lastMessageID || [self.lastMessageID compare:[lastMessageHavingID id]] != NSOrderedSame) if (!self.lastMessageID || [self.lastMessageID compare:[lastMessageHavingID identifier]] != NSOrderedSame)
self.lastMessageID = [lastMessageHavingID id]; self.lastMessageID = [lastMessageHavingID identifier];
} }
} }
@ -723,13 +723,13 @@
if (matchingSendInProgressOrInConflictMessage) { if (matchingSendInProgressOrInConflictMessage) {
matchingSendInProgressOrInConflictMessage.date = [self parseRFC3339Date:[(NSDictionary *)objMessage objectForKey:@"created_at"]]; matchingSendInProgressOrInConflictMessage.date = [self parseRFC3339Date:[(NSDictionary *)objMessage objectForKey:@"created_at"]];
matchingSendInProgressOrInConflictMessage.id = messageID; matchingSendInProgressOrInConflictMessage.identifier = messageID;
matchingSendInProgressOrInConflictMessage.status = BITFeedbackMessageStatusRead; matchingSendInProgressOrInConflictMessage.status = BITFeedbackMessageStatusRead;
NSArray *feedbackAttachments =[(NSDictionary *)objMessage objectForKey:@"attachments"]; NSArray *feedbackAttachments =[(NSDictionary *)objMessage objectForKey:@"attachments"];
if (matchingSendInProgressOrInConflictMessage.attachments.count == feedbackAttachments.count) { if (matchingSendInProgressOrInConflictMessage.attachments.count == feedbackAttachments.count) {
int attachmentIndex = 0; int attachmentIndex = 0;
for (BITFeedbackMessageAttachment* attachment in matchingSendInProgressOrInConflictMessage.attachments){ for (BITFeedbackMessageAttachment* attachment in matchingSendInProgressOrInConflictMessage.attachments){
attachment.id =feedbackAttachments[attachmentIndex][@"id"]; attachment.identifier =feedbackAttachments[attachmentIndex][@"id"];
attachmentIndex++; attachmentIndex++;
} }
} }
@ -741,13 +741,13 @@
message.email = [(NSDictionary *)objMessage objectForKey:@"email"] ?: @""; message.email = [(NSDictionary *)objMessage objectForKey:@"email"] ?: @"";
message.date = [self parseRFC3339Date:[(NSDictionary *)objMessage objectForKey:@"created_at"]] ?: [NSDate date]; message.date = [self parseRFC3339Date:[(NSDictionary *)objMessage objectForKey:@"created_at"]] ?: [NSDate date];
message.id = [(NSDictionary *)objMessage objectForKey:@"id"]; message.identifier = [(NSDictionary *)objMessage objectForKey:@"id"];
message.status = BITFeedbackMessageStatusUnread; message.status = BITFeedbackMessageStatusUnread;
for (NSDictionary *attachmentData in objMessage[@"attachments"]) { for (NSDictionary *attachmentData in objMessage[@"attachments"]) {
BITFeedbackMessageAttachment *newAttachment = [BITFeedbackMessageAttachment new]; BITFeedbackMessageAttachment *newAttachment = [BITFeedbackMessageAttachment new];
newAttachment.originalFilename = attachmentData[@"file_name"]; newAttachment.originalFilename = attachmentData[@"file_name"];
newAttachment.id = attachmentData[@"id"]; newAttachment.identifier = attachmentData[@"id"];
newAttachment.sourceURL = attachmentData[@"url"]; newAttachment.sourceURL = attachmentData[@"url"];
newAttachment.contentType = attachmentData[@"content_type"]; newAttachment.contentType = attachmentData[@"content_type"];
[message addAttachmentsObject:newAttachment]; [message addAttachmentsObject:newAttachment];

View File

@ -72,7 +72,7 @@ typedef NS_ENUM(NSInteger, BITFeedbackMessageStatus) {
@property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *email; @property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSDate *date; @property (nonatomic, copy) NSDate *date;
@property (nonatomic, copy) NSNumber *id; @property (nonatomic, copy) NSNumber *identifier;
@property (nonatomic, copy) NSString *token; @property (nonatomic, copy) NSString *token;
@property (nonatomic, strong) NSArray *attachments; @property (nonatomic, strong) NSArray *attachments;
@property (nonatomic) BITFeedbackMessageStatus status; @property (nonatomic) BITFeedbackMessageStatus status;

View File

@ -44,7 +44,7 @@
_date = [[NSDate alloc] init]; _date = [[NSDate alloc] init];
_token = nil; _token = nil;
_attachments = nil; _attachments = nil;
_id = [[NSNumber alloc] initWithInteger:0]; _identifier = [[NSNumber alloc] initWithInteger:0];
_status = BITFeedbackMessageStatusSendPending; _status = BITFeedbackMessageStatusSendPending;
_userMessage = NO; _userMessage = NO;
} }
@ -60,7 +60,7 @@
[encoder encodeObject:self.name forKey:@"name"]; [encoder encodeObject:self.name forKey:@"name"];
[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.identifier forKey:@"id"];
[encoder encodeObject:self.attachments forKey:@"attachments"]; [encoder encodeObject:self.attachments forKey:@"attachments"];
[encoder encodeInteger:self.status forKey:@"status"]; [encoder encodeInteger:self.status forKey:@"status"];
[encoder encodeBool:self.userMessage forKey:@"userMessage"]; [encoder encodeBool:self.userMessage forKey:@"userMessage"];
@ -74,7 +74,7 @@
self.name = [decoder decodeObjectForKey:@"name"]; self.name = [decoder decodeObjectForKey:@"name"];
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.identifier = [decoder decodeObjectForKey:@"id"];
self.attachments = [decoder decodeObjectForKey:@"attachments"]; self.attachments = [decoder decodeObjectForKey:@"attachments"];
self.status = (BITFeedbackMessageStatus)[decoder decodeIntegerForKey:@"status"]; self.status = (BITFeedbackMessageStatus)[decoder decodeIntegerForKey:@"status"];
self.userMessage = [decoder decodeBoolForKey:@"userMessage"]; self.userMessage = [decoder decodeBoolForKey:@"userMessage"];

View File

@ -35,7 +35,7 @@
*/ */
@interface BITFeedbackMessageAttachment : NSObject<NSCoding, QLPreviewItem> @interface BITFeedbackMessageAttachment : NSObject<NSCoding, QLPreviewItem>
@property (nonatomic, copy) NSNumber *id; @property (nonatomic, copy) NSNumber *identifier;
@property (nonatomic, copy) NSString *originalFilename; @property (nonatomic, copy) NSString *originalFilename;
@property (nonatomic, copy) NSString *contentType; @property (nonatomic, copy) NSString *contentType;
@property (nonatomic, copy) NSString *sourceURL; @property (nonatomic, copy) NSString *sourceURL;

View File

@ -72,8 +72,8 @@
- (instancetype)init { - (instancetype)init {
if ((self = [super init])) { if ((self = [super init])) {
self.isLoading = NO; _isLoading = NO;
self.thumbnailRepresentations = [NSMutableDictionary new]; _thumbnailRepresentations = [NSMutableDictionary new];
_fm = [[NSFileManager alloc] init]; _fm = [[NSFileManager alloc] init];
_cachePath = [bit_settingsDir() stringByAppendingPathComponent:kCacheFolderName]; _cachePath = [bit_settingsDir() stringByAppendingPathComponent:kCacheFolderName];

View File

@ -54,8 +54,6 @@
- (instancetype)initWithStyle:(UITableViewStyle)style { - (instancetype)initWithStyle:(UITableViewStyle)style {
self = [super initWithStyle:style]; self = [super initWithStyle:style];
if (self) { if (self) {
self.title = BITHockeyLocalizedString(@"HockeyFeedbackUserDataTitle");
_delegate = nil; _delegate = nil;
_manager = [BITHockeyManager sharedHockeyManager].feedbackManager; _manager = [BITHockeyManager sharedHockeyManager].feedbackManager;
@ -68,6 +66,8 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.title = BITHockeyLocalizedString(@"HockeyFeedbackUserDataTitle");
[self.tableView setScrollEnabled:NO]; [self.tableView setScrollEnabled:NO];
} }