Skip to content

Commit

Permalink
beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
normansander committed Sep 18, 2014
1 parent c772958 commit 65505ae
Show file tree
Hide file tree
Showing 8 changed files with 1,084 additions and 1,030 deletions.
2 changes: 2 additions & 0 deletions CriticalMass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@
INFOPLIST_FILE = "CriticalMass/CriticalMass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -475,6 +476,7 @@
INFOPLIST_FILE = "CriticalMass/CriticalMass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
PRODUCT_NAME = "$(TARGET_NAME)";
TARGETED_DEVICE_FAMILY = 1;
WRAPPER_EXTENSION = app;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion CriticalMass/CriticalMass-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>pokuslabs.${PRODUCT_NAME:rfc1034identifier}</string>
<string>de.pokuslabs.criticalmassberlin</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
1 change: 0 additions & 1 deletion CriticalMass/PLAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ - (void)applicationWillEnterForeground:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"applicationDidBecomeActive");
[[PLData sharedManager] setIsBackroundMode:NO];
}

- (void)applicationWillTerminate:(UIApplication *)application
Expand Down
1 change: 1 addition & 0 deletions CriticalMass/PLConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ FOUNDATION_EXPORT NSString *const kNotificationGpsStateChanged;

// Misc
FOUNDATION_EXPORT NSTimeInterval const kRequestRepeatTime;
FOUNDATION_EXPORT NSUInteger const kMaxRequestsInBackground;
FOUNDATION_EXPORT double const kTestLocationLatitude;
FOUNDATION_EXPORT double const kTestLocationLongitude;

Expand Down
5 changes: 3 additions & 2 deletions CriticalMass/PLConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ @implementation PLConstants

// Debug
BOOL const kDebug = NO;
BOOL const kDebugEnableTestURL = YES;
BOOL const kDebugEnableTestLocation = YES;
BOOL const kDebugEnableTestURL = NO;
BOOL const kDebugEnableTestLocation = NO;
BOOL const kDebugDisableHTTPRequests = NO;
BOOL const kDebugInitialTabIndex = 0;

Expand All @@ -31,6 +31,7 @@ @implementation PLConstants

// Misc
NSTimeInterval const kRequestRepeatTime = 30.0;
NSUInteger const kMaxRequestsInBackground = 480;
double const kTestLocationLatitude = +52.50266880;
double const kTestLocationLongitude = +13.41227278;

1 change: 1 addition & 0 deletions CriticalMass/PLData.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NSTimer *_timer;
NSString *_uid;
NSUInteger _updateCount;
NSUInteger _requestCount;
}

@property (nonatomic, readonly) CLLocation *currentLocation;
Expand Down
32 changes: 26 additions & 6 deletions CriticalMass/PLData.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ - (void)initLocationManager
if(kDebug && kDebugEnableTestLocation){
CLLocation *testLocation = [[CLLocation alloc] initWithLatitude:kTestLocationLatitude longitude:kTestLocationLongitude];
_currentLocation = testLocation;
[self performSelector:@selector(startRequestInterval) withObject:nil afterDelay:1.0];
}else{
[self enableGps];
}


if(!(kDebug && kDebugDisableHTTPRequests)){
[self performSelector:@selector(startRequestInterval) withObject:nil afterDelay:1.0];
}
}

- (void)initHTTPRequestManager
Expand Down Expand Up @@ -85,6 +81,8 @@ - (void)stopRequestInterval

- (void)request
{
_requestCount++;

NSString *longitudeString = _gpsEnabled ? [PLUtils locationdegrees2String:_currentLocation.coordinate.longitude] : @"";
NSString *latitudeString = _gpsEnabled ? [PLUtils locationdegrees2String:_currentLocation.coordinate.latitude] : @"";

Expand All @@ -101,11 +99,16 @@ - (void)request
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];

if(_isBackroundMode && (_requestCount >= kMaxRequestsInBackground)){
[self disableGps];
}
}

- (void)enableGps{
NSLog(@"enableGps");
_updateCount = 0;
[self stopRequestInterval];
[_locationManager startUpdatingLocation];
_gpsEnabled = YES;
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationGpsStateChanged object:self];
Expand Down Expand Up @@ -149,12 +152,29 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLoca
}

if(_updateCount == 0){
[self startRequestInterval];
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationInitialGpsDataReceived object:self];

if(!(kDebug && kDebugDisableHTTPRequests)){
[self performSelector:@selector(startRequestInterval) withObject:nil afterDelay:1.0];
}
}
_updateCount++;
}

-(void)setIsBackroundMode:(BOOL)isBackroundMode
{
_isBackroundMode = isBackroundMode;

if (_isBackroundMode) {
_requestCount = 0;
}else{
if(!_gpsEnabled && _gpsEnabledUser){
[self enableGps];
}
}

NSLog(@"backgroundMode: %@", _isBackroundMode ? @"YES" : @"NO");
}


@end
Loading

0 comments on commit 65505ae

Please sign in to comment.