diff options
Diffstat (limited to 'iphone/FixMyStreet/Classes')
-rw-r--r-- | iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h | 7 | ||||
-rw-r--r-- | iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m | 15 | ||||
-rw-r--r-- | iphone/FixMyStreet/Classes/InputTableViewController.m | 16 |
3 files changed, 27 insertions, 11 deletions
diff --git a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h index 0c67e845a..35dbb0837 100644 --- a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h +++ b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.h @@ -17,7 +17,9 @@ // The report currently being entered. UIImage* image; - CLLocation* location; + + NSString* latitude; + NSString* longitude; NSString* subject; NSString* name; @@ -33,7 +35,8 @@ //@property (nonatomic, retain) IBOutlet UIViewController *viewController; @property (nonatomic, retain) UIImage* image; -@property (nonatomic, retain) CLLocation* location; +@property (nonatomic, retain) NSString* latitude; +@property (nonatomic, retain) NSString* longitude; @property (nonatomic, retain) NSString* subject; @property (nonatomic, retain) NSString* name; @property (nonatomic, retain) NSString* email; diff --git a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m index 01b742de2..a58ba893b 100644 --- a/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m +++ b/iphone/FixMyStreet/Classes/FixMyStreetAppDelegate.m @@ -12,7 +12,7 @@ @implementation FixMyStreetAppDelegate @synthesize window, navigationController; //, viewController; -@synthesize image, location, subject, name, email, phone; +@synthesize image, latitude, longitude, subject, name, email, phone; - (void)applicationDidFinishLaunching:(UIApplication *)application { InputTableViewController *inputTableViewController = [[InputTableViewController alloc] initWithNibName:@"MainViewController" bundle:[NSBundle mainBundle]]; @@ -37,6 +37,8 @@ // image = (UIImage *)[NSKeyedUnarchiver unarchiveObjectWithData:imageData]; // [imageData release]; + latitude = [[NSUserDefaults standardUserDefaults] stringForKey:@"Latitude"]; + longitude = [[NSUserDefaults standardUserDefaults] stringForKey:@"Longitude"]; // NSData *locationData = [[NSUserDefaults standardUserDefaults] objectForKey:@"Location"]; // if (locationData != nil) // location = (CLLocation *)[NSUnarchiver unarchiveObjectWithData:locationData]; @@ -60,8 +62,9 @@ [navigationController release]; // [viewController release]; [image release]; + [latitude release]; + [longitude release]; [subject release]; - [location release]; [name release]; [email release]; [phone release]; @@ -87,6 +90,8 @@ // [[NSUserDefaults standardUserDefaults] setObject:imageData forKey:@"Image"]; // [imageData release]; + [[NSUserDefaults standardUserDefaults] setObject:latitude forKey:@"Latitude"]; + [[NSUserDefaults standardUserDefaults] setObject:longitude forKey:@"Longitude"]; // NSData *locationData = [NSKeyedArchiver archivedDataWithRootObject:location]; // [[NSUserDefaults standardUserDefaults] setObject:locationData forKey:@"Location"]; // [locationData release]; @@ -149,9 +154,9 @@ [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"phone\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]]; [postBody appendData:[phone dataUsingEncoding:NSASCIIStringEncoding]]; - if (location) { - NSString* latitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude]; - NSString* longitude = [NSString stringWithFormat:@"%f", location.coordinate.longitude]; + if (latitude) { +// NSString* latitude = [NSString stringWithFormat:@"%f", location.coordinates.latitude]; +// NSString* longitude = [NSString stringWithFormat:@"%f", location.coordinates.longitude]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSASCIIStringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"lat\"\r\n\r\n"] dataUsingEncoding:NSASCIIStringEncoding]]; [postBody appendData:[latitude dataUsingEncoding:NSASCIIStringEncoding]]; diff --git a/iphone/FixMyStreet/Classes/InputTableViewController.m b/iphone/FixMyStreet/Classes/InputTableViewController.m index 6515e3e75..91c7ec5e9 100644 --- a/iphone/FixMyStreet/Classes/InputTableViewController.m +++ b/iphone/FixMyStreet/Classes/InputTableViewController.m @@ -53,6 +53,12 @@ // Let's start trying to find our location... [MyCLController sharedInstance].delegate = self; [[MyCLController sharedInstance] startUpdatingLocation]; + + FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; + if (delegate.image) { + imageView.image = delegate.image; + } + } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -66,7 +72,7 @@ -(void)enableSubmissionButton { [actionsToDoView reloadData]; FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; - if (delegate.image && delegate.location && delegate.subject && delegate.subject.length) { + if (delegate.image && delegate.latitude && delegate.subject && delegate.subject.length) { self.navigationItem.rightBarButtonItem.enabled = YES; } else { self.navigationItem.rightBarButtonItem.enabled = NO; @@ -124,7 +130,7 @@ cell.text = @"Take photo"; actionTakePhotoCell = cell; } else if (indexPath.section == 2) { - if (delegate.location) { + if (delegate.latitude) { cell.accessoryView = nil; cell.accessoryType = UITableViewCellAccessoryCheckmark; } else if ([MyCLController sharedInstance].updating) { @@ -270,8 +276,10 @@ //[alert release]; FixMyStreetAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; - delegate.location = location; - +// delegate.location = location; + delegate.latitude = [NSString stringWithFormat:@"%f", location.coordinate.latitude]; + delegate.longitude = [NSString stringWithFormat:@"%f", location.coordinate.longitude]; + [self enableSubmissionButton]; } |