diff --git a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj index e11b88c..96bb38f 100644 --- a/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj +++ b/phoneClients/ios/GpsTracker.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 88051648195AB5EB0069FAC6 /* CustomButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 88051647195AB5EB0069FAC6 /* CustomButton.m */; }; + 8805164B195ABC2C0069FAC6 /* UIColor+HexColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 8805164A195ABC2C0069FAC6 /* UIColor+HexColor.m */; }; 8884704B1874EB9400867228 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8884704A1874EB9400867228 /* Foundation.framework */; }; 8884704D1874EB9400867228 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8884704C1874EB9400867228 /* CoreGraphics.framework */; }; 8884704F1874EB9400867228 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8884704E1874EB9400867228 /* UIKit.framework */; }; @@ -22,6 +24,10 @@ /* Begin PBXFileReference section */ 6C8880B2EE17432CA6FDD050 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 88051646195AB5EB0069FAC6 /* CustomButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomButton.h; sourceTree = ""; }; + 88051647195AB5EB0069FAC6 /* CustomButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomButton.m; sourceTree = ""; }; + 88051649195ABC2C0069FAC6 /* UIColor+HexColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+HexColor.h"; sourceTree = ""; }; + 8805164A195ABC2C0069FAC6 /* UIColor+HexColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+HexColor.m"; sourceTree = ""; }; 888470471874EB9400867228 /* GpsTracker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GpsTracker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8884704A1874EB9400867228 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 8884704C1874EB9400867228 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -37,9 +43,6 @@ 888470601874EB9400867228 /* WSViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WSViewController.m; sourceTree = ""; }; 888470621874EB9400867228 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 888470691874EB9400867228 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - 888470711874EB9400867228 /* GpsTrackerTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GpsTrackerTests-Info.plist"; sourceTree = ""; }; - 888470731874EB9400867228 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - 888470751874EB9400867228 /* GpsTrackerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GpsTrackerTests.m; sourceTree = ""; }; 8884707F1875826600867228 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; BE3B3497D30F48C2ADC3BCE7 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ @@ -64,7 +67,6 @@ isa = PBXGroup; children = ( 888470501874EB9400867228 /* GpsTracker */, - 8884706F1874EB9400867228 /* GpsTrackerTests */, 888470491874EB9400867228 /* Frameworks */, 888470481874EB9400867228 /* Products */, BE3B3497D30F48C2ADC3BCE7 /* Pods.xcconfig */, @@ -100,6 +102,10 @@ 8884705C1874EB9400867228 /* Main.storyboard */, 8884705F1874EB9400867228 /* WSViewController.h */, 888470601874EB9400867228 /* WSViewController.m */, + 88051646195AB5EB0069FAC6 /* CustomButton.h */, + 88051647195AB5EB0069FAC6 /* CustomButton.m */, + 88051649195ABC2C0069FAC6 /* UIColor+HexColor.h */, + 8805164A195ABC2C0069FAC6 /* UIColor+HexColor.m */, 888470621874EB9400867228 /* Images.xcassets */, 888470511874EB9400867228 /* Supporting Files */, ); @@ -117,24 +123,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 8884706F1874EB9400867228 /* GpsTrackerTests */ = { - isa = PBXGroup; - children = ( - 888470751874EB9400867228 /* GpsTrackerTests.m */, - 888470701874EB9400867228 /* Supporting Files */, - ); - path = GpsTrackerTests; - sourceTree = ""; - }; - 888470701874EB9400867228 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 888470711874EB9400867228 /* GpsTrackerTests-Info.plist */, - 888470721874EB9400867228 /* InfoPlist.strings */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -245,6 +233,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 88051648195AB5EB0069FAC6 /* CustomButton.m in Sources */, + 8805164B195ABC2C0069FAC6 /* UIColor+HexColor.m in Sources */, 8884705B1874EB9400867228 /* WSAppDelegate.m in Sources */, 888470571874EB9400867228 /* main.m in Sources */, 888470611874EB9400867228 /* WSViewController.m in Sources */, @@ -270,14 +260,6 @@ name = Main.storyboard; sourceTree = ""; }; - 888470721874EB9400867228 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 888470731874EB9400867228 /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -362,6 +344,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "GpsTracker/GpsTracker-Prefix.pch"; INFOPLIST_FILE = "GpsTracker/GpsTracker-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; @@ -376,6 +359,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "GpsTracker/GpsTracker-Prefix.pch"; INFOPLIST_FILE = "GpsTracker/GpsTracker-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.1; PRODUCT_NAME = "$(TARGET_NAME)"; WRAPPER_EXTENSION = app; }; diff --git a/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard b/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard index cb1c188..6fb12e2 100644 --- a/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard +++ b/phoneClients/ios/GpsTracker/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -18,14 +18,14 @@ @@ -91,12 +122,12 @@ - + - + @@ -104,4 +135,4 @@ - \ No newline at end of file + diff --git a/phoneClients/ios/GpsTracker/CustomButton.h b/phoneClients/ios/GpsTracker/CustomButton.h new file mode 100644 index 0000000..62416d8 --- /dev/null +++ b/phoneClients/ios/GpsTracker/CustomButton.h @@ -0,0 +1,8 @@ +#import +#import + +@interface CustomButton : UIButton + +- (void)setButtonColor:(NSString *)buttonHexColor andHighLightColor:(NSString *)highlightHexColor andTextColor:(NSString *)textHexColor andHighlightTextColor:(NSString *)highlighTextHexColor; + +@end diff --git a/phoneClients/ios/GpsTracker/CustomButton.m b/phoneClients/ios/GpsTracker/CustomButton.m new file mode 100644 index 0000000..19da1f3 --- /dev/null +++ b/phoneClients/ios/GpsTracker/CustomButton.m @@ -0,0 +1,146 @@ + +#import "CustomButton.h" +#import "UIColor+HexColor.h" + +@interface CustomButton () + @property (assign, nonatomic) BOOL tapped; + @property (assign, nonatomic) BOOL setupLayers; + @property (strong, nonatomic) CALayer *backgroundLayer; + @property (strong, nonatomic) CALayer *highlightBackgroundLayer; + @property (strong, nonatomic) CALayer *innerGlow; + @property (strong, nonatomic) NSString *buttonHexColor; + @property (strong, nonatomic) NSString *highlightHexColor; + @property (strong, nonatomic) NSString *textHexColor; + @property (strong, nonatomic) NSString *highlighTextHexColor; +@end + +@implementation CustomButton + +#pragma mark - + +- (void)drawRect:(CGRect)rect +{ + // this is not drawing properly when changing orientation, but i'm staying in portrait anyway, will deal with it later + + if (!_setupLayers) + { + self.layer.cornerRadius = 4.5f; + self.layer.masksToBounds = YES; + self.layer.borderWidth = 1; + self.layer.borderColor = [UIColor colorFromHexString:@"#999999" andAlpha:1.0].CGColor; + + // [self setInnerGlow]; + [self setBackgroundLayer]; + [self setHighlightBackgroundLayer]; + } + + if (_tapped) + { + //NSLog(@"highlighted"); + _highlightBackgroundLayer.hidden = NO; + // self.titleLabel.textColor = [UIColor colorFromHexString:@"#999999" andAlpha:1.0]; + self.titleLabel.textColor = [UIColor colorFromHexString:_highlighTextHexColor andAlpha:1.0]; + _backgroundLayer.backgroundColor = [UIColor colorFromHexString:_highlightHexColor andAlpha:1.0].CGColor; + } + else + { + //NSLog(@"not highlighted"); + _highlightBackgroundLayer.hidden = YES; + // self.titleLabel.textColor = [UIColor colorFromHexString:@"#333333" andAlpha:1.0]; + self.titleLabel.textColor = [UIColor colorFromHexString:_textHexColor andAlpha:1.0]; + _backgroundLayer.backgroundColor = [UIColor colorFromHexString:_buttonHexColor andAlpha:1.0].CGColor; + } + + _setupLayers = YES; +} + +#pragma mark - Layer setters + +- (void)setBackgroundLayer +{ + if (!_backgroundLayer) + { + _backgroundLayer = [CAGradientLayer layer]; + _backgroundLayer.frame = self.bounds; + _backgroundLayer.backgroundColor = [UIColor colorFromHexString:_buttonHexColor andAlpha:1.0].CGColor; + + [self.layer insertSublayer:_backgroundLayer atIndex:0]; + + // here is the red color, #ff0033 and its highlight, #ff7691 + // here is the green color, #33ffcc and it's highlight, #a9ffe9 + } +} + +- (void)setHighlightBackgroundLayer +{ + if (!_highlightBackgroundLayer) + { + _highlightBackgroundLayer = [CAGradientLayer layer]; + _highlightBackgroundLayer.frame = self.bounds; + _highlightBackgroundLayer.backgroundColor = [UIColor colorFromHexString:_highlightHexColor andAlpha:1.0].CGColor; + [self.layer insertSublayer:_highlightBackgroundLayer atIndex:1]; + } +} + +- (void)setInnerGlow +{ + if (!_innerGlow) + { + _innerGlow = [CALayer layer]; + CGRect innerGlowFrame = CGRectMake(self.bounds.origin.x+1, self.bounds.origin.y+1, self.bounds.size.width-2, self.bounds.size.height-2); + _innerGlow.frame = innerGlowFrame; + _innerGlow.cornerRadius= 4.5f; + _innerGlow.borderWidth = 1; + _innerGlow.borderColor = [[UIColor whiteColor] CGColor]; + _innerGlow.opacity = 0.5; + + [self.layer insertSublayer:_innerGlow atIndex:2]; + } +} + +- (void)setButtonColor:(NSString *)buttonHexColor andHighLightColor:(NSString *)highlightHexColor andTextColor:(NSString *)textHexColor andHighlightTextColor:(NSString *)highlighTextHexColor { + _buttonHexColor = buttonHexColor; + _highlightHexColor = highlightHexColor; + _textHexColor = textHexColor; + _highlighTextHexColor = highlighTextHexColor; + + //[self setNeedsDisplay]; +} + +#pragma mark - Touch event overrides + +-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + _tapped = YES; + [self setNeedsDisplay]; + [super touchesBegan:touches withEvent:event]; +} + +-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + _tapped = NO; + [self setNeedsDisplay]; + [super touchesEnded:touches withEvent:event]; +} + +-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + CGPoint touchPoint = [[touches anyObject] locationInView:self]; + CGRect testRect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); + + if (CGRectContainsPoint(testRect, touchPoint)) + { + _tapped = YES; + [self setNeedsDisplay]; + } + + else + { + _tapped = NO; + [self setNeedsDisplay]; + } + + [super touchesMoved:touches withEvent:event]; +} + +@end diff --git a/phoneClients/ios/GpsTracker/GpsTracker-Info.plist b/phoneClients/ios/GpsTracker/GpsTracker-Info.plist index 076b570..2c2d26f 100644 --- a/phoneClients/ios/GpsTracker/GpsTracker-Info.plist +++ b/phoneClients/ios/GpsTracker/GpsTracker-Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.0.0 + 3.2.4 CFBundleSignature ???? CFBundleVersion - 1 + 2 LSRequiresIPhoneOS UIBackgroundModes diff --git a/phoneClients/ios/GpsTracker/UIColor+HexColor.h b/phoneClients/ios/GpsTracker/UIColor+HexColor.h new file mode 100644 index 0000000..cf80859 --- /dev/null +++ b/phoneClients/ios/GpsTracker/UIColor+HexColor.h @@ -0,0 +1,14 @@ +// +// UiColor+HexColor.h +// GpsTracker +// +// Created by Nick Fox on 6/25/14. +// Copyright (c) 2014 Nick Fox. All rights reserved. +// + +@interface UIColor (HexColor) + +// this category allows us to create a UIColor using a hex color value like #FF00FF ++ (UIColor *)colorFromHexString:(NSString *)hexString andAlpha:(float)alphaValue; + +@end diff --git a/phoneClients/ios/GpsTracker/UIColor+HexColor.m b/phoneClients/ios/GpsTracker/UIColor+HexColor.m new file mode 100644 index 0000000..d371ee4 --- /dev/null +++ b/phoneClients/ios/GpsTracker/UIColor+HexColor.m @@ -0,0 +1,60 @@ +// +// UiColor+HexColor.m +// GpsTracker +// +// Created by Nick Fox on 6/25/14. +// Copyright (c) 2014 Nick Fox. All rights reserved. +// + +#import "UIColor+HexColor.h" + +// modified from https://gist.github.com/simonwhitaker/1219029 + +@implementation UIColor (HexColor) + ++ (UIColor *)colorFromHexString:(NSString *)hexValue andAlpha:(float)alphaValue +{ + UIColor *defaultColor = [UIColor blackColor]; + + // Strip leading # if there is one + if ([hexValue hasPrefix:@"#"] && [hexValue length] > 1) { + hexValue = [hexValue substringFromIndex:1]; + } + + NSUInteger componentLength = 0; + if ([hexValue length] == 3) + componentLength = 1; + else if ([hexValue length] == 6) + componentLength = 2; + else + return defaultColor; + + BOOL isValid = YES; + CGFloat components[3]; + + for (NSUInteger i = 0; i < 3; i++) { + NSString *component = [hexValue substringWithRange:NSMakeRange(componentLength * i, componentLength)]; + if (componentLength == 1) { + component = [component stringByAppendingString:component]; + } + NSScanner *scanner = [NSScanner scannerWithString:component]; + unsigned int value; + isValid &= [scanner scanHexInt:&value]; + components[i] = (CGFloat)value / 256.0; + } + + if (!isValid) { + return defaultColor; + } + + if (alphaValue < 0.0 || alphaValue > 1.0 ) { + alphaValue = 1.0; + } + + return [UIColor colorWithRed:components[0] + green:components[1] + blue:components[2] + alpha:alphaValue]; +} + +@end diff --git a/phoneClients/ios/GpsTracker/WSViewController.m b/phoneClients/ios/GpsTracker/WSViewController.m index 100b7b3..587704d 100644 --- a/phoneClients/ios/GpsTracker/WSViewController.m +++ b/phoneClients/ios/GpsTracker/WSViewController.m @@ -9,13 +9,15 @@ #import "WSViewController.h" #import #import "AFHTTPRequestOperationManager.h" +#import "UIColor+HexColor.h" +#import "CustomButton.h" @interface WSViewController () @property (weak, nonatomic) IBOutlet UILabel *latitudeLabel; @property (weak, nonatomic) IBOutlet UILabel *longitudeLabel; @property (weak, nonatomic) IBOutlet UILabel *accuracyLabel; @property (weak, nonatomic) IBOutlet UILabel *timestampLabel; -@property (weak, nonatomic) IBOutlet UIButton *trackingButton; +@property (weak, nonatomic) IBOutlet CustomButton *trackingButton; @property (weak, nonatomic) IBOutlet UILabel *accuracyLevelLabel; @property (weak, nonatomic) IBOutlet UILabel *sessionIDLabel; @end @@ -36,6 +38,12 @@ - (void)viewDidLoad { [super viewDidLoad]; + + [self.trackingButton setButtonColor:@"#ff0033" andHighLightColor:@"#ff7691" andTextColor:@"#FFFFFF" andHighlightTextColor:@"#333333"]; + + // here is the red color, #ff0033 and its highlight, #ff7691 + // here is the green color, #33ffcc and it's highlight, #a9ffe9 + currentlyTracking = NO; timeIntervalInSeconds = 60; // change this to the time interval you want } @@ -76,13 +84,25 @@ - (IBAction)handleTrackingButton:(id)sender { if (currentlyTracking) { - [self stopTracking]; + //[self stopTracking]; currentlyTracking = NO; - [self.trackingButton setTitle:@"start tracking" forState:UIControlStateNormal]; + + [self.trackingButton setButtonColor:@"#ff0033" andHighLightColor:@"#ff7691" andTextColor:@"#FFFFFF" andHighlightTextColor:@"#333333"]; + + // here is the red color, #ff0033 and its highlight, #ff7691 + // here is the green color, #33ffcc and it's highlight, #a9ffe9 + + [self.trackingButton setTitle:@"Tracking is Off" forState:UIControlStateNormal]; } else { - [self startTracking]; + //[self startTracking]; currentlyTracking = YES; - [self.trackingButton setTitle:@"stop tracking" forState:UIControlStateNormal]; + + [self.trackingButton setButtonColor:@"#33ffcc" andHighLightColor:@"#a9ffe9" andTextColor:@"#333333" andHighlightTextColor:@"#999999"]; + + // here is the red color, #ff0033 and its highlight, #ff7691 + // here is the green color, #33ffcc and it's highlight, #a9ffe9 + + [self.trackingButton setTitle:@"Tracking is On" forState:UIControlStateNormal]; } } diff --git a/phoneClients/ios/README.md b/phoneClients/ios/README.md index 8cab686..b75fa64 100644 --- a/phoneClients/ios/README.md +++ b/phoneClients/ios/README.md @@ -1,3 +1,11 @@ +PLEASE NOTE - THIS APP IS CURRENTLY BEING REWRITTEN, IT IS NOT FULLY FUNCTIONAL, June 25, 2014. + +Please download the latest release of GpsTracker for a fully functional version. + +https://github.com/nickfox/GpsTracker/releases + +I am currently updating the UI and it should be done within a couple of days. + this is the ios client for gpstracker. Remember that you need to open this project with GpsTracker.xcworkspace since you are using AFNetworking cocoapods. use the websmithing defaultUploadWebsite: