Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions WordPress/Classes/ActivityLogViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
#import "ActivityLogDetailViewController.h"
#import <DDFileLogger.h>

static NSString *const ActivityLogCellIdentifier = @"ActivityLogCell";

@interface ActivityLogViewController ()
{
NSArray *logFiles;
NSDateFormatter *dateFormatter;
DDFileLogger *fileLogger;
}

@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, weak) DDFileLogger *fileLogger;
@property (nonatomic, strong) NSArray *logFiles;

@end

Expand All @@ -28,20 +29,15 @@ - (id)init
if (self) {
// TODO - Replace this call with an injected value, depending on design conventions already in place
WordPressAppDelegate *delegate = (WordPressAppDelegate *)[[UIApplication sharedApplication] delegate];
fileLogger = delegate.fileLogger;

dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateStyle = NSDateFormatterMediumStyle;
dateFormatter.doesRelativeDateFormatting = YES;
dateFormatter.timeStyle = NSDateFormatterShortStyle;
_fileLogger = delegate.fileLogger;

self.title = NSLocalizedString(@"Activity Logs", @"");

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Logs", @"")
style:UIBarButtonItemStyleBordered
target:nil
action:nil];
[[self navigationItem] setBackBarButtonItem:backButton];
[self.navigationItem setBackBarButtonItem:backButton];
}

return self;
Expand All @@ -53,6 +49,8 @@ - (void)viewDidLoad

[WPStyleGuide configureColorsForView:self.view andTableView:self.tableView];
[self loadLogFiles];

[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:ActivityLogCellIdentifier];
}

- (void)didReceiveMemoryWarning
Expand All @@ -63,7 +61,18 @@ - (void)didReceiveMemoryWarning

- (void)loadLogFiles
{
logFiles = fileLogger.logFileManager.sortedLogFileInfos;
self.logFiles = self.fileLogger.logFileManager.sortedLogFileInfos;
}

- (NSDateFormatter *)dateFormatter {
if (_dateFormatter) {
return _dateFormatter;
}
_dateFormatter = [[NSDateFormatter alloc] init];
_dateFormatter.dateStyle = NSDateFormatterMediumStyle;
_dateFormatter.doesRelativeDateFormatting = YES;
_dateFormatter.timeStyle = NSDateFormatterShortStyle;
return _dateFormatter;
}

#pragma mark - Table view data source
Expand All @@ -76,24 +85,17 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
return logFiles.count;
return self.logFiles.count;

return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ActivityLogCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ActivityLogCellIdentifier];
if (indexPath.section == 0) {
DDLogFileInfo *logFileInfo = (DDLogFileInfo *)logFiles[indexPath.row];
DDLogFileInfo *logFileInfo = (DDLogFileInfo *)self.logFiles[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = indexPath.row == 0 ? NSLocalizedString(@"Current", @"") : [dateFormatter stringFromDate:logFileInfo.creationDate];
cell.textLabel.text = indexPath.row == 0 ? NSLocalizedString(@"Current", @"") : [self.dateFormatter stringFromDate:logFileInfo.creationDate];
cell.textLabel.textAlignment = NSTextAlignmentLeft;
[WPStyleGuide configureTableViewCell:cell];
} else {
Expand All @@ -102,8 +104,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.textLabel.text = NSLocalizedString(@"Clear Old Activity Logs", @"");
[WPStyleGuide configureTableViewActionCell:cell];
}


return cell;
}

Expand Down Expand Up @@ -132,15 +132,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
[tableView deselectRowAtIndexPath:indexPath animated:YES];

