diff --git a/phoneClients/android/.idea/workspace.xml b/phoneClients/android/.idea/workspace.xml index 0b9e974..1721efe 100644 --- a/phoneClients/android/.idea/workspace.xml +++ b/phoneClients/android/.idea/workspace.xml @@ -116,9 +116,7 @@ - - - + @@ -967,9 +965,7 @@ - - - + @@ -1194,9 +1190,7 @@ - - - + diff --git a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj index 7a79917..a04b8d1 100644 --- a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj +++ b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 882C391C186A5FB300FF2664 /* WSMHttpClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 882C391B186A5FB300FF2664 /* WSMHttpClient.m */; }; + 882C3920186A662400FF2664 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 882C391F186A662400FF2664 /* CoreLocation.framework */; }; 88B1AAD518697121005276D4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88B1AAD418697121005276D4 /* Foundation.framework */; }; 88B1AAD718697121005276D4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88B1AAD618697121005276D4 /* CoreGraphics.framework */; }; 88B1AAD918697121005276D4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88B1AAD818697121005276D4 /* UIKit.framework */; }; @@ -19,6 +21,9 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 882C391A186A5FB300FF2664 /* WSMHttpClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WSMHttpClient.h; sourceTree = ""; }; + 882C391B186A5FB300FF2664 /* WSMHttpClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WSMHttpClient.m; sourceTree = ""; }; + 882C391F186A662400FF2664 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; 88B1AAD118697121005276D4 /* GpsTracker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GpsTracker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 88B1AAD418697121005276D4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 88B1AAD618697121005276D4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -41,6 +46,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 882C3920186A662400FF2664 /* CoreLocation.framework in Frameworks */, 88B1AAD718697121005276D4 /* CoreGraphics.framework in Frameworks */, 88B1AAD918697121005276D4 /* UIKit.framework in Frameworks */, 88B1AAD518697121005276D4 /* Foundation.framework in Frameworks */, @@ -70,6 +76,7 @@ 88B1AAD318697121005276D4 /* Frameworks */ = { isa = PBXGroup; children = ( + 882C391F186A662400FF2664 /* CoreLocation.framework */, 88B1AAD418697121005276D4 /* Foundation.framework */, 88B1AAD618697121005276D4 /* CoreGraphics.framework */, 88B1AAD818697121005276D4 /* UIKit.framework */, @@ -86,6 +93,8 @@ 88B1AAE618697121005276D4 /* Main.storyboard */, 88B1AAE918697121005276D4 /* WSMViewController.h */, 88B1AAEA18697121005276D4 /* WSMViewController.m */, + 882C391A186A5FB300FF2664 /* WSMHttpClient.h */, + 882C391B186A5FB300FF2664 /* WSMHttpClient.m */, 88B1AAEC18697121005276D4 /* Images.xcassets */, 88B1AADB18697121005276D4 /* Supporting Files */, ); @@ -178,6 +187,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 882C391C186A5FB300FF2664 /* WSMHttpClient.m in Sources */, 88B1AAE518697121005276D4 /* WSMAppDelegate.m in Sources */, 88B1AAE118697121005276D4 /* main.m in Sources */, 88B1AAEB18697121005276D4 /* WSMViewController.m in Sources */, diff --git a/phoneClients/ios/GpsTracker/WSMHttpClient.h b/phoneClients/ios/GpsTracker/WSMHttpClient.h new file mode 100644 index 0000000..9cc7e07 --- /dev/null +++ b/phoneClients/ios/GpsTracker/WSMHttpClient.h @@ -0,0 +1,15 @@ +// +// WSMHttpClient.h +// GpsTracker +// +// Created by Nick Fox on 12/24/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +#import + +@interface WSMHttpClient : NSObject + +- (void)sendLocationToWebsite; + +@end diff --git a/phoneClients/ios/GpsTracker/WSMHttpClient.m b/phoneClients/ios/GpsTracker/WSMHttpClient.m new file mode 100644 index 0000000..60b2ed0 --- /dev/null +++ b/phoneClients/ios/GpsTracker/WSMHttpClient.m @@ -0,0 +1,71 @@ +// +// WSMHttpClient.m +// GpsTracker +// +// Created by Nick Fox on 12/24/13. +// Copyright (c) 2013 Nick Fox. All rights reserved. +// + +#import "WSMHttpClient.h" + +@interface WSMHttpClient () +{ + //NSString *defaultUploadWebsite; +} +@end + +@implementation WSMHttpClient + + +- (id)init; +{ + if((self = [super init])) + { + //defaultUploadWebsite = @"http://www.websmithing.com/gpstracker2/getgooglemap3.php"; + //NSLog(@"archiveFilePath: %@", [self archiveFilePath]); + } + + return self; +} + +- (void)sendLocationToWebsite { + + static NSString *defaultUploadWebsite = @"http://www.websmithing.com/gpstracker2/getgooglemap3.php"; + NSURLRequest *defaultUploadWebsiteRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:defaultUploadWebsite]]; + + [NSURLConnection sendAsynchronousRequest:defaultUploadWebsiteRequest queue:[NSOperationQueue mainQueue] + completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { + + // back on the main thread, check for errors, if no errors start the parsing + // + [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; + + // here we check for any returned NSError from the server, "and" we also check for any http response errors + if (error != nil) { + //[self handleError:error]; + } + else { + // check for any response errors + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if ((([httpResponse statusCode]/100) == 2) && [[response MIMEType] isEqual:@"application/atom+xml"]) { + + // Update the UI and start parsing the data, + // Spawn an NSOperation to parse the earthquake data so that the UI is not + // blocked while the application parses the XML data. + // + //APLParseOperation *parseOperation = [[APLParseOperation alloc] initWithData:data]; + //[self.parseQueue addOperation:parseOperation]; + } + else { + NSString *errorString = + NSLocalizedString(@"HTTP Error", @"Error message displayed when receving a connection error."); + NSDictionary *userInfo = @{NSLocalizedDescriptionKey : errorString}; + //NSError *reportError = [NSError errorWithDomain:@"HTTP" code:[httpResponse statusCode] userInfo:userInfo]; + //[self handleError:reportError]; + } + } + }]; + + +} +@end \ No newline at end of file diff --git a/phoneClients/ios/GpsTracker/WSMViewController.m b/phoneClients/ios/GpsTracker/WSMViewController.m index 836ee12..e2a8cf0 100644 --- a/phoneClients/ios/GpsTracker/WSMViewController.m +++ b/phoneClients/ios/GpsTracker/WSMViewController.m @@ -7,23 +7,58 @@ // #import "WSMViewController.h" +#import -@interface WSMViewController () + +@interface WSMViewController () @end @implementation WSMViewController +{ + CLLocationManager *locationManager; + bool firstTimeGettingPosition; + CLLocation *previousLocation; + int totalDistanceInMeters; +} - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + + firstTimeGettingPosition = true; + totalDistanceInMeters = 0; + + locationManager = [[CLLocationManager alloc] init]; + locationManager.delegate = self; + locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; + [locationManager startUpdatingLocation]; + +} + +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations +{ + if (firstTimeGettingPosition) { + firstTimeGettingPosition = false; + } else { + CLLocation *currentLocation = locations[0]; + CLLocationDistance distance = [currentLocation distanceFromLocation:previousLocation]; + totalDistanceInMeters += (int)distance; + } + + previousLocation = locations[0]; + + +} + +- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error +{ + } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. } @end