From 212590a5e92108460108b3e62284be1184c405b4 Mon Sep 17 00:00:00 2001 From: David Chiles Date: Thu, 7 Aug 2014 14:04:07 -0700 Subject: [PATCH] Added embargo passcode on launch --- Podfile | 3 +- Podfile.lock | 3 + README.md | 2 +- iBurn.xcodeproj/project.pbxproj | 12 ++ iBurn/BRCAppDelegate.h | 2 + iBurn/BRCAppDelegate.m | 76 +++++++--- iBurn/BRCEmbargo.h | 19 +++ iBurn/BRCEmbargo.m | 31 ++++ iBurn/BRCEmbargoPasscodeViewController.h | 13 ++ iBurn/BRCEmbargoPasscodeViewController.m | 181 +++++++++++++++++++++++ iBurn/BRCSecrets.h | 3 +- iBurn/NSUserDefaults+iBurn.h | 3 + iBurn/NSUserDefaults+iBurn.m | 18 ++- 13 files changed, 337 insertions(+), 29 deletions(-) create mode 100644 iBurn/BRCEmbargo.h create mode 100644 iBurn/BRCEmbargo.m create mode 100644 iBurn/BRCEmbargoPasscodeViewController.h create mode 100644 iBurn/BRCEmbargoPasscodeViewController.m diff --git a/Podfile b/Podfile index a6aca152..d8db758f 100644 --- a/Podfile +++ b/Podfile @@ -8,4 +8,5 @@ pod 'FormatterKit/LocationFormatter', '~> 1.6' pod 'FormatterKit/TimeIntervalFormatter', '~> 1.6' pod 'HockeySDK', '~> 3.5' pod 'PureLayout', '~> 1.0' -pod 'MCSwipeTableViewCell', '~> 2.1' \ No newline at end of file +pod 'MCSwipeTableViewCell', '~> 2.1' +pod 'DAKeyboardControl', '~> 2.4' \ No newline at end of file diff --git a/Podfile.lock b/Podfile.lock index 1b8767e5..0bdc7eec 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -5,6 +5,7 @@ PODS: - CocoaLumberjack/Core (1.6.5.1) - CocoaLumberjack/Extensions (1.6.5.1): - CocoaLumberjack/Core + - DAKeyboardControl (2.4.0) - FMDB (2.3): - FMDB/standard - FMDB/common (2.3) @@ -34,6 +35,7 @@ PODS: - YapDatabase/common DEPENDENCIES: + - DAKeyboardControl (~> 2.4) - FormatterKit/LocationFormatter (~> 1.6) - FormatterKit/TimeIntervalFormatter (~> 1.6) - HockeySDK (~> 3.5) @@ -50,6 +52,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CocoaLumberjack: baf4a09a3bcbdfea3363556a90104e026d3504e2 + DAKeyboardControl: 45a363c85c48a7df76f21f236d9f85800e001775 FMDB: 31ec26773c7f7b7890a6038235a1f2bbd933a7cb FormatterKit: 534b21b52b9b822a9ec884a14e2debf92e7a3126 GRMustache: ab96109b7ba4b9568425bea40d6cd2cdc7582b6c diff --git a/README.md b/README.md index ec9f4923..bcb9fd2e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Fortunately, you can still run and test the app with the previous year's data. * Show data from previous years * Optimizations * Data Embargo :( -* Show Favorites on the Map +* Show Favorites on the Map * Favorite items by long-pressing on cell * Scroll back to top when switching sort * Put Playa location as first item in detail view (e.g. 7:45 & E) diff --git a/iBurn.xcodeproj/project.pbxproj b/iBurn.xcodeproj/project.pbxproj index 63802541..ac85ebb8 100644 --- a/iBurn.xcodeproj/project.pbxproj +++ b/iBurn.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ 63228321198AB383009E472B /* RMMarker+iBurn.m in Sources */ = {isa = PBXBuildFile; fileRef = 63228320198AB383009E472B /* RMMarker+iBurn.m */; }; 63228327198C1BF7009E472B /* BRCEventsFilterTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63228326198C1BF7009E472B /* BRCEventsFilterTableViewController.m */; }; 6322832B198C2B48009E472B /* NSUserDefaults+iBurn.m in Sources */ = {isa = PBXBuildFile; fileRef = 6322832A198C2B48009E472B /* NSUserDefaults+iBurn.m */; }; + 632F77571993FC8100707FAF /* BRCEmbargoPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 632F77561993FC8100707FAF /* BRCEmbargoPasscodeViewController.m */; }; + 639E638D1994178500B62A92 /* BRCEmbargo.m in Sources */ = {isa = PBXBuildFile; fileRef = 639E638C1994178500B62A92 /* BRCEmbargo.m */; }; 63CE2A581987140F00F65B01 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CE2A571987140F00F65B01 /* Foundation.framework */; }; 63CE2A5A1987140F00F65B01 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CE2A591987140F00F65B01 /* CoreGraphics.framework */; }; 63CE2A5C1987140F00F65B01 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63CE2A5B1987140F00F65B01 /* UIKit.framework */; }; @@ -80,6 +82,10 @@ 63228326198C1BF7009E472B /* BRCEventsFilterTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRCEventsFilterTableViewController.m; sourceTree = ""; }; 63228329198C2B48009E472B /* NSUserDefaults+iBurn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+iBurn.h"; sourceTree = ""; }; 6322832A198C2B48009E472B /* NSUserDefaults+iBurn.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSUserDefaults+iBurn.m"; sourceTree = ""; }; + 632F77551993FC8100707FAF /* BRCEmbargoPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRCEmbargoPasscodeViewController.h; sourceTree = ""; }; + 632F77561993FC8100707FAF /* BRCEmbargoPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRCEmbargoPasscodeViewController.m; sourceTree = ""; }; + 639E638B1994178500B62A92 /* BRCEmbargo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRCEmbargo.h; sourceTree = ""; }; + 639E638C1994178500B62A92 /* BRCEmbargo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BRCEmbargo.m; sourceTree = ""; }; 63CE2A541987140F00F65B01 /* iBurn.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iBurn.app; sourceTree = BUILT_PRODUCTS_DIR; }; 63CE2A571987140F00F65B01 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 63CE2A591987140F00F65B01 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -246,6 +252,8 @@ 63CE2A671987140F00F65B01 /* BRCAppDelegate.m */, 63228329198C2B48009E472B /* NSUserDefaults+iBurn.h */, 6322832A198C2B48009E472B /* NSUserDefaults+iBurn.m */, + 639E638B1994178500B62A92 /* BRCEmbargo.h */, + 639E638C1994178500B62A92 /* BRCEmbargo.m */, 6322830C1989836F009E472B /* MapClasses */, 63D270F61987157900204954 /* ViewControllers */, 63CE2A691987140F00F65B01 /* Images.xcassets */, @@ -272,6 +280,8 @@ 6322830219881E27009E472B /* DetailViewControllers */, D994155E19871D9000D245C7 /* Filtered Tables */, D99395A5198B806800E9ADD2 /* MapViewControllers */, + 632F77551993FC8100707FAF /* BRCEmbargoPasscodeViewController.h */, + 632F77561993FC8100707FAF /* BRCEmbargoPasscodeViewController.m */, ); name = ViewControllers; sourceTree = ""; @@ -513,10 +523,12 @@ files = ( D994156119871E8400D245C7 /* BRCEventsTableViewController.m in Sources */, D97D7A31198ADBE400CA7828 /* NSDateFormatter+iBurn.m in Sources */, + 639E638D1994178500B62A92 /* BRCEmbargo.m in Sources */, 630861C9199029D100AD7109 /* BRCLocations.m in Sources */, D92562C6198876C400ED6B50 /* BRCEventObjectTableViewCell.m in Sources */, 6322830B19882153009E472B /* BRCRelationshipDetailInfoCell.m in Sources */, D99395A8198B897B00E9ADD2 /* BRCDetailInfoTableViewCell.m in Sources */, + 632F77571993FC8100707FAF /* BRCEmbargoPasscodeViewController.m in Sources */, 6322830119881DDE009E472B /* BRCDetailViewController.m in Sources */, D94EFA51199158D2009F12F4 /* CLLocationManager+iBurn.m in Sources */, D9941568198726A700D245C7 /* BRCArtObject.m in Sources */, diff --git a/iBurn/BRCAppDelegate.h b/iBurn/BRCAppDelegate.h index 86fb7db1..309bd488 100644 --- a/iBurn/BRCAppDelegate.h +++ b/iBurn/BRCAppDelegate.h @@ -13,4 +13,6 @@ @property (strong, nonatomic) UIWindow *window; +- (void)showTabBarAnimated:(BOOL)animated; + @end diff --git a/iBurn/BRCAppDelegate.m b/iBurn/BRCAppDelegate.m index de5e104a..119550fa 100644 --- a/iBurn/BRCAppDelegate.m +++ b/iBurn/BRCAppDelegate.m @@ -17,6 +17,8 @@ #import "BRCEventObject_Private.h" #import "NSDateFormatter+iBurn.h" #import "BRCSecrets.h" +#import "BRCEmbargoPasscodeViewController.h" +#import "BRCEmbargo.h" static NSString * const kBRCHasImportedDataKey = @"kBRCHasImportedDataKey"; @@ -48,31 +50,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - BRCMapViewController *mapViewController = [[BRCMapViewController alloc] init]; - UINavigationController *mapNavController = [[UINavigationController alloc] initWithRootViewController:mapViewController]; - mapNavController.tabBarItem.image = [UIImage imageNamed:@"BRCMapIcon"]; - - BRCFilteredTableViewController *artTableVC = [[BRCFilteredTableViewController alloc] initWithViewClass:[BRCArtObject class]]; - artTableVC.title = @"Art"; - UINavigationController *artNavController = [[UINavigationController alloc] initWithRootViewController:artTableVC]; - artNavController.tabBarItem.image = [UIImage imageNamed:@"BRCArtIcon"]; - - BRCFilteredTableViewController *campTableVC = [[BRCFilteredTableViewController alloc] initWithViewClass:[BRCCampObject class]]; - campTableVC.title = @"Camps"; - UINavigationController *campNavController = [[UINavigationController alloc] initWithRootViewController:campTableVC]; - campNavController.tabBarItem.image = [UIImage imageNamed:@"BRCCampIcon"]; - - BRCEventsTableViewController *eventsTableVC = [[BRCEventsTableViewController alloc] initWithViewClass:[BRCEventObject class]]; - eventsTableVC.title = @"Events"; - UINavigationController *eventsNavController = [[UINavigationController alloc] initWithRootViewController:eventsTableVC]; - eventsNavController.tabBarItem.image = [UIImage imageNamed:@"BRCEventIcon"]; - - UITabBarController *tabBarController = [[UITabBarController alloc] init]; - tabBarController.viewControllers = @[mapNavController, artNavController, campNavController, eventsNavController]; + if ([BRCEmbargo allowEmbargoedData]) { + + self.window.rootViewController = [self defaultTabBarController]; + } + else { + self.window.rootViewController = [self embargoViewController]; + } self.window.backgroundColor = [UIColor whiteColor]; - self.window.rootViewController = tabBarController; - [self.window makeKeyAndVisible]; return YES; } @@ -104,6 +90,50 @@ - (void)applicationWillTerminate:(UIApplication *)application // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } +- (void)showTabBarAnimated:(BOOL)animated{ + + [UIView transitionWithView:self.window + duration:0.5 + options:UIViewAnimationOptionTransitionFlipFromLeft + animations:^{ + self.window.rootViewController = [self defaultTabBarController]; + } + completion:nil]; + +} + +- (UIViewController *)defaultTabBarController +{ + BRCMapViewController *mapViewController = [[BRCMapViewController alloc] init]; + UINavigationController *mapNavController = [[UINavigationController alloc] initWithRootViewController:mapViewController]; + mapNavController.tabBarItem.image = [UIImage imageNamed:@"BRCMapIcon"]; + + BRCFilteredTableViewController *artTableVC = [[BRCFilteredTableViewController alloc] initWithViewClass:[BRCArtObject class]]; + artTableVC.title = @"Art"; + UINavigationController *artNavController = [[UINavigationController alloc] initWithRootViewController:artTableVC]; + artNavController.tabBarItem.image = [UIImage imageNamed:@"BRCArtIcon"]; + + BRCFilteredTableViewController *campTableVC = [[BRCFilteredTableViewController alloc] initWithViewClass:[BRCCampObject class]]; + campTableVC.title = @"Camps"; + UINavigationController *campNavController = [[UINavigationController alloc] initWithRootViewController:campTableVC]; + campNavController.tabBarItem.image = [UIImage imageNamed:@"BRCCampIcon"]; + + BRCEventsTableViewController *eventsTableVC = [[BRCEventsTableViewController alloc] initWithViewClass:[BRCEventObject class]]; + eventsTableVC.title = @"Events"; + UINavigationController *eventsNavController = [[UINavigationController alloc] initWithRootViewController:eventsTableVC]; + eventsNavController.tabBarItem.image = [UIImage imageNamed:@"BRCEventIcon"]; + + UITabBarController *tabBarController = [[UITabBarController alloc] init]; + tabBarController.viewControllers = @[mapNavController, artNavController, campNavController, eventsNavController]; + + return tabBarController; +} + +- (UIViewController *)embargoViewController +{ + return [[BRCEmbargoPasscodeViewController alloc] init]; +} + - (void) setupFestivalDates { if ([[NSUserDefaults standardUserDefaults] objectForKey:kBRCStartDateKey]) { return; diff --git a/iBurn/BRCEmbargo.h b/iBurn/BRCEmbargo.h new file mode 100644 index 00000000..31ec0906 --- /dev/null +++ b/iBurn/BRCEmbargo.h @@ -0,0 +1,19 @@ +// +// BRCEmbargo.h +// iBurn +// +// Created by David Chiles on 8/7/14. +// Copyright (c) 2014 Burning Man Earth. All rights reserved. +// + +#import + +@interface BRCEmbargo : NSObject + + ++ (BOOL)isEmbargoPasscodeString:(NSString *)passcode; + +/**Checks if the password has been entered or before gates open */ ++ (BOOL)allowEmbargoedData; + +@end diff --git a/iBurn/BRCEmbargo.m b/iBurn/BRCEmbargo.m new file mode 100644 index 00000000..7e272ffe --- /dev/null +++ b/iBurn/BRCEmbargo.m @@ -0,0 +1,31 @@ +// +// BRCEmbargo.m +// iBurn +// +// Created by David Chiles on 8/7/14. +// Copyright (c) 2014 Burning Man Earth. All rights reserved. +// + +#import "BRCEmbargo.h" +#import "NSUserDefaults+iBurn.h" +#import "BRCSecrets.h" +#import "BRCEventObject.h" + +@implementation BRCEmbargo + ++ (BOOL)isEmbargoPasscodeString:(NSString *)passcode +{ + return [passcode isEqualToString:kBRCEmbargoPasscode]; +} + ++ (BOOL)allowEmbargoedData +{ + //Data is not embargoed after start of festival or if the passcode has been entered + if ([[NSUserDefaults standardUserDefaults] enteredEmbargoPasscode] || [[BRCEventObject festivalStartDate] timeIntervalSinceNow] < 0) { + return YES; + } + return NO; +} + + +@end diff --git a/iBurn/BRCEmbargoPasscodeViewController.h b/iBurn/BRCEmbargoPasscodeViewController.h new file mode 100644 index 00000000..0e0836c8 --- /dev/null +++ b/iBurn/BRCEmbargoPasscodeViewController.h @@ -0,0 +1,13 @@ +// +// BRCEmbargoPasscodeViewController.h +// iBurn +// +// Created by David Chiles on 8/7/14. +// Copyright (c) 2014 Burning Man Earth. All rights reserved. +// + +#import + +@interface BRCEmbargoPasscodeViewController : UIViewController + +@end diff --git a/iBurn/BRCEmbargoPasscodeViewController.m b/iBurn/BRCEmbargoPasscodeViewController.m new file mode 100644 index 00000000..0c41c793 --- /dev/null +++ b/iBurn/BRCEmbargoPasscodeViewController.m @@ -0,0 +1,181 @@ +// +// BRCEmbargoPasscodeViewController.m +// iBurn +// +// Created by David Chiles on 8/7/14. +// Copyright (c) 2014 Burning Man Earth. All rights reserved. +// + +#import "BRCEmbargoPasscodeViewController.h" +#import "PureLayout.h" +#import "DAKeyboardControl.h" +#import "BRCEmbargo.h" +#import "NSUserDefaults+iBurn.h" +#import "BRCAppDelegate.h" + +@interface BRCEmbargoPasscodeViewController () + +@property (nonatomic, strong) UIButton *unlockBotton; +@property (nonatomic, strong) UIButton *noPasscodeButton; +@property (nonatomic, strong) UITextView *descriptionTextView; +@property (nonatomic, strong) UITextField *passcodeTextField; +@property (nonatomic, strong) UIView *containerView; +@property (nonatomic) BOOL didAddConstraints; + +@property (nonatomic, strong) NSLayoutConstraint *bottomCostraint; +@property (nonatomic, strong) NSLayoutConstraint *textFieldAxisConstraint; + +@end + +@implementation BRCEmbargoPasscodeViewController + +- (void)viewDidLoad +{ + [super viewDidLoad]; + self.didAddConstraints = NO; + + self.containerView = [[UIView alloc] initForAutoLayout]; + + self.noPasscodeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + self.noPasscodeButton.translatesAutoresizingMaskIntoConstraints = NO; + [self.noPasscodeButton addTarget:self action:@selector(nopasscodeButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; + [self.noPasscodeButton setTitle:@"No Passcode" forState:UIControlStateNormal]; + + self.unlockBotton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; + self.unlockBotton.translatesAutoresizingMaskIntoConstraints = NO; + [self.unlockBotton addTarget:self action:@selector(unlockButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; + [self.unlockBotton setTitle:@"Unlock" forState:UIControlStateNormal]; + + self.descriptionTextView = [[UITextView alloc] initForAutoLayout]; + self.descriptionTextView.text = @"Describe what embargo is and what is diabled until Burning Man starts"; + self.descriptionTextView.editable = NO; + + self.passcodeTextField = [[UITextField alloc] initForAutoLayout]; + self.passcodeTextField.secureTextEntry = YES; + self.passcodeTextField.clearButtonMode = UITextFieldViewModeWhileEditing; + self.passcodeTextField.borderStyle = UITextBorderStyleRoundedRect; + self.passcodeTextField.returnKeyType = UIReturnKeyDone; + self.passcodeTextField.delegate = self; + + [self.view addSubview:self.containerView]; + [self.containerView addSubview:self.descriptionTextView]; + [self.containerView addSubview:self.noPasscodeButton]; + [self.containerView addSubview:self.unlockBotton]; + [self.containerView addSubview:self.passcodeTextField]; + + + [self.view updateConstraintsIfNeeded]; + + __weak BRCEmbargoPasscodeViewController *welf = self; + [self.view addKeyboardNonpanningWithFrameBasedActionHandler:nil constraintBasedActionHandler:^(CGRect keyboardFrameInView, BOOL opening, BOOL closing) { + if (opening) + { + welf.bottomCostraint.constant = -keyboardFrameInView.size.height; + } + else if (closing) + { + welf.bottomCostraint.constant = 0.0; + } + }]; +} + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + [self.passcodeTextField becomeFirstResponder]; +} + +- (void)updateViewConstraints +{ + [super updateViewConstraints]; + + if (!self.didAddConstraints) { + [self.containerView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(30, 0, 0, 0) excludingEdge:ALEdgeBottom]; + self.bottomCostraint = [self.containerView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.view]; + + [self.descriptionTextView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(10, 10, 10, 10) excludingEdge:ALEdgeBottom]; + [self.descriptionTextView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.passcodeTextField withOffset:0 relation:NSLayoutRelationGreaterThanOrEqual]; + + self.textFieldAxisConstraint = [self.passcodeTextField autoAlignAxis:ALAxisVertical toSameAxisOfView:self.containerView]; + [self.passcodeTextField autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.descriptionTextView]; + [self.passcodeTextField autoSetDimension:ALDimensionHeight toSize:31.0]; + [self.passcodeTextField autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.noPasscodeButton withOffset:-10 relation:NSLayoutRelationGreaterThanOrEqual]; + + [self.noPasscodeButton autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:self.containerView withOffset:10]; + [self.noPasscodeButton autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.containerView withOffset:-10]; + [self.noPasscodeButton autoPinEdge:ALEdgeRight toEdge:ALEdgeLeft ofView:self.unlockBotton withOffset:10 relation:NSLayoutRelationGreaterThanOrEqual]; + [self.noPasscodeButton autoSetDimension:ALDimensionHeight toSize:44.0]; + + + [self.unlockBotton autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:self.containerView withOffset:-10]; + [self.unlockBotton autoAlignAxis:ALAxisHorizontal toSameAxisOfView:self.noPasscodeButton]; + [self.unlockBotton autoMatchDimension:ALDimensionHeight toDimension:ALDimensionHeight ofView:self.noPasscodeButton]; + [self.unlockBotton autoMatchDimension:ALDimensionWidth toDimension:ALDimensionWidth ofView:self.noPasscodeButton]; + + + + + + self.didAddConstraints = YES; + } +} + +- (void)nopasscodeButtonPressed:(id)sender +{ + [self showTabBarController]; +} + +- (void)unlockButtonPressed:(id)sender +{ + if ([BRCEmbargo isEmbargoPasscodeString:self.passcodeTextField.text]) { + [[NSUserDefaults standardUserDefaults] setEnteredEmbargoPasscode:YES]; + [self showTabBarController]; + } + else { + [self shakeTextField:5]; + } +} + +-(void)shakeTextField:(int)shakes { + + int direction = 1; + if (shakes%2) { + direction = -1; + } + + if (shakes > 0) { + self.textFieldAxisConstraint.constant = 5*direction; + } + else { + self.textFieldAxisConstraint.constant = 0.0; + } + + + [UIView animateWithDuration:0.05 animations:^ { + [self.view layoutIfNeeded]; + } + completion:^(BOOL finished) + { + if(shakes > 0) + { + [self shakeTextField:shakes-1]; + } + + }]; +} + +- (void)showTabBarController +{ + [self.view removeKeyboardControl]; + [((BRCAppDelegate *)[UIApplication sharedApplication].delegate) showTabBarAnimated:YES]; +} + +#pragma - mark UITextfieldDelegate + +- (BOOL)textFieldShouldReturn:(UITextField *)textField +{ + [self unlockButtonPressed:textField]; + return NO; +} + +@end diff --git a/iBurn/BRCSecrets.h b/iBurn/BRCSecrets.h index 3c333b38..f1e0af17 100644 --- a/iBurn/BRCSecrets.h +++ b/iBurn/BRCSecrets.h @@ -1,2 +1,3 @@ extern NSString * const kBRCHockeyBetaIdentifier; -extern NSString * const kBRCHockeyLiveIdentifier; \ No newline at end of file +extern NSString * const kBRCHockeyLiveIdentifier; +extern NSString * const kBRCEmbargoPasscode; \ No newline at end of file diff --git a/iBurn/NSUserDefaults+iBurn.h b/iBurn/NSUserDefaults+iBurn.h index edc015f8..43ccc48f 100644 --- a/iBurn/NSUserDefaults+iBurn.h +++ b/iBurn/NSUserDefaults+iBurn.h @@ -17,6 +17,9 @@ - (BOOL)showExpiredEvents; - (void)setShowExpiredEvents:(BOOL)showEpiredEvents; +- (BOOL)enteredEmbargoPasscode; +- (void)setEnteredEmbargoPasscode:(BOOL)enteredEmbargoPasscode; + @property (nonatomic, strong, readwrite) CLLocation *recentLocation; @end diff --git a/iBurn/NSUserDefaults+iBurn.m b/iBurn/NSUserDefaults+iBurn.m index 26de0522..229e0f8f 100644 --- a/iBurn/NSUserDefaults+iBurn.m +++ b/iBurn/NSUserDefaults+iBurn.m @@ -8,9 +8,10 @@ #import "NSUserDefaults+iBurn.h" -static NSString *const kBRCSelectedEventsTypesKey = @"kBRCSelectedEventsTypesKey"; -static NSString *const kBRCShowExpiredEventsKey = @"kBRCShowExpiredEventsKey"; -static NSString *const kBRCRecentLocationKey = @"kBRCRecentLocationKey"; +static NSString *const kBRCSelectedEventsTypesKey = @"kBRCSelectedEventsTypesKey"; +static NSString *const kBRCShowExpiredEventsKey = @"kBRCShowExpiredEventsKey"; +static NSString *const kBRCRecentLocationKey = @"kBRCRecentLocationKey"; +static NSString *const kBRCEnteredEmbargoPasscodeKey = @"kBRCEnteredEmbargoPasscodeKey"; @implementation NSUserDefaults (iBurn) @@ -54,4 +55,15 @@ - (CLLocation*) recentLocation { return location; } +- (BOOL)enteredEmbargoPasscode +{ + return [self boolForKey:kBRCEnteredEmbargoPasscodeKey]; +} + +- (void)setEnteredEmbargoPasscode:(BOOL)enteredEmbargoPasscode +{ + [self setBool:enteredEmbargoPasscode forKey:kBRCEnteredEmbargoPasscodeKey]; + [self synchronize]; +} + @end