if (indexPath.section == 0) {
DDLogFileInfo *logFileInfo = (DDLogFileInfo *)logFiles[indexPath.row];
DDLogFileInfo *logFileInfo = (DDLogFileInfo *)self.logFiles[indexPath.row];
NSData *logData = [NSData dataWithContentsOfFile:logFileInfo.filePath];
NSString *logText = [[NSString alloc] initWithData:logData encoding:NSUTF8StringEncoding];

ActivityLogDetailViewController *detailViewController = [[ActivityLogDetailViewController alloc] initWithLog:logText
forDateString:[dateFormatter stringFromDate:logFileInfo.creationDate]];
forDateString:[self.dateFormatter stringFromDate:logFileInfo.creationDate]];
[self.navigationController pushViewController:detailViewController animated:YES];
} else {
for (DDLogFileInfo *logFileInfo in logFiles) {
for (DDLogFileInfo *logFileInfo in self.logFiles) {
if (logFileInfo.isArchived)
[[NSFileManager defaultManager] removeItemAtPath:logFileInfo.filePath error:nil];
}
Expand Down
14 changes: 6 additions & 8 deletions WordPress/Classes/BlogDetailsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#import "WPTableViewCell.h"
#import "ContextManager.h"

static NSString *const BlogDetailsCellIdentifier = @"BlogDetailsCell";

typedef enum {
BlogDetailsRowPosts = 0,
BlogDetailsRowPages,
Expand Down Expand Up @@ -84,6 +86,8 @@ - (void)viewDidLoad {
}

[WPStyleGuide configureColorsForView:self.view andTableView:self.tableView];

[self.tableView registerClass:[WPTableViewCell class] forCellReuseIdentifier:BlogDetailsCellIdentifier];
}

- (void)viewWillAppear:(BOOL)animated {
Expand Down Expand Up @@ -136,14 +140,8 @@ - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPa
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"BlogDetailsCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
cell = [[WPTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:BlogDetailsCellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
[self configureCell:cell atIndexPath:indexPath];
[WPStyleGuide configureTableViewCell:cell];

Expand Down
14 changes: 7 additions & 7 deletions WordPress/Classes/BlogListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#import "Blog.h"
#import "WPAccount.h"

static NSString *const BlogCellIdentifier = @"BlogCell";
CGFloat const blavatarImageSize = 50.f;
NSString * const WPBlogListRestorationID = @"WPBlogListID";

@interface BlogListViewController ()

@property (nonatomic, strong) NSFetchedResultsController *resultsController;
@property (nonatomic, strong) UIBarButtonItem *settingsButton;
@property (nonatomic) BOOL sectionDeletedByController;
Expand Down Expand Up @@ -92,6 +94,8 @@ - (void)viewDidLoad {

[WPStyleGuide configureColorsForView:self.view andTableView:self.tableView];

[self.tableView registerClass:[WPTableViewCell class] forCellReuseIdentifier:BlogCellIdentifier];

self.navigationItem.leftBarButtonItem = self.editButtonItem;
}

Expand Down Expand Up @@ -149,11 +153,8 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"BlogCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[WPTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}

UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:BlogCellIdentifier];

[WPStyleGuide configureTableViewCell:cell];
[self configureCell:cell atIndexPath:indexPath];
Expand Down Expand Up @@ -358,8 +359,7 @@ - (void)visibilitySwitchAction:(id)sender {
}
}

#pragma mark -
#pragma mark NSFetchedResultsController
#pragma mark - NSFetchedResultsController

- (NSFetchedResultsController *)resultsController {
if (_resultsController) {
Expand Down
9 changes: 2 additions & 7 deletions WordPress/Classes/CommentsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,8 @@ - (NSString *)sectionNameKeyPath {
return @"status";
}

- (UITableViewCell *)newCell {
static NSString *cellIdentifier = @"CommentCell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[NewCommentsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
return cell;
- (Class)cellClass {
return [NewCommentsTableViewCell class];
}

- (void)syncItemsWithSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
Expand Down
2 changes: 0 additions & 2 deletions WordPress/Classes/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
#define PENDING_COMMENT_TABLE_VIEW_CELL_BACKGROUND_COLOR [UIColor colorWithRed:1.0 green:1.0 blue:170.0 / 255.0 alpha:1.0]
#define PENDING_COMMENT_TABLE_VIEW_CELL_BORDER_COLOR [UIColor colorWithRed:226.0 / 255.0 green:215.0 / 255.0 blue:58.0 / 255.0 alpha:1.0]
#define LOAD_MORE_DATA_TEXT_COLOR [UIColor colorWithRed:35.0 / 255.0 green:112.0 / 255.0 blue:216.0 / 255.0 alpha:1.0]
#define WRONG_FIELD_COLOR [UIColor colorWithRed:0.7 green:0.0 blue:0.0 alpha:1.0]
#define GOOD_FIELD_COLOR [UIColor blackColor]
#define WP_LINK_COLOR [UIColor colorWithRed:0.0 / 255.0 green:117.0 / 255.0 blue:156.0 / 255.0 alpha:1.0]
#define COMMENT_PARENT_BACKGROUND_COLOR [UIColor colorWithRed:222.0 / 255.0 green:222.0 / 255.0 blue:222.0 / 255.0 alpha:1.0]

Expand Down
Loading