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;
_customActivityTitle = nil;
self.items = [NSMutableArray array];;
_items = [NSMutableArray array];
}
return self;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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