-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from birarda/18834
Code Review for Job #18834
- Loading branch information
Showing
20 changed files
with
620 additions
and
75 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// GeofenceLogEntryCell.h | ||
// candpiosapp | ||
// | ||
// Created by Stephen Birarda on 12/17/12. | ||
// Copyright (c) 2012 Coffee and Power Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface GeofenceLogEntryCell : UITableViewCell | ||
@property (weak, nonatomic) IBOutlet UILabel *venueNameLabel; | ||
@property (weak, nonatomic) IBOutlet UILabel *entryDateLabel; | ||
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// GeofenceLogEntryCell.m | ||
// candpiosapp | ||
// | ||
// Created by Stephen Birarda on 12/17/12. | ||
// Copyright (c) 2012 Coffee and Power Inc. All rights reserved. | ||
// | ||
|
||
#import "GeofenceLogEntryCell.h" | ||
|
||
@implementation GeofenceLogEntryCell | ||
|
||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier | ||
{ | ||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; | ||
if (self) { | ||
// Initialization code | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated | ||
{ | ||
[super setSelected:selected animated:animated]; | ||
|
||
// Configure the view for the selected state | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// GeofenceLogTableViewController.h | ||
// candpiosapp | ||
// | ||
// Created by Stephen Birarda on 12/17/12. | ||
// Copyright (c) 2012 Coffee and Power Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface GeofenceLogTableViewController : UITableViewController | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// GeofenceLogTableViewController.m | ||
// candpiosapp | ||
// | ||
// Created by Stephen Birarda on 12/17/12. | ||
// Copyright (c) 2012 Coffee and Power Inc. All rights reserved. | ||
// | ||
|
||
#import "GeofenceLogTableViewController.h" | ||
#import "GeofenceLogEntryCell.h" | ||
#import <MessageUI/MFMailComposeViewController.h> | ||
|
||
@interface GeofenceLogTableViewController () <MFMailComposeViewControllerDelegate> | ||
|
||
@property (strong, nonatomic) NSArray *logEntries; | ||
@property (strong, nonatomic) NSDateFormatter *entryDateFormatter; | ||
|
||
@end | ||
|
||
@implementation GeofenceLogTableViewController | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
|
||
self.logEntries = [CPUserDefaultsHandler geofenceRequestLog]; | ||
|
||
if (![MFMailComposeViewController canSendMail] || self.logEntries.count == 0) { | ||
// hide the email button | ||
self.navigationItem.rightBarButtonItem = nil; | ||
} | ||
} | ||
|
||
- (NSDateFormatter *)entryDateFormatter | ||
{ | ||
if (!_entryDateFormatter) { | ||
_entryDateFormatter = [[NSDateFormatter alloc] init]; | ||
_entryDateFormatter.dateFormat = @"MMMM d - h:mm:ss a"; | ||
} | ||
|
||
return _entryDateFormatter; | ||
} | ||
|
||
#pragma mark - Table view data source | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | ||
{ | ||
// Return the number of rows in the section. | ||
return self.logEntries.count; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
static NSString *CellIdentifier = @"GeofenceLogEntryCell"; | ||
GeofenceLogEntryCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; | ||
|
||
NSDictionary *logEntryDict = [self.logEntries objectAtIndex:indexPath.row]; | ||
|
||
cell.venueNameLabel.text = logEntryDict[@"venueName"]; | ||
cell.entryDateLabel.text = [self.entryDateFormatter stringFromDate:logEntryDict[@"date"]]; | ||
|
||
NSString *imageName = [logEntryDict[@"type"] isEqualToString:@"checkIn"] ? @"check-in-for-list" : @"check-out-for-list"; | ||
cell.iconImageView.image = [UIImage imageNamed:imageName]; | ||
|
||
return cell; | ||
} | ||
|
||
#pragma mark - IBActions | ||
- (IBAction)emailLogButtonPressed:(id)sender | ||
{ | ||
MFMailComposeViewController *composeVC = [[MFMailComposeViewController alloc] init]; | ||
composeVC.mailComposeDelegate = self; | ||
[composeVC setSubject:[NSString stringWithFormat:@"Geofence log for %@ (%@)", | ||
[CPUserDefaultsHandler currentUser].nickname, | ||
[CPUserDefaultsHandler currentUser].userID]]; | ||
|
||
NSMutableString *emailBody = [NSMutableString stringWithString:@""]; | ||
|
||
for (NSDictionary *logEntryDict in self.logEntries) { | ||
[emailBody appendString:[NSString stringWithFormat:@"%@, %@, %@, %@, %@\n", | ||
logEntryDict[@"venueID"], | ||
logEntryDict[@"lat"], | ||
logEntryDict[@"lng"], | ||
[self.entryDateFormatter stringFromDate:logEntryDict[@"date"]], | ||
logEntryDict[@"type"]]]; | ||
} | ||
|
||
[composeVC setMessageBody:emailBody isHTML:NO]; | ||
[composeVC setToRecipients:@[@"[email protected]"]]; | ||
[self presentModalViewController:composeVC animated:YES]; | ||
} | ||
|
||
#pragma mark - MFMailComposeViewControllerDelegate | ||
- (void)mailComposeController:(MFMailComposeViewController *)controller | ||
didFinishWithResult:(MFMailComposeResult)result | ||
error:(NSError *)error | ||
{ | ||
[self dismissModalViewControllerAnimated:YES]; | ||
} | ||
|
||
@end |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.