From 08d961f9b95f14d30ef7f194f7847752b26b6554 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 18 Jan 2012 00:12:02 -0500 Subject: [PATCH 01/62] Update README.mdown --- README.mdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.mdown b/README.mdown index 223fca1..6152881 100644 --- a/README.mdown +++ b/README.mdown @@ -2,7 +2,9 @@ KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passcode settings in ios apps. ![](https://github.com/aporat/KKPasscodeLock/raw/master/screenshots/iphone-1.png) +    ![](https://github.com/aporat/KKPasscodeLock/raw/master/screenshots/iphone-2.png) +    ![](https://github.com/aporat/KKPasscodeLock/raw/master/screenshots/ipad-1.png) From 65705e2e49ab1b59b8da80cbe1ee1881afc6dc6f Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 18 Jan 2012 17:40:20 -0500 Subject: [PATCH 02/62] Added KKPasscodeViewControllerDelegate --- example/KKPasscodeLock/RootViewController.h | 4 ++-- src/KKKeychain.h | 1 + src/KKPasscodeLock.m | 2 +- src/KKPasscodeViewController.h | 22 +++++++++++++---- src/KKPasscodeViewController.m | 26 +++++++++++++++++---- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/example/KKPasscodeLock/RootViewController.h b/example/KKPasscodeLock/RootViewController.h index 567ba9e..3cd2e98 100755 --- a/example/KKPasscodeLock/RootViewController.h +++ b/example/KKPasscodeLock/RootViewController.h @@ -16,9 +16,9 @@ // #import +#import "KKPasscodeViewController.h" - -@interface RootViewController : UIViewController { +@interface RootViewController : UIViewController { } diff --git a/src/KKKeychain.h b/src/KKKeychain.h index a3638b1..1cce8fa 100755 --- a/src/KKKeychain.h +++ b/src/KKKeychain.h @@ -21,6 +21,7 @@ } + (BOOL)setString:(NSString*)string forKey:(NSString*)key; + + (NSString*)getStringForKey:(NSString*)key; @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 376d4ea..35760f0 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -97,7 +97,7 @@ - (void)showPasscodeController:(UINavigationController*)navController if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.mode = KKPasscodeModeEnter; - //vc.rootViewController = self; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { vc.modalPresentationStyle = UIModalPresentationFullScreen; } diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 3788bb9..611a4ca 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -28,13 +28,27 @@ typedef NSUInteger KKPasscodeMode; @class KKPasscodeSettingsViewController; +@class KKPasscodeViewController; + +@protocol KKPasscodeViewControllerDelegate + +@optional +- (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController; + +- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController; + +@end + + @interface KKPasscodeViewController : UIViewController { - KKPasscodeSettingsViewController* _passcodeLockViewController; + id _delegate; + + KKPasscodeSettingsViewController* _passcodeLockViewController; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; UILabel* _failedAttemptsLabel; @@ -66,12 +80,10 @@ typedef NSUInteger KKPasscodeMode; CGFloat _viewWidth; } -@property (nonatomic, assign) KKPasscodeMode mode; @property (nonatomic, retain) KKPasscodeSettingsViewController* passcodeLockViewController; - +@property (nonatomic, assign) id delegate; +@property (nonatomic, assign) KKPasscodeMode mode; @end - - diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 781969b..50a808d 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -41,6 +41,7 @@ - (void)moveToPreviousTableView; /////////////////////////////////////////////////////////////////////////////////////////////////// @implementation KKPasscodeViewController +@synthesize delegate = _delegate; @synthesize mode, passcodeLockViewController; @@ -270,6 +271,12 @@ - (void)incrementAndShowFailedAttemptsLabel _failedAttemptsLabel.hidden = NO; _failedAttemptsView.hidden = NO; + if (_failedAttemptsCount == 10) { + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { + [_delegate didPasscodeEnteredCorrectly:self]; + } + } + if (_failedAttemptsCount == 10 && _eraseData) { if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; @@ -649,19 +656,22 @@ - (NSArray*)squares /////////////////////////////////////////////////////////////////////////////////////////////////// -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ return _simplePasscodeOn ? 0 : 1; } /////////////////////////////////////////////////////////////////////////////////////////////////// -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ return 1; } /////////////////////////////////////////////////////////////////////////////////////////////////// -- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { +- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ static NSString *CellIdentifier = @"Cell"; @@ -691,7 +701,8 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:( /////////////////////////////////////////////////////////////////////////////////////////////////// -- (BOOL)textFieldShouldReturn:(UITextField *)textField { +- (BOOL)textFieldShouldReturn:(UITextField *)textField +{ if ([textField isEqual:[_textFields lastObject]]) { [self doneButtonPressed:nil]; } else { @@ -702,7 +713,8 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField { /////////////////////////////////////////////////////////////////////////////////////////////////// -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ if (_simplePasscodeOn) { NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; @@ -741,6 +753,10 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang [UIView commitAnimations]; } + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } else { [self incrementAndShowFailedAttemptsLabel]; From 392a87fe19009890c6149f0cb9a0e6d1f340ad79 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 20 Jan 2012 19:39:41 -0500 Subject: [PATCH 03/62] adding delegate functions --- src/KKPasscodeSettingsViewController.h | 18 ++++++++- src/KKPasscodeSettingsViewController.m | 20 +++++++++- src/KKPasscodeViewController.h | 6 +-- src/KKPasscodeViewController.m | 51 +++++++++++++++++++++----- 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index 684760d..8ed1bbf 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -16,8 +16,22 @@ // #import +#import "KKPasscodeViewController.h" -@interface KKPasscodeSettingsViewController : UITableViewController { +@class KKPasscodeSettingsViewController; + +@protocol KKPasscodeSettingsViewControllerDelegate + +@optional + +- (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController; + +@end + +@interface KKPasscodeSettingsViewController : UITableViewController { + + id _delegate; + UISwitch* _simplePasscodeSwitch; UISwitch* _eraseDataSwitch; @@ -26,4 +40,6 @@ BOOL _eraseDataOn; } +@property (nonatomic, assign) id delegate; + @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index c7a7912..a61695a 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -27,6 +27,8 @@ @implementation KKPasscodeSettingsViewController +@synthesize delegate = _delegate; + /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -227,12 +229,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath if (indexPath.section == 0) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; + vc.delegate = self; + if (_passcodeLockOn) { vc.mode = KKPasscodeModeDisabled; } else { vc.mode = KKPasscodeModeSet; } - vc.passcodeLockViewController = self; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { vc.modalPresentationStyle = UIModalPresentationFormSheet; } @@ -258,8 +261,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [vc release]; } else if (indexPath.section == 1 && _passcodeLockOn) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:@"KKPasscodeViewController" bundle:nil]; + vc.delegate = self; + vc.mode = KKPasscodeModeChange; - vc.passcodeLockViewController = self; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { vc.modalPresentationStyle = UIModalPresentationFormSheet; } @@ -286,6 +290,18 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } +/////////////////////////////////////////////////////////////////////////////////////////////////// +- (void)didSettingsChanged:(KKPasscodeViewController*)viewController { + [self.tableView reloadData]; + + NSLog(@"OKOKO"); + if ([_delegate respondsToSelector:@selector(didSettingsChanged::)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + +} + /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 611a4ca..3319375 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -27,16 +27,18 @@ enum { typedef NSUInteger KKPasscodeMode; -@class KKPasscodeSettingsViewController; @class KKPasscodeViewController; @protocol KKPasscodeViewControllerDelegate @optional + - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController; - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController; +- (void)didSettingsChanged:(KKPasscodeViewController*)viewController; + @end @@ -48,7 +50,6 @@ typedef NSUInteger KKPasscodeMode; id _delegate; - KKPasscodeSettingsViewController* _passcodeLockViewController; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; UILabel* _failedAttemptsLabel; @@ -80,7 +81,6 @@ typedef NSUInteger KKPasscodeMode; CGFloat _viewWidth; } -@property (nonatomic, retain) KKPasscodeSettingsViewController* passcodeLockViewController; @property (nonatomic, assign) id delegate; @property (nonatomic, assign) KKPasscodeMode mode; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 50a808d..09049e9 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -42,7 +42,7 @@ - (void)moveToPreviousTableView; @implementation KKPasscodeViewController @synthesize delegate = _delegate; -@synthesize mode, passcodeLockViewController; +@synthesize mode; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -381,7 +381,11 @@ - (void)nextButtonPressed:(id)sender if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -413,7 +417,11 @@ - (void)nextButtonPressed:(id)sender if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -455,7 +463,11 @@ - (void)doneButtonPressed:(id)sender if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -487,7 +499,11 @@ - (void)doneButtonPressed:(id)sender if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -497,7 +513,11 @@ - (void)doneButtonPressed:(id)sender if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } else { [self incrementAndShowFailedAttemptsLabel]; @@ -738,7 +758,11 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } else { [self incrementAndShowFailedAttemptsLabel]; @@ -792,7 +816,11 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -808,7 +836,11 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; } - [self.passcodeLockViewController.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } } @@ -836,7 +868,6 @@ - (void)dealloc { [_tableViews release]; [_textFields release]; [_squares release]; - [_passcodeLockViewController release]; [super dealloc]; } From 484759564d38b1b964f71387830551635021b2ce Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 20 Jan 2012 20:38:23 -0500 Subject: [PATCH 04/62] added settings controller --- .../KKPasscodeLock.xcodeproj/project.pbxproj | 4 +- example/KKPasscodeLock/AppDelegate.m | 5 +- src/KKPasscodeLock.h | 3 +- src/KKPasscodeLock.m | 69 ++----- src/KKPasscodeSettingsViewController.h | 2 - src/KKPasscodeSettingsViewController.m | 55 +----- src/KKPasscodeViewController.h | 1 - src/KKPasscodeViewController.m | 174 ++++++------------ 8 files changed, 86 insertions(+), 227 deletions(-) diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLock.xcodeproj/project.pbxproj index e7e3005..630f4e6 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLock.xcodeproj/project.pbxproj @@ -51,9 +51,9 @@ 6DF13A5D14C6870B0069BBA5 /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = ../../src/KKKeychain.h; sourceTree = ""; }; 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = ../../src/KKKeychain.m; sourceTree = ""; }; 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; }; - 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; }; + 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; - 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; }; + 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; 6DF13A6514C6870B0069BBA5 /* passcode_square_empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = passcode_square_empty.png; path = ../../src/passcode_square_empty.png; sourceTree = ""; }; diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index bed143f..1321c4a 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -41,12 +41,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( RootViewController* vc = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil] autorelease]; _navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; - [self.window addSubview:_navigationController.view]; - - + [self.window addSubview:_navigationController.view]; [self.window makeKeyAndVisible]; - return YES; } diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 3c4397a..8ac1b9d 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -21,9 +21,10 @@ + (KKPasscodeLock*)sharedLock; +- (BOOL)isPasscodeRequired; - (void)setDefaultSettings; -- (BOOL)isPasscodeRequired; + - (void)showPasscodeController:(UINavigationController*)navController; @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 35760f0..24d5439 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -40,54 +40,23 @@ + (KKPasscodeLock*)sharedLock } -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)setDefaultSettings -{ - if (![KKKeychain getStringForKey:@"passcode_lock_passcode_on"]) { - [KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]; - } - - if (![KKKeychain getStringForKey:@"passcode_lock_simple_passcode_on"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_simple_passcode_on"]; - } - - if (![KKKeychain getStringForKey:@"passcode_lock_erase_data_on"]) { - [KKKeychain setString:@"NO" forKey:@"passcode_lock_erase_data_on"]; - } -} - - /////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)isPasscodeRequired { - return [[KKKeychain getStringForKey:@"passcode_lock_passcode_on"] isEqualToString:@"YES"]; + return [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; } /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)presentAndRelease:(NSTimer *)timer +- (void)setDefaultSettings { - UIViewController *vc = [timer.userInfo objectForKey:@"vc"]; - UINavigationController *navController = [timer.userInfo objectForKey:@"nav"]; - - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - nav.modalPresentationStyle = UIModalPresentationFormSheet; - nav.navigationBar.barStyle = UIBarStyleBlack; - nav.navigationBar.opaque = NO; - } else { - nav.navigationBar.tintColor = navController.navigationBar.tintColor; - nav.navigationBar.translucent = navController.navigationBar.translucent; - nav.navigationBar.opaque = navController.navigationBar.opaque; - nav.navigationBar.barStyle = navController.navigationBar.barStyle; + if (![KKKeychain getStringForKey:@"passcode_on"]) { + [KKKeychain setString:@"NO" forKey:@"passcode_on"]; } - [navController presentModalViewController:nav animated:YES]; - [nav release]; - - - [vc release]; + if (![KKKeychain getStringForKey:@"erase_data_on"]) { + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + } } @@ -97,25 +66,15 @@ - (void)showPasscodeController:(UINavigationController*)navController if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.mode = KKPasscodeModeEnter; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - vc.modalPresentationStyle = UIModalPresentationFullScreen; - } if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + vc.modalPresentationStyle = UIModalPresentationFullScreen; for (UIViewController *svc in navController.viewControllers) { svc.view.alpha = 0.0; } - - NSDictionary* userinfo = [NSDictionary dictionaryWithObjectsAndKeys: - @"vc", vc, - @"nav", navController, nil]; - - [NSTimer scheduledTimerWithTimeInterval:0.3 target:self - selector:@selector(presentAndRelease:) userInfo: - userinfo repeats:NO]; - - } else { + } + + dispatch_async(dispatch_get_main_queue(),^ { UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -129,10 +88,12 @@ - (void)showPasscodeController:(UINavigationController*)navController nav.navigationBar.barStyle = navController.navigationBar.barStyle; } - [navController presentModalViewController:nav animated:NO]; + [navController presentModalViewController:nav animated:YES]; [nav release]; + [vc release]; - } + }); + } } diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index 8ed1bbf..9868cb9 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -32,11 +32,9 @@ id _delegate; - UISwitch* _simplePasscodeSwitch; UISwitch* _eraseDataSwitch; BOOL _passcodeLockOn; - BOOL _simplePasscodeOn; BOOL _eraseDataOn; } diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index a61695a..1eae640 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -41,10 +41,7 @@ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"Passcode Lock"; - - _simplePasscodeSwitch = [[UISwitch alloc] init]; - [_simplePasscodeSwitch addTarget:self action:@selector(simplePasscodeSwitchChanged:) forControlEvents:UIControlEventValueChanged]; - + _eraseDataSwitch = [[UISwitch alloc] init]; [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; } @@ -54,10 +51,8 @@ - (void)viewDidLoad - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_lock_passcode_on"] isEqualToString:@"YES"]; - _simplePasscodeOn = [[KKKeychain getStringForKey:@"passcode_lock_simple_passcode_on"] isEqualToString:@"YES"]; - _eraseDataOn = [[KKKeychain getStringForKey:@"passcode_lock_erase_data_on"] isEqualToString:@"YES"]; - _simplePasscodeSwitch.on = _simplePasscodeOn; + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; _eraseDataSwitch.on = _eraseDataOn; } @@ -69,23 +64,6 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa } -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma mark - -#pragma mark UISwitch - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)simplePasscodeSwitchChanged:(id)sender -{ - _simplePasscodeOn = _simplePasscodeSwitch.on; - if (_simplePasscodeOn) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_simple_passcode_on"]; - } else { - [KKKeychain setString:@"NO" forKey:@"passcode_lock_simple_passcode_on"]; - } -} - - /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - @@ -97,10 +75,10 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger { if (buttonIndex == 0) { _eraseDataOn = YES; - [KKKeychain setString:@"YES" forKey:@"passcode_lock_erase_data_on"]; + [KKKeychain setString:@"YES" forKey:@"erase_data_on"]; } else { _eraseDataOn = NO; - [KKKeychain setString:@"NO" forKey:@"passcode_lock_erase_data_on"]; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; } [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; } @@ -114,7 +92,7 @@ - (void)eraseDataSwitchChanged:(id)sender { [sheet release]; } else { _eraseDataOn = NO; - [KKKeychain setString:@"NO" forKey:@"passcode_lock_erase_data_on"]; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; } } @@ -129,7 +107,7 @@ - (void)eraseDataSwitchChanged:(id)sender { /////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 4; + return 3; } @@ -144,8 +122,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return @"A simple passcode is a 4 digit number."; - } else if (section == 3) { return @"Erase all data in this app after 10 failed passcode attempts."; } else { return @""; @@ -187,19 +163,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cell.textLabel.textAlignment = UITextAlignmentCenter; cell.accessoryView = nil; } else if (indexPath.section == 2) { - cell.textLabel.text = @"Simple Passcode"; - cell.textLabel.textColor = [UIColor blackColor]; - cell.textLabel.textAlignment = UITextAlignmentLeft; - cell.accessoryView = _simplePasscodeSwitch; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - if (_passcodeLockOn) { - cell.textLabel.textColor = [UIColor grayColor]; - _simplePasscodeSwitch.enabled = NO; - } else { - cell.textLabel.textColor = [UIColor blackColor]; - _simplePasscodeSwitch.enabled = YES; - } - } else if (indexPath.section == 3) { cell.textLabel.text = @"Erase Data"; cell.textLabel.textAlignment = UITextAlignmentLeft; cell.accessoryView = _eraseDataSwitch; @@ -260,7 +223,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [vc release]; } else if (indexPath.section == 1 && _passcodeLockOn) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:@"KKPasscodeViewController" bundle:nil]; + KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; vc.mode = KKPasscodeModeChange; @@ -294,7 +257,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath - (void)didSettingsChanged:(KKPasscodeViewController*)viewController { [self.tableView reloadData]; - NSLog(@"OKOKO"); if ([_delegate respondsToSelector:@selector(didSettingsChanged::)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } @@ -311,7 +273,6 @@ - (void)didSettingsChanged:(KKPasscodeViewController*)viewController { /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)dealloc { - [_simplePasscodeSwitch release]; [_eraseDataSwitch release]; [super dealloc]; diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 3319375..5e030b2 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -74,7 +74,6 @@ typedef NSUInteger KKPasscodeMode; KKPasscodeMode _mode; - BOOL _simplePasscodeOn; BOOL _passcodeLockOn; BOOL _eraseData; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 09049e9..f4280c5 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -28,8 +28,6 @@ @interface KKPasscodeViewController(Private) - (UITextField*)allocAndInitPasscodeTextField; - (NSArray*)squares; - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField; -- (void)addNextButton; -- (void)addDoneButton; - (void)moveToNextTableView; - (void)moveToPreviousTableView; @@ -93,9 +91,8 @@ - (void)viewDidLoad { [super viewDidLoad]; - _simplePasscodeOn = [[KKKeychain getStringForKey:@"passcode_lock_simple_passcode_on"] isEqualToString:@"YES"]; - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_lock_passcode_on"] isEqualToString:@"YES"]; - _eraseData = [[KKKeychain getStringForKey:@"passcode_lock_erase_data_on"] isEqualToString:@"YES"]; + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseData = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { _viewWidth = 540.0f; @@ -122,41 +119,33 @@ - (void)viewWillAppear:(BOOL)animated { _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; - if (_simplePasscodeOn) { - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } + [_squares addObject:[self squares]]; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; } } _setPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_setPasscodeTextField]; [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; - if (_simplePasscodeOn) { - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_setPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } + [_squares addObject:[self squares]]; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [_setPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; } _confirmPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_confirmPasscodeTextField]; [_tableViews addObject:_confirmPasscodeTableView]; [_textFields addObject:_confirmPasscodeTextField]; - if (_simplePasscodeOn) { - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_confirmPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } + [_squares addObject:[self squares]]; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [_confirmPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; } } else { _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; - if (_simplePasscodeOn) { - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } + [_squares addObject:[self squares]]; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; } } @@ -168,12 +157,7 @@ - (void)viewWillAppear:(BOOL)animated { tableView.frame = CGRectMake(tableView.frame.origin.x + _viewWidth, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); [self.view addSubview:tableView]; } - - if (_tableIndex == [_tableViews count] - 1) { - [self addDoneButton]; - } else { - [self addNextButton]; - } + [[_textFields objectAtIndex:0] becomeFirstResponder]; [[_tableViews objectAtIndex:0] reloadData]; @@ -200,9 +184,10 @@ - (void)viewWillAppear:(BOOL)animated { /////////////////////////////////////////////////////////////////////////////////////////////////// - (UITextField*)allocAndInitPasscodeTextField { - UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 13.0, 271.0, 24.0)]; + UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 18.0, 271.0, 24.0)]; + textField.font = [UIFont systemFontOfSize:14]; textField.text = @""; - textField.textColor = [UIColor colorWithRed:0.220 green:0.329 blue:0.529 alpha:1.0]; + textField.textColor = [UIColor blackColor]; textField.secureTextEntry = YES; textField.delegate = self; @@ -213,43 +198,19 @@ - (UITextField*)allocAndInitPasscodeTextField /////////////////////////////////////////////////////////////////////////////////////////////////// --(void)cancelButtonPressed:(id)sender +- (void)cancelButtonPressed:(id)sender { [self dismissModalViewControllerAnimated:YES]; } -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)addNextButton -{ - if (!_simplePasscodeOn) { - UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextButtonPressed:)]; - self.navigationItem.rightBarButtonItem = nextButton; - [nextButton release]; - } -} - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)addDoneButton -{ - if (!_simplePasscodeOn) { - UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; - self.navigationItem.rightBarButtonItem = doneButton; - [doneButton release]; - } -} - - /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)incrementAndShowFailedAttemptsLabel { _enterPasscodeTextField.text = @""; - if (_simplePasscodeOn) { - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } - } + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + } _failedAttemptsCount += 1; if (_failedAttemptsCount == 1) { @@ -278,8 +239,8 @@ - (void)incrementAndShowFailedAttemptsLabel } if (_failedAttemptsCount == 10 && _eraseData) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; } [self dismissModalViewControllerAnimated:YES]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -306,10 +267,8 @@ - (void)moveToNextTableView UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x + _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - if (_simplePasscodeOn) { - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -317,12 +276,7 @@ - (void)moveToNextTableView oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); newTableView.frame = self.view.frame; [UIView commitAnimations]; - - if (_tableIndex == [_tableViews count] - 1) { - [self addDoneButton]; - } else { - [self addNextButton]; - } + [[_textFields objectAtIndex:_tableIndex - 1] resignFirstResponder]; [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; @@ -337,10 +291,8 @@ - (void)moveToPreviousTableView UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x - _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - if (_simplePasscodeOn) { - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -349,11 +301,7 @@ - (void)moveToPreviousTableView newTableView.frame = self.view.frame; [UIView commitAnimations]; - if (_tableIndex == [_tableViews count] - 1) { - [self addDoneButton]; - } else { - [self addNextButton]; - } + [[_textFields objectAtIndex:_tableIndex + 1] resignFirstResponder]; [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; @@ -378,8 +326,8 @@ - (void)nextButtonPressed:(id)sender _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -390,7 +338,7 @@ - (void)nextButtonPressed:(id)sender } } } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; @@ -414,8 +362,8 @@ - (void)nextButtonPressed:(id)sender _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -437,7 +385,7 @@ - (void)doneButtonPressed:(id)sender UITextField *textField = [_textFields objectAtIndex:_tableIndex]; if (mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [UIView beginAnimations:@"fadeIn" context:nil]; @@ -460,8 +408,8 @@ - (void)doneButtonPressed:(id)sender _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -472,7 +420,7 @@ - (void)doneButtonPressed:(id)sender } } } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; @@ -496,8 +444,8 @@ - (void)doneButtonPressed:(id)sender _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -508,10 +456,10 @@ - (void)doneButtonPressed:(id)sender } } } else if (mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -530,15 +478,10 @@ - (void)doneButtonPressed:(id)sender - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField { - if (_simplePasscodeOn) { - textField.keyboardType = UIKeyboardTypeNumberPad; + textField.keyboardType = UIKeyboardTypeNumberPad; - textField.hidden = YES; - [self.view addSubview:textField]; - } else { - textField.keyboardType = UIKeyboardTypeDefault; - textField.returnKeyType = UIReturnKeyNext; - } + textField.hidden = YES; + [self.view addSubview:textField]; UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, _viewWidth, 70.0)] autorelease]; UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, _viewWidth, 30.0)]; @@ -678,7 +621,7 @@ - (NSArray*)squares /////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return _simplePasscodeOn ? 0 : 1; + return 0; } @@ -701,7 +644,6 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:( cell.selectionStyle = UITableViewCellSelectionStyleNone; } - //cell.accessoryView = enterPasscodeTextField; //[textFields objectAtIndex:tableIndex]; if ([aTableView isEqual:_enterPasscodeTableView]) { cell.accessoryView = _enterPasscodeTextField; } else if ([aTableView isEqual:_setPasscodeTableView]) { @@ -736,7 +678,7 @@ - (BOOL)textFieldShouldReturn:(UITextField *)textField - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - if (_simplePasscodeOn) { + if (YES) { NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; textField.text = result; @@ -753,10 +695,10 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([result length] == 4) { if (mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_lock_passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode_lock_passcode"]; + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -768,7 +710,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang [self incrementAndShowFailedAttemptsLabel]; } } else if (mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [UIView beginAnimations:@"fadeIn" context:nil]; @@ -786,7 +728,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang [self incrementAndShowFailedAttemptsLabel]; } } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode_lock_passcode"]; + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; @@ -813,8 +755,8 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { @@ -833,8 +775,8 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; [self moveToPreviousTableView]; } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode_lock_passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_lock_passcode_on"]; + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; } if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { From 128e704f185a28130d45e50300777b694cb44a9d Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 20 Jan 2012 21:00:08 -0500 Subject: [PATCH 05/62] erase delegate function --- example/KKPasscodeLock/AppDelegate.h | 3 +- example/KKPasscodeLock/AppDelegate.m | 16 +++++++- src/KKPasscodeLock.h | 4 +- src/KKPasscodeLock.m | 4 +- src/KKPasscodeSettingsViewController.m | 1 - src/KKPasscodeViewController.h | 4 +- src/KKPasscodeViewController.m | 53 +++++++++++++------------- 7 files changed, 52 insertions(+), 33 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.h b/example/KKPasscodeLock/AppDelegate.h index 235e555..7c39181 100644 --- a/example/KKPasscodeLock/AppDelegate.h +++ b/example/KKPasscodeLock/AppDelegate.h @@ -16,8 +16,9 @@ // #import +#import "KKPasscodeLock.h" -@interface AppDelegate : UIResponder +@interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController *navigationController; diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 1321c4a..53c3e27 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -50,7 +50,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (void)applicationDidBecomeActive:(UIApplication *)application { - [[KKPasscodeLock sharedLock] showPasscodeController:self.navigationController]; + [[KKPasscodeLock sharedLock] showPasscodeController:self.navigationController withDelegate:self]; } +- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController +{ + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times. All account data in this app has been deleted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + [alert release]; +} + +- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController +{ + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + [alert release];} + + @end diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 8ac1b9d..09e7c15 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -16,6 +16,7 @@ // #import +#import "KKPasscodeViewController.h" @interface KKPasscodeLock : NSObject @@ -25,6 +26,7 @@ - (void)setDefaultSettings; -- (void)showPasscodeController:(UINavigationController*)navController; +- (void)showPasscodeController:(UINavigationController*)navController + withDelegate:(id)delegate; @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 24d5439..7c8fd00 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -61,11 +61,13 @@ - (void)setDefaultSettings /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)showPasscodeController:(UINavigationController*)navController +- (void)showPasscodeController:(UINavigationController*)navController + withDelegate:(id)delegate { if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.mode = KKPasscodeModeEnter; + vc.delegate = delegate; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { vc.modalPresentationStyle = UIModalPresentationFullScreen; diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 1eae640..dcdef1a 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -261,7 +261,6 @@ - (void)didSettingsChanged:(KKPasscodeViewController*)viewController { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } - } /////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 5e030b2..9f07539 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -37,13 +37,15 @@ typedef NSUInteger KKPasscodeMode; - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController; +- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController; + - (void)didSettingsChanged:(KKPasscodeViewController*)viewController; @end -@interface KKPasscodeViewController : UIViewController { diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index f4280c5..90b8089 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -66,7 +66,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil _setPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_setPasscodeTableView]; - + _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds]; _confirmPasscodeTableView.delegate = self; _confirmPasscodeTableView.dataSource = self; @@ -157,7 +157,7 @@ - (void)viewWillAppear:(BOOL)animated { tableView.frame = CGRectMake(tableView.frame.origin.x + _viewWidth, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); [self.view addSubview:tableView]; } - + [[_textFields objectAtIndex:0] becomeFirstResponder]; [[_tableViews objectAtIndex:0] reloadData]; @@ -233,27 +233,26 @@ - (void)incrementAndShowFailedAttemptsLabel _failedAttemptsView.hidden = NO; if (_failedAttemptsCount == 10) { - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { - [_delegate didPasscodeEnteredCorrectly:self]; - } - } - - if (_failedAttemptsCount == 10 && _eraseData) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - [self dismissModalViewControllerAnimated:YES]; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times. All account data in this app has been deleted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; - [alert release]; + _enterPasscodeTextField.delegate = nil; + + if (_eraseData) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + + if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { + [_delegate shouldEraseApplicationData:self]; + } + } else { + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { + [_delegate didPasscodeEnteredIncorrectly:self]; + } + } } } @@ -276,7 +275,7 @@ - (void)moveToNextTableView oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); newTableView.frame = self.view.frame; [UIView commitAnimations]; - + [[_textFields objectAtIndex:_tableIndex - 1] resignFirstResponder]; [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; @@ -301,7 +300,7 @@ - (void)moveToPreviousTableView newTableView.frame = self.view.frame; [UIView commitAnimations]; - + [[_textFields objectAtIndex:_tableIndex + 1] resignFirstResponder]; [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; @@ -348,7 +347,7 @@ - (void)nextButtonPressed:(id)sender } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. You cannot re-use the same passcode."; _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, _viewWidth, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -391,7 +390,7 @@ - (void)doneButtonPressed:(id)sender [UIView beginAnimations:@"fadeIn" context:nil]; [UIView setAnimationDelay:0.25]; [UIView setAnimationDuration:0.5]; - + [UIView commitAnimations]; } [self dismissModalViewControllerAnimated:YES]; @@ -479,7 +478,7 @@ - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField { textField.keyboardType = UIKeyboardTypeNumberPad; - + textField.hidden = YES; [self.view addSubview:textField]; From 81e4fbaa0b6f1859bd1288ed8a2904d0d887ef8d Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 21 Jan 2012 11:42:38 -0500 Subject: [PATCH 06/62] delagate functions --- example/KKPasscodeLock/AppDelegate.m | 31 +++++++++++++++++++++- src/KKPasscodeLock.h | 3 --- src/KKPasscodeLock.m | 39 ---------------------------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 53c3e27..7333379 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -50,7 +50,36 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (void)applicationDidBecomeActive:(UIApplication *)application { - [[KKPasscodeLock sharedLock] showPasscodeController:self.navigationController withDelegate:self]; + if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { + KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; + vc.mode = KKPasscodeModeEnter; + vc.delegate = self; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + vc.modalPresentationStyle = UIModalPresentationFullScreen; + for (UIViewController *svc in _navigationController.viewControllers) { + svc.view.alpha = 0.0; + } + } + + dispatch_async(dispatch_get_main_queue(),^ { + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + nav.modalPresentationStyle = UIModalPresentationFormSheet; + nav.navigationBar.barStyle = UIBarStyleBlack; + nav.navigationBar.opaque = NO; + } else { + nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor; + nav.navigationBar.translucent = _navigationController.navigationBar.translucent; + nav.navigationBar.opaque = _navigationController.navigationBar.opaque; + nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle; + } + + [_navigationController presentModalViewController:nav animated:YES]; + }); + + } } - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 09e7c15..b261c47 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -26,7 +26,4 @@ - (void)setDefaultSettings; -- (void)showPasscodeController:(UINavigationController*)navController - withDelegate:(id)delegate; - @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 7c8fd00..986b986 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -60,44 +60,5 @@ - (void)setDefaultSettings } -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)showPasscodeController:(UINavigationController*)navController - withDelegate:(id)delegate -{ - if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; - vc.mode = KKPasscodeModeEnter; - vc.delegate = delegate; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - vc.modalPresentationStyle = UIModalPresentationFullScreen; - for (UIViewController *svc in navController.viewControllers) { - svc.view.alpha = 0.0; - } - } - - dispatch_async(dispatch_get_main_queue(),^ { - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - nav.modalPresentationStyle = UIModalPresentationFormSheet; - nav.navigationBar.barStyle = UIBarStyleBlack; - nav.navigationBar.opaque = NO; - } else { - nav.navigationBar.tintColor = navController.navigationBar.tintColor; - nav.navigationBar.translucent = navController.navigationBar.translucent; - nav.navigationBar.opaque = navController.navigationBar.opaque; - nav.navigationBar.barStyle = navController.navigationBar.barStyle; - } - - [navController presentModalViewController:nav animated:YES]; - [nav release]; - - [vc release]; - }); - - } -} - @end From 69ed030db883cab2b37bf46d4a49dc015c119d5e Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 21 Jan 2012 12:46:32 -0500 Subject: [PATCH 07/62] fixed iPad issues --- example/KKPasscodeLock/AppDelegate.m | 7 ---- .../KKPasscodeLock/SettingsViewController.h | 3 +- .../KKPasscodeLock/SettingsViewController.m | 9 +++-- src/KKPasscodeSettingsViewController.m | 34 ++++++++----------- src/KKPasscodeViewController.m | 19 ++++++++--- 5 files changed, 38 insertions(+), 34 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 7333379..65fbfe0 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -55,13 +55,6 @@ - (void)applicationDidBecomeActive:(UIApplication *)application vc.mode = KKPasscodeModeEnter; vc.delegate = self; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - vc.modalPresentationStyle = UIModalPresentationFullScreen; - for (UIViewController *svc in _navigationController.viewControllers) { - svc.view.alpha = 0.0; - } - } - dispatch_async(dispatch_get_main_queue(),^ { UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; diff --git a/example/KKPasscodeLock/SettingsViewController.h b/example/KKPasscodeLock/SettingsViewController.h index d6db093..ba82505 100755 --- a/example/KKPasscodeLock/SettingsViewController.h +++ b/example/KKPasscodeLock/SettingsViewController.h @@ -16,7 +16,8 @@ // #import +#import "KKPasscodeSettingsViewController.h" -@interface SettingsViewController : UITableViewController +@interface SettingsViewController : UITableViewController @end diff --git a/example/KKPasscodeLock/SettingsViewController.m b/example/KKPasscodeLock/SettingsViewController.m index 36a6c86..ff9be37 100755 --- a/example/KKPasscodeLock/SettingsViewController.m +++ b/example/KKPasscodeLock/SettingsViewController.m @@ -81,10 +81,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { - KKPasscodeSettingsViewController *vc = [[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; + KKPasscodeSettingsViewController *vc = [[[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; + vc.delegate = self; [self.navigationController pushViewController:vc animated:YES]; - [vc release]; } } +- (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController +{ + [self.tableView reloadData]; +} + @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index dcdef1a..9b5047e 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -190,8 +190,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil - bundle:nil]; + KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil + bundle:nil] autorelease]; vc.delegate = self; if (_passcodeLockOn) { @@ -199,11 +199,8 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } else { vc.mode = KKPasscodeModeSet; } - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - vc.modalPresentationStyle = UIModalPresentationFormSheet; - } - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -218,20 +215,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } [self.navigationController presentModalViewController:nav animated:YES]; - [nav release]; - [vc release]; } else if (indexPath.section == 1 && _passcodeLockOn) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; + KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; vc.delegate = self; - vc.mode = KKPasscodeModeChange; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - vc.modalPresentationStyle = UIModalPresentationFormSheet; - } + vc.mode = KKPasscodeModeChange; - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -245,24 +237,26 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } - [self.navigationController presentModalViewController:nav animated:YES]; - [nav release]; - - [vc release]; + [self.navigationController presentModalViewController:nav animated:YES]; } } /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)didSettingsChanged:(KKPasscodeViewController*)viewController { - [self.tableView reloadData]; + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + _eraseDataSwitch.on = _eraseDataOn; - if ([_delegate respondsToSelector:@selector(didSettingsChanged::)]) { + [self.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } } + /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 90b8089..115b41f 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -53,6 +53,8 @@ @implementation KKPasscodeViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + self.modalPresentationStyle = UIModalPresentationFormSheet; + _enterPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds]; _enterPasscodeTableView.delegate = self; _enterPasscodeTableView.dataSource = self; @@ -200,6 +202,10 @@ - (UITextField*)allocAndInitPasscodeTextField /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)cancelButtonPressed:(id)sender { + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } @@ -308,7 +314,7 @@ - (void)moveToPreviousTableView /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)nextButtonPressed:(id)sender +- (void)nextDigitPressed { UITextField *textField = [_textFields objectAtIndex:_tableIndex]; @@ -378,7 +384,7 @@ - (void)nextButtonPressed:(id)sender /////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)doneButtonPressed:(id)sender +- (void)doneButtonPressed { UITextField *textField = [_textFields objectAtIndex:_tableIndex]; @@ -393,6 +399,11 @@ - (void)doneButtonPressed:(id)sender [UIView commitAnimations]; } + + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly::)]) { + [_delegate didPasscodeEnteredCorrectly:self]; + } + [self dismissModalViewControllerAnimated:YES]; } else { [self incrementAndShowFailedAttemptsLabel]; @@ -665,9 +676,9 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:( - (BOOL)textFieldShouldReturn:(UITextField *)textField { if ([textField isEqual:[_textFields lastObject]]) { - [self doneButtonPressed:nil]; + [self doneButtonPressed]; } else { - [self nextButtonPressed:nil]; + [self nextDigitPressed]; } return NO; } From 3f53961ef8f08b2c36518bfa338f05ac6d7201ad Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 21 Jan 2012 13:27:24 -0500 Subject: [PATCH 08/62] added option to customize erase option and tries allowed --- src/KKPasscodeLock.h | 8 +++++++- src/KKPasscodeLock.m | 5 +++++ src/KKPasscodeSettingsViewController.m | 13 ++++++++++--- src/KKPasscodeViewController.m | 5 +++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index b261c47..cb43912 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -18,7 +18,10 @@ #import #import "KKPasscodeViewController.h" -@interface KKPasscodeLock : NSObject +@interface KKPasscodeLock : NSObject { + BOOL _eraseOption; + NSUInteger _attemptsAllowed; +} + (KKPasscodeLock*)sharedLock; @@ -26,4 +29,7 @@ - (void)setDefaultSettings; +@property (nonatomic,assign) BOOL eraseOption; +@property (nonatomic,assign) NSUInteger attemptsAllowed; + @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 986b986..f66c541 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -28,12 +28,17 @@ @implementation KKPasscodeLock +@synthesize eraseOption = _eraseOption; +@synthesize attemptsAllowed = _attemptsAllowed; + /////////////////////////////////////////////////////////////////////////////////////////////////// + (KKPasscodeLock*)sharedLock { @synchronized(self) { if (sharedLock == nil) { sharedLock = [[self alloc] init]; + sharedLock.eraseOption = YES; + sharedLock.attemptsAllowed = 5; } } return sharedLock; diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 9b5047e..1ea1cd1 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -19,6 +19,7 @@ #import "KKKeychain.h" #import "KKPasscodeViewController.h" #import "SettingsViewController.h" +#import "KKPasscodeLock.h" /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -87,7 +88,9 @@ - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger /////////////////////////////////////////////////////////////////////////////////////////////////// - (void)eraseDataSwitchChanged:(id)sender { if (_eraseDataSwitch.on) { - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"All data in this app will be erased after 10 failed passcode attempts." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Enable" otherButtonTitles:nil]; + NSString* title = [NSString stringWithFormat:@"All data in this app will be erased after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]]; + + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Enable" otherButtonTitles:nil]; [sheet showInView:self.view]; [sheet release]; } else { @@ -107,7 +110,11 @@ - (void)eraseDataSwitchChanged:(id)sender { /////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 3; + if ([[KKPasscodeLock sharedLock] eraseOption]) { + return 3; + } + + return 2; } @@ -122,7 +129,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return @"Erase all data in this app after 10 failed passcode attempts."; + return [NSString stringWithFormat:@"Erase all data in this app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; } diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 115b41f..0bff305 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -18,6 +18,7 @@ #import "KKPasscodeViewController.h" #import "KKKeychain.h" #import "KKPasscodeSettingsViewController.h" +#import "KKPasscodeLock.h" #import /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -94,7 +95,7 @@ - (void)viewDidLoad [super viewDidLoad]; _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; - _eraseData = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { _viewWidth = 540.0f; @@ -238,7 +239,7 @@ - (void)incrementAndShowFailedAttemptsLabel _failedAttemptsLabel.hidden = NO; _failedAttemptsView.hidden = NO; - if (_failedAttemptsCount == 10) { + if (_failedAttemptsCount == [[KKPasscodeLock sharedLock] attemptsAllowed]) { _enterPasscodeTextField.delegate = nil; From 6fbe05c471210c1dbe183bd16fc3fcf4c8b0ce23 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sun, 22 Jan 2012 19:11:46 -0500 Subject: [PATCH 09/62] Update README.mdown --- README.mdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mdown b/README.mdown index 6152881..36d4926 100644 --- a/README.mdown +++ b/README.mdown @@ -10,7 +10,7 @@ KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passc

Main Features in KKPasscodeLock

-- Either a simple 4 digit passcode (using a numeric keyboard) or a free-text passcode +- Either a simple 4 digit passcode (using a numeric keyboard) or a free-text passcode (in development) - Supports universal apps (both iPhone and iPad) - Advanced passcode settings controller: set & change passcode, turn off/on passcode and passcode tries allowed - Passcode is saved securly in the device keychain From 82e76cb816a387022db3f622d90f361ab81f3fbf Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Mon, 23 Jan 2012 20:31:24 -0500 Subject: [PATCH 10/62] merging changes from AppSales https://github.com/omz/AppSales-Mobile/commit/fd918a94fb2c76501b7315d9091b8cdbfdeb7068 --- src/KKKeychain.h | 1 + src/KKKeychain.m | 38 +- src/KKPasscodeLock.h | 6 +- src/KKPasscodeLock.m | 44 +- src/KKPasscodeSettingsViewController.h | 16 +- src/KKPasscodeSettingsViewController.m | 344 +++--- src/KKPasscodeViewController.h | 82 +- src/KKPasscodeViewController.m | 1346 ++++++++++++------------ 8 files changed, 874 insertions(+), 1003 deletions(-) diff --git a/src/KKKeychain.h b/src/KKKeychain.h index 1cce8fa..6838c85 100755 --- a/src/KKKeychain.h +++ b/src/KKKeychain.h @@ -18,6 +18,7 @@ #import @interface KKKeychain : NSObject { + } + (BOOL)setString:(NSString*)string forKey:(NSString*)key; diff --git a/src/KKKeychain.m b/src/KKKeychain.m index 15d2011..89274c6 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -18,34 +18,28 @@ #import "KKKeychain.h" #import -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// @implementation KKKeychain - -/////////////////////////////////////////////////////////////////////////////////////////////////// -+ (NSString*)appName { ++ (NSString*)appName +{ NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; if (!appName) { appName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; } - return appName; + return appName; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -+ (BOOL)setString:(NSString*)string forKey:(NSString*)key { ++ (BOOL)setString:(NSString*)string forKey:(NSString*)key +{ if (string == nil || key == nil) { return NO; } + + key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; - key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; - - // First check if it already exists, by creating a search dictionary and requesting that - // nothing be returned, and performing the search anyway. + // First check if it already exists, by creating a search dictionary and requesting that + // nothing be returned, and performing the search anyway. NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary]; NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; @@ -69,25 +63,18 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key { // Modify an existing one // Actually pull it now of the keychain at this point. NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(id)kSecValueData]; - res = SecItemUpdate((CFDictionaryRef)existsQueryDictionary, (CFDictionaryRef)attributeDict); NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %d!", res); - } else { NSAssert1(NO, @"Received %d from SecItemCopyMatching!", res); } - return YES; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -+ (NSString*)getStringForKey:(NSString*)key { - - key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; - ++ (NSString*)getStringForKey:(NSString*)key +{ + key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary]; - [existsQueryDictionary setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; // Add the keys to the search dict @@ -112,5 +99,4 @@ + (NSString*)getStringForKey:(NSString*)key { } - @end diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index cb43912..a47fb17 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -19,8 +19,8 @@ #import "KKPasscodeViewController.h" @interface KKPasscodeLock : NSObject { - BOOL _eraseOption; - NSUInteger _attemptsAllowed; + BOOL _eraseOption; + NSUInteger _attemptsAllowed; } + (KKPasscodeLock*)sharedLock; diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index f66c541..daf97b4 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -22,48 +22,38 @@ static KKPasscodeLock *sharedLock = nil; -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// @implementation KKPasscodeLock - @synthesize eraseOption = _eraseOption; @synthesize attemptsAllowed = _attemptsAllowed; -/////////////////////////////////////////////////////////////////////////////////////////////////// + (KKPasscodeLock*)sharedLock { - @synchronized(self) { - if (sharedLock == nil) { - sharedLock = [[self alloc] init]; - sharedLock.eraseOption = YES; - sharedLock.attemptsAllowed = 5; - } - } - return sharedLock; + @synchronized(self) { + if (sharedLock == nil) { + sharedLock = [[self alloc] init]; + sharedLock.eraseOption = YES; + sharedLock.attemptsAllowed = 5; + } + } + return sharedLock; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)isPasscodeRequired { - return [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + return [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)setDefaultSettings { - if (![KKKeychain getStringForKey:@"passcode_on"]) { - [KKKeychain setString:@"NO" forKey:@"passcode_on"]; - } - - if (![KKKeychain getStringForKey:@"erase_data_on"]) { - [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; - } + if (![KKKeychain getStringForKey:@"passcode_on"]) { + [KKKeychain setString:@"NO" forKey:@"passcode_on"]; + } + + if (![KKKeychain getStringForKey:@"erase_data_on"]) { + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + } } - @end diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index 9868cb9..61b5e7a 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -29,13 +29,13 @@ @end @interface KKPasscodeSettingsViewController : UITableViewController { - - id _delegate; - - UISwitch* _eraseDataSwitch; - - BOOL _passcodeLockOn; - BOOL _eraseDataOn; + + id _delegate; + + UISwitch* _eraseDataSwitch; + + BOOL _passcodeLockOn; + BOOL _eraseDataOn; } @property (nonatomic, assign) id delegate; diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 1ea1cd1..47a2350 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -18,264 +18,218 @@ #import "KKPasscodeSettingsViewController.h" #import "KKKeychain.h" #import "KKPasscodeViewController.h" -#import "SettingsViewController.h" #import "KKPasscodeLock.h" -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// @implementation KKPasscodeSettingsViewController @synthesize delegate = _delegate; - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark UIViewController - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)viewDidLoad { - [super viewDidLoad]; - self.navigationItem.title = @"Passcode Lock"; - - _eraseDataSwitch = [[UISwitch alloc] init]; - [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; + [super viewDidLoad]; + self.navigationItem.title = @"Passcode Lock"; + + _eraseDataSwitch = [[UISwitch alloc] init]; + [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; - _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - _eraseDataSwitch.on = _eraseDataOn; + [super viewWillAppear:animated]; + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + _eraseDataSwitch.on = _eraseDataOn; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); + return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark UIActionSheetDelegate - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { - if (buttonIndex == 0) { - _eraseDataOn = YES; - [KKKeychain setString:@"YES" forKey:@"erase_data_on"]; - } else { - _eraseDataOn = NO; - [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; - } - [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; + if (buttonIndex == 0) { + _eraseDataOn = YES; + [KKKeychain setString:@"YES" forKey:@"erase_data_on"]; + } else { + _eraseDataOn = NO; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + } + [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)eraseDataSwitchChanged:(id)sender { - if (_eraseDataSwitch.on) { - NSString* title = [NSString stringWithFormat:@"All data in this app will be erased after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]]; - - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Enable" otherButtonTitles:nil]; - [sheet showInView:self.view]; - [sheet release]; - } else { - _eraseDataOn = NO; - [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; - } +- (void)eraseDataSwitchChanged:(id)sender +{ + if (_eraseDataSwitch.on) { + NSString* title = [NSString stringWithFormat:@"All data in this app will be erased after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]]; + + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Enable" otherButtonTitles:nil]; + [sheet showInView:self.view]; + [sheet release]; + } else { + _eraseDataOn = NO; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + } } - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Table view data source - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - if ([[KKPasscodeLock sharedLock] eraseOption]) { - return 3; - } - - return 2; + if ([[KKPasscodeLock sharedLock] eraseOption]) { + return 3; + } + + return 2; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 1; + return 1; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { - if (section == 2) { - return [NSString stringWithFormat:@"Erase all data in this app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; - } else { - return @""; - } + if (section == 2) { + return [NSString stringWithFormat:@"Erase all data in this app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; + } else { + return @""; + } } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (UITableViewCell *)tableView:(UITableView *)tableView - cellForRowAtIndexPath:(NSIndexPath *)indexPath +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - static NSString *CellIdentifier = @"Cell"; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; - } - - if (indexPath.section == 0) { - if (_passcodeLockOn) { - cell.textLabel.text = @"Turn Passcode Off"; - } else { - cell.textLabel.text = @"Turn Passcode On"; - } - cell.textLabel.textColor = [UIColor blackColor]; - cell.textLabel.textAlignment = UITextAlignmentCenter; - cell.accessoryView = nil; - cell.selectionStyle = UITableViewCellSelectionStyleBlue; - } else if (indexPath.section == 1) { - cell.textLabel.text = @"Change Passcode"; - if (_passcodeLockOn) { - cell.textLabel.textColor = [UIColor blackColor]; - cell.selectionStyle = UITableViewCellSelectionStyleBlue; - } else { - cell.textLabel.textColor = [UIColor grayColor]; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - } - cell.textLabel.textAlignment = UITextAlignmentCenter; - cell.accessoryView = nil; - } else if (indexPath.section == 2) { - cell.textLabel.text = @"Erase Data"; - cell.textLabel.textAlignment = UITextAlignmentLeft; - cell.accessoryView = _eraseDataSwitch; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - if (_passcodeLockOn) { - cell.textLabel.textColor = [UIColor blackColor]; - _eraseDataSwitch.enabled = YES; - } else { - cell.textLabel.textColor = [UIColor grayColor]; - _eraseDataSwitch.enabled = NO; - } - } - - return cell; + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + if (indexPath.section == 0) { + if (_passcodeLockOn) { + cell.textLabel.text = @"Turn Passcode Off"; + } else { + cell.textLabel.text = @"Turn Passcode On"; + } + cell.textLabel.textColor = [UIColor blackColor]; + cell.textLabel.textAlignment = UITextAlignmentCenter; + cell.accessoryView = nil; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + } else if (indexPath.section == 1) { + cell.textLabel.text = @"Change Passcode"; + if (_passcodeLockOn) { + cell.textLabel.textColor = [UIColor blackColor]; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + } else { + cell.textLabel.textColor = [UIColor grayColor]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + } + cell.textLabel.textAlignment = UITextAlignmentCenter; + cell.accessoryView = nil; + } else if (indexPath.section == 2) { + cell.textLabel.text = @"Erase Data"; + cell.textLabel.textAlignment = UITextAlignmentLeft; + cell.accessoryView = _eraseDataSwitch; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (_passcodeLockOn) { + cell.textLabel.textColor = [UIColor blackColor]; + _eraseDataSwitch.enabled = YES; + } else { + cell.textLabel.textColor = [UIColor grayColor]; + _eraseDataSwitch.enabled = NO; + } + } + + return cell; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Table view delegate - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 0) { - KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil - bundle:nil] autorelease]; - vc.delegate = self; - - if (_passcodeLockOn) { - vc.mode = KKPasscodeModeDisabled; - } else { - vc.mode = KKPasscodeModeSet; - } - - UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; - - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - nav.modalPresentationStyle = UIModalPresentationFormSheet; - nav.navigationBar.barStyle = UIBarStyleBlack; - nav.navigationBar.opaque = NO; - } else { - nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; - nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; - nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; - nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; - } - - [self.navigationController presentModalViewController:nav animated:YES]; - - - } else if (indexPath.section == 1 && _passcodeLockOn) { - KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; - vc.delegate = self; - - vc.mode = KKPasscodeModeChange; - - UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; - - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - nav.modalPresentationStyle = UIModalPresentationFormSheet; - nav.navigationBar.barStyle = UIBarStyleBlack; - nav.navigationBar.opaque = NO; - } else { - nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; - nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; - nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; - nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; - } - - [self.navigationController presentModalViewController:nav animated:YES]; - } + if (indexPath.section == 0) { + KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil + bundle:nil] autorelease]; + vc.delegate = self; + + if (_passcodeLockOn) { + vc.mode = KKPasscodeModeDisabled; + } else { + vc.mode = KKPasscodeModeSet; + } + + UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + nav.modalPresentationStyle = UIModalPresentationFormSheet; + nav.navigationBar.barStyle = UIBarStyleBlack; + nav.navigationBar.opaque = NO; + } else { + nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; + nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; + nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; + nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; + } + + [self.navigationController presentModalViewController:nav animated:YES]; + + + } else if (indexPath.section == 1 && _passcodeLockOn) { + KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; + vc.delegate = self; + + vc.mode = KKPasscodeModeChange; + + UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; + + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + nav.modalPresentationStyle = UIModalPresentationFormSheet; + nav.navigationBar.barStyle = UIBarStyleBlack; + nav.navigationBar.opaque = NO; + } else { + nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; + nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; + nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; + nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; + } + + [self.navigationController presentModalViewController:nav animated:YES]; + } } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)didSettingsChanged:(KKPasscodeViewController*)viewController { - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; - _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - _eraseDataSwitch.on = _eraseDataOn; - - [self.tableView reloadData]; - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - +- (void)didSettingsChanged:(KKPasscodeViewController*)viewController +{ + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + _eraseDataSwitch.on = _eraseDataOn; + + [self.tableView reloadData]; + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Memory management - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)dealloc { - [_eraseDataSwitch release]; - - [super dealloc]; + [_eraseDataSwitch release]; + [super dealloc]; } diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 9f07539..b06a107 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -19,10 +19,10 @@ enum { - KKPasscodeModeEnter = 0, - KKPasscodeModeSet = 1, - KKPasscodeModeDisabled = 2, - KKPasscodeModeChange = 3 + KKPasscodeModeEnter = 0, + KKPasscodeModeSet = 1, + KKPasscodeModeDisabled = 2, + KKPasscodeModeChange = 3 }; typedef NSUInteger KKPasscodeMode; @@ -34,57 +34,53 @@ typedef NSUInteger KKPasscodeMode; @optional - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController; - - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController; - - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController; - - (void)didSettingsChanged:(KKPasscodeViewController*)viewController; @end -@interface KKPasscodeViewController : UIViewController { - - - id _delegate; - - UILabel* _passcodeConfirmationWarningLabel; - UIView* _failedAttemptsView; - UILabel* _failedAttemptsLabel; - NSInteger _failedAttemptsCount; - - NSUInteger _tableIndex; - NSMutableArray* _tableViews; - NSMutableArray* _textFields; - NSMutableArray* _squares; - - UITableView* _enterPasscodeTableView; - UITextField* _enterPasscodeTextField; - NSArray* _enterPasscodeSquareImageViews; - - UITableView* _setPasscodeTableView; - UITextField* _setPasscodeTextField; - NSArray* _setPasscodeSquareImageViews; - - UITableView* _confirmPasscodeTableView; - UITextField* _confirmPasscodeTextField; - NSArray* _confirmPasscodeSquareImageViews; - - KKPasscodeMode _mode; - - BOOL _passcodeLockOn; - BOOL _eraseData; - - CGFloat _viewWidth; +@interface KKPasscodeViewController : UIViewController { + + id _delegate; + + UILabel* _passcodeConfirmationWarningLabel; + UIView* _failedAttemptsView; + UILabel* _failedAttemptsLabel; + NSInteger _failedAttemptsCount; + + NSUInteger _tableIndex; + NSMutableArray* _tableViews; + NSMutableArray* _textFields; + NSMutableArray* _squares; + + UITableView* _enterPasscodeTableView; + UITextField* _enterPasscodeTextField; + NSArray* _enterPasscodeSquareImageViews; + + UITableView* _setPasscodeTableView; + UITextField* _setPasscodeTextField; + NSArray* _setPasscodeSquareImageViews; + + UITableView* _confirmPasscodeTableView; + UITextField* _confirmPasscodeTextField; + NSArray* _confirmPasscodeSquareImageViews; + + KKPasscodeMode _mode; + + BOOL _passcodeLockOn; + BOOL _eraseData; } @property (nonatomic, assign) id delegate; @property (nonatomic, assign) KKPasscodeMode mode; +@property (nonatomic, retain) UITableView *enterPasscodeTableView; +@property (nonatomic, retain) UITableView *setPasscodeTableView; +@property (nonatomic, retain) UITableView *confirmPasscodeTableView; + @end diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 0bff305..80fc12a 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -6,7 +6,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -21,12 +21,9 @@ #import "KKPasscodeLock.h" #import -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// @interface KKPasscodeViewController(Private) -- (UITextField*)allocAndInitPasscodeTextField; +- (UITextField*)newPasscodeTextField; - (NSArray*)squares; - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField; - (void)moveToNextTableView; @@ -35,794 +32,741 @@ - (void)moveToPreviousTableView; @end -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// @implementation KKPasscodeViewController @synthesize delegate = _delegate; @synthesize mode; +@synthesize enterPasscodeTableView=_enterPasscodeTableView, setPasscodeTableView=_setPasscodeTableView, confirmPasscodeTableView=_confirmPasscodeTableView; - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark UIViewController - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +- (void)loadView { - if (self == [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { - self.modalPresentationStyle = UIModalPresentationFormSheet; - - _enterPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds]; - _enterPasscodeTableView.delegate = self; - _enterPasscodeTableView.dataSource = self; - _enterPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _enterPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; - [self.view addSubview:_enterPasscodeTableView]; - - _setPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds]; - _setPasscodeTableView.delegate = self; - _setPasscodeTableView.dataSource = self; - _setPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; - [self.view addSubview:_setPasscodeTableView]; - - _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds]; - _confirmPasscodeTableView.delegate = self; - _confirmPasscodeTableView.dataSource = self; - _confirmPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; - _confirmPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; - [self.view addSubview:_confirmPasscodeTableView]; - } - - return self; + [super loadView]; + + self.view.backgroundColor = [UIColor whiteColor]; + + self.enterPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _enterPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _enterPasscodeTableView.delegate = self; + _enterPasscodeTableView.dataSource = self; + _enterPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _enterPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; + [self.view addSubview:_enterPasscodeTableView]; + + self.setPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _setPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _setPasscodeTableView.delegate = self; + _setPasscodeTableView.dataSource = self; + _setPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; + [self.view addSubview:_setPasscodeTableView]; + + self.confirmPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _confirmPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + _confirmPasscodeTableView.delegate = self; + _confirmPasscodeTableView.dataSource = self; + _confirmPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _confirmPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; + [self.view addSubview:_confirmPasscodeTableView]; + + [self.view addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)] autorelease]]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); + return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)viewDidLoad { - [super viewDidLoad]; - - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; - _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - _viewWidth = 540.0f; - } else { - _viewWidth = 320.0f; - } + [super viewDidLoad]; + + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + } - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)viewWillAppear:(BOOL)animated { - [super viewWillAppear:animated]; - - _enterPasscodeTextField = [self allocAndInitPasscodeTextField]; - _setPasscodeTextField = [self allocAndInitPasscodeTextField]; - _confirmPasscodeTextField = [self allocAndInitPasscodeTextField]; - - _tableViews = [[NSMutableArray alloc] init]; - _textFields = [[NSMutableArray alloc] init]; - _squares = [[NSMutableArray alloc] init]; - - if (mode == KKPasscodeModeSet || mode == KKPasscodeModeChange) { - if (_passcodeLockOn) { - _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; - [_tableViews addObject:_enterPasscodeTableView]; - [_textFields addObject:_enterPasscodeTextField]; - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } - } - - _setPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_setPasscodeTextField]; - [_tableViews addObject:_setPasscodeTableView]; - [_textFields addObject:_setPasscodeTextField]; - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_setPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } - _confirmPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_confirmPasscodeTextField]; - [_tableViews addObject:_confirmPasscodeTableView]; - [_textFields addObject:_confirmPasscodeTextField]; - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_confirmPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } - } else { - _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; - [_tableViews addObject:_enterPasscodeTableView]; - [_textFields addObject:_enterPasscodeTextField]; - [_squares addObject:[self squares]]; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [_enterPasscodeTableView.tableHeaderView addSubview:[[_squares lastObject] objectAtIndex:i]]; - } - } - - [self.view addSubview:[_tableViews objectAtIndex:0]]; - - // shift any extra table views away - for (int i = 1; i < [_tableViews count]; i++) { - UITableView *tableView = [_tableViews objectAtIndex:i]; - tableView.frame = CGRectMake(tableView.frame.origin.x + _viewWidth, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); - [self.view addSubview:tableView]; - } - - - [[_textFields objectAtIndex:0] becomeFirstResponder]; - [[_tableViews objectAtIndex:0] reloadData]; - [[_textFields objectAtIndex:[_tableViews count] - 1] setReturnKeyType:UIReturnKeyDone]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - if ([_tableViews count] > 1) { - [self moveToNextTableView]; - [self moveToPreviousTableView]; - } else { - UITableView *tv = [_tableViews objectAtIndex:0]; - tv.frame = CGRectMake(tv.frame.origin.x, tv.frame.origin.y, 768.0, 960.0); - } - } +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + _enterPasscodeTextField = [self newPasscodeTextField]; + _setPasscodeTextField = [self newPasscodeTextField]; + _confirmPasscodeTextField = [self newPasscodeTextField]; + + _tableViews = [[NSMutableArray alloc] init]; + _textFields = [[NSMutableArray alloc] init]; + _squares = [[NSMutableArray alloc] init]; + + if (mode == KKPasscodeModeSet || mode == KKPasscodeModeChange) { + if (_passcodeLockOn) { + _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; + [_tableViews addObject:_enterPasscodeTableView]; + [_textFields addObject:_enterPasscodeTextField]; + [_squares addObject:[self squares]]; + UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; + squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + } + [_enterPasscodeTableView.tableHeaderView addSubview:squaresView]; + } + + _setPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_setPasscodeTextField]; + [_tableViews addObject:_setPasscodeTableView]; + [_textFields addObject:_setPasscodeTextField]; + [_squares addObject:[self squares]]; + UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; + squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + } + [_setPasscodeTableView.tableHeaderView addSubview:squaresView]; + + _confirmPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_confirmPasscodeTextField]; + [_tableViews addObject:_confirmPasscodeTableView]; + [_textFields addObject:_confirmPasscodeTextField]; + [_squares addObject:[self squares]]; + UIView *squaresConfirmView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; + squaresConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [squaresConfirmView addSubview:[[_squares lastObject] objectAtIndex:i]]; + } + [_confirmPasscodeTableView.tableHeaderView addSubview:squaresConfirmView]; + } else { + _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; + [_tableViews addObject:_enterPasscodeTableView]; + [_textFields addObject:_enterPasscodeTextField]; + [_squares addObject:[self squares]]; + UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; + squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_squares lastObject] count]; i++) { + [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + } + [_enterPasscodeTableView.tableHeaderView addSubview:squaresView]; + } + + [self.view addSubview:[_tableViews objectAtIndex:0]]; + + // shift any extra table views away + for (int i = 1; i < [_tableViews count]; i++) { + UITableView *tableView = [_tableViews objectAtIndex:i]; + tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); + [self.view addSubview:tableView]; + } + + [[_textFields objectAtIndex:0] becomeFirstResponder]; + [[_tableViews objectAtIndex:0] reloadData]; + [[_textFields objectAtIndex:[_tableViews count] - 1] setReturnKeyType:UIReturnKeyDone]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + if ([_tableViews count] > 1) { + [self moveToNextTableView]; + [self moveToPreviousTableView]; + } else { + UITableView *tv = [_tableViews objectAtIndex:0]; + tv.frame = CGRectMake(tv.frame.origin.x, tv.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height); + } + } } +- (void)viewTapped:(UITapGestureRecognizer *)recognizer +{ + [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; +} -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Private - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (UITextField*)allocAndInitPasscodeTextField +- (UITextField*)newPasscodeTextField { - UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 18.0, 271.0, 24.0)]; - textField.font = [UIFont systemFontOfSize:14]; - textField.text = @""; - textField.textColor = [UIColor blackColor]; - textField.secureTextEntry = YES; - textField.delegate = self; - - textField.keyboardAppearance = UIKeyboardAppearanceAlert; - - return textField; + UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 18.0, 271.0, 24.0)]; + textField.font = [UIFont systemFontOfSize:14]; + textField.text = @""; + textField.textColor = [UIColor blackColor]; + textField.secureTextEntry = YES; + textField.delegate = self; + textField.keyboardAppearance = UIKeyboardAppearanceAlert; + return textField; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)cancelButtonPressed:(id)sender { - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)incrementAndShowFailedAttemptsLabel { - _enterPasscodeTextField.text = @""; - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } - - _failedAttemptsCount += 1; - if (_failedAttemptsCount == 1) { - _failedAttemptsLabel.text = @"1 Failed Passcode Attempt"; - } else { - _failedAttemptsLabel.text = [NSString stringWithFormat:@"%i Failed Passcode Attempts", _failedAttemptsCount]; - } - CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsView.frame = CGRectMake((_viewWidth - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); - _failedAttemptsLabel.frame = CGRectMake((_viewWidth - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); - - CAGradientLayer *gradient = [CAGradientLayer layer]; - gradient.frame = _failedAttemptsView.bounds; - gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; - [_failedAttemptsView.layer insertSublayer:gradient atIndex:0]; - _failedAttemptsView.layer.masksToBounds = YES; - - _failedAttemptsLabel.hidden = NO; - _failedAttemptsView.hidden = NO; - - if (_failedAttemptsCount == [[KKPasscodeLock sharedLock] attemptsAllowed]) { - - _enterPasscodeTextField.delegate = nil; - - if (_eraseData) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - - if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { - [_delegate shouldEraseApplicationData:self]; - } - } else { - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { - [_delegate didPasscodeEnteredIncorrectly:self]; - } - } - } - + _enterPasscodeTextField.text = @""; + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + } + + _failedAttemptsCount += 1; + if (_failedAttemptsCount == 1) { + _failedAttemptsLabel.text = @"1 Failed Passcode Attempt"; + } else { + _failedAttemptsLabel.text = [NSString stringWithFormat:@"%i Failed Passcode Attempts", _failedAttemptsCount]; + } + CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; + _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); + _failedAttemptsLabel.frame = CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); + + CAGradientLayer *gradient = [CAGradientLayer layer]; + gradient.frame = _failedAttemptsView.bounds; + gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], + (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; + [_failedAttemptsView.layer insertSublayer:gradient atIndex:0]; + _failedAttemptsView.layer.masksToBounds = YES; + + _failedAttemptsLabel.hidden = NO; + _failedAttemptsView.hidden = NO; + + if (_failedAttemptsCount == [[KKPasscodeLock sharedLock] attemptsAllowed]) { + + _enterPasscodeTextField.delegate = nil; + + if (_eraseData) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + + if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { + [_delegate shouldEraseApplicationData:self]; + } + } else { + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { + [_delegate didPasscodeEnteredIncorrectly:self]; + } + } + } + } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)moveToNextTableView { - _tableIndex += 1; - UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex - 1]; - UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; - newTableView.frame = CGRectMake(oldTableView.frame.origin.x + _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } - - [UIView beginAnimations:@"" context:nil]; - [UIView setAnimationDuration:0.25]; - oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - newTableView.frame = self.view.frame; - [UIView commitAnimations]; - - - [[_textFields objectAtIndex:_tableIndex - 1] resignFirstResponder]; - [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; + _tableIndex += 1; + UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex - 1]; + UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; + newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); + + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + } + + [UIView beginAnimations:@"" context:nil]; + [UIView setAnimationDuration:0.25]; + oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); + newTableView.frame = self.view.frame; + [UIView commitAnimations]; + + + [[_textFields objectAtIndex:_tableIndex - 1] resignFirstResponder]; + [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)moveToPreviousTableView { - _tableIndex -= 1; - UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex + 1]; - UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; - newTableView.frame = CGRectMake(oldTableView.frame.origin.x - _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } - - [UIView beginAnimations:@"" context:nil]; - [UIView setAnimationDuration:0.25]; - oldTableView.frame = CGRectMake(oldTableView.frame.origin.x + _viewWidth, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - newTableView.frame = self.view.frame; - [UIView commitAnimations]; - - - - [[_textFields objectAtIndex:_tableIndex + 1] resignFirstResponder]; - [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; + _tableIndex -= 1; + UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex + 1]; + UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; + newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); + + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + } + + [UIView beginAnimations:@"" context:nil]; + [UIView setAnimationDuration:0.25]; + oldTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); + newTableView.frame = self.view.frame; + [UIView commitAnimations]; + + [[_textFields objectAtIndex:_tableIndex + 1] resignFirstResponder]; + [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)nextDigitPressed { - - UITextField *textField = [_textFields objectAtIndex:_tableIndex]; - - if (![textField.text isEqualToString:@""]) { - - if (mode == KKPasscodeModeSet) { - if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. You cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, _viewWidth, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, _viewWidth, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } - } + UITextField *textField = [_textFields objectAtIndex:_tableIndex]; + + if (![textField.text isEqualToString:@""]) { + + if (mode == KKPasscodeModeSet) { + if ([textField isEqual:_setPasscodeTextField]) { + [self moveToNextTableView]; + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if (mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. You cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } + } } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (void)doneButtonPressed -{ - - UITextField *textField = [_textFields objectAtIndex:_tableIndex]; - - if (mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly::)]) { - [_delegate didPasscodeEnteredCorrectly:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if (mode == KKPasscodeModeSet) { - if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, _viewWidth, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, _viewWidth, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if (mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } +{ + UITextField *textField = [_textFields objectAtIndex:_tableIndex]; + + if (mode == KKPasscodeModeEnter) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly::)]) { + [_delegate didPasscodeEnteredCorrectly:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if (mode == KKPasscodeModeSet) { + if ([textField isEqual:_setPasscodeTextField]) { + [self moveToNextTableView]; + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if (mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if (mode == KKPasscodeModeDisabled) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField { - - textField.keyboardType = UIKeyboardTypeNumberPad; - - textField.hidden = YES; - [self.view addSubview:textField]; - - UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, _viewWidth, 70.0)] autorelease]; - UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, _viewWidth, 30.0)]; - headerLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; - headerLabel.backgroundColor = [UIColor clearColor]; - headerLabel.textAlignment = UITextAlignmentCenter; - headerLabel.font = [UIFont boldSystemFontOfSize:17.0]; - headerLabel.shadowOffset = CGSizeMake(0, 1.0); - headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; - - if ([textField isEqual:_setPasscodeTextField]) { - _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.5, _viewWidth, 30.0)]; - _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; - _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; - _passcodeConfirmationWarningLabel.textAlignment = UITextAlignmentCenter; - _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0]; - _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0); - _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.numberOfLines = 0; - _passcodeConfirmationWarningLabel.lineBreakMode = UILineBreakModeWordWrap; - [headerView addSubview:_passcodeConfirmationWarningLabel]; - } - - if ([textField isEqual:_enterPasscodeTextField]) { - - NSString *text = @"1 Failed Passcode Attempt"; - CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsView = [[UIView alloc] initWithFrame:CGRectMake((_viewWidth - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; - _failedAttemptsLabel = [[UILabel alloc] initWithFrame:CGRectMake((_viewWidth - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; - _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; - _failedAttemptsLabel.textColor = [UIColor whiteColor]; - _failedAttemptsLabel.text = text; - _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:14.0]; - _failedAttemptsLabel.textAlignment = UITextAlignmentCenter; - _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); - _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; - _failedAttemptsView.layer.cornerRadius = 14; - _failedAttemptsView.layer.borderWidth = 1.0; - _failedAttemptsView.layer.borderColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.25] CGColor]; - - _failedAttemptsLabel.hidden = YES; - _failedAttemptsView.hidden = YES; - - CAGradientLayer *gradient = [CAGradientLayer layer]; - gradient.frame = _failedAttemptsView.bounds; - gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; - [_failedAttemptsView.layer insertSublayer:gradient atIndex:1]; - _failedAttemptsView.layer.masksToBounds = YES; - - [headerView addSubview:_failedAttemptsView]; - [headerView addSubview:_failedAttemptsLabel]; - - [_failedAttemptsView release]; - [_failedAttemptsLabel release]; - } - - if (mode == KKPasscodeModeSet) { - self.navigationItem.title = @"Set Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; - - - if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = @"Enter your passcode"; - } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = @"Enter a passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; - - } else if ([textField isEqual:_confirmPasscodeTextField]) { - headerLabel.text = @"Re-enter your passcode"; - } - } else if (mode == KKPasscodeModeDisabled) { - self.navigationItem.title = @"Turn off Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; - - headerLabel.text = @"Enter your passcode"; - } else if (mode == KKPasscodeModeChange) { - self.navigationItem.title = @"Change Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; - - if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = @"Enter your old passcode"; - } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = @"Enter your new passcode"; - } else { - headerLabel.text = @"Re-enter your new passcode"; - } - } else { - self.navigationItem.title = @"Enter Passcode"; - headerLabel.text = @"Enter your passcode"; - } - - [headerView addSubview:headerLabel]; - [headerLabel release]; - - return headerView; + textField.keyboardType = UIKeyboardTypeNumberPad; + + textField.hidden = YES; + [self.view addSubview:textField]; + + UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; + UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, self.view.bounds.size.width, 30.0)]; + headerLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; + headerLabel.backgroundColor = [UIColor clearColor]; + headerLabel.textAlignment = UITextAlignmentCenter; + headerLabel.font = [UIFont boldSystemFontOfSize:17.0]; + headerLabel.shadowOffset = CGSizeMake(0, 1.0); + headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + + if ([textField isEqual:_setPasscodeTextField]) { + _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0)]; + _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; + _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; + _passcodeConfirmationWarningLabel.textAlignment = UITextAlignmentCenter; + _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0]; + _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0); + _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.numberOfLines = 0; + _passcodeConfirmationWarningLabel.lineBreakMode = UILineBreakModeWordWrap; + [headerView addSubview:_passcodeConfirmationWarningLabel]; + } + + if ([textField isEqual:_enterPasscodeTextField]) { + NSString *text = @"1 Failed Passcode Attempt"; + CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; + _failedAttemptsView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; + _failedAttemptsLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; + _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; + _failedAttemptsLabel.textColor = [UIColor whiteColor]; + _failedAttemptsLabel.text = text; + _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:14.0]; + _failedAttemptsLabel.textAlignment = UITextAlignmentCenter; + _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); + _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; + _failedAttemptsView.layer.cornerRadius = 14; + _failedAttemptsView.layer.borderWidth = 1.0; + _failedAttemptsView.layer.borderColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.25] CGColor]; + + _failedAttemptsLabel.hidden = YES; + _failedAttemptsView.hidden = YES; + + CAGradientLayer *gradient = [CAGradientLayer layer]; + gradient.frame = _failedAttemptsView.bounds; + gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], + (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; + [_failedAttemptsView.layer insertSublayer:gradient atIndex:1]; + _failedAttemptsView.layer.masksToBounds = YES; + + [headerView addSubview:_failedAttemptsView]; + [headerView addSubview:_failedAttemptsLabel]; + + [_failedAttemptsView release]; + [_failedAttemptsLabel release]; + } + + if (mode == KKPasscodeModeSet) { + self.navigationItem.title = @"Set Passcode"; + UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; + self.navigationItem.leftBarButtonItem = cancel; + [cancel release]; + + + if ([textField isEqual:_enterPasscodeTextField]) { + headerLabel.text = @"Enter your passcode"; + } else if ([textField isEqual:_setPasscodeTextField]) { + headerLabel.text = @"Enter a passcode"; + UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; + self.navigationItem.leftBarButtonItem = cancel; + [cancel release]; + + } else if ([textField isEqual:_confirmPasscodeTextField]) { + headerLabel.text = @"Re-enter your passcode"; + } + } else if (mode == KKPasscodeModeDisabled) { + self.navigationItem.title = @"Turn off Passcode"; + UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; + self.navigationItem.leftBarButtonItem = cancel; + [cancel release]; + + headerLabel.text = @"Enter your passcode"; + } else if (mode == KKPasscodeModeChange) { + self.navigationItem.title = @"Change Passcode"; + UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; + self.navigationItem.leftBarButtonItem = cancel; + [cancel release]; + + if ([textField isEqual:_enterPasscodeTextField]) { + headerLabel.text = @"Enter your old passcode"; + } else if ([textField isEqual:_setPasscodeTextField]) { + headerLabel.text = @"Enter your new passcode"; + } else { + headerLabel.text = @"Re-enter your new passcode"; + } + } else { + self.navigationItem.title = @"Enter Passcode"; + headerLabel.text = @"Enter your passcode"; + } + headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; + + [headerView addSubview:headerLabel]; + [headerLabel release]; + + return headerView; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSArray*)squares { - NSMutableArray *squareViews = [[NSMutableArray alloc] initWithCapacity:4]; - NSInteger squareX = 23.0; - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - squareX = 133.0; - } - - for (int i = 0; i < 4; i++) { - UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - square.frame = CGRectMake(squareX, 74.0, 61.0, 53.0); - [squareViews addObject:square]; - [square release]; - squareX += 71.0; - } - return [[NSArray alloc] initWithArray:squareViews]; + NSMutableArray *squareViews = [NSMutableArray array]; + + CGFloat squareX = 0.0; + + for (int i = 0; i < 4; i++) { + UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + square.frame = CGRectMake(squareX, 74.0, 61.0, 53.0); + [squareViews addObject:square]; + [square release]; + squareX += 71.0; + } + return [NSArray arrayWithArray:squareViews]; } - - - -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Table view data source - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 0; + return 0; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 1; + return 1; } - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - static NSString *CellIdentifier = @"Cell"; - - UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; - cell.selectionStyle = UITableViewCellSelectionStyleNone; - } - - if ([aTableView isEqual:_enterPasscodeTableView]) { - cell.accessoryView = _enterPasscodeTextField; - } else if ([aTableView isEqual:_setPasscodeTableView]) { - cell.accessoryView = _setPasscodeTextField; - } else if ([aTableView isEqual:_confirmPasscodeTableView]) { - cell.accessoryView = _confirmPasscodeTextField; - } - - return cell; + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + } + + if ([aTableView isEqual:_enterPasscodeTableView]) { + cell.accessoryView = _enterPasscodeTextField; + } else if ([aTableView isEqual:_setPasscodeTableView]) { + cell.accessoryView = _setPasscodeTextField; + } else if ([aTableView isEqual:_confirmPasscodeTableView]) { + cell.accessoryView = _confirmPasscodeTextField; + } + + return cell; } -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark UITextFieldDelegate - -/////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)textFieldShouldReturn:(UITextField *)textField { - if ([textField isEqual:[_textFields lastObject]]) { - [self doneButtonPressed]; - } else { - [self nextDigitPressed]; - } - return NO; + if ([textField isEqual:[_textFields lastObject]]) { + [self doneButtonPressed]; + } else { + [self nextDigitPressed]; + } + return NO; } -/////////////////////////////////////////////////////////////////////////////////////////////////// - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - - if (YES) { - NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; - - textField.text = result; - - for (int i = 0; i < 4; i++) { - UIImageView *square = [[_squares objectAtIndex:_tableIndex] objectAtIndex:i]; - if (i < [result length]) { - square.image = [UIImage imageNamed:@"passcode_square_filled.png"]; - } else { - square.image = [UIImage imageNamed:@"passcode_square_empty.png"]; - } - } - - if ([result length] == 4) { - - if (mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if (mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { - [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementAndShowFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; - } - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, _viewWidth, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, _viewWidth, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } - - return NO; - } - - return YES; + if (YES) { + NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; + textField.text = result; + + for (int i = 0; i < 4; i++) { + UIImageView *square = [[_squares objectAtIndex:_tableIndex] objectAtIndex:i]; + if (i < [result length]) { + square.image = [UIImage imageNamed:@"passcode_square_filled.png"]; + } else { + square.image = [UIImage imageNamed:@"passcode_square_empty.png"]; + } + } + + if ([result length] == 4) { + + if (mode == KKPasscodeModeDisabled) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if (mode == KKPasscodeModeEnter) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if (mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementAndShowFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + for (int i = 0; i < 4; i++) { + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + } + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if ([textField isEqual:_setPasscodeTextField]) { + [self moveToNextTableView]; + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + [self dismissModalViewControllerAnimated:YES]; + } + } + } + return NO; + } + + return YES; } -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// #pragma mark - #pragma mark Memory management - -/////////////////////////////////////////////////////////////////////////////////////////////////// -- (void)dealloc { - - [_enterPasscodeTextField release]; - [_setPasscodeTextField release]; - [_confirmPasscodeTextField release]; - [_tableViews release]; - [_textFields release]; - [_squares release]; - - [super dealloc]; +- (void)dealloc +{ + [_enterPasscodeTextField release]; + [_setPasscodeTextField release]; + [_confirmPasscodeTextField release]; + [_tableViews release]; + [_textFields release]; + [_squares release]; + [super dealloc]; } @end From 2127d5b7d4d99d66cf4d2e3817ef969fab8be7d3 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Tue, 24 Jan 2012 23:36:44 -0500 Subject: [PATCH 11/62] KKPasscodeLock.bundle added with assets --- .../KKPasscodeLock.xcodeproj/project.pbxproj | 20 ++++-------------- .../box_empty.png} | Bin .../box_empty@2x.png} | Bin .../box_filled.png} | Bin .../box_filled@2x.png} | Bin src/KKPasscodeViewController.m | 14 ++++++------ 6 files changed, 11 insertions(+), 23 deletions(-) rename src/{passcode_square_empty.png => KKPasscodeLock.bundle/box_empty.png} (100%) rename src/{passcode_square_empty@2x.png => KKPasscodeLock.bundle/box_empty@2x.png} (100%) rename src/{passcode_square_filled.png => KKPasscodeLock.bundle/box_filled.png} (100%) rename src/{passcode_square_filled@2x.png => KKPasscodeLock.bundle/box_filled@2x.png} (100%) diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLock.xcodeproj/project.pbxproj index 630f4e6..cdc460c 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLock.xcodeproj/project.pbxproj @@ -23,10 +23,7 @@ 6DF13A6A14C6870B0069BBA5 /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */; }; 6DF13A6B14C6870B0069BBA5 /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */; }; 6DF13A6C14C6870B0069BBA5 /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */; }; - 6DF13A6D14C6870B0069BBA5 /* passcode_square_empty.png in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A6514C6870B0069BBA5 /* passcode_square_empty.png */; }; - 6DF13A6E14C6870B0069BBA5 /* passcode_square_empty@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A6614C6870B0069BBA5 /* passcode_square_empty@2x.png */; }; - 6DF13A6F14C6870B0069BBA5 /* passcode_square_filled.png in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A6714C6870B0069BBA5 /* passcode_square_filled.png */; }; - 6DF13A7014C6870B0069BBA5 /* passcode_square_filled@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A6814C6870B0069BBA5 /* passcode_square_filled@2x.png */; }; + 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -56,10 +53,7 @@ 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; - 6DF13A6514C6870B0069BBA5 /* passcode_square_empty.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = passcode_square_empty.png; path = ../../src/passcode_square_empty.png; sourceTree = ""; }; - 6DF13A6614C6870B0069BBA5 /* passcode_square_empty@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "passcode_square_empty@2x.png"; path = "../../src/passcode_square_empty@2x.png"; sourceTree = ""; }; - 6DF13A6714C6870B0069BBA5 /* passcode_square_filled.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = passcode_square_filled.png; path = ../../src/passcode_square_filled.png; sourceTree = ""; }; - 6DF13A6814C6870B0069BBA5 /* passcode_square_filled@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "passcode_square_filled@2x.png"; path = "../../src/passcode_square_filled@2x.png"; sourceTree = ""; }; + 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -134,6 +128,7 @@ 6D3E345714C4F54E0003B72B /* KKPasscodeLock */ = { isa = PBXGroup; children = ( + 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */, 6DF13A5D14C6870B0069BBA5 /* KKKeychain.h */, 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */, 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */, @@ -142,10 +137,6 @@ 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */, 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */, 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */, - 6DF13A6514C6870B0069BBA5 /* passcode_square_empty.png */, - 6DF13A6614C6870B0069BBA5 /* passcode_square_empty@2x.png */, - 6DF13A6714C6870B0069BBA5 /* passcode_square_filled.png */, - 6DF13A6814C6870B0069BBA5 /* passcode_square_filled@2x.png */, ); path = KKPasscodeLock; sourceTree = ""; @@ -232,10 +223,7 @@ 6D3E345C14C4F54E0003B72B /* InfoPlist.strings in Resources */, 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */, 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, - 6DF13A6D14C6870B0069BBA5 /* passcode_square_empty.png in Resources */, - 6DF13A6E14C6870B0069BBA5 /* passcode_square_empty@2x.png in Resources */, - 6DF13A6F14C6870B0069BBA5 /* passcode_square_filled.png in Resources */, - 6DF13A7014C6870B0069BBA5 /* passcode_square_filled@2x.png in Resources */, + 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/passcode_square_empty.png b/src/KKPasscodeLock.bundle/box_empty.png similarity index 100% rename from src/passcode_square_empty.png rename to src/KKPasscodeLock.bundle/box_empty.png diff --git a/src/passcode_square_empty@2x.png b/src/KKPasscodeLock.bundle/box_empty@2x.png similarity index 100% rename from src/passcode_square_empty@2x.png rename to src/KKPasscodeLock.bundle/box_empty@2x.png diff --git a/src/passcode_square_filled.png b/src/KKPasscodeLock.bundle/box_filled.png similarity index 100% rename from src/passcode_square_filled.png rename to src/KKPasscodeLock.bundle/box_filled.png diff --git a/src/passcode_square_filled@2x.png b/src/KKPasscodeLock.bundle/box_filled@2x.png similarity index 100% rename from src/passcode_square_filled@2x.png rename to src/KKPasscodeLock.bundle/box_filled@2x.png diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 80fc12a..8fe744f 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -205,7 +205,7 @@ - (void)incrementAndShowFailedAttemptsLabel { _enterPasscodeTextField.text = @""; for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _failedAttemptsCount += 1; @@ -261,7 +261,7 @@ - (void)moveToNextTableView newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -283,7 +283,7 @@ - (void)moveToPreviousTableView newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -581,7 +581,7 @@ - (NSArray*)squares CGFloat squareX = 0.0; for (int i = 0; i < 4; i++) { - UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; square.frame = CGRectMake(squareX, 74.0, 61.0, 53.0); [squareViews addObject:square]; [square release]; @@ -649,9 +649,9 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang for (int i = 0; i < 4; i++) { UIImageView *square = [[_squares objectAtIndex:_tableIndex] objectAtIndex:i]; if (i < [result length]) { - square.image = [UIImage imageNamed:@"passcode_square_filled.png"]; + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; } else { - square.image = [UIImage imageNamed:@"passcode_square_empty.png"]; + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; } } @@ -702,7 +702,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"passcode_square_empty.png"]]; + [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); From 54afdc8ae5ce8a39db56d4ca3829acdf61700335 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Tue, 24 Jan 2012 23:39:37 -0500 Subject: [PATCH 12/62] adding a vibrate effect on failed attempts --- example/KKPasscodeLock.xcodeproj/project.pbxproj | 4 ++++ src/KKPasscodeViewController.m | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLock.xcodeproj/project.pbxproj index cdc460c..2c4bff9 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLock.xcodeproj/project.pbxproj @@ -24,6 +24,7 @@ 6DF13A6B14C6870B0069BBA5 /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */; }; 6DF13A6C14C6870B0069BBA5 /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */; }; 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */; }; + 6DFE344414CFBE8400E6EEA4 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -54,6 +55,7 @@ 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; }; + 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,6 +68,7 @@ 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */, 6D3E34BC14C4F90B0003B72B /* Security.framework in Frameworks */, 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */, + 6DFE344414CFBE8400E6EEA4 /* AudioToolbox.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -116,6 +119,7 @@ 6D3E345014C4F54E0003B72B /* Frameworks */ = { isa = PBXGroup; children = ( + 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */, 6D3E34BA14C4F90B0003B72B /* Security.framework */, 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */, 6D3E345114C4F54E0003B72B /* UIKit.framework */, diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 8fe744f..34e21bd 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -19,7 +19,9 @@ #import "KKKeychain.h" #import "KKPasscodeSettingsViewController.h" #import "KKPasscodeLock.h" + #import +#import @interface KKPasscodeViewController(Private) @@ -203,6 +205,8 @@ - (void)cancelButtonPressed:(id)sender - (void)incrementAndShowFailedAttemptsLabel { + AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); + _enterPasscodeTextField.text = @""; for (int i = 0; i < 4; i++) { [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; From 26796c717c8776fa23541291d39fbfb5c1ac2f81 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Tue, 24 Jan 2012 23:54:22 -0500 Subject: [PATCH 13/62] adding some documentation --- src/KKPasscodeLock.h | 15 +++++++++++++++ src/KKPasscodeViewController.h | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index a47fb17..81c79fc 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -19,17 +19,32 @@ #import "KKPasscodeViewController.h" @interface KKPasscodeLock : NSObject { + + // whatever the erase option is enabled in the passcode settings BOOL _eraseOption; + + // how many attemepts is user is allowed to have before the screen is locked NSUInteger _attemptsAllowed; } +/** + * a shared object which can change the passcode settings and perform generic actions + */ + (KKPasscodeLock*)sharedLock; +/** + * checks if a passcode has to be displayed + */ - (BOOL)isPasscodeRequired; + +/** + * set the initial settings of the passcode settings + */ - (void)setDefaultSettings; @property (nonatomic,assign) BOOL eraseOption; + @property (nonatomic,assign) NSUInteger attemptsAllowed; @end diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index b06a107..58688c4 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -18,10 +18,29 @@ #import +// The mode which controls the passcode view behavior enum { + /** + * Displays the passcode enter view, which the user has to enter the correct passcode + */ KKPasscodeModeEnter = 0, + + /** + * Creates a new passcode. This allows the user to enter a new passcode then + * imediately verify it. + */ KKPasscodeModeSet = 1, + + /** + * Disables an existing passcode. This allows the user to disable the passcode lock by + * entering the passcode + */ KKPasscodeModeDisabled = 2, + + /** + * Changes an existing passcode. This allows the user to change the passcode by + * entering the existing passcode, followed by a new passcode + */ KKPasscodeModeChange = 3 }; typedef NSUInteger KKPasscodeMode; @@ -44,6 +63,7 @@ typedef NSUInteger KKPasscodeMode; @interface KKPasscodeViewController : UIViewController { + // delegate which called when major events happens id _delegate; UILabel* _passcodeConfirmationWarningLabel; @@ -52,8 +72,12 @@ typedef NSUInteger KKPasscodeMode; NSInteger _failedAttemptsCount; NSUInteger _tableIndex; + NSMutableArray* _tableViews; + + // array of passcode entry text fields NSMutableArray* _textFields; + NSMutableArray* _squares; UITableView* _enterPasscodeTableView; @@ -68,6 +92,7 @@ typedef NSUInteger KKPasscodeMode; UITextField* _confirmPasscodeTextField; NSArray* _confirmPasscodeSquareImageViews; + // readwrite override for passlock mode KKPasscodeMode _mode; BOOL _passcodeLockOn; From fe6232702b8146ce5cdf4801301285b220f82d27 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Jan 2012 00:12:40 -0500 Subject: [PATCH 14/62] adding documentation to the passcode settings view --- src/KKPasscodeSettingsViewController.h | 8 ++++ src/KKPasscodeSettingsViewController.m | 60 +++++++++++++------------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index 61b5e7a..f19dbc8 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -24,17 +24,25 @@ @optional +/** + * called when the passcode settings (either turned on/off) is changed + */ - (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController; @end @interface KKPasscodeSettingsViewController : UITableViewController { + // delegate which notified then the passcode is turned on/off id _delegate; + // the erase content switch. UISwitch* _eraseDataSwitch; + // whatever the passcode lock is turned on or off BOOL _passcodeLockOn; + + // whatever the erase data option is turned on or off BOOL _eraseDataOn; } diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 47a2350..6a3cb9d 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -27,7 +27,7 @@ @implementation KKPasscodeSettingsViewController @synthesize delegate = _delegate; #pragma mark - -#pragma mark UIViewController +#pragma mark UIViewController methods - (void)viewDidLoad { @@ -38,9 +38,18 @@ - (void)viewDidLoad [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; } +- (void)viewDidUnload +{ + [_eraseDataSwitch release]; + _eraseDataSwitch = nil; + + [super viewDidUnload]; +} + - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; _eraseDataSwitch.on = _eraseDataOn; @@ -52,9 +61,9 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa } #pragma mark - -#pragma mark UIActionSheetDelegate +#pragma mark UIActionSheetDelegate methods -- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +- (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { _eraseDataOn = YES; @@ -81,7 +90,7 @@ - (void)eraseDataSwitchChanged:(id)sender } #pragma mark - -#pragma mark Table view data source +#pragma mark UITableViewDataSource methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -100,45 +109,43 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return [NSString stringWithFormat:@"Erase all data in this app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; + return [NSString stringWithFormat:@"Erase all content in the app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; } } -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { - static NSString *CellIdentifier = @"Cell"; + static NSString *CellIdentifier = @"KKPasscodeSettingsCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } + + cell.accessoryView = nil; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + cell.textLabel.textAlignment = UITextAlignmentLeft; + cell.textLabel.textColor = [UIColor blackColor]; + if (indexPath.section == 0) { + cell.textLabel.textAlignment = UITextAlignmentCenter; if (_passcodeLockOn) { cell.textLabel.text = @"Turn Passcode Off"; } else { cell.textLabel.text = @"Turn Passcode On"; } - cell.textLabel.textColor = [UIColor blackColor]; - cell.textLabel.textAlignment = UITextAlignmentCenter; - cell.accessoryView = nil; - cell.selectionStyle = UITableViewCellSelectionStyleBlue; } else if (indexPath.section == 1) { cell.textLabel.text = @"Change Passcode"; - if (_passcodeLockOn) { - cell.textLabel.textColor = [UIColor blackColor]; - cell.selectionStyle = UITableViewCellSelectionStyleBlue; - } else { + cell.textLabel.textAlignment = UITextAlignmentCenter; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; - cell.selectionStyle = UITableViewCellSelectionStyleNone; } - cell.textLabel.textAlignment = UITextAlignmentCenter; - cell.accessoryView = nil; } else if (indexPath.section == 2) { cell.textLabel.text = @"Erase Data"; - cell.textLabel.textAlignment = UITextAlignmentLeft; cell.accessoryView = _eraseDataSwitch; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (_passcodeLockOn) { @@ -154,12 +161,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } #pragma mark - -#pragma mark Table view delegate +#pragma mark UITableViewDelegate methods -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { if (indexPath.section == 0) { - KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil + KKPasscodeViewController* vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; vc.delegate = self; @@ -223,15 +230,6 @@ - (void)didSettingsChanged:(KKPasscodeViewController*)viewController } -#pragma mark - -#pragma mark Memory management - -- (void)dealloc -{ - [_eraseDataSwitch release]; - [super dealloc]; -} - @end From 663a04b8285e74a603b6f124e9a5ed7a8b71e5bd Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Jan 2012 00:49:08 -0500 Subject: [PATCH 15/62] documentation added --- .../KKPasscodeLock.xcodeproj/project.pbxproj | 2 +- src/KKPasscodeViewController.h | 21 ++- src/KKPasscodeViewController.m | 169 +++++++++--------- 3 files changed, 95 insertions(+), 97 deletions(-) diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLock.xcodeproj/project.pbxproj index 2c4bff9..74df6ca 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLock.xcodeproj/project.pbxproj @@ -53,7 +53,7 @@ 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; - 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; + 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; }; 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 58688c4..41389be 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -18,6 +18,12 @@ #import +#define kPasscodeBoxesCount 4 + +#define kPasscodeBoxWidth 61.0 +#define kPasscodeBoxHeight 53.0 + + // The mode which controls the passcode view behavior enum { /** @@ -73,39 +79,36 @@ typedef NSUInteger KKPasscodeMode; NSUInteger _tableIndex; + // used to transition between table views NSMutableArray* _tableViews; // array of passcode entry text fields NSMutableArray* _textFields; - NSMutableArray* _squares; + NSMutableArray* _boxes; UITableView* _enterPasscodeTableView; UITextField* _enterPasscodeTextField; - NSArray* _enterPasscodeSquareImageViews; UITableView* _setPasscodeTableView; UITextField* _setPasscodeTextField; - NSArray* _setPasscodeSquareImageViews; UITableView* _confirmPasscodeTableView; UITextField* _confirmPasscodeTextField; - NSArray* _confirmPasscodeSquareImageViews; // readwrite override for passlock mode KKPasscodeMode _mode; + // whatever the passcode lock is turned on or off BOOL _passcodeLockOn; - BOOL _eraseData; + + // whatever the erase data option is turned on or off + BOOL _eraseData; } @property (nonatomic, assign) id delegate; @property (nonatomic, assign) KKPasscodeMode mode; -@property (nonatomic, retain) UITableView *enterPasscodeTableView; -@property (nonatomic, retain) UITableView *setPasscodeTableView; -@property (nonatomic, retain) UITableView *confirmPasscodeTableView; - @end diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 34e21bd..f9e1ee4 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -25,11 +25,12 @@ @interface KKPasscodeViewController(Private) -- (UITextField*)newPasscodeTextField; -- (NSArray*)squares; +- (UITextField*)passcodeTextField; +- (NSArray*)boxes; - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField; - (void)moveToNextTableView; - (void)moveToPreviousTableView; +- (void)incrementFailedAttemptsLabel; @end @@ -38,7 +39,6 @@ @implementation KKPasscodeViewController @synthesize delegate = _delegate; @synthesize mode; -@synthesize enterPasscodeTableView=_enterPasscodeTableView, setPasscodeTableView=_setPasscodeTableView, confirmPasscodeTableView=_confirmPasscodeTableView; #pragma mark - #pragma mark UIViewController @@ -49,7 +49,7 @@ - (void)loadView self.view.backgroundColor = [UIColor whiteColor]; - self.enterPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _enterPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; _enterPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _enterPasscodeTableView.delegate = self; _enterPasscodeTableView.dataSource = self; @@ -57,7 +57,7 @@ - (void)loadView _enterPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_enterPasscodeTableView]; - self.setPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _setPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; _setPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _setPasscodeTableView.delegate = self; _setPasscodeTableView.dataSource = self; @@ -65,7 +65,7 @@ - (void)loadView _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_setPasscodeTableView]; - self.confirmPasscodeTableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease]; + _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; _confirmPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _confirmPasscodeTableView.delegate = self; _confirmPasscodeTableView.dataSource = self; @@ -81,78 +81,71 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); } -- (void)viewDidLoad -{ - [super viewDidLoad]; - - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; - _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - -} - - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - _enterPasscodeTextField = [self newPasscodeTextField]; - _setPasscodeTextField = [self newPasscodeTextField]; - _confirmPasscodeTextField = [self newPasscodeTextField]; + + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; + + _enterPasscodeTextField = [self passcodeTextField]; + _setPasscodeTextField = [self passcodeTextField]; + _confirmPasscodeTextField = [self passcodeTextField]; _tableViews = [[NSMutableArray alloc] init]; _textFields = [[NSMutableArray alloc] init]; - _squares = [[NSMutableArray alloc] init]; + _boxes = [[NSMutableArray alloc] init]; if (mode == KKPasscodeModeSet || mode == KKPasscodeModeChange) { if (_passcodeLockOn) { _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; - [_squares addObject:[self squares]]; - UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; - squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + [_boxes addObject:[self boxes]]; + UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_boxes lastObject] count]; i++) { + [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; } - [_enterPasscodeTableView.tableHeaderView addSubview:squaresView]; + [_enterPasscodeTableView.tableHeaderView addSubview:boxesView]; } _setPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_setPasscodeTextField]; [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; - [_squares addObject:[self squares]]; - UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; - squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + [_boxes addObject:[self boxes]]; + UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_boxes lastObject] count]; i++) { + [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; } - [_setPasscodeTableView.tableHeaderView addSubview:squaresView]; + [_setPasscodeTableView.tableHeaderView addSubview:boxesView]; _confirmPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_confirmPasscodeTextField]; [_tableViews addObject:_confirmPasscodeTableView]; [_textFields addObject:_confirmPasscodeTextField]; - [_squares addObject:[self squares]]; - UIView *squaresConfirmView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; - squaresConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [squaresConfirmView addSubview:[[_squares lastObject] objectAtIndex:i]]; + [_boxes addObject:[self boxes]]; + UIView *boxesConfirmView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + boxesConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_boxes lastObject] count]; i++) { + [boxesConfirmView addSubview:[[_boxes lastObject] objectAtIndex:i]]; } - [_confirmPasscodeTableView.tableHeaderView addSubview:squaresConfirmView]; + [_confirmPasscodeTableView.tableHeaderView addSubview:boxesConfirmView]; } else { _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; - [_squares addObject:[self squares]]; - UIView *squaresView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * 4 * 0.5, 0, 71.0 * 4, 53)] autorelease]; - squaresView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - for (int i = 0; i < [[_squares lastObject] count]; i++) { - [squaresView addSubview:[[_squares lastObject] objectAtIndex:i]]; + [_boxes addObject:[self boxes]]; + UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; + for (int i = 0; i < [[_boxes lastObject] count]; i++) { + [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; } - [_enterPasscodeTableView.tableHeaderView addSubview:squaresView]; + [_enterPasscodeTableView.tableHeaderView addSubview:boxesView]; } [self.view addSubview:[_tableViews objectAtIndex:0]]; - // shift any extra table views away for (int i = 1; i < [_tableViews count]; i++) { UITableView *tableView = [_tableViews objectAtIndex:i]; tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); @@ -168,21 +161,24 @@ - (void)viewWillAppear:(BOOL)animated [self moveToNextTableView]; [self moveToPreviousTableView]; } else { - UITableView *tv = [_tableViews objectAtIndex:0]; - tv.frame = CGRectMake(tv.frame.origin.x, tv.frame.origin.y, self.view.bounds.size.width, self.view.bounds.size.height); + UITableView *tableView = [_tableViews objectAtIndex:0]; + tableView.frame = CGRectMake(tableView.frame.origin.x, + tableView.frame.origin.y, + self.view.bounds.size.width, + self.view.bounds.size.height); } } } -- (void)viewTapped:(UITapGestureRecognizer *)recognizer +- (void)viewTapped:(UITapGestureRecognizer*)recognizer { [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; } #pragma mark - -#pragma mark Private +#pragma mark Private methods -- (UITextField*)newPasscodeTextField +- (UITextField*)passcodeTextField { UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 18.0, 271.0, 24.0)]; textField.font = [UIFont systemFontOfSize:14]; @@ -196,20 +192,16 @@ - (UITextField*)newPasscodeTextField - (void)cancelButtonPressed:(id)sender { - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - [self dismissModalViewControllerAnimated:YES]; } -- (void)incrementAndShowFailedAttemptsLabel +- (void)incrementFailedAttemptsLabel { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); _enterPasscodeTextField.text = @""; - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _failedAttemptsCount += 1; @@ -264,8 +256,8 @@ - (void)moveToNextTableView UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -286,8 +278,8 @@ - (void)moveToPreviousTableView UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -333,7 +325,7 @@ - (void)nextDigitPressed if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { @@ -388,7 +380,7 @@ - (void)doneButtonPressed [self dismissModalViewControllerAnimated:YES]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if (mode == KKPasscodeModeSet) { if ([textField isEqual:_setPasscodeTextField]) { @@ -417,7 +409,7 @@ - (void)doneButtonPressed if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { @@ -460,7 +452,7 @@ - (void)doneButtonPressed [self dismissModalViewControllerAnimated:YES]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } } @@ -473,7 +465,7 @@ - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField [self.view addSubview:textField]; UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; - UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, self.view.bounds.size.width, 30.0)]; + UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, self.view.bounds.size.width, 30.0)] autorelease]; headerLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.textAlignment = UITextAlignmentCenter; @@ -573,20 +565,19 @@ - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; [headerView addSubview:headerLabel]; - [headerLabel release]; return headerView; } -- (NSArray*)squares +- (NSArray*)boxes { NSMutableArray *squareViews = [NSMutableArray array]; CGFloat squareX = 0.0; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < kPasscodeBoxesCount; i++) { UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - square.frame = CGRectMake(squareX, 74.0, 61.0, 53.0); + square.frame = CGRectMake(squareX, 74.0, kPasscodeBoxWidth, kPasscodeBoxHeight); [squareViews addObject:square]; [square release]; squareX += 71.0; @@ -595,24 +586,24 @@ - (NSArray*)squares } #pragma mark - -#pragma mark Table view data source +#pragma mark UITableViewDataSource methods -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView { return 0; } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { return 1; } -- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +- (UITableViewCell*)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { - static NSString *CellIdentifier = @"Cell"; + static NSString* CellIdentifier = @"KKPasscodeViewControllerCell"; - UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; + UITableViewCell* cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -631,9 +622,9 @@ - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:( #pragma mark - -#pragma mark UITextFieldDelegate +#pragma mark UITextFieldDelegate methods -- (BOOL)textFieldShouldReturn:(UITextField *)textField +- (BOOL)textFieldShouldReturn:(UITextField*)textField { if ([textField isEqual:[_textFields lastObject]]) { [self doneButtonPressed]; @@ -650,8 +641,8 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; textField.text = result; - for (int i = 0; i < 4; i++) { - UIImageView *square = [[_squares objectAtIndex:_tableIndex] objectAtIndex:i]; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + UIImageView *square = [[_boxes objectAtIndex:_tableIndex] objectAtIndex:i]; if (i < [result length]) { square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; } else { @@ -659,7 +650,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang } } - if ([result length] == 4) { + if ([result length] == kPasscodeBoxesCount) { if (mode == KKPasscodeModeDisabled) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; @@ -674,7 +665,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang [self dismissModalViewControllerAnimated:YES]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if (mode == KKPasscodeModeEnter) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; @@ -692,7 +683,7 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang [self dismissModalViewControllerAnimated:YES]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if (mode == KKPasscodeModeChange) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; @@ -700,13 +691,13 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; } else { - [self incrementAndShowFailedAttemptsLabel]; + [self incrementFailedAttemptsLabel]; } } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; - for (int i = 0; i < 4; i++) { - [[[_squares objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); @@ -764,12 +755,16 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang - (void)dealloc { + [_enterPasscodeTableView release]; + [_setPasscodeTableView release]; + [_confirmPasscodeTableView release]; + [_enterPasscodeTextField release]; [_setPasscodeTextField release]; [_confirmPasscodeTextField release]; [_tableViews release]; [_textFields release]; - [_squares release]; + [_boxes release]; [super dealloc]; } From e896d89fbfada7fce58f3450c905c89bcce1912b Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Jan 2012 01:10:09 -0500 Subject: [PATCH 16/62] deselect the cells in the settings view --- src/KKPasscodeSettingsViewController.m | 3 +- src/KKPasscodeViewController.m | 286 ++++++++++++------------- 2 files changed, 140 insertions(+), 149 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 6a3cb9d..5403b4a 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -212,7 +212,8 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } - [self.navigationController presentModalViewController:nav animated:YES]; + [self.navigationController presentModalViewController:nav animated:YES]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; } } diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index f9e1ee4..2f8dc69 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -27,7 +27,7 @@ @interface KKPasscodeViewController(Private) - (UITextField*)passcodeTextField; - (NSArray*)boxes; -- (UIView*)passwordHeaderViewForTextField:(UITextField*)textField; +- (UIView*)headerViewForTextField:(UITextField*)textField; - (void)moveToNextTableView; - (void)moveToPreviousTableView; - (void)incrementFailedAttemptsLabel; @@ -72,8 +72,6 @@ - (void)loadView _confirmPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _confirmPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_confirmPasscodeTableView]; - - [self.view addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)] autorelease]]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation @@ -84,13 +82,18 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - - _enterPasscodeTextField = [self passcodeTextField]; - _setPasscodeTextField = [self passcodeTextField]; - _confirmPasscodeTextField = [self passcodeTextField]; + + _enterPasscodeTextField = [[UITextField alloc] init]; + _enterPasscodeTextField.delegate = self; + + _setPasscodeTextField = [[UITextField alloc] init]; + _setPasscodeTextField.delegate = self; + + _confirmPasscodeTextField = [[UITextField alloc] init]; + _confirmPasscodeTextField.delegate = self; _tableViews = [[NSMutableArray alloc] init]; _textFields = [[NSMutableArray alloc] init]; @@ -98,7 +101,7 @@ - (void)viewWillAppear:(BOOL)animated if (mode == KKPasscodeModeSet || mode == KKPasscodeModeChange) { if (_passcodeLockOn) { - _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; + _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -110,7 +113,7 @@ - (void)viewWillAppear:(BOOL)animated [_enterPasscodeTableView.tableHeaderView addSubview:boxesView]; } - _setPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_setPasscodeTextField]; + _setPasscodeTableView.tableHeaderView = [self headerViewForTextField:_setPasscodeTextField]; [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -121,7 +124,7 @@ - (void)viewWillAppear:(BOOL)animated } [_setPasscodeTableView.tableHeaderView addSubview:boxesView]; - _confirmPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_confirmPasscodeTextField]; + _confirmPasscodeTableView.tableHeaderView = [self headerViewForTextField:_confirmPasscodeTextField]; [_tableViews addObject:_confirmPasscodeTableView]; [_textFields addObject:_confirmPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -132,7 +135,7 @@ - (void)viewWillAppear:(BOOL)animated } [_confirmPasscodeTableView.tableHeaderView addSubview:boxesConfirmView]; } else { - _enterPasscodeTableView.tableHeaderView = [self passwordHeaderViewForTextField:_enterPasscodeTextField]; + _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -148,7 +151,10 @@ - (void)viewWillAppear:(BOOL)animated for (int i = 1; i < [_tableViews count]; i++) { UITableView *tableView = [_tableViews objectAtIndex:i]; - tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width, tableView.frame.origin.y, tableView.frame.size.width, tableView.frame.size.height); + tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width, + tableView.frame.origin.y, + tableView.frame.size.width, + tableView.frame.size.height); [self.view addSubview:tableView]; } @@ -170,26 +176,10 @@ - (void)viewWillAppear:(BOOL)animated } } -- (void)viewTapped:(UITapGestureRecognizer*)recognizer -{ - [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; -} #pragma mark - #pragma mark Private methods -- (UITextField*)passcodeTextField -{ - UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(29.0, 18.0, 271.0, 24.0)]; - textField.font = [UIFont systemFontOfSize:14]; - textField.text = @""; - textField.textColor = [UIColor blackColor]; - textField.secureTextEntry = YES; - textField.delegate = self; - textField.keyboardAppearance = UIKeyboardAppearanceAlert; - return textField; -} - - (void)cancelButtonPressed:(id)sender { [self dismissModalViewControllerAnimated:YES]; @@ -198,7 +188,7 @@ - (void)cancelButtonPressed:(id)sender - (void)incrementFailedAttemptsLabel { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); - + _enterPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; @@ -236,7 +226,7 @@ - (void)incrementFailedAttemptsLabel [UIView commitAnimations]; } - + if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { [_delegate shouldEraseApplicationData:self]; } @@ -252,6 +242,7 @@ - (void)incrementFailedAttemptsLabel - (void)moveToNextTableView { _tableIndex += 1; + UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex - 1]; UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); @@ -274,6 +265,7 @@ - (void)moveToNextTableView - (void)moveToPreviousTableView { _tableIndex -= 1; + UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex + 1]; UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); @@ -294,7 +286,7 @@ - (void)moveToPreviousTableView - (void)nextDigitPressed { - UITextField *textField = [_textFields objectAtIndex:_tableIndex]; + UITextField* textField = [_textFields objectAtIndex:_tableIndex]; if (![textField.text isEqualToString:@""]) { @@ -373,11 +365,11 @@ - (void)doneButtonPressed [UIView commitAnimations]; } - + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly::)]) { [_delegate didPasscodeEnteredCorrectly:self]; } - + [self dismissModalViewControllerAnimated:YES]; } else { [self incrementFailedAttemptsLabel]; @@ -457,7 +449,7 @@ - (void)doneButtonPressed } } -- (UIView*)passwordHeaderViewForTextField:(UITextField*)textField +- (UIView*)headerViewForTextField:(UITextField*)textField { textField.keyboardType = UIKeyboardTypeNumberPad; @@ -571,7 +563,7 @@ - (UIView*)passwordHeaderViewForTextField:(UITextField*)textField - (NSArray*)boxes { - NSMutableArray *squareViews = [NSMutableArray array]; + NSMutableArray* squareViews = [NSMutableArray array]; CGFloat squareX = 0.0; @@ -600,7 +592,6 @@ - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger) - (UITableViewCell*)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { - static NSString* CellIdentifier = @"KKPasscodeViewControllerCell"; UITableViewCell* cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; @@ -635,118 +626,117 @@ - (BOOL)textFieldShouldReturn:(UITextField*)textField } -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string { - if (YES) { - NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; - textField.text = result; - - for (int i = 0; i < kPasscodeBoxesCount; i++) { - UIImageView *square = [[_boxes objectAtIndex:_tableIndex] objectAtIndex:i]; - if (i < [result length]) { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; - } else { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; - } - } - - if ([result length] == kPasscodeBoxesCount) { - - if (mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { - [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - } - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - [self dismissModalViewControllerAnimated:YES]; - } - } - } - return NO; - } - - return YES; + NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; + textField.text = result; + + for (int i = 0; i < kPasscodeBoxesCount; i++) { + UIImageView *square = [[_boxes objectAtIndex:_tableIndex] objectAtIndex:i]; + if (i < [result length]) { + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; + } else { + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; + } + } + + if ([result length] == kPasscodeBoxesCount) { + + if (mode == KKPasscodeModeDisabled) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (mode == KKPasscodeModeEnter) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + } + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if ([textField isEqual:_setPasscodeTextField]) { + [self moveToNextTableView]; + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } + + return NO; } From f6f28946323000bf645e90da44535b92b8920a3e Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Jan 2012 01:21:24 -0500 Subject: [PATCH 17/62] mode variable name fixed --- src/KKPasscodeViewController.h | 6 ++-- src/KKPasscodeViewController.m | 62 +++++++++++++++++----------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 41389be..eba3e68 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -66,7 +66,6 @@ typedef NSUInteger KKPasscodeMode; @end - @interface KKPasscodeViewController : UIViewController { // delegate which called when major events happens @@ -75,9 +74,12 @@ typedef NSUInteger KKPasscodeMode; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; UILabel* _failedAttemptsLabel; + + // failed attements coutner NSInteger _failedAttemptsCount; - NSUInteger _tableIndex; + // the current panel that being displayed + NSUInteger _currentPanel; // used to transition between table views NSMutableArray* _tableViews; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 2f8dc69..c7809ba 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -38,7 +38,7 @@ - (void)incrementFailedAttemptsLabel; @implementation KKPasscodeViewController @synthesize delegate = _delegate; -@synthesize mode; +@synthesize mode = _mode; #pragma mark - #pragma mark UIViewController @@ -99,7 +99,7 @@ - (void)viewWillAppear:(BOOL)animated _textFields = [[NSMutableArray alloc] init]; _boxes = [[NSMutableArray alloc] init]; - if (mode == KKPasscodeModeSet || mode == KKPasscodeModeChange) { + if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) { if (_passcodeLockOn) { _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; [_tableViews addObject:_enterPasscodeTableView]; @@ -191,7 +191,7 @@ - (void)incrementFailedAttemptsLabel _enterPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _failedAttemptsCount += 1; @@ -241,14 +241,14 @@ - (void)incrementFailedAttemptsLabel - (void)moveToNextTableView { - _tableIndex += 1; + _currentPanel += 1; - UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex - 1]; - UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; + UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel - 1]; + UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -258,20 +258,20 @@ - (void)moveToNextTableView [UIView commitAnimations]; - [[_textFields objectAtIndex:_tableIndex - 1] resignFirstResponder]; - [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; + [[_textFields objectAtIndex:_currentPanel - 1] resignFirstResponder]; + [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } - (void)moveToPreviousTableView { - _tableIndex -= 1; + _currentPanel -= 1; - UITableView *oldTableView = [_tableViews objectAtIndex:_tableIndex + 1]; - UITableView *newTableView = [_tableViews objectAtIndex:_tableIndex]; + UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel + 1]; + UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; @@ -280,17 +280,17 @@ - (void)moveToPreviousTableView newTableView.frame = self.view.frame; [UIView commitAnimations]; - [[_textFields objectAtIndex:_tableIndex + 1] resignFirstResponder]; - [[_textFields objectAtIndex:_tableIndex] becomeFirstResponder]; + [[_textFields objectAtIndex:_currentPanel + 1] resignFirstResponder]; + [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } - (void)nextDigitPressed { - UITextField* textField = [_textFields objectAtIndex:_tableIndex]; + UITextField* textField = [_textFields objectAtIndex:_currentPanel]; if (![textField.text isEqualToString:@""]) { - if (mode == KKPasscodeModeSet) { + if (_mode == KKPasscodeModeSet) { if ([textField isEqual:_setPasscodeTextField]) { [self moveToNextTableView]; } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -311,7 +311,7 @@ - (void)nextDigitPressed [self dismissModalViewControllerAnimated:YES]; } } - } else if (mode == KKPasscodeModeChange) { + } else if (_mode == KKPasscodeModeChange) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { @@ -353,9 +353,9 @@ - (void)nextDigitPressed - (void)doneButtonPressed { - UITextField *textField = [_textFields objectAtIndex:_tableIndex]; + UITextField *textField = [_textFields objectAtIndex:_currentPanel]; - if (mode == KKPasscodeModeEnter) { + if (_mode == KKPasscodeModeEnter) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -374,7 +374,7 @@ - (void)doneButtonPressed } else { [self incrementFailedAttemptsLabel]; } - } else if (mode == KKPasscodeModeSet) { + } else if (_mode == KKPasscodeModeSet) { if ([textField isEqual:_setPasscodeTextField]) { [self moveToNextTableView]; } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -395,7 +395,7 @@ - (void)doneButtonPressed [self dismissModalViewControllerAnimated:YES]; } } - } else if (mode == KKPasscodeModeChange) { + } else if (_mode == KKPasscodeModeChange) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { @@ -431,7 +431,7 @@ - (void)doneButtonPressed [self dismissModalViewControllerAnimated:YES]; } } - } else if (mode == KKPasscodeModeDisabled) { + } else if (_mode == KKPasscodeModeDisabled) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { @@ -512,7 +512,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField [_failedAttemptsLabel release]; } - if (mode == KKPasscodeModeSet) { + if (_mode == KKPasscodeModeSet) { self.navigationItem.title = @"Set Passcode"; UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; self.navigationItem.leftBarButtonItem = cancel; @@ -530,14 +530,14 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } else if ([textField isEqual:_confirmPasscodeTextField]) { headerLabel.text = @"Re-enter your passcode"; } - } else if (mode == KKPasscodeModeDisabled) { + } else if (_mode == KKPasscodeModeDisabled) { self.navigationItem.title = @"Turn off Passcode"; UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; self.navigationItem.leftBarButtonItem = cancel; [cancel release]; headerLabel.text = @"Enter your passcode"; - } else if (mode == KKPasscodeModeChange) { + } else if (_mode == KKPasscodeModeChange) { self.navigationItem.title = @"Change Passcode"; UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; self.navigationItem.leftBarButtonItem = cancel; @@ -632,7 +632,7 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange textField.text = result; for (int i = 0; i < kPasscodeBoxesCount; i++) { - UIImageView *square = [[_boxes objectAtIndex:_tableIndex] objectAtIndex:i]; + UIImageView *square = [[_boxes objectAtIndex:_currentPanel] objectAtIndex:i]; if (i < [result length]) { square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; } else { @@ -642,7 +642,7 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange if ([result length] == kPasscodeBoxesCount) { - if (mode == KKPasscodeModeDisabled) { + if (_mode == KKPasscodeModeDisabled) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { @@ -657,7 +657,7 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange } else { [self incrementFailedAttemptsLabel]; } - } else if (mode == KKPasscodeModeEnter) { + } else if (_mode == KKPasscodeModeEnter) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([_enterPasscodeTextField.text isEqualToString:passcode]) { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { @@ -675,7 +675,7 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange } else { [self incrementFailedAttemptsLabel]; } - } else if (mode == KKPasscodeModeChange) { + } else if (_mode == KKPasscodeModeChange) { NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { @@ -687,7 +687,7 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_tableIndex] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); From e1f2575d6602f9a1ee66665c7c5161158b8f97e5 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 27 Jan 2012 00:27:19 -0500 Subject: [PATCH 18/62] originze passcode logic --- src/KKPasscodeViewController.m | 88 +++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index c7809ba..311d8dc 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -74,10 +74,6 @@ - (void)loadView [self.view addSubview:_confirmPasscodeTableView]; } -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation -{ - return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); -} - (void)viewWillAppear:(BOOL)animated { @@ -177,14 +173,19 @@ - (void)viewWillAppear:(BOOL)animated } + + + #pragma mark - #pragma mark Private methods + - (void)cancelButtonPressed:(id)sender { [self dismissModalViewControllerAnimated:YES]; } + - (void)incrementFailedAttemptsLabel { AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); @@ -201,13 +202,13 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsLabel.text = [NSString stringWithFormat:@"%i Failed Passcode Attempts", _failedAttemptsCount]; } CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); - _failedAttemptsLabel.frame = CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0); + _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = _failedAttemptsView.bounds; - gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; + gradient.colors = [NSArray arrayWithObjects: + (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor], + (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil]; [_failedAttemptsView.layer insertSublayer:gradient atIndex:0]; _failedAttemptsView.layer.masksToBounds = YES; @@ -219,14 +220,6 @@ - (void)incrementFailedAttemptsLabel _enterPasscodeTextField.delegate = nil; if (_eraseData) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { [_delegate shouldEraseApplicationData:self]; } @@ -245,7 +238,11 @@ - (void)moveToNextTableView UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel - 1]; UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel]; - newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); + + newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, + oldTableView.frame.origin.y, + oldTableView.frame.size.width, + oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; @@ -262,6 +259,7 @@ - (void)moveToNextTableView [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } + - (void)moveToPreviousTableView { _currentPanel -= 1; @@ -284,6 +282,7 @@ - (void)moveToPreviousTableView [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } + - (void)nextDigitPressed { UITextField* textField = [_textFields objectAtIndex:_currentPanel]; @@ -312,7 +311,7 @@ - (void)nextDigitPressed } } } else if (_mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + NSString* passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { [self moveToNextTableView]; @@ -323,10 +322,10 @@ - (void)nextDigitPressed if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. You cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -407,10 +406,10 @@ - (void)doneButtonPressed if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -458,7 +457,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, self.view.bounds.size.width, 30.0)] autorelease]; - headerLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; + headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.textAlignment = UITextAlignmentCenter; headerLabel.font = [UIFont boldSystemFontOfSize:17.0]; @@ -466,8 +465,8 @@ - (UIView*)headerViewForTextField:(UITextField*)textField headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; if ([textField isEqual:_setPasscodeTextField]) { - _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0)]; - _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.298 green:0.337 blue:0.424 alpha:1.0]; + _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0)]; + _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; _passcodeConfirmationWarningLabel.textAlignment = UITextAlignmentCenter; _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0]; @@ -482,8 +481,8 @@ - (UIView*)headerViewForTextField:(UITextField*)textField if ([textField isEqual:_enterPasscodeTextField]) { NSString *text = @"1 Failed Passcode Attempt"; CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; - _failedAttemptsLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 147.5, size.width + 36.0, size.height + 10.0)]; + _failedAttemptsView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 146.0, size.width + 36.0, size.height + 10.0)]; + _failedAttemptsLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 146.0, size.width + 36.0, size.height + 10.0)]; _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; _failedAttemptsLabel.textColor = [UIColor whiteColor]; _failedAttemptsLabel.text = text; @@ -500,8 +499,9 @@ - (UIView*)headerViewForTextField:(UITextField*)textField CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = _failedAttemptsView.bounds; - gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithRed:0.714 green:0.043 blue:0.043 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.761 green:0.192 blue:0.192 alpha:1.0] CGColor], nil]; + gradient.colors = [NSArray arrayWithObjects: + (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor], + (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil]; [_failedAttemptsView.layer insertSublayer:gradient atIndex:1]; _failedAttemptsView.layer.masksToBounds = YES; @@ -514,34 +514,33 @@ - (UIView*)headerViewForTextField:(UITextField*)textField if (_mode == KKPasscodeModeSet) { self.navigationItem.title = @"Set Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; - + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; if ([textField isEqual:_enterPasscodeTextField]) { headerLabel.text = @"Enter your passcode"; } else if ([textField isEqual:_setPasscodeTextField]) { headerLabel.text = @"Enter a passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; } else if ([textField isEqual:_confirmPasscodeTextField]) { headerLabel.text = @"Re-enter your passcode"; } } else if (_mode == KKPasscodeModeDisabled) { self.navigationItem.title = @"Turn off Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; headerLabel.text = @"Enter your passcode"; } else if (_mode == KKPasscodeModeChange) { self.navigationItem.title = @"Change Passcode"; - UIBarButtonItem *cancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; - self.navigationItem.leftBarButtonItem = cancel; - [cancel release]; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; if ([textField isEqual:_enterPasscodeTextField]) { headerLabel.text = @"Enter your old passcode"; @@ -561,6 +560,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField return headerView; } + - (NSArray*)boxes { NSMutableArray* squareViews = [NSMutableArray array]; @@ -690,10 +690,10 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 131.5, self.view.bounds.size.width, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.5, self.view.bounds.size.width, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { From a42d1bbc62ed7a655042cb1b623eb8e77692e7c1 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 27 Jan 2012 00:43:48 -0500 Subject: [PATCH 19/62] removed duplicated logic --- src/KKPasscodeViewController.m | 340 +++++++++++++-------------------- 1 file changed, 132 insertions(+), 208 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 311d8dc..abebfba 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -95,6 +95,30 @@ - (void)viewWillAppear:(BOOL)animated _textFields = [[NSMutableArray alloc] init]; _boxes = [[NSMutableArray alloc] init]; + + + + if (_mode == KKPasscodeModeSet) { + self.navigationItem.title = @"Set Passcode"; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; + } else if (_mode == KKPasscodeModeChange) { + self.navigationItem.title = @"Change Passcode"; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; + + } else if (_mode == KKPasscodeModeDisabled) { + self.navigationItem.title = @"Turn off Passcode"; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)] autorelease]; + + } else { + self.navigationItem.title = @"Enter Passcode"; + } + if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) { if (_passcodeLockOn) { _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; @@ -110,6 +134,7 @@ - (void)viewWillAppear:(BOOL)animated } _setPasscodeTableView.tableHeaderView = [self headerViewForTextField:_setPasscodeTextField]; + [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -350,104 +375,110 @@ - (void)nextDigitPressed } } +- (void)vaildatePasscode:(UITextField*)textField +{ + if (_mode == KKPasscodeModeDisabled) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (_mode == KKPasscodeModeEnter) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (_mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + } + _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } + } else if ([textField isEqual:_setPasscodeTextField]) { + [self moveToNextTableView]; + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } +} + + - (void)doneButtonPressed { UITextField *textField = [_textFields objectAtIndex:_currentPanel]; - - if (_mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly::)]) { - [_delegate didPasscodeEnteredCorrectly:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (_mode == KKPasscodeModeSet) { - if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if (_mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if (_mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } + [self vaildatePasscode:textField]; } + - (UIView*)headerViewForTextField:(UITextField*)textField { textField.keyboardType = UIKeyboardTypeNumberPad; @@ -456,7 +487,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField [self.view addSubview:textField]; UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; - UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 27.5, self.view.bounds.size.width, 30.0)] autorelease]; + UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)] autorelease]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.textAlignment = UITextAlignmentCenter; @@ -513,35 +544,16 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } if (_mode == KKPasscodeModeSet) { - self.navigationItem.title = @"Set Passcode"; - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)] autorelease]; - if ([textField isEqual:_enterPasscodeTextField]) { headerLabel.text = @"Enter your passcode"; } else if ([textField isEqual:_setPasscodeTextField]) { headerLabel.text = @"Enter a passcode"; - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)] autorelease]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { headerLabel.text = @"Re-enter your passcode"; } } else if (_mode == KKPasscodeModeDisabled) { - self.navigationItem.title = @"Turn off Passcode"; - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)] autorelease]; - headerLabel.text = @"Enter your passcode"; } else if (_mode == KKPasscodeModeChange) { - self.navigationItem.title = @"Change Passcode"; - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)] autorelease]; - if ([textField isEqual:_enterPasscodeTextField]) { headerLabel.text = @"Enter your old passcode"; } else if ([textField isEqual:_setPasscodeTextField]) { @@ -550,11 +562,10 @@ - (UIView*)headerViewForTextField:(UITextField*)textField headerLabel.text = @"Re-enter your new passcode"; } } else { - self.navigationItem.title = @"Enter Passcode"; headerLabel.text = @"Enter your passcode"; } + headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; - [headerView addSubview:headerLabel]; return headerView; @@ -626,6 +637,9 @@ - (BOOL)textFieldShouldReturn:(UITextField*)textField } + + + - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string { NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; @@ -641,105 +655,15 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange } if ([result length] == kPasscodeBoxesCount) { - - if (_mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (_mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { - [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (_mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - } - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); - [self moveToNextTableView]; - } - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } - } else if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } + [self vaildatePasscode:textField]; } return NO; } + + #pragma mark - #pragma mark Memory management From 2f96e62a13438e02e3697e251fd6ef9d2392897a Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Fri, 27 Jan 2012 00:55:59 -0500 Subject: [PATCH 20/62] trimmed duplicated logic --- src/KKPasscodeViewController.m | 37 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index abebfba..72a206a 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -84,12 +84,18 @@ - (void)viewWillAppear:(BOOL)animated _enterPasscodeTextField = [[UITextField alloc] init]; _enterPasscodeTextField.delegate = self; - + _enterPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + _enterPasscodeTextField.hidden = YES; + _setPasscodeTextField = [[UITextField alloc] init]; _setPasscodeTextField.delegate = self; + _setPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + _setPasscodeTextField.hidden = YES; _confirmPasscodeTextField = [[UITextField alloc] init]; _confirmPasscodeTextField.delegate = self; + _confirmPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + _confirmPasscodeTextField.hidden = YES; _tableViews = [[NSMutableArray alloc] init]; _textFields = [[NSMutableArray alloc] init]; @@ -119,6 +125,8 @@ - (void)viewWillAppear:(BOOL)animated self.navigationItem.title = @"Enter Passcode"; } + + if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) { if (_passcodeLockOn) { _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; @@ -481,11 +489,7 @@ - (void)doneButtonPressed - (UIView*)headerViewForTextField:(UITextField*)textField { - textField.keyboardType = UIKeyboardTypeNumberPad; - - textField.hidden = YES; - [self.view addSubview:textField]; - + [self.view addSubview:textField]; UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)] autorelease]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; @@ -510,13 +514,11 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } if ([textField isEqual:_enterPasscodeTextField]) { - NSString *text = @"1 Failed Passcode Attempt"; - CGSize size = [text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 146.0, size.width + 36.0, size.height + 10.0)]; - _failedAttemptsLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - (size.width + 36.0)) / 2, 146.0, size.width + 36.0, size.height + 10.0)]; + _failedAttemptsView = [[[UIView alloc] init] autorelease]; + _failedAttemptsLabel = [[[UILabel alloc] init] autorelease]; _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; _failedAttemptsLabel.textColor = [UIColor whiteColor]; - _failedAttemptsLabel.text = text; + _failedAttemptsLabel.text = @""; _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:14.0]; _failedAttemptsLabel.textAlignment = UITextAlignmentCenter; _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); @@ -527,20 +529,11 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _failedAttemptsLabel.hidden = YES; _failedAttemptsView.hidden = YES; - - CAGradientLayer *gradient = [CAGradientLayer layer]; - gradient.frame = _failedAttemptsView.bounds; - gradient.colors = [NSArray arrayWithObjects: - (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil]; - [_failedAttemptsView.layer insertSublayer:gradient atIndex:1]; + _failedAttemptsView.layer.masksToBounds = YES; [headerView addSubview:_failedAttemptsView]; [headerView addSubview:_failedAttemptsLabel]; - - [_failedAttemptsView release]; - [_failedAttemptsLabel release]; } if (_mode == KKPasscodeModeSet) { @@ -596,11 +589,13 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView return 0; } + - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section { return 1; } + - (UITableViewCell*)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString* CellIdentifier = @"KKPasscodeViewControllerCell"; From 691db858ebf05206daf529771f61c95218b6c7b2 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Mon, 6 Feb 2012 17:58:02 -0500 Subject: [PATCH 21/62] basic localization support --- .../KKPasscodeLock.xcodeproj/project.pbxproj | 4 ++ example/KKPasscodeLock/AppDelegate.m | 3 +- example/KKPasscodeLock/Localizable.strings | 1 + .../KKPasscodeLock/SettingsViewController.m | 8 ++-- .../en.lproj/Localizable.strings | Bin 0 -> 2804 bytes src/KKPasscodeSettingsViewController.m | 16 +++---- src/KKPasscodeViewController.m | 40 +++++++++--------- 7 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 example/KKPasscodeLock/Localizable.strings create mode 100644 src/KKPasscodeLock.bundle/en.lproj/Localizable.strings diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLock.xcodeproj/project.pbxproj index 74df6ca..60ae7b8 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLock.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */; }; 6D3E34CF14C4F9910003B72B /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E34CC14C4F9910003B72B /* RootViewController.m */; }; 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D3E34CD14C4F9910003B72B /* RootViewController.xib */; }; + 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6DE61E6614E091FC008E1DB0 /* Localizable.strings */; }; 6DF13A5B14C686FC0069BBA5 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */; }; 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */; }; 6DF13A6914C6870B0069BBA5 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */; }; @@ -43,6 +44,7 @@ 6D3E34CB14C4F9910003B72B /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 6D3E34CC14C4F9910003B72B /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 6D3E34CD14C4F9910003B72B /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; }; + 6DE61E6614E091FC008E1DB0 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; 6DF13A5814C686FC0069BBA5 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsViewController.xib; sourceTree = ""; }; @@ -94,6 +96,7 @@ 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */, 6D3E345D14C4F54E0003B72B /* main.m */, 6D3E345F14C4F54E0003B72B /* KKPasscodeLock-Prefix.pch */, + 6DE61E6614E091FC008E1DB0 /* Localizable.strings */, ); name = "Supporting Files"; sourceTree = ""; @@ -228,6 +231,7 @@ 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */, 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, + 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 65fbfe0..fcad757 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -86,7 +86,8 @@ - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; - [alert release];} + [alert release]; +} @end diff --git a/example/KKPasscodeLock/Localizable.strings b/example/KKPasscodeLock/Localizable.strings new file mode 100644 index 0000000..b6a4846 --- /dev/null +++ b/example/KKPasscodeLock/Localizable.strings @@ -0,0 +1 @@ +"Passcode Lock" = "Passcode Lock"; diff --git a/example/KKPasscodeLock/SettingsViewController.m b/example/KKPasscodeLock/SettingsViewController.m index ff9be37..a9354cc 100755 --- a/example/KKPasscodeLock/SettingsViewController.m +++ b/example/KKPasscodeLock/SettingsViewController.m @@ -33,7 +33,7 @@ - (void)doneButtonPressed:(id)sender { - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = @"Settings"; + self.navigationItem.title = NSLocalizedString(@"Settings", ""); UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; @@ -66,11 +66,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } if (indexPath.section == 0) { - cell.textLabel.text = @"Passcode Lock"; + cell.textLabel.text = NSLocalizedString(@"Passcode Lock", ""); if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - cell.detailTextLabel.text = @"On"; + cell.detailTextLabel.text = NSLocalizedString(@"On", ""); } else { - cell.detailTextLabel.text = @"Off"; + cell.detailTextLabel.text = NSLocalizedString(@"Off", ""); } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } diff --git a/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..0fc380b46e9d95c5f81ce71f2ae54fcd1bc409b4 GIT binary patch literal 2804 zcmd5;O;5r=6ntlXMMJ_-63@m1K|Gmgl#9nwiW+4h7DD**>dd|@yL4$O1OwTWmhHT+ zd9%Cy{b@;Co+On5Ba@koC6`1V@RZ3X-X(I2s~&SBEsVDG5UCqvepy+O ztG4t}fdRugYVsU!&nj{NTq+}5yGL%%I;7)}3@W?qsIkoOH|z(y?7DGUz6YCLo+l5d z#-S{c3H2B2`wama2K{dQV4RNl%=lgK63hv;S>(KiMd*k1# zQ3tX3FW_R;ihu^J-W`5bP7^xngttM1U`h8NDh5L3o%qq^^$C%+< m=UR*NbFp?aT5VSs&7j)V5z(sc_On=R>nf~cv)Y=Gb^HNklF)kq literal 0 HcmV?d00001 diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 5403b4a..db84219 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -32,7 +32,7 @@ @implementation KKPasscodeSettingsViewController - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = @"Passcode Lock"; + self.navigationItem.title = NSLocalizedString(@"Passcode Lock", ""); _eraseDataSwitch = [[UISwitch alloc] init]; [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; @@ -78,9 +78,9 @@ - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger) - (void)eraseDataSwitchChanged:(id)sender { if (_eraseDataSwitch.on) { - NSString* title = [NSString stringWithFormat:@"All data in this app will be erased after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]]; + NSString* title = [NSString stringWithFormat:NSLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", ""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Enable" otherButtonTitles:nil]; + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", "") destructiveButtonTitle:NSLocalizedString(@"Enable", "") otherButtonTitles:nil]; [sheet showInView:self.view]; [sheet release]; } else { @@ -109,7 +109,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return [NSString stringWithFormat:@"Erase all content in the app after %d failed passcode attempts.", [[KKPasscodeLock sharedLock] attemptsAllowed]];; + return [NSString stringWithFormat:NSLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", ""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; } @@ -133,19 +133,19 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI if (indexPath.section == 0) { cell.textLabel.textAlignment = UITextAlignmentCenter; if (_passcodeLockOn) { - cell.textLabel.text = @"Turn Passcode Off"; + cell.textLabel.text = NSLocalizedString(@"Turn Passcode Off", ""); } else { - cell.textLabel.text = @"Turn Passcode On"; + cell.textLabel.text = NSLocalizedString(@"Turn Passcode On", ""); } } else if (indexPath.section == 1) { - cell.textLabel.text = @"Change Passcode"; + cell.textLabel.text = NSLocalizedString(@"Change Passcode", ""); cell.textLabel.textAlignment = UITextAlignmentCenter; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; } } else if (indexPath.section == 2) { - cell.textLabel.text = @"Erase Data"; + cell.textLabel.text = NSLocalizedString(@"Erase Data", ""); cell.accessoryView = _eraseDataSwitch; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (_passcodeLockOn) { diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 72a206a..d32bb32 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -105,24 +105,24 @@ - (void)viewWillAppear:(BOOL)animated if (_mode == KKPasscodeModeSet) { - self.navigationItem.title = @"Set Passcode"; + self.navigationItem.title = NSLocalizedString(@"Set Passcode", ""); self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)] autorelease]; } else if (_mode == KKPasscodeModeChange) { - self.navigationItem.title = @"Change Passcode"; + self.navigationItem.title = NSLocalizedString(@"Change Passcode", ""); self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)] autorelease]; } else if (_mode == KKPasscodeModeDisabled) { - self.navigationItem.title = @"Turn off Passcode"; + self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", ""); self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)] autorelease]; } else { - self.navigationItem.title = @"Enter Passcode"; + self.navigationItem.title = NSLocalizedString(@"Enter Passcode", ""); } @@ -230,9 +230,9 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsCount += 1; if (_failedAttemptsCount == 1) { - _failedAttemptsLabel.text = @"1 Failed Passcode Attempt"; + _failedAttemptsLabel.text = NSLocalizedString(@"1 Failed Passcode Attempt", ""); } else { - _failedAttemptsLabel.text = [NSString stringWithFormat:@"%i Failed Passcode Attempts", _failedAttemptsCount]; + _failedAttemptsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Failed Passcode Attempts", ""), _failedAttemptsCount]; } CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); @@ -329,7 +329,7 @@ - (void)nextDigitPressed if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -354,7 +354,7 @@ - (void)nextDigitPressed } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. You cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", ""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -365,7 +365,7 @@ - (void)nextDigitPressed if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -432,7 +432,7 @@ - (void)vaildatePasscode:(UITextField*)textField for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } - _passcodeConfirmationWarningLabel.text = @"Enter a different passcode. Cannot re-use the same passcode."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", ""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -443,7 +443,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -463,7 +463,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = @"Passcodes did not match. Try again."; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -538,24 +538,24 @@ - (UIView*)headerViewForTextField:(UITextField*)textField if (_mode == KKPasscodeModeSet) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = @"Enter your passcode"; + headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = @"Enter a passcode"; + headerLabel.text = NSLocalizedString(@"Enter a passcode", ""); } else if ([textField isEqual:_confirmPasscodeTextField]) { - headerLabel.text = @"Re-enter your passcode"; + headerLabel.text = NSLocalizedString(@"Re-enter your passcode", ""); } } else if (_mode == KKPasscodeModeDisabled) { - headerLabel.text = @"Enter your passcode"; + headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); } else if (_mode == KKPasscodeModeChange) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = @"Enter your old passcode"; + headerLabel.text = NSLocalizedString(@"Enter your old passcode", ""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = @"Enter your new passcode"; + headerLabel.text = NSLocalizedString(@"Enter your new passcode", ""); } else { - headerLabel.text = @"Re-enter your new passcode"; + headerLabel.text = NSLocalizedString(@"Re-enter your new passcode", ""); } } else { - headerLabel.text = @"Enter your passcode"; + headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); } headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; From e93ad25f1bcbe3defa99252b9777a7672dedae28 Mon Sep 17 00:00:00 2001 From: Tom Nys Date: Wed, 25 Apr 2012 21:26:12 +0200 Subject: [PATCH 22/62] Dutch Localization --- .../nl.lproj/Localizable.strings | Bin 0 -> 3330 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings diff --git a/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..712cea18ed425d8435731c81ecb7e59c72504f8b GIT binary patch literal 3330 zcmdT`U5gq~49#3n zeYJZluV8iDV>;1a4op2Uk2f*}wj_^=s);l3eZ%{;S`z=d1F3r)sNF{Wy~mCcSJTf< zW-?bM=;;==jQK|&H3XB-_|JiwY$QC5_~tLzW2{Vm z!EUa1)Zkh>b&6*TTI?A@{JbY87BH!D@m&-)R)?2-wJ9jZ2F|UBF zIuYpqJG^i4Kf=3&pJm5A*LZFnRU%8yj}2^=de`<8*?v-V383MR?9vGM;^kdt-*ro1bkwJz+>CfC7q^yeHLxn;2EY*hVH8>e{m+L>+J z=NCl0*2-KGafYm``tHggm??B>oR*IEBcqcT}hUrZyMt ze6OF&hKFh%>t5WhBWsU;d|cbyCnBnrXDr$0 z$q-ZEBc5bhr+dXoiwxQERDHsoce2gTCtcfDUbD9?Z!*k__TV{4aRg?Uf5?D`G#QTq56qoHOL&YfdI#NxBZ@AYedz*^lJ5EBXf;Fdl zh_PPRdLK5`#E5M@9qz;d;^fdbH669{Z|gqZrTuAsqpJ}t7Zuw+EE0N(9*CB8`3pk6 BHDCY$ literal 0 HcmV?d00001 From 4d5b929b6804758eefa332453e5593b7c44191fb Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Apr 2012 20:08:33 -0400 Subject: [PATCH 23/62] adding pod spec file --- KKPasscodeLock.podspec | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 KKPasscodeLock.podspec diff --git a/KKPasscodeLock.podspec b/KKPasscodeLock.podspec new file mode 100644 index 0000000..4c145c2 --- /dev/null +++ b/KKPasscodeLock.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = 'KKPasscodeLock' + s.version = '0.1.5' + s.license = 'Apache 2.0' + s.summary = 'KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passcode settings in ios apps' + s.homepage = 'https://github.com/aporat/KKPasscodeLock.git' + s.author = { 'Adar Porat' => 'adar.porat@gmail.com' } + s.source = { :git => 'https://github.com/aporat/KKPasscodeLock.git' } + s.platform = :ios + s.source_files = 'src/*.{h,m}' + s.resources = "src/KKPasscodeLock.bundle" + s.clean_paths = "Classes", "*.{plist,pch,md,m,xcodeproj}", "SampleApp" + s.frameworks = 'QuartzCore', 'AudioToolbox', 'Security' +end From c8d1c37d3309eaefb42faac8427acd6d2daf52ff Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 25 Apr 2012 20:31:12 -0400 Subject: [PATCH 24/62] unit tests added --- ...fo.plist => KKPasscodeLockDemo-Info.plist} | 0 ...efix.pch => KKPasscodeLockDemo-Prefix.pch} | 0 .../project.pbxproj | 45 +-- .../KKPasscodeLock/KKPasscodeLock-Prefix.pch | 7 + .../project.pbxproj | 340 ++++++++++++++++++ .../KKPasscodeLock-Info.plist | 22 ++ .../KKPasscodeLockTests/KKPasscodeLockTests.h | 22 ++ .../KKPasscodeLockTests/KKPasscodeLockTests.m | 47 +++ .../en.lproj/InfoPlist.strings | 2 + 9 files changed, 463 insertions(+), 22 deletions(-) rename example/KKPasscodeLock/{KKPasscodeLock-Info.plist => KKPasscodeLockDemo-Info.plist} (100%) rename example/KKPasscodeLock/{KKPasscodeLock-Prefix.pch => KKPasscodeLockDemo-Prefix.pch} (100%) rename example/{KKPasscodeLock.xcodeproj => KKPasscodeLockDemo.xcodeproj}/project.pbxproj (92%) create mode 100644 tests/KKPasscodeLock/KKPasscodeLock-Prefix.pch create mode 100644 tests/KKPasscodeLockTests.xcodeproj/project.pbxproj create mode 100644 tests/KKPasscodeLockTests/KKPasscodeLock-Info.plist create mode 100644 tests/KKPasscodeLockTests/KKPasscodeLockTests.h create mode 100644 tests/KKPasscodeLockTests/KKPasscodeLockTests.m create mode 100644 tests/KKPasscodeLockTests/en.lproj/InfoPlist.strings diff --git a/example/KKPasscodeLock/KKPasscodeLock-Info.plist b/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist similarity index 100% rename from example/KKPasscodeLock/KKPasscodeLock-Info.plist rename to example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist diff --git a/example/KKPasscodeLock/KKPasscodeLock-Prefix.pch b/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch similarity index 100% rename from example/KKPasscodeLock/KKPasscodeLock-Prefix.pch rename to example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch diff --git a/example/KKPasscodeLock.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj similarity index 92% rename from example/KKPasscodeLock.xcodeproj/project.pbxproj rename to example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index 60ae7b8..de6edde 100644 --- a/example/KKPasscodeLock.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -29,14 +29,14 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 6D3E344D14C4F54E0003B72B /* KKPasscodeLock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLock.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 6D3E345914C4F54E0003B72B /* KKPasscodeLock-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KKPasscodeLock-Info.plist"; sourceTree = ""; }; + 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */ = {isa = PBXFileReference; path = "KKPasscodeLockDemo-Info.plist"; sourceTree = ""; }; 6D3E345B14C4F54E0003B72B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6D3E345D14C4F54E0003B72B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 6D3E345F14C4F54E0003B72B /* KKPasscodeLock-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLock-Prefix.pch"; sourceTree = ""; }; + 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */ = {isa = PBXFileReference; path = "KKPasscodeLockDemo-Prefix.pch"; sourceTree = ""; }; 6D3E346014C4F54E0003B72B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 6D3E346114C4F54E0003B72B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6D3E34BA14C4F90B0003B72B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; @@ -51,7 +51,7 @@ 6DF13A5D14C6870B0069BBA5 /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = ../../src/KKKeychain.h; sourceTree = ""; }; 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = ../../src/KKKeychain.m; sourceTree = ""; }; 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; }; - 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; }; 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; @@ -92,10 +92,10 @@ 6D2F0BD614C51D0300C1862D /* Supporting Files */ = { isa = PBXGroup; children = ( - 6D3E345914C4F54E0003B72B /* KKPasscodeLock-Info.plist */, + 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */, 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */, 6D3E345D14C4F54E0003B72B /* main.m */, - 6D3E345F14C4F54E0003B72B /* KKPasscodeLock-Prefix.pch */, + 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */, 6DE61E6614E091FC008E1DB0 /* Localizable.strings */, ); name = "Supporting Files"; @@ -114,7 +114,7 @@ 6D3E344E14C4F54E0003B72B /* Products */ = { isa = PBXGroup; children = ( - 6D3E344D14C4F54E0003B72B /* KKPasscodeLock.app */, + 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */, ); name = Products; sourceTree = ""; @@ -180,9 +180,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 6D3E344C14C4F54D0003B72B /* KKPasscodeLock */ = { + 6D3E344C14C4F54D0003B72B /* KKPasscodeLockDemo */ = { isa = PBXNativeTarget; - buildConfigurationList = 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLock" */; + buildConfigurationList = 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLockDemo" */; buildPhases = ( 6D3E344914C4F54D0003B72B /* Sources */, 6D3E344A14C4F54D0003B72B /* Frameworks */, @@ -192,9 +192,9 @@ ); dependencies = ( ); - name = KKPasscodeLock; + name = KKPasscodeLockDemo; productName = KKPasscodeLock; - productReference = 6D3E344D14C4F54E0003B72B /* KKPasscodeLock.app */; + productReference = 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -203,9 +203,10 @@ 6D3E344414C4F54D0003B72B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0420; + LastUpgradeCheck = 0430; + ORGANIZATIONNAME = "Kosher Penguin LLC"; }; - buildConfigurationList = 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLock" */; + buildConfigurationList = 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLockDemo" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -217,7 +218,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 6D3E344C14C4F54D0003B72B /* KKPasscodeLock */, + 6D3E344C14C4F54D0003B72B /* KKPasscodeLockDemo */, ); }; /* End PBXProject section */ @@ -316,10 +317,10 @@ isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; - INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLock-Info.plist"; + GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch"; + INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 4.0; - PRODUCT_NAME = KKPasscodeLock; + PRODUCT_NAME = KKPasscodeLockDemo; WRAPPER_EXTENSION = app; }; name = Debug; @@ -328,10 +329,10 @@ isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; - INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLock-Info.plist"; + GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch"; + INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 4.0; - PRODUCT_NAME = KKPasscodeLock; + PRODUCT_NAME = KKPasscodeLockDemo; WRAPPER_EXTENSION = app; }; name = Release; @@ -339,7 +340,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLock" */ = { + 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLockDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( 6D3E346314C4F54E0003B72B /* Debug */, @@ -348,7 +349,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLock" */ = { + 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLockDemo" */ = { isa = XCConfigurationList; buildConfigurations = ( 6D3E346614C4F54E0003B72B /* Debug */, diff --git a/tests/KKPasscodeLock/KKPasscodeLock-Prefix.pch b/tests/KKPasscodeLock/KKPasscodeLock-Prefix.pch new file mode 100644 index 0000000..7c5cd99 --- /dev/null +++ b/tests/KKPasscodeLock/KKPasscodeLock-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'KKPasscodeLock' target in the 'KKPasscodeLock' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ce716b2 --- /dev/null +++ b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj @@ -0,0 +1,340 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 6D2394C81548CA89004DF3B7 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */; }; + 6D2394CA1548CA89004DF3B7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C91548CA89004DF3B7 /* UIKit.framework */; }; + 6D2394CB1548CA89004DF3B7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394B91548CA89004DF3B7 /* Foundation.framework */; }; + 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */; }; + 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */; }; + 6D2394E91548CAA8004DF3B7 /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */; }; + 6D2394EC1548CAA8004DF3B7 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */; }; + 6D2394EF1548CAA8004DF3B7 /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */; }; + 6D2394F21548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */; }; + 6D2394F51548CAA8004DF3B7 /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */; }; + 6D2394F81548CBAA004DF3B7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */; }; + 6D2394F91548CBAA004DF3B7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */; }; + 6D2394FB1548CBAE004DF3B7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394FA1548CBAE004DF3B7 /* Security.framework */; }; + 6D2394FD1548CBC5004DF3B7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6D2394B91548CA89004DF3B7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 6D2394BD1548CA89004DF3B7 /* KKPasscodeLock-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLock-Prefix.pch"; sourceTree = ""; }; + 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KKPasscodeLock.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; + 6D2394C91548CA89004DF3B7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 6D2394D11548CA89004DF3B7 /* KKPasscodeLock-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KKPasscodeLock-Info.plist"; sourceTree = ""; }; + 6D2394D31548CA89004DF3B7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 6D2394D51548CA89004DF3B7 /* KKPasscodeLockTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KKPasscodeLockTests.h; sourceTree = ""; }; + 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KKPasscodeLockTests.m; sourceTree = ""; }; + 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.bundle; sourceTree = ""; }; + 6D2394E11548CAA8004DF3B7 /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKKeychain.h; sourceTree = ""; }; + 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKKeychain.m; sourceTree = ""; }; + 6D2394E31548CAA8004DF3B7 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.h; sourceTree = ""; }; + 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.m; sourceTree = ""; }; + 6D2394E51548CAA8004DF3B7 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; + 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; }; + 6D2394E71548CAA8004DF3B7 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeViewController.h; sourceTree = ""; }; + 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeViewController.m; sourceTree = ""; }; + 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 6D2394FA1548CBAE004DF3B7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; + 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6D2394C21548CA89004DF3B7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2394FD1548CBC5004DF3B7 /* QuartzCore.framework in Frameworks */, + 6D2394FB1548CBAE004DF3B7 /* Security.framework in Frameworks */, + 6D2394F81548CBAA004DF3B7 /* AudioToolbox.framework in Frameworks */, + 6D2394F91548CBAA004DF3B7 /* CoreGraphics.framework in Frameworks */, + 6D2394C81548CA89004DF3B7 /* SenTestingKit.framework in Frameworks */, + 6D2394CA1548CA89004DF3B7 /* UIKit.framework in Frameworks */, + 6D2394CB1548CA89004DF3B7 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6D2394AB1548CA89004DF3B7 = { + isa = PBXGroup; + children = ( + 6D2394BB1548CA89004DF3B7 /* KKPasscodeLock */, + 6D2394CF1548CA89004DF3B7 /* KKPasscodeLockTests */, + 6D2394B81548CA89004DF3B7 /* Frameworks */, + 6D2394B71548CA89004DF3B7 /* Products */, + ); + sourceTree = ""; + }; + 6D2394B71548CA89004DF3B7 /* Products */ = { + isa = PBXGroup; + children = ( + 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */, + ); + name = Products; + sourceTree = ""; + }; + 6D2394B81548CA89004DF3B7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */, + 6D2394FA1548CBAE004DF3B7 /* Security.framework */, + 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */, + 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */, + 6D2394B91548CA89004DF3B7 /* Foundation.framework */, + 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */, + 6D2394C91548CA89004DF3B7 /* UIKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 6D2394BB1548CA89004DF3B7 /* KKPasscodeLock */ = { + isa = PBXGroup; + children = ( + 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */, + 6D2394E11548CAA8004DF3B7 /* KKKeychain.h */, + 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */, + 6D2394E31548CAA8004DF3B7 /* KKPasscodeLock.h */, + 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */, + 6D2394E51548CAA8004DF3B7 /* KKPasscodeSettingsViewController.h */, + 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */, + 6D2394E71548CAA8004DF3B7 /* KKPasscodeViewController.h */, + 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */, + 6D2394BC1548CA89004DF3B7 /* Supporting Files */, + ); + path = KKPasscodeLock; + sourceTree = ""; + }; + 6D2394BC1548CA89004DF3B7 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6D2394BD1548CA89004DF3B7 /* KKPasscodeLock-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 6D2394CF1548CA89004DF3B7 /* KKPasscodeLockTests */ = { + isa = PBXGroup; + children = ( + 6D2394D51548CA89004DF3B7 /* KKPasscodeLockTests.h */, + 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */, + 6D2394D01548CA89004DF3B7 /* Supporting Files */, + ); + path = KKPasscodeLockTests; + sourceTree = ""; + }; + 6D2394D01548CA89004DF3B7 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 6D2394D11548CA89004DF3B7 /* KKPasscodeLock-Info.plist */, + 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6D2394C51548CA89004DF3B7 /* KKPasscodeLockTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6D2394DD1548CA89004DF3B7 /* Build configuration list for PBXNativeTarget "KKPasscodeLockTests" */; + buildPhases = ( + 6D2394C11548CA89004DF3B7 /* Sources */, + 6D2394C21548CA89004DF3B7 /* Frameworks */, + 6D2394C31548CA89004DF3B7 /* Resources */, + 6D2394C41548CA89004DF3B7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = KKPasscodeLockTests; + productName = KKPasscodeLockTests; + productReference = 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6D2394AD1548CA89004DF3B7 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + ORGANIZATIONNAME = "Kosher Penguin LLC"; + }; + buildConfigurationList = 6D2394B01548CA89004DF3B7 /* Build configuration list for PBXProject "KKPasscodeLockTests" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 6D2394AB1548CA89004DF3B7; + productRefGroup = 6D2394B71548CA89004DF3B7 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6D2394C51548CA89004DF3B7 /* KKPasscodeLockTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6D2394C31548CA89004DF3B7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */, + 6D2394E91548CAA8004DF3B7 /* KKPasscodeLock.bundle in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 6D2394C41548CA89004DF3B7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6D2394C11548CA89004DF3B7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */, + 6D2394EC1548CAA8004DF3B7 /* KKKeychain.m in Sources */, + 6D2394EF1548CAA8004DF3B7 /* KKPasscodeLock.m in Sources */, + 6D2394F21548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m in Sources */, + 6D2394F51548CAA8004DF3B7 /* KKPasscodeViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 6D2394D31548CA89004DF3B7 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6D2394D81548CA89004DF3B7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 6D2394D91548CA89004DF3B7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6D2394DE1548CA89004DF3B7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(DEVELOPER_LIBRARY_DIR)/Frameworks", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; + INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist"; + PRODUCT_NAME = KKPasscodeLock; + WRAPPER_EXTENSION = octest; + }; + name = Debug; + }; + 6D2394DF1548CA89004DF3B7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(DEVELOPER_LIBRARY_DIR)/Frameworks", + ); + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; + INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist"; + PRODUCT_NAME = KKPasscodeLock; + WRAPPER_EXTENSION = octest; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6D2394B01548CA89004DF3B7 /* Build configuration list for PBXProject "KKPasscodeLockTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D2394D81548CA89004DF3B7 /* Debug */, + 6D2394D91548CA89004DF3B7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6D2394DD1548CA89004DF3B7 /* Build configuration list for PBXNativeTarget "KKPasscodeLockTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6D2394DE1548CA89004DF3B7 /* Debug */, + 6D2394DF1548CA89004DF3B7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6D2394AD1548CA89004DF3B7 /* Project object */; +} diff --git a/tests/KKPasscodeLockTests/KKPasscodeLock-Info.plist b/tests/KKPasscodeLockTests/KKPasscodeLock-Info.plist new file mode 100644 index 0000000..0a33f6c --- /dev/null +++ b/tests/KKPasscodeLockTests/KKPasscodeLock-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.kosherpenguin.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/tests/KKPasscodeLockTests/KKPasscodeLockTests.h b/tests/KKPasscodeLockTests/KKPasscodeLockTests.h new file mode 100644 index 0000000..6f02f46 --- /dev/null +++ b/tests/KKPasscodeLockTests/KKPasscodeLockTests.h @@ -0,0 +1,22 @@ +// +// Copyright 2011-2012 Kosher Penguin LLC +// Created by Adar Porat (https://github.com/aporat) on 1/16/2012. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import + +@interface KKPasscodeLockTests : SenTestCase + +@end diff --git a/tests/KKPasscodeLockTests/KKPasscodeLockTests.m b/tests/KKPasscodeLockTests/KKPasscodeLockTests.m new file mode 100644 index 0000000..665587f --- /dev/null +++ b/tests/KKPasscodeLockTests/KKPasscodeLockTests.m @@ -0,0 +1,47 @@ +// +// Copyright 2011-2012 Kosher Penguin LLC +// Created by Adar Porat (https://github.com/aporat) on 1/16/2012. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "KKPasscodeLockTests.h" +#import "KKPasscodeLock.h" + +@implementation KKPasscodeLockTests + +- (void)setUp +{ + [super setUp]; + + // Set-up code here. +} + +- (void)tearDown +{ + // Tear-down code here. + + [super tearDown]; +} + +- (void)testDefaultSettings +{ + KKPasscodeLock* sharedLock = [KKPasscodeLock sharedLock]; + + STAssertEquals(sharedLock.eraseOption, YES, @"Erase option is default to YES"); + STAssertEquals(sharedLock.attemptsAllowed, (NSUInteger)5, @"attemptsAllowed default to 5 tries"); + + +} + +@end diff --git a/tests/KKPasscodeLockTests/en.lproj/InfoPlist.strings b/tests/KKPasscodeLockTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/tests/KKPasscodeLockTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + From 516e36cadc95b25495032b659a5f084912c34fe3 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Mon, 30 Apr 2012 19:36:38 -0400 Subject: [PATCH 25/62] automatic ARC conversion --- example/KKPasscodeLock/AppDelegate.h | 2 +- example/KKPasscodeLock/AppDelegate.m | 13 ++---- example/KKPasscodeLock/RootViewController.m | 10 ++--- .../KKPasscodeLock/SettingsViewController.m | 5 +-- .../project.pbxproj | 10 +++-- src/KKKeychain.m | 37 +++++++-------- src/KKPasscodeSettingsViewController.h | 4 +- src/KKPasscodeSettingsViewController.m | 14 +++--- src/KKPasscodeViewController.h | 4 +- src/KKPasscodeViewController.m | 45 +++++++------------ .../project.pbxproj | 3 ++ 11 files changed, 62 insertions(+), 85 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.h b/example/KKPasscodeLock/AppDelegate.h index 7c39181..b646d4d 100644 --- a/example/KKPasscodeLock/AppDelegate.h +++ b/example/KKPasscodeLock/AppDelegate.h @@ -21,6 +21,6 @@ @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; -@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; +@property (nonatomic) IBOutlet UINavigationController *navigationController; @end diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index fcad757..0a936c2 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -24,21 +24,16 @@ @implementation AppDelegate @synthesize window = _window; @synthesize navigationController=_navigationController; -- (void)dealloc -{ - [_window release]; - [super dealloc]; -} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[KKPasscodeLock sharedLock] setDefaultSettings]; - self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; - RootViewController* vc = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil] autorelease]; + RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; _navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; [self.window addSubview:_navigationController.view]; @@ -51,7 +46,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( - (void)applicationDidBecomeActive:(UIApplication *)application { if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; + KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.mode = KKPasscodeModeEnter; vc.delegate = self; @@ -79,14 +74,12 @@ - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times. All account data in this app has been deleted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; - [alert release]; } - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; - [alert release]; } diff --git a/example/KKPasscodeLock/RootViewController.m b/example/KKPasscodeLock/RootViewController.m index 885486e..3b58ae0 100755 --- a/example/KKPasscodeLock/RootViewController.m +++ b/example/KKPasscodeLock/RootViewController.m @@ -22,18 +22,14 @@ @implementation RootViewController - (IBAction)showPasscode:(id)sender { - SettingsViewController* settingsViewController = [[[SettingsViewController alloc] - initWithNibName:@"SettingsViewController" bundle:nil] autorelease]; + SettingsViewController* settingsViewController = [[SettingsViewController alloc] + initWithNibName:@"SettingsViewController" bundle:nil]; - UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:settingsViewController] autorelease]; + UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:settingsViewController]; [self presentModalViewController:navController animated:YES]; } -- (void)dealloc -{ - [super dealloc]; -} @end diff --git a/example/KKPasscodeLock/SettingsViewController.m b/example/KKPasscodeLock/SettingsViewController.m index a9354cc..a05dd4a 100755 --- a/example/KKPasscodeLock/SettingsViewController.m +++ b/example/KKPasscodeLock/SettingsViewController.m @@ -39,7 +39,6 @@ - (void)viewDidLoad { UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; self.navigationItem.rightBarButtonItem = doneButton; - [doneButton release]; } #pragma mark - Table view data source @@ -62,7 +61,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } if (indexPath.section == 0) { @@ -81,7 +80,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { - KKPasscodeSettingsViewController *vc = [[[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; + KKPasscodeSettingsViewController *vc = [[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; vc.delegate = self; [self.navigationController pushViewController:vc animated:YES]; } diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index de6edde..f2a369c 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -33,10 +33,10 @@ 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */ = {isa = PBXFileReference; path = "KKPasscodeLockDemo-Info.plist"; sourceTree = ""; }; + 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KKPasscodeLockDemo-Info.plist"; sourceTree = ""; }; 6D3E345B14C4F54E0003B72B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6D3E345D14C4F54E0003B72B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */ = {isa = PBXFileReference; path = "KKPasscodeLockDemo-Prefix.pch"; sourceTree = ""; }; + 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLockDemo-Prefix.pch"; sourceTree = ""; }; 6D3E346014C4F54E0003B72B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 6D3E346114C4F54E0003B72B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 6D3E34BA14C4F90B0003B72B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; @@ -53,9 +53,9 @@ 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; }; 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; }; 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; - 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; }; 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; - 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; + 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; }; 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -316,6 +316,7 @@ 6D3E346614C4F54E0003B72B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch"; INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist"; @@ -328,6 +329,7 @@ 6D3E346714C4F54E0003B72B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch"; INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist"; diff --git a/src/KKKeychain.m b/src/KKKeychain.m index 89274c6..d6eb9c7 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -44,26 +44,27 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding]; - [existsQueryDictionary setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [existsQueryDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; // Add the keys to the search dict - [existsQueryDictionary setObject:@"service" forKey:(id)kSecAttrService]; - [existsQueryDictionary setObject:key forKey:(id)kSecAttrAccount]; - - OSStatus res = SecItemCopyMatching((CFDictionaryRef)existsQueryDictionary, NULL); + [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService]; + [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount]; + + OSStatus res = SecItemCopyMatching((__bridge_retained CFDictionaryRef) existsQueryDictionary, NULL); + if (res == errSecItemNotFound) { if (string != nil) { NSMutableDictionary *addDict = existsQueryDictionary; - [addDict setObject:data forKey:(id)kSecValueData]; + [addDict setObject:data forKey:(__bridge id)kSecValueData]; - res = SecItemAdd((CFDictionaryRef)addDict, NULL); + res = SecItemAdd((__bridge_retained CFDictionaryRef)addDict, NULL); NSAssert1(res == errSecSuccess, @"Recieved %d from SecItemAdd!", res); } } else if (res == errSecSuccess) { // Modify an existing one // Actually pull it now of the keychain at this point. - NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(id)kSecValueData]; - res = SecItemUpdate((CFDictionaryRef)existsQueryDictionary, (CFDictionaryRef)attributeDict); + NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(__bridge id)kSecValueData]; + res = SecItemUpdate((__bridge_retained CFDictionaryRef)existsQueryDictionary, (__bridge_retained CFDictionaryRef)attributeDict); NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %d!", res); } else { NSAssert1(NO, @"Received %d from SecItemCopyMatching!", res); @@ -75,21 +76,21 @@ + (NSString*)getStringForKey:(NSString*)key { key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary]; - [existsQueryDictionary setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass]; + [existsQueryDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; // Add the keys to the search dict - [existsQueryDictionary setObject:@"service" forKey:(id)kSecAttrService]; - [existsQueryDictionary setObject:key forKey:(id)kSecAttrAccount]; + [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService]; + [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount]; // We want the data back! - NSData *data = nil; + CFTypeRef data = nil; - [existsQueryDictionary setObject:(id)kCFBooleanTrue forKey:(id)kSecReturnData]; - - OSStatus res = SecItemCopyMatching((CFDictionaryRef)existsQueryDictionary, (CFTypeRef *)&data); - [data autorelease]; + [existsQueryDictionary setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; + + OSStatus res = SecItemCopyMatching((__bridge CFDictionaryRef)existsQueryDictionary, &data); + if (res == errSecSuccess) { - NSString *string = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; + NSString *string = [[NSString alloc] initWithData:(__bridge NSData*)data encoding:NSUTF8StringEncoding]; return string; } else { NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %d!", res); diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index f19dbc8..dd18fec 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -34,7 +34,7 @@ @interface KKPasscodeSettingsViewController : UITableViewController { // delegate which notified then the passcode is turned on/off - id _delegate; + id __unsafe_unretained _delegate; // the erase content switch. UISwitch* _eraseDataSwitch; @@ -46,6 +46,6 @@ BOOL _eraseDataOn; } -@property (nonatomic, assign) id delegate; +@property (nonatomic, unsafe_unretained) id delegate; @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index db84219..2b741b0 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -40,7 +40,6 @@ - (void)viewDidLoad - (void)viewDidUnload { - [_eraseDataSwitch release]; _eraseDataSwitch = nil; [super viewDidUnload]; @@ -82,7 +81,6 @@ - (void)eraseDataSwitchChanged:(id)sender UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", "") destructiveButtonTitle:NSLocalizedString(@"Enable", "") otherButtonTitles:nil]; [sheet showInView:self.view]; - [sheet release]; } else { _eraseDataOn = NO; [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; @@ -121,7 +119,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.accessoryView = nil; @@ -166,8 +164,8 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { if (indexPath.section == 0) { - KKPasscodeViewController* vc = [[[KKPasscodeViewController alloc] initWithNibName:nil - bundle:nil] autorelease]; + KKPasscodeViewController* vc = [[KKPasscodeViewController alloc] initWithNibName:nil + bundle:nil]; vc.delegate = self; if (_passcodeLockOn) { @@ -176,7 +174,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) vc.mode = KKPasscodeModeSet; } - UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { nav.modalPresentationStyle = UIModalPresentationFormSheet; @@ -193,12 +191,12 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) } else if (indexPath.section == 1 && _passcodeLockOn) { - KKPasscodeViewController *vc = [[[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil] autorelease]; + KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; vc.mode = KKPasscodeModeChange; - UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease]; + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index eba3e68..0591247 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -69,7 +69,7 @@ typedef NSUInteger KKPasscodeMode; @interface KKPasscodeViewController : UIViewController { // delegate which called when major events happens - id _delegate; + id __unsafe_unretained _delegate; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; @@ -108,7 +108,7 @@ typedef NSUInteger KKPasscodeMode; BOOL _eraseData; } -@property (nonatomic, assign) id delegate; +@property (nonatomic, unsafe_unretained) id delegate; @property (nonatomic, assign) KKPasscodeMode mode; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index d32bb32..713e8be 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -106,20 +106,20 @@ - (void)viewWillAppear:(BOOL)animated if (_mode == KKPasscodeModeSet) { self.navigationItem.title = NSLocalizedString(@"Set Passcode", ""); - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self - action:@selector(cancelButtonPressed:)] autorelease]; + action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeChange) { self.navigationItem.title = NSLocalizedString(@"Change Passcode", ""); - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self - action:@selector(cancelButtonPressed:)] autorelease]; + action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeDisabled) { self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", ""); - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self - action:@selector(cancelButtonPressed:)] autorelease]; + action:@selector(cancelButtonPressed:)]; } else { self.navigationItem.title = NSLocalizedString(@"Enter Passcode", ""); @@ -133,7 +133,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -146,7 +146,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -157,7 +157,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_confirmPasscodeTableView]; [_textFields addObject:_confirmPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesConfirmView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + UIView *boxesConfirmView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; boxesConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesConfirmView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -168,7 +168,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)] autorelease]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -490,8 +490,8 @@ - (void)doneButtonPressed - (UIView*)headerViewForTextField:(UITextField*)textField { [self.view addSubview:textField]; - UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)] autorelease]; - UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)] autorelease]; + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)]; + UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.textAlignment = UITextAlignmentCenter; @@ -514,8 +514,8 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } if ([textField isEqual:_enterPasscodeTextField]) { - _failedAttemptsView = [[[UIView alloc] init] autorelease]; - _failedAttemptsLabel = [[[UILabel alloc] init] autorelease]; + _failedAttemptsView = [[UIView alloc] init]; + _failedAttemptsLabel = [[UILabel alloc] init]; _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; _failedAttemptsLabel.textColor = [UIColor whiteColor]; _failedAttemptsLabel.text = @""; @@ -575,7 +575,6 @@ - (NSArray*)boxes UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; square.frame = CGRectMake(squareX, 74.0, kPasscodeBoxWidth, kPasscodeBoxHeight); [squareViews addObject:square]; - [square release]; squareX += 71.0; } return [NSArray arrayWithArray:squareViews]; @@ -602,7 +601,7 @@ - (UITableViewCell*)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(NS UITableViewCell* cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } @@ -662,19 +661,5 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange #pragma mark - #pragma mark Memory management -- (void)dealloc -{ - [_enterPasscodeTableView release]; - [_setPasscodeTableView release]; - [_confirmPasscodeTableView release]; - - [_enterPasscodeTextField release]; - [_setPasscodeTextField release]; - [_confirmPasscodeTextField release]; - [_tableViews release]; - [_textFields release]; - [_boxes release]; - [super dealloc]; -} @end diff --git a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj index ce716b2..bfaebdd 100644 --- a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj +++ b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj @@ -287,6 +287,7 @@ 6D2394DE1548CA89004DF3B7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(DEVELOPER_LIBRARY_DIR)/Frameworks", @@ -302,6 +303,7 @@ 6D2394DF1548CA89004DF3B7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(DEVELOPER_LIBRARY_DIR)/Frameworks", @@ -333,6 +335,7 @@ 6D2394DF1548CA89004DF3B7 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; From ea8807f4d23f5aac8d99ee34775fbcb1ac98e6f9 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 2 May 2012 16:47:32 -0400 Subject: [PATCH 26/62] fixed calls to NSLocalizedString --- src/KKPasscodeSettingsViewController.m | 16 +++++------ src/KKPasscodeViewController.m | 38 +++++++++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 2b741b0..e41f1ea 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -32,7 +32,7 @@ @implementation KKPasscodeSettingsViewController - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = NSLocalizedString(@"Passcode Lock", ""); + self.navigationItem.title = NSLocalizedString(@"Passcode Lock", @""); _eraseDataSwitch = [[UISwitch alloc] init]; [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; @@ -77,9 +77,9 @@ - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger) - (void)eraseDataSwitchChanged:(id)sender { if (_eraseDataSwitch.on) { - NSString* title = [NSString stringWithFormat:NSLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", ""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; + NSString* title = [NSString stringWithFormat:NSLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", "") destructiveButtonTitle:NSLocalizedString(@"Enable", "") otherButtonTitles:nil]; + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") destructiveButtonTitle:NSLocalizedString(@"Enable", @"") otherButtonTitles:nil]; [sheet showInView:self.view]; } else { _eraseDataOn = NO; @@ -107,7 +107,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return [NSString stringWithFormat:NSLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", ""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; + return [NSString stringWithFormat:NSLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; } @@ -131,19 +131,19 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI if (indexPath.section == 0) { cell.textLabel.textAlignment = UITextAlignmentCenter; if (_passcodeLockOn) { - cell.textLabel.text = NSLocalizedString(@"Turn Passcode Off", ""); + cell.textLabel.text = NSLocalizedString(@"Turn Passcode Off", @""); } else { - cell.textLabel.text = NSLocalizedString(@"Turn Passcode On", ""); + cell.textLabel.text = NSLocalizedString(@"Turn Passcode On", @""); } } else if (indexPath.section == 1) { - cell.textLabel.text = NSLocalizedString(@"Change Passcode", ""); + cell.textLabel.text = NSLocalizedString(@"Change Passcode", @""); cell.textLabel.textAlignment = UITextAlignmentCenter; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; } } else if (indexPath.section == 2) { - cell.textLabel.text = NSLocalizedString(@"Erase Data", ""); + cell.textLabel.text = NSLocalizedString(@"Erase Data", @""); cell.accessoryView = _eraseDataSwitch; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (_passcodeLockOn) { diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 713e8be..b255b13 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -105,24 +105,24 @@ - (void)viewWillAppear:(BOOL)animated if (_mode == KKPasscodeModeSet) { - self.navigationItem.title = NSLocalizedString(@"Set Passcode", ""); + self.navigationItem.title = NSLocalizedString(@"Set Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeChange) { - self.navigationItem.title = NSLocalizedString(@"Change Passcode", ""); + self.navigationItem.title = NSLocalizedString(@"Change Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeDisabled) { - self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", ""); + self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else { - self.navigationItem.title = NSLocalizedString(@"Enter Passcode", ""); + self.navigationItem.title = NSLocalizedString(@"Enter Passcode", @""); } @@ -230,9 +230,9 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsCount += 1; if (_failedAttemptsCount == 1) { - _failedAttemptsLabel.text = NSLocalizedString(@"1 Failed Passcode Attempt", ""); + _failedAttemptsLabel.text = NSLocalizedString(@"1 Failed Passcode Attempt", @""); } else { - _failedAttemptsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Failed Passcode Attempts", ""), _failedAttemptsCount]; + _failedAttemptsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Failed Passcode Attempts", @""), _failedAttemptsCount]; } CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); @@ -329,7 +329,7 @@ - (void)nextDigitPressed if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -354,7 +354,7 @@ - (void)nextDigitPressed } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", ""); + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -432,7 +432,7 @@ - (void)vaildatePasscode:(UITextField*)textField for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", ""); + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", @""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -443,7 +443,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -463,7 +463,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -538,24 +538,24 @@ - (UIView*)headerViewForTextField:(UITextField*)textField if (_mode == KKPasscodeModeSet) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter a passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter a passcode", @""); } else if ([textField isEqual:_confirmPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Re-enter your passcode", ""); + headerLabel.text = NSLocalizedString(@"Re-enter your passcode", @""); } } else if (_mode == KKPasscodeModeDisabled) { - headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); } else if (_mode == KKPasscodeModeChange) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your old passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter your old passcode", @""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your new passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter your new passcode", @""); } else { - headerLabel.text = NSLocalizedString(@"Re-enter your new passcode", ""); + headerLabel.text = NSLocalizedString(@"Re-enter your new passcode", @""); } } else { - headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); + headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); } headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; From 10cf916615d05ad9369c3068ecfe3c84d5443d85 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 2 May 2012 17:55:07 -0300 Subject: [PATCH 27/62] Update README.mdown --- README.mdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.mdown b/README.mdown index 36d4926..e12d26d 100644 --- a/README.mdown +++ b/README.mdown @@ -15,5 +15,15 @@ KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passc - Advanced passcode settings controller: set & change passcode, turn off/on passcode and passcode tries allowed - Passcode is saved securly in the device keychain + +

Using KKPasscodeLock

+ +Using this framework is really easy. + +- Add all the source files under the src folder, including KKPasscodeLock.bundle +- `#import "KKPasscodeLock.h"` where you need it. +- Add the `AudioToolbox.framework`, `Security.framework` and the `QuartzCore.framework` into your project +- See the usage of the passcode lock from the sample app +

Terms of Use

- Provided under the Apache 2.0 License From bd244ce74802975f51828a71e18f3ce237c73fd9 Mon Sep 17 00:00:00 2001 From: Jeff Morris Date: Mon, 4 Jun 2012 18:54:22 -0700 Subject: [PATCH 28/62] Corrected an issue on the iPad when the user tries to hide the keyboard, they cant until they enter a correct passcord. --- src/KKPasscodeViewController.h | 4 ++++ src/KKPasscodeViewController.m | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 0591247..ca2246e 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -106,6 +106,10 @@ typedef NSUInteger KKPasscodeMode; // whatever the erase data option is turned on or off BOOL _eraseData; + + // Used to make sure we do not release the keyboard when on iPad + BOOL _shouldReleaseFirstResponser; + } @property (nonatomic, unsafe_unretained) id delegate; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index b255b13..69c6ec3 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -23,7 +23,7 @@ #import #import -@interface KKPasscodeViewController(Private) +@interface KKPasscodeViewController (Private) - (UITextField*)passcodeTextField; - (NSArray*)boxes; @@ -72,6 +72,9 @@ - (void)loadView _confirmPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone; _confirmPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_confirmPasscodeTableView]; + + _shouldReleaseFirstResponser = NO; + } @@ -206,7 +209,14 @@ - (void)viewWillAppear:(BOOL)animated } - +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + + _shouldReleaseFirstResponser = YES; + [_enterPasscodeTextField resignFirstResponder]; + [_setPasscodeTextField resignFirstResponder]; + [_confirmPasscodeTextField resignFirstResponder]; +} #pragma mark - @@ -287,8 +297,9 @@ - (void)moveToNextTableView newTableView.frame = self.view.frame; [UIView commitAnimations]; - + _shouldReleaseFirstResponser = YES; [[_textFields objectAtIndex:_currentPanel - 1] resignFirstResponder]; + _shouldReleaseFirstResponser = NO; [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } @@ -311,7 +322,9 @@ - (void)moveToPreviousTableView newTableView.frame = self.view.frame; [UIView commitAnimations]; + _shouldReleaseFirstResponser = YES; [[_textFields objectAtIndex:_currentPanel + 1] resignFirstResponder]; + _shouldReleaseFirstResponser = NO; [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder]; } @@ -657,6 +670,9 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange +- (BOOL)textFieldShouldEndEditing:(UITextField *)textField { + return _shouldReleaseFirstResponser; +} #pragma mark - #pragma mark Memory management From 1f2aa43bef35bcb5d2c8a680ce812069ecb0d104 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sun, 2 Sep 2012 21:35:09 -0400 Subject: [PATCH 29/62] code indentation cleanup --- example/KKPasscodeLock/AppDelegate.h | 2 +- example/KKPasscodeLock/AppDelegate.m | 86 ++--- .../KKPasscodeLockDemo-Info.plist | 2 +- .../KKPasscodeLockDemo-Prefix.pch | 2 +- example/KKPasscodeLock/RootViewController.h | 4 +- example/KKPasscodeLock/RootViewController.m | 18 +- .../KKPasscodeLock/SettingsViewController.h | 2 +- .../KKPasscodeLock/SettingsViewController.m | 72 ++-- example/KKPasscodeLock/main.m | 17 +- src/KKKeychain.h | 6 +- src/KKKeychain.m | 30 +- src/KKPasscodeLock.h | 10 +- src/KKPasscodeLock.m | 2 +- src/KKPasscodeSettingsViewController.h | 12 +- src/KKPasscodeSettingsViewController.m | 52 +-- src/KKPasscodeViewController.h | 68 ++-- src/KKPasscodeViewController.m | 342 +++++++++--------- 17 files changed, 366 insertions(+), 361 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.h b/example/KKPasscodeLock/AppDelegate.h index b646d4d..d304cc1 100644 --- a/example/KKPasscodeLock/AppDelegate.h +++ b/example/KKPasscodeLock/AppDelegate.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 0a936c2..e3b8e0f 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,59 +27,59 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - - [[KKPasscodeLock sharedLock] setDefaultSettings]; - - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.backgroundColor = [UIColor whiteColor]; - - RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; - - _navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; - [self.window addSubview:_navigationController.view]; - [self.window makeKeyAndVisible]; - - return YES; + + [[KKPasscodeLock sharedLock] setDefaultSettings]; + + self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + self.window.backgroundColor = [UIColor whiteColor]; + + RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; + + _navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; + [self.window addSubview:_navigationController.view]; + [self.window makeKeyAndVisible]; + + return YES; } - (void)applicationDidBecomeActive:(UIApplication *)application { - if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; - vc.mode = KKPasscodeModeEnter; - vc.delegate = self; - - dispatch_async(dispatch_get_main_queue(),^ { - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - nav.modalPresentationStyle = UIModalPresentationFormSheet; - nav.navigationBar.barStyle = UIBarStyleBlack; - nav.navigationBar.opaque = NO; - } else { - nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor; - nav.navigationBar.translucent = _navigationController.navigationBar.translucent; - nav.navigationBar.opaque = _navigationController.navigationBar.opaque; - nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle; - } - - [_navigationController presentModalViewController:nav animated:YES]; - }); - - } + if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { + KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; + vc.mode = KKPasscodeModeEnter; + vc.delegate = self; + + dispatch_async(dispatch_get_main_queue(),^ { + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + nav.modalPresentationStyle = UIModalPresentationFormSheet; + nav.navigationBar.barStyle = UIBarStyleBlack; + nav.navigationBar.opaque = NO; + } else { + nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor; + nav.navigationBar.translucent = _navigationController.navigationBar.translucent; + nav.navigationBar.opaque = _navigationController.navigationBar.opaque; + nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle; + } + + [_navigationController presentModalViewController:nav animated:YES]; + }); + + } } -- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController +- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times. All account data in this app has been deleted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times. All account data in this app has been deleted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; } -- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController +- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; - [alert show]; + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; } diff --git a/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist b/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist index 4c95cff..e476ef1 100644 --- a/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist +++ b/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist @@ -11,7 +11,7 @@ CFBundleIconFiles CFBundleIdentifier - com.kosherpenguin.kosherkit.demo.${PRODUCT_NAME:rfc1034identifier} + com.kosherpenguin.passcode.demo.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch b/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch index 26bc5cb..c2949e1 100644 --- a/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch +++ b/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch @@ -1,5 +1,5 @@ // -// Prefix header for all source files of the 'APPasscodeLock' target in the 'APPasscodeLock' project +// Prefix header for all source files of the 'KKPasscodeLock' target in the 'KKPasscodeLock' project // #import diff --git a/example/KKPasscodeLock/RootViewController.h b/example/KKPasscodeLock/RootViewController.h index 3cd2e98..08ca127 100755 --- a/example/KKPasscodeLock/RootViewController.h +++ b/example/KKPasscodeLock/RootViewController.h @@ -18,9 +18,7 @@ #import #import "KKPasscodeViewController.h" -@interface RootViewController : UIViewController { - -} +@interface RootViewController : UIViewController - (IBAction)showPasscode:(id)sender; diff --git a/example/KKPasscodeLock/RootViewController.m b/example/KKPasscodeLock/RootViewController.m index 3b58ae0..005771f 100755 --- a/example/KKPasscodeLock/RootViewController.m +++ b/example/KKPasscodeLock/RootViewController.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,14 +21,14 @@ @implementation RootViewController - (IBAction)showPasscode:(id)sender { - - SettingsViewController* settingsViewController = [[SettingsViewController alloc] - initWithNibName:@"SettingsViewController" bundle:nil]; - - UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:settingsViewController]; - - [self presentModalViewController:navController animated:YES]; - + + SettingsViewController* settingsViewController = [[SettingsViewController alloc] + initWithNibName:@"SettingsViewController" bundle:nil]; + + UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:settingsViewController]; + + [self presentModalViewController:navController animated:YES]; + } diff --git a/example/KKPasscodeLock/SettingsViewController.h b/example/KKPasscodeLock/SettingsViewController.h index ba82505..ce2bdbd 100755 --- a/example/KKPasscodeLock/SettingsViewController.h +++ b/example/KKPasscodeLock/SettingsViewController.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/example/KKPasscodeLock/SettingsViewController.m b/example/KKPasscodeLock/SettingsViewController.m index a05dd4a..0f2cc09 100755 --- a/example/KKPasscodeLock/SettingsViewController.m +++ b/example/KKPasscodeLock/SettingsViewController.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,73 +22,73 @@ @implementation SettingsViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { - return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); + return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait); } - (void)doneButtonPressed:(id)sender { - [self dismissModalViewControllerAnimated:YES]; + [self dismissModalViewControllerAnimated:YES]; } #pragma mark - View lifecycle - (void)viewDidLoad { - [super viewDidLoad]; - self.navigationItem.title = NSLocalizedString(@"Settings", ""); - - - UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; - - self.navigationItem.rightBarButtonItem = doneButton; + [super viewDidLoad]; + self.navigationItem.title = NSLocalizedString(@"Settings", ""); + + + UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; + + self.navigationItem.rightBarButtonItem = doneButton; } #pragma mark - Table view data source - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { - return @""; + return @""; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 1; + return 1; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - static NSString *CellIdentifier = @"Cell"; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (cell == nil) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; - } - - if (indexPath.section == 0) { - cell.textLabel.text = NSLocalizedString(@"Passcode Lock", ""); - if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - cell.detailTextLabel.text = NSLocalizedString(@"On", ""); - } else { - cell.detailTextLabel.text = NSLocalizedString(@"Off", ""); + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]; } - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - } - return cell; + + if (indexPath.section == 0) { + cell.textLabel.text = NSLocalizedString(@"Passcode Lock", ""); + if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { + cell.detailTextLabel.text = NSLocalizedString(@"On", ""); + } else { + cell.detailTextLabel.text = NSLocalizedString(@"Off", ""); + } + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + } + return cell; } #pragma mark - Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 0) { - KKPasscodeSettingsViewController *vc = [[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; - vc.delegate = self; - [self.navigationController pushViewController:vc animated:YES]; - } + if (indexPath.section == 0) { + KKPasscodeSettingsViewController *vc = [[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped]; + vc.delegate = self; + [self.navigationController pushViewController:vc animated:YES]; + } } - (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController { - [self.tableView reloadData]; + [self.tableView reloadData]; } @end diff --git a/example/KKPasscodeLock/main.m b/example/KKPasscodeLock/main.m index fd8f9b4..6cfc991 100644 --- a/example/KKPasscodeLock/main.m +++ b/example/KKPasscodeLock/main.m @@ -1,9 +1,18 @@ // -// main.m -// APPasscodeLock +// Copyright 2011-2012 Kosher Penguin LLC +// Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // -// Created by Adar Porat on 1/16/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. // #import diff --git a/src/KKKeychain.h b/src/KKKeychain.h index 6838c85..98fbdf7 100755 --- a/src/KKKeychain.h +++ b/src/KKKeychain.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,9 +17,7 @@ #import -@interface KKKeychain : NSObject { - -} +@interface KKKeychain : NSObject + (BOOL)setString:(NSString*)string forKey:(NSString*)key; diff --git a/src/KKKeychain.m b/src/KKKeychain.m index d6eb9c7..8009e3f 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,24 +20,24 @@ @implementation KKKeychain -+ (NSString*)appName -{ ++ (NSString*)appName +{ NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"]; if (!appName) { - appName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; + appName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; } return appName; } -+ (BOOL)setString:(NSString*)string forKey:(NSString*)key ++ (BOOL)setString:(NSString*)string forKey:(NSString*)key { if (string == nil || key == nil) { return NO; } key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; - + // First check if it already exists, by creating a search dictionary and requesting that // nothing be returned, and performing the search anyway. NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary]; @@ -49,14 +49,14 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key // Add the keys to the search dict [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService]; [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount]; - - OSStatus res = SecItemCopyMatching((__bridge_retained CFDictionaryRef) existsQueryDictionary, NULL); - + + OSStatus res = SecItemCopyMatching((__bridge_retained CFDictionaryRef) existsQueryDictionary, NULL); + if (res == errSecItemNotFound) { if (string != nil) { NSMutableDictionary *addDict = existsQueryDictionary; [addDict setObject:data forKey:(__bridge id)kSecValueData]; - + res = SecItemAdd((__bridge_retained CFDictionaryRef)addDict, NULL); NSAssert1(res == errSecSuccess, @"Recieved %d from SecItemAdd!", res); } @@ -72,8 +72,8 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key return YES; } -+ (NSString*)getStringForKey:(NSString*)key -{ ++ (NSString*)getStringForKey:(NSString*)key +{ key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key]; NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary]; [existsQueryDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; @@ -86,15 +86,15 @@ + (NSString*)getStringForKey:(NSString*)key CFTypeRef data = nil; [existsQueryDictionary setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; - + OSStatus res = SecItemCopyMatching((__bridge CFDictionaryRef)existsQueryDictionary, &data); - + if (res == errSecSuccess) { NSString *string = [[NSString alloc] initWithData:(__bridge NSData*)data encoding:NSUTF8StringEncoding]; return string; } else { NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %d!", res); - } + } return nil; } diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 81c79fc..880c37b 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,11 +19,11 @@ #import "KKPasscodeViewController.h" @interface KKPasscodeLock : NSObject { - - // whatever the erase option is enabled in the passcode settings + + // whatever the erase option is enabled in the passcode settings BOOL _eraseOption; - - // how many attemepts is user is allowed to have before the screen is locked + + // how many attemepts is user is allowed to have before the screen is locked NSUInteger _attemptsAllowed; } diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index daf97b4..5aed4cc 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index dd18fec..511dd90 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,16 +33,16 @@ @interface KKPasscodeSettingsViewController : UITableViewController { - // delegate which notified then the passcode is turned on/off + // delegate which notified then the passcode is turned on/off id __unsafe_unretained _delegate; - // the erase content switch. + // the erase content switch. UISwitch* _eraseDataSwitch; - // whatever the passcode lock is turned on or off + // whatever the passcode lock is turned on or off BOOL _passcodeLockOn; - - // whatever the erase data option is turned on or off + + // whatever the erase data option is turned on or off BOOL _eraseDataOn; } diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 2b741b0..2dec328 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,22 +33,22 @@ - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = NSLocalizedString(@"Passcode Lock", ""); - + _eraseDataSwitch = [[UISwitch alloc] init]; [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; } - (void)viewDidUnload -{ - _eraseDataSwitch = nil; - - [super viewDidUnload]; +{ + _eraseDataSwitch = nil; + + [super viewDidUnload]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; _eraseDataSwitch.on = _eraseDataOn; @@ -74,7 +74,7 @@ - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger) [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; } -- (void)eraseDataSwitchChanged:(id)sender +- (void)eraseDataSwitchChanged:(id)sender { if (_eraseDataSwitch.on) { NSString* title = [NSString stringWithFormat:NSLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", ""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; @@ -84,7 +84,7 @@ - (void)eraseDataSwitchChanged:(id)sender } else { _eraseDataOn = NO; [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; - } + } } #pragma mark - @@ -121,12 +121,12 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } - - cell.accessoryView = nil; - cell.selectionStyle = UITableViewCellSelectionStyleBlue; - cell.textLabel.textAlignment = UITextAlignmentLeft; - cell.textLabel.textColor = [UIColor blackColor]; - + + cell.accessoryView = nil; + cell.selectionStyle = UITableViewCellSelectionStyleBlue; + cell.textLabel.textAlignment = UITextAlignmentLeft; + cell.textLabel.textColor = [UIColor blackColor]; + if (indexPath.section == 0) { cell.textLabel.textAlignment = UITextAlignmentCenter; @@ -138,7 +138,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI } else if (indexPath.section == 1) { cell.textLabel.text = NSLocalizedString(@"Change Passcode", ""); cell.textLabel.textAlignment = UITextAlignmentCenter; - cell.selectionStyle = UITableViewCellSelectionStyleNone; + cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; } @@ -164,8 +164,8 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { if (indexPath.section == 0) { - KKPasscodeViewController* vc = [[KKPasscodeViewController alloc] initWithNibName:nil - bundle:nil]; + KKPasscodeViewController* vc = [[KKPasscodeViewController alloc] initWithNibName:nil + bundle:nil]; vc.delegate = self; if (_passcodeLockOn) { @@ -175,7 +175,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) } UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { nav.modalPresentationStyle = UIModalPresentationFormSheet; nav.navigationBar.barStyle = UIBarStyleBlack; @@ -184,7 +184,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; - nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; + nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } [self.navigationController presentModalViewController:nav animated:YES]; @@ -194,7 +194,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; - vc.mode = KKPasscodeModeChange; + vc.mode = KKPasscodeModeChange; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; @@ -207,20 +207,20 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor; nav.navigationBar.translucent = self.navigationController.navigationBar.translucent; nav.navigationBar.opaque = self.navigationController.navigationBar.opaque; - nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; + nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } - [self.navigationController presentModalViewController:nav animated:YES]; - [tableView deselectRowAtIndexPath:indexPath animated:YES]; + [self.navigationController presentModalViewController:nav animated:YES]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; } } -- (void)didSettingsChanged:(KKPasscodeViewController*)viewController +- (void)didSettingsChanged:(KKPasscodeViewController*)viewController { _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; _eraseDataSwitch.on = _eraseDataOn; - + [self.tableView reloadData]; if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 0591247..1c39f82 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,27 +26,27 @@ // The mode which controls the passcode view behavior enum { - /** - * Displays the passcode enter view, which the user has to enter the correct passcode - */ + /** + * Displays the passcode enter view, which the user has to enter the correct passcode + */ KKPasscodeModeEnter = 0, - - /** - * Creates a new passcode. This allows the user to enter a new passcode then - * imediately verify it. - */ + + /** + * Creates a new passcode. This allows the user to enter a new passcode then + * imediately verify it. + */ KKPasscodeModeSet = 1, - - /** - * Disables an existing passcode. This allows the user to disable the passcode lock by - * entering the passcode - */ + + /** + * Disables an existing passcode. This allows the user to disable the passcode lock by + * entering the passcode + */ KKPasscodeModeDisabled = 2, - - /** - * Changes an existing passcode. This allows the user to change the passcode by - * entering the existing passcode, followed by a new passcode - */ + + /** + * Changes an existing passcode. This allows the user to change the passcode by + * entering the existing passcode, followed by a new passcode + */ KKPasscodeModeChange = 3 }; typedef NSUInteger KKPasscodeMode; @@ -68,25 +68,25 @@ typedef NSUInteger KKPasscodeMode; @interface KKPasscodeViewController : UIViewController { - // delegate which called when major events happens + // delegate which called when major events happens id __unsafe_unretained _delegate; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; UILabel* _failedAttemptsLabel; - - // failed attements coutner + + // failed attements coutner NSInteger _failedAttemptsCount; - // the current panel that being displayed + // the current panel that being displayed NSUInteger _currentPanel; - - // used to transition between table views + + // used to transition between table views NSMutableArray* _tableViews; - - // array of passcode entry text fields + + // array of passcode entry text fields NSMutableArray* _textFields; - + NSMutableArray* _boxes; UITableView* _enterPasscodeTableView; @@ -98,17 +98,17 @@ typedef NSUInteger KKPasscodeMode; UITableView* _confirmPasscodeTableView; UITextField* _confirmPasscodeTextField; - // readwrite override for passlock mode + // readwrite override for passlock mode KKPasscodeMode _mode; - // whatever the passcode lock is turned on or off + // whatever the passcode lock is turned on or off BOOL _passcodeLockOn; - - // whatever the erase data option is turned on or off - BOOL _eraseData; + + // whatever the erase data option is turned on or off + BOOL _eraseData; } -@property (nonatomic, unsafe_unretained) id delegate; +@property (nonatomic, unsafe_unretained) id delegate; @property (nonatomic, assign) KKPasscodeMode mode; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 713e8be..a77eda3 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Kosher Penguin LLC +// Copyright 2011-2012 Kosher Penguin LLC // Created by Adar Porat (https://github.com/aporat) on 1/16/2012. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,58 +75,58 @@ - (void)loadView } -- (void)viewWillAppear:(BOOL)animated +- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; + + _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"]; - + _enterPasscodeTextField = [[UITextField alloc] init]; - _enterPasscodeTextField.delegate = self; - _enterPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + _enterPasscodeTextField.delegate = self; + _enterPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; _enterPasscodeTextField.hidden = YES; - - _setPasscodeTextField = [[UITextField alloc] init]; - _setPasscodeTextField.delegate = self; - _setPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + + _setPasscodeTextField = [[UITextField alloc] init]; + _setPasscodeTextField.delegate = self; + _setPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; _setPasscodeTextField.hidden = YES; - + _confirmPasscodeTextField = [[UITextField alloc] init]; - _confirmPasscodeTextField.delegate = self; - _confirmPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; + _confirmPasscodeTextField.delegate = self; + _confirmPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad; _confirmPasscodeTextField.hidden = YES; _tableViews = [[NSMutableArray alloc] init]; _textFields = [[NSMutableArray alloc] init]; _boxes = [[NSMutableArray alloc] init]; - - - - if (_mode == KKPasscodeModeSet) { - self.navigationItem.title = NSLocalizedString(@"Set Passcode", ""); - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)]; - } else if (_mode == KKPasscodeModeChange) { - self.navigationItem.title = NSLocalizedString(@"Change Passcode", ""); - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)]; - - } else if (_mode == KKPasscodeModeDisabled) { - self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", ""); - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelButtonPressed:)]; - - } else { - self.navigationItem.title = NSLocalizedString(@"Enter Passcode", ""); - } - - - + + + + if (_mode == KKPasscodeModeSet) { + self.navigationItem.title = NSLocalizedString(@"Set Passcode", ""); + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)]; + } else if (_mode == KKPasscodeModeChange) { + self.navigationItem.title = NSLocalizedString(@"Change Passcode", ""); + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)]; + + } else if (_mode == KKPasscodeModeDisabled) { + self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", ""); + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelButtonPressed:)]; + + } else { + self.navigationItem.title = NSLocalizedString(@"Enter Passcode", ""); + } + + + if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) { if (_passcodeLockOn) { _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField]; @@ -142,7 +142,7 @@ - (void)viewWillAppear:(BOOL)animated } _setPasscodeTableView.tableHeaderView = [self headerViewForTextField:_setPasscodeTextField]; - + [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; [_boxes addObject:[self boxes]]; @@ -181,9 +181,9 @@ - (void)viewWillAppear:(BOOL)animated for (int i = 1; i < [_tableViews count]; i++) { UITableView *tableView = [_tableViews objectAtIndex:i]; tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width, - tableView.frame.origin.y, - tableView.frame.size.width, - tableView.frame.size.height); + tableView.frame.origin.y, + tableView.frame.size.width, + tableView.frame.size.height); [self.view addSubview:tableView]; } @@ -198,9 +198,9 @@ - (void)viewWillAppear:(BOOL)animated } else { UITableView *tableView = [_tableViews objectAtIndex:0]; tableView.frame = CGRectMake(tableView.frame.origin.x, - tableView.frame.origin.y, - self.view.bounds.size.width, - self.view.bounds.size.height); + tableView.frame.origin.y, + self.view.bounds.size.width, + self.view.bounds.size.height); } } } @@ -221,12 +221,12 @@ - (void)cancelButtonPressed:(id)sender - (void)incrementFailedAttemptsLabel { - AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); - + AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); + _enterPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - } + } _failedAttemptsCount += 1; if (_failedAttemptsCount == 1) { @@ -238,10 +238,10 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); CAGradientLayer *gradient = [CAGradientLayer layer]; - gradient.frame = _failedAttemptsView.bounds; + gradient.frame = _failedAttemptsView.bounds; gradient.colors = [NSArray arrayWithObjects: - (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor], - (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil]; + (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor], + (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil]; [_failedAttemptsView.layer insertSublayer:gradient atIndex:0]; _failedAttemptsView.layer.masksToBounds = YES; @@ -268,21 +268,21 @@ - (void)incrementFailedAttemptsLabel - (void)moveToNextTableView { _currentPanel += 1; - + UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel - 1]; UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel]; - - newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, - oldTableView.frame.origin.y, - oldTableView.frame.size.width, - oldTableView.frame.size.height); + + newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, + oldTableView.frame.origin.y, + oldTableView.frame.size.width, + oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } [UIView beginAnimations:@"" context:nil]; - [UIView setAnimationDuration:0.25]; + [UIView setAnimationDuration:0.25]; oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); newTableView.frame = self.view.frame; [UIView commitAnimations]; @@ -296,7 +296,7 @@ - (void)moveToNextTableView - (void)moveToPreviousTableView { _currentPanel -= 1; - + UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel + 1]; UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel]; newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); @@ -306,7 +306,7 @@ - (void)moveToPreviousTableView } [UIView beginAnimations:@"" context:nil]; - [UIView setAnimationDuration:0.25]; + [UIView setAnimationDuration:0.25]; oldTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); newTableView.frame = self.view.frame; [UIView commitAnimations]; @@ -342,7 +342,7 @@ - (void)nextDigitPressed [self dismissModalViewControllerAnimated:YES]; } - } + } } else if (_mode == KKPasscodeModeChange) { NSString* passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { @@ -380,108 +380,108 @@ - (void)nextDigitPressed } } } - } + } } - (void)vaildatePasscode:(UITextField*)textField { - if (_mode == KKPasscodeModeDisabled) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { - [KKKeychain setString:@"" forKey:@"passcode"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (_mode == KKPasscodeModeEnter) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([_enterPasscodeTextField.text isEqualToString:passcode]) { - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [UIView beginAnimations:@"fadeIn" context:nil]; - [UIView setAnimationDelay:0.25]; - [UIView setAnimationDuration:0.5]; - - [UIView commitAnimations]; - } - if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { - [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } else { - [self incrementFailedAttemptsLabel]; - } - } else if (_mode == KKPasscodeModeChange) { - NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; - if ([textField isEqual:_enterPasscodeTextField]) { - if ([passcode isEqualToString:_enterPasscodeTextField.text]) { - [self moveToNextTableView]; - } else { - [self incrementFailedAttemptsLabel]; - } + if (_mode == KKPasscodeModeDisabled) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) { + [KKKeychain setString:@"" forKey:@"passcode"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (_mode == KKPasscodeModeEnter) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([_enterPasscodeTextField.text isEqualToString:passcode]) { + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [UIView beginAnimations:@"fadeIn" context:nil]; + [UIView setAnimationDelay:0.25]; + [UIView setAnimationDuration:0.5]; + + [UIView commitAnimations]; + } + if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if (_mode == KKPasscodeModeChange) { + NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; + if ([textField isEqual:_enterPasscodeTextField]) { + if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [self moveToNextTableView]; + } else { + [self incrementFailedAttemptsLabel]; + } + } else if ([textField isEqual:_setPasscodeTextField]) { + if ([passcode isEqualToString:_setPasscodeTextField.text]) { + _setPasscodeTextField.text = @""; + for (int i = 0; i < kPasscodeBoxesCount; i++) { + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + } + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", ""); + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); + } else { + _passcodeConfirmationWarningLabel.text = @""; + _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); + [self moveToNextTableView]; + } + } else if ([textField isEqual:_confirmPasscodeTextField]) { + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; + } + } } else if ([textField isEqual:_setPasscodeTextField]) { - if ([passcode isEqualToString:_setPasscodeTextField.text]) { - _setPasscodeTextField.text = @""; - for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - } - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", ""); - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); - } else { - _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); [self moveToNextTableView]; - } } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { + _confirmPasscodeTextField.text = @""; + _setPasscodeTextField.text = @""; + _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + [self moveToPreviousTableView]; + } else { + if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { + [KKKeychain setString:@"YES" forKey:@"passcode_on"]; + } + + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; + } + + [self dismissModalViewControllerAnimated:YES]; } - - [self dismissModalViewControllerAnimated:YES]; - } } - } else if ([textField isEqual:_setPasscodeTextField]) { - [self moveToNextTableView]; - } else if ([textField isEqual:_confirmPasscodeTextField]) { - if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { - _confirmPasscodeTextField.text = @""; - _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); - [self moveToPreviousTableView]; - } else { - if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { - [KKKeychain setString:@"YES" forKey:@"passcode_on"]; - } - - if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { - [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; - } - - [self dismissModalViewControllerAnimated:YES]; - } - } } - (void)doneButtonPressed -{ +{ UITextField *textField = [_textFields objectAtIndex:_currentPanel]; [self vaildatePasscode:textField]; } @@ -489,7 +489,7 @@ - (void)doneButtonPressed - (UIView*)headerViewForTextField:(UITextField*)textField { - [self.view addSubview:textField]; + [self.view addSubview:textField]; UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)]; UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; @@ -529,7 +529,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _failedAttemptsLabel.hidden = YES; _failedAttemptsView.hidden = YES; - + _failedAttemptsView.layer.masksToBounds = YES; [headerView addSubview:_failedAttemptsView]; @@ -557,7 +557,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } else { headerLabel.text = NSLocalizedString(@"Enter your passcode", ""); } - + headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; [headerView addSubview:headerLabel]; @@ -636,23 +636,23 @@ - (BOOL)textFieldShouldReturn:(UITextField*)textField - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string { - NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; - textField.text = result; - - for (int i = 0; i < kPasscodeBoxesCount; i++) { - UIImageView *square = [[_boxes objectAtIndex:_currentPanel] objectAtIndex:i]; - if (i < [result length]) { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; - } else { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; + NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string]; + textField.text = result; + + for (int i = 0; i < kPasscodeBoxesCount; i++) { + UIImageView *square = [[_boxes objectAtIndex:_currentPanel] objectAtIndex:i]; + if (i < [result length]) { + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; + } else { + square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; + } } - } - - if ([result length] == kPasscodeBoxesCount) { - [self vaildatePasscode:textField]; - } - - return NO; + + if ([result length] == kPasscodeBoxesCount) { + [self vaildatePasscode:textField]; + } + + return NO; } From f6b57a5c87e7e8abcb6cc593689d1ab838cfa78e Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sun, 2 Sep 2012 21:36:10 -0400 Subject: [PATCH 30/62] fixed llvm compiler warnings --- src/KKKeychain.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/KKKeychain.m b/src/KKKeychain.m index 8009e3f..0e28cd0 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -58,16 +58,16 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key [addDict setObject:data forKey:(__bridge id)kSecValueData]; res = SecItemAdd((__bridge_retained CFDictionaryRef)addDict, NULL); - NSAssert1(res == errSecSuccess, @"Recieved %d from SecItemAdd!", res); + NSAssert1(res == errSecSuccess, @"Recieved %ld from SecItemAdd!", res); } } else if (res == errSecSuccess) { // Modify an existing one // Actually pull it now of the keychain at this point. NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(__bridge id)kSecValueData]; res = SecItemUpdate((__bridge_retained CFDictionaryRef)existsQueryDictionary, (__bridge_retained CFDictionaryRef)attributeDict); - NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %d!", res); + NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %ld!", res); } else { - NSAssert1(NO, @"Received %d from SecItemCopyMatching!", res); + NSAssert1(NO, @"Received %ld from SecItemCopyMatching!", res); } return YES; } @@ -93,7 +93,7 @@ + (NSString*)getStringForKey:(NSString*)key NSString *string = [[NSString alloc] initWithData:(__bridge NSData*)data encoding:NSUTF8StringEncoding]; return string; } else { - NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %d!", res); + NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %ld!", res); } return nil; From 65cb2507b0224990c036594354140daa2b7a364c Mon Sep 17 00:00:00 2001 From: Hannes Kaeufler Date: Wed, 7 Nov 2012 14:25:18 +0100 Subject: [PATCH 31/62] Added german translation --- .../de.lproj/Localizable.strings | Bin 0 -> 3214 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/KKPasscodeLock.bundle/de.lproj/Localizable.strings diff --git a/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..b67e3e9554f19a6e60c716d4c1b4fbc4ccf62027 GIT binary patch literal 3214 zcmchZ&2G~`6ov1ar?4V*StQnoMJXv_(<0Ih?A*j{B2uSH9HR2PJOe8PoNsQYGl^3t zsSvW9c5cB5oj!aywt?Mg z##|Tkm|faeYiwfQbn~T>&7Qrs7dw40Z!&uB_u6g(mQ5CI+lBqmY%s$+V(e=K zfB3x9Q=>br^*3-TY-&G)O5-(-1C1Je?ec#i%YDrm==ajT==c25e~QB_sNQYKBXnpS z`oiA?-uqZDG;^XA=z66)Y4u7R&ZN&oT2xZ9ZLP2qdBWGNGNs9s^tF{@HdU?=gM~71 zsBw(Mk?bC7f022J>$mx+9=&YFX(68@d4^4`JSUd7ArHXzQlm>@z1M#!Mc`iRZOV{X z8`xRtyH`N*$Pp`426@NI!rp4^8lg0~SV;-|uIu9SqdIvEOU(r{Rf+{>vi?r~^Ge3s zXK`BUf2eP@E@#M^W4-shZ-kNjUue#4cxqcpjC1@cN62n?#_RzTn#GFqaa1eL0%2S? zvR~o?BUaY3hIa6B?NF`~MzYImFuvcW;wspQs&7;AJ}5Jn{Y|!s>w8)88b~-l$a{?P zCZBD7h}K~qy#BT;7Cn3tvg5!pR`zrGL=|%`c~&}_=(n%Pv^~yL)l|@7JaZ*WS->u_ z&yi4X-M*=x)xo}VjlBZ9eRt{oJOnxWrx0|-A?;geH&YOf=3~0*Ls(F`eqDSk@xh)TK_xOSL(Ddw{@myw0pd3>p0U+>u((;Sx7COJfK|P zZRxmvrilHFy`O$bCy5#9dlEgT5T82e;b)bh7__q!ZDzW>pp~l(KE`wp=LtjhO|&1aX&5^oYht%)SLOH6$2ldyg_up{!L|2n zrW>b@obd0bI305?WR4a)DF#iz`~M@5I`JVIjdjvnN}-9=*iWgLT`}IfTHRhimlbK|1ipWXF$^TUIsXuZkUvVWX?44jD&!qcb DQv@E9 literal 0 HcmV?d00001 From 576e96155ead1f75d842afe7299b469a5656bed9 Mon Sep 17 00:00:00 2001 From: Hannes Kaeufler Date: Wed, 7 Nov 2012 14:46:19 +0100 Subject: [PATCH 32/62] fixed German translation --- .../de.lproj/Localizable.strings | Bin 3214 -> 3220 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings index b67e3e9554f19a6e60c716d4c1b4fbc4ccf62027..3e4ecdc44d0133c8146f59f8ad6c84682575194d 100644 GIT binary patch delta 38 pcmeB^oFciQkWn(9A%!88L4hF+NES1cFysK~bRf>#+``Dk4FI`w2=V{` delta 32 kcmbOt*(bT7kWtv5!G*z Date: Thu, 8 Nov 2012 16:44:24 +0100 Subject: [PATCH 33/62] reworked localized strings to use the strings file in the bundle, fixed localization issues --- example/KKPasscodeLock/Localizable.strings | 1 - .../NSBundle+KKPasscodeLockAdditions.h | 17 ++++++++ .../NSBundle+KKPasscodeLockAdditions.m | 23 ++++++++++ .../KKPasscodeLock/SettingsViewController.m | 8 ++-- .../de.lproj/Localizable.strings | 11 +++++ .../en.lproj/Localizable.strings | 11 +++++ .../project.pbxproj | 25 +++++++++-- ...lizable.strings => KKPasscodeLock.strings} | Bin 3220 -> 2662 bytes ...lizable.strings => KKPasscodeLock.strings} | Bin 2804 -> 2560 bytes ...lizable.strings => KKPasscodeLock.strings} | Bin src/KKPasscodeSettingsViewController.m | 17 ++++---- src/KKPasscodeViewController.m | 41 +++++++++--------- 12 files changed, 117 insertions(+), 37 deletions(-) delete mode 100644 example/KKPasscodeLock/Localizable.strings create mode 100644 example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h create mode 100644 example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m create mode 100644 example/KKPasscodeLock/de.lproj/Localizable.strings create mode 100644 example/KKPasscodeLock/en.lproj/Localizable.strings rename src/KKPasscodeLock.bundle/de.lproj/{Localizable.strings => KKPasscodeLock.strings} (68%) rename src/KKPasscodeLock.bundle/en.lproj/{Localizable.strings => KKPasscodeLock.strings} (89%) rename src/KKPasscodeLock.bundle/nl.lproj/{Localizable.strings => KKPasscodeLock.strings} (100%) diff --git a/example/KKPasscodeLock/Localizable.strings b/example/KKPasscodeLock/Localizable.strings deleted file mode 100644 index b6a4846..0000000 --- a/example/KKPasscodeLock/Localizable.strings +++ /dev/null @@ -1 +0,0 @@ -"Passcode Lock" = "Passcode Lock"; diff --git a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h new file mode 100644 index 0000000..4498ea2 --- /dev/null +++ b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h @@ -0,0 +1,17 @@ +// +// NSBundle+KKPasscodeLockAdditions.h +// KKPasscodeLockDemo +// +// Created by Hannes Käufler on 08.11.12. +// Copyright (c) 2012 Kosher Penguin LLC. All rights reserved. +// + +#import + +#define KKPasscodeLockLocalizedString(key, comment) [[NSBundle KKPasscodeLockBundle] localizedStringForKey:(key) value:@"" table:@"KKPasscodeLock"] + +@interface NSBundle (KKPasscodeLockAdditions) + ++(NSBundle *)KKPasscodeLockBundle; + +@end diff --git a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m new file mode 100644 index 0000000..fde445c --- /dev/null +++ b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m @@ -0,0 +1,23 @@ +// +// NSBundle+KKPasscodeLockAdditions.m +// KKPasscodeLockDemo +// +// Created by Hannes Käufler on 08.11.12. +// Copyright (c) 2012 Kosher Penguin LLC. All rights reserved. +// + +#import "NSBundle+KKPasscodeLockAdditions.h" + +@implementation NSBundle (KKPasscodeLockAdditions) + ++ (NSBundle *)KKPasscodeLockBundle { + static NSBundle *bundle = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"KKPasscodeLock.bundle"]; + bundle = [[NSBundle alloc] initWithPath:bundlePath]; + }); + return bundle; +} + +@end diff --git a/example/KKPasscodeLock/SettingsViewController.m b/example/KKPasscodeLock/SettingsViewController.m index 0f2cc09..87494eb 100755 --- a/example/KKPasscodeLock/SettingsViewController.m +++ b/example/KKPasscodeLock/SettingsViewController.m @@ -33,7 +33,7 @@ - (void)doneButtonPressed:(id)sender { - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = NSLocalizedString(@"Settings", ""); + self.navigationItem.title = NSLocalizedString(@"Settings", nil); UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]; @@ -65,11 +65,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } if (indexPath.section == 0) { - cell.textLabel.text = NSLocalizedString(@"Passcode Lock", ""); + cell.textLabel.text = NSLocalizedString(@"Passcode Lock", nil); if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) { - cell.detailTextLabel.text = NSLocalizedString(@"On", ""); + cell.detailTextLabel.text = NSLocalizedString(@"On", nil); } else { - cell.detailTextLabel.text = NSLocalizedString(@"Off", ""); + cell.detailTextLabel.text = NSLocalizedString(@"Off", nil); } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } diff --git a/example/KKPasscodeLock/de.lproj/Localizable.strings b/example/KKPasscodeLock/de.lproj/Localizable.strings new file mode 100644 index 0000000..e1feb6e --- /dev/null +++ b/example/KKPasscodeLock/de.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"Passcode Lock" = "Code-Sperre"; + +/* No comment provided by engineer. */ +"Off" = "Aus"; + +/* No comment provided by engineer. */ +"On" = "An"; + +/* No comment provided by engineer. */ +"Settings" = "Einstellungen"; + diff --git a/example/KKPasscodeLock/en.lproj/Localizable.strings b/example/KKPasscodeLock/en.lproj/Localizable.strings new file mode 100644 index 0000000..14fa401 --- /dev/null +++ b/example/KKPasscodeLock/en.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"Passcode Lock" = "Passcode Lock"; + +/* No comment provided by engineer. */ +"Off" = "Off"; + +/* No comment provided by engineer. */ +"On" = "On"; + +/* No comment provided by engineer. */ +"Settings" = "Settings"; + diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index f2a369c..275574d 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 26C69D30164C00540022396E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 26C69D32164C00540022396E /* Localizable.strings */; }; + 26C69D37164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 26C69D36164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.m */; }; 6D3E345214C4F54E0003B72B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345114C4F54E0003B72B /* UIKit.framework */; }; 6D3E345414C4F54E0003B72B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345314C4F54E0003B72B /* Foundation.framework */; }; 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */; }; @@ -17,7 +19,6 @@ 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */; }; 6D3E34CF14C4F9910003B72B /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E34CC14C4F9910003B72B /* RootViewController.m */; }; 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D3E34CD14C4F9910003B72B /* RootViewController.xib */; }; - 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6DE61E6614E091FC008E1DB0 /* Localizable.strings */; }; 6DF13A5B14C686FC0069BBA5 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */; }; 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */; }; 6DF13A6914C6870B0069BBA5 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */; }; @@ -29,6 +30,10 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 26C69D31164C00540022396E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 26C69D34164C00600022396E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = ""; }; + 26C69D35164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBundle+KKPasscodeLockAdditions.h"; sourceTree = ""; }; + 26C69D36164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+KKPasscodeLockAdditions.m"; sourceTree = ""; }; 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -44,7 +49,6 @@ 6D3E34CB14C4F9910003B72B /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 6D3E34CC14C4F9910003B72B /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 6D3E34CD14C4F9910003B72B /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; }; - 6DE61E6614E091FC008E1DB0 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; 6DF13A5814C686FC0069BBA5 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsViewController.xib; sourceTree = ""; }; @@ -96,7 +100,7 @@ 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */, 6D3E345D14C4F54E0003B72B /* main.m */, 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */, - 6DE61E6614E091FC008E1DB0 /* Localizable.strings */, + 26C69D32164C00540022396E /* Localizable.strings */, ); name = "Supporting Files"; sourceTree = ""; @@ -144,6 +148,8 @@ 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */, 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */, 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */, + 26C69D35164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.h */, + 26C69D36164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.m */, ); path = KKPasscodeLock; sourceTree = ""; @@ -212,6 +218,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + de, ); mainGroup = 6D3E344214C4F54D0003B72B; productRefGroup = 6D3E344E14C4F54E0003B72B /* Products */; @@ -232,7 +239,7 @@ 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */, 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, - 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */, + 26C69D30164C00540022396E /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -251,12 +258,22 @@ 6DF13A6A14C6870B0069BBA5 /* KKPasscodeLock.m in Sources */, 6DF13A6B14C6870B0069BBA5 /* KKPasscodeSettingsViewController.m in Sources */, 6DF13A6C14C6870B0069BBA5 /* KKPasscodeViewController.m in Sources */, + 26C69D37164C00A70022396E /* NSBundle+KKPasscodeLockAdditions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ + 26C69D32164C00540022396E /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 26C69D31164C00540022396E /* en */, + 26C69D34164C00600022396E /* de */, + ); + name = Localizable.strings; + sourceTree = ""; + }; 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( diff --git a/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/de.lproj/KKPasscodeLock.strings similarity index 68% rename from src/KKPasscodeLock.bundle/de.lproj/Localizable.strings rename to src/KKPasscodeLock.bundle/de.lproj/KKPasscodeLock.strings index 3e4ecdc44d0133c8146f59f8ad6c84682575194d..c9b03b291284c406e6865583960676d58110a476 100644 GIT binary patch delta 149 zcmbOt`AkIN-+u-!1|^07hD3&9AWUY+XGmd4Wl&)70kV=AvL|*ZvMMoHGjMH|;g)8c zoXMj-*@(w{@@e*O6H}EoD$ikLbeZTSKRJ_?XEQU?1SatqhCGH~hD@*#DGYxYiWt&> v?7YcaSd=;Qfa1vv84M+p`ean9R(xBV$2`IeYTToo8O^(#c ECyY*bKL7v# diff --git a/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/en.lproj/KKPasscodeLock.strings similarity index 89% rename from src/KKPasscodeLock.bundle/en.lproj/Localizable.strings rename to src/KKPasscodeLock.bundle/en.lproj/KKPasscodeLock.strings index 0fc380b46e9d95c5f81ce71f2ae54fcd1bc409b4..6d3ee106570f8aa7494b2b73696ded4e4eb2c976 100644 GIT binary patch delta 27 jcmew&+90yQk7e^57AIy#uF2;)B`5oEN^Rc2VZ#Iff%OP- delta 34 lcmZn=`69Z(k7aTTv)^Vv7ANM(4_N1Ip1@wf#KFY?fdI|Z2~+?8 diff --git a/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/nl.lproj/KKPasscodeLock.strings similarity index 100% rename from src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings rename to src/KKPasscodeLock.bundle/nl.lproj/KKPasscodeLock.strings diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index e5f7c57..26092be 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -19,6 +19,7 @@ #import "KKKeychain.h" #import "KKPasscodeViewController.h" #import "KKPasscodeLock.h" +#import "NSBundle+KKPasscodeLockAdditions.h" @implementation KKPasscodeSettingsViewController @@ -32,7 +33,7 @@ @implementation KKPasscodeSettingsViewController - (void)viewDidLoad { [super viewDidLoad]; - self.navigationItem.title = NSLocalizedString(@"Passcode Lock", @""); + self.navigationItem.title = KKPasscodeLockLocalizedString(@"Passcode Lock", @""); _eraseDataSwitch = [[UISwitch alloc] init]; [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged]; @@ -77,9 +78,9 @@ - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger) - (void)eraseDataSwitchChanged:(id)sender { if (_eraseDataSwitch.on) { - NSString* title = [NSString stringWithFormat:NSLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; + NSString* title = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:NSLocalizedString(@"Cancel", @"") destructiveButtonTitle:NSLocalizedString(@"Enable", @"") otherButtonTitles:nil]; + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:KKPasscodeLockLocalizedString(@"Cancel", @"") destructiveButtonTitle:KKPasscodeLockLocalizedString(@"Enable", @"") otherButtonTitles:nil]; [sheet showInView:self.view]; } else { _eraseDataOn = NO; @@ -107,7 +108,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { if (section == 2) { - return [NSString stringWithFormat:NSLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; + return [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; } @@ -131,19 +132,19 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI if (indexPath.section == 0) { cell.textLabel.textAlignment = UITextAlignmentCenter; if (_passcodeLockOn) { - cell.textLabel.text = NSLocalizedString(@"Turn Passcode Off", @""); + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode Off", @""); } else { - cell.textLabel.text = NSLocalizedString(@"Turn Passcode On", @""); + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode On", @""); } } else if (indexPath.section == 1) { - cell.textLabel.text = NSLocalizedString(@"Change Passcode", @""); + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Change Passcode", @""); cell.textLabel.textAlignment = UITextAlignmentCenter; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; } } else if (indexPath.section == 2) { - cell.textLabel.text = NSLocalizedString(@"Erase Data", @""); + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Erase Data", @""); cell.accessoryView = _eraseDataSwitch; cell.selectionStyle = UITableViewCellSelectionStyleNone; if (_passcodeLockOn) { diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index c00dfa8..d64b3ac 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -19,6 +19,7 @@ #import "KKKeychain.h" #import "KKPasscodeSettingsViewController.h" #import "KKPasscodeLock.h" +#import "NSBundle+KKPasscodeLockAdditions.h" #import #import @@ -108,24 +109,24 @@ - (void)viewWillAppear:(BOOL)animated if (_mode == KKPasscodeModeSet) { - self.navigationItem.title = NSLocalizedString(@"Set Passcode", @""); + self.navigationItem.title = KKPasscodeLockLocalizedString(@"Set Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeChange) { - self.navigationItem.title = NSLocalizedString(@"Change Passcode", @""); + self.navigationItem.title = KKPasscodeLockLocalizedString(@"Change Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else if (_mode == KKPasscodeModeDisabled) { - self.navigationItem.title = NSLocalizedString(@"Turn off Passcode", @""); + self.navigationItem.title = KKPasscodeLockLocalizedString(@"Turn off Passcode", @""); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelButtonPressed:)]; } else { - self.navigationItem.title = NSLocalizedString(@"Enter Passcode", @""); + self.navigationItem.title = KKPasscodeLockLocalizedString(@"Enter Passcode", @""); } @@ -240,9 +241,9 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsCount += 1; if (_failedAttemptsCount == 1) { - _failedAttemptsLabel.text = NSLocalizedString(@"1 Failed Passcode Attempt", @""); + _failedAttemptsLabel.text = KKPasscodeLockLocalizedString(@"1 Failed Passcode Attempt", @""); } else { - _failedAttemptsLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%i Failed Passcode Attempts", @""), _failedAttemptsCount]; + _failedAttemptsLabel.text = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"%i Failed Passcode Attempts", @""), _failedAttemptsCount]; } CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); @@ -342,7 +343,7 @@ - (void)nextDigitPressed if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -367,7 +368,7 @@ - (void)nextDigitPressed } else if ([textField isEqual:_setPasscodeTextField]) { if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -378,7 +379,7 @@ - (void)nextDigitPressed if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", ""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", ""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -445,7 +446,7 @@ - (void)vaildatePasscode:(UITextField*)textField for (int i = 0; i < kPasscodeBoxesCount; i++) { [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Enter a different passcode. Cannot re-use the same passcode.", @""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; @@ -456,7 +457,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -476,7 +477,7 @@ - (void)vaildatePasscode:(UITextField*)textField if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) { _confirmPasscodeTextField.text = @""; _setPasscodeTextField.text = @""; - _passcodeConfirmationWarningLabel.text = NSLocalizedString(@"Passcodes did not match. Try again.", @""); + _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @""); [self moveToPreviousTableView]; } else { if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) { @@ -551,24 +552,24 @@ - (UIView*)headerViewForTextField:(UITextField*)textField if (_mode == KKPasscodeModeSet) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter a passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter a passcode", @""); } else if ([textField isEqual:_confirmPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Re-enter your passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your passcode", @""); } } else if (_mode == KKPasscodeModeDisabled) { - headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); } else if (_mode == KKPasscodeModeChange) { if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your old passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your old passcode", @""); } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = NSLocalizedString(@"Enter your new passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your new passcode", @""); } else { - headerLabel.text = NSLocalizedString(@"Re-enter your new passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your new passcode", @""); } } else { - headerLabel.text = NSLocalizedString(@"Enter your passcode", @""); + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); } headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; From e0347c2f7ec312339e59a8b99e869824670a8ca0 Mon Sep 17 00:00:00 2001 From: Yusuke Obayashi Date: Thu, 15 Nov 2012 10:36:58 +0900 Subject: [PATCH 34/62] fixed warnings in ios 6 --- src/KKPasscodeSettingsViewController.m | 35 ++++++++++++-- src/KKPasscodeViewController.m | 64 +++++++++++++++++++++++--- 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index e5f7c57..68836c2 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -124,12 +124,24 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI cell.accessoryView = nil; cell.selectionStyle = UITableViewCellSelectionStyleBlue; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 cell.textLabel.textAlignment = UITextAlignmentLeft; +#else + cell.textLabel.textAlignment = NSTextAlignmentLeft; +#endif + cell.textLabel.textColor = [UIColor blackColor]; if (indexPath.section == 0) { - cell.textLabel.textAlignment = UITextAlignmentCenter; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + cell.textLabel.textAlignment = UITextAlignmentCenter; +#else + cell.textLabel.textAlignment = NSTextAlignmentCenter; +#endif + if (_passcodeLockOn) { cell.textLabel.text = NSLocalizedString(@"Turn Passcode Off", @""); } else { @@ -137,7 +149,13 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI } } else if (indexPath.section == 1) { cell.textLabel.text = NSLocalizedString(@"Change Passcode", @""); - cell.textLabel.textAlignment = UITextAlignmentCenter; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + cell.textLabel.textAlignment = UITextAlignmentCenter; +#else + cell.textLabel.textAlignment = NSTextAlignmentCenter; +#endif + cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; @@ -187,8 +205,11 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } - [self.navigationController presentModalViewController:nav animated:YES]; - +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + [self.navigationController presentModalViewController:nav animated:YES]; +#else + [self.navigationController presentViewController:nav animated:YES completion:nil]; +#endif } else if (indexPath.section == 1 && _passcodeLockOn) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; @@ -210,7 +231,11 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle; } - [self.navigationController presentModalViewController:nav animated:YES]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + [self.navigationController presentModalViewController:nav animated:YES]; +#else + [self.navigationController presentViewController:nav animated:YES completion:nil]; +#endif [tableView deselectRowAtIndexPath:indexPath animated:YES]; } } diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index c00dfa8..d41bef8 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -225,7 +225,11 @@ - (void)viewWillDisappear:(BOOL)animated { - (void)cancelButtonPressed:(id)sender { - [self dismissModalViewControllerAnimated:YES]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } @@ -353,7 +357,11 @@ - (void)nextDigitPressed [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } - [self dismissModalViewControllerAnimated:YES]; +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } } } else if (_mode == KKPasscodeModeChange) { @@ -388,8 +396,12 @@ - (void)nextDigitPressed if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } - - [self dismissModalViewControllerAnimated:YES]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 + [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } } } @@ -409,7 +421,11 @@ - (void)vaildatePasscode:(UITextField*)textField [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } else { [self incrementFailedAttemptsLabel]; } @@ -426,8 +442,12 @@ - (void)vaildatePasscode:(UITextField*)textField if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; } - + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } else { [self incrementFailedAttemptsLabel]; } @@ -466,8 +486,12 @@ - (void)vaildatePasscode:(UITextField*)textField if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } - + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } } } else if ([textField isEqual:_setPasscodeTextField]) { @@ -487,7 +511,11 @@ - (void)vaildatePasscode:(UITextField*)textField [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 [self dismissModalViewControllerAnimated:YES]; +#else + [self dismissViewControllerAnimated:YES completion:nil]; +#endif } } } @@ -507,7 +535,13 @@ - (UIView*)headerViewForTextField:(UITextField*)textField UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 headerLabel.textAlignment = UITextAlignmentCenter; +#else + headerLabel.textAlignment = NSTextAlignmentCenter; +#endif + headerLabel.font = [UIFont boldSystemFontOfSize:17.0]; headerLabel.shadowOffset = CGSizeMake(0, 1.0); headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; @@ -516,13 +550,25 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0)]; _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 _passcodeConfirmationWarningLabel.textAlignment = UITextAlignmentCenter; +#else + _passcodeConfirmationWarningLabel.textAlignment = NSTextAlignmentCenter; +#endif + _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0]; _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0); _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; _passcodeConfirmationWarningLabel.text = @""; _passcodeConfirmationWarningLabel.numberOfLines = 0; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 _passcodeConfirmationWarningLabel.lineBreakMode = UILineBreakModeWordWrap; +#else + _passcodeConfirmationWarningLabel.lineBreakMode = NSLineBreakByWordWrapping; +#endif + [headerView addSubview:_passcodeConfirmationWarningLabel]; } @@ -533,7 +579,13 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _failedAttemptsLabel.textColor = [UIColor whiteColor]; _failedAttemptsLabel.text = @""; _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:14.0]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 _failedAttemptsLabel.textAlignment = UITextAlignmentCenter; +#else + _failedAttemptsLabel.textAlignment = NSTextAlignmentCenter; +#endif + _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; _failedAttemptsView.layer.cornerRadius = 14; From 138f41f3330670eb2044ae97d2c2cc80bb8cf86d Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 24 Nov 2012 10:16:39 -0500 Subject: [PATCH 35/62] fixed iOS 6 deprecated warnings --- example/Default-568h@2x.png | Bin 0 -> 18594 bytes example/KKPasscodeLock/RootViewController.xib | 85 +++--------------- .../project.pbxproj | 4 + 3 files changed, 18 insertions(+), 71 deletions(-) create mode 100644 example/Default-568h@2x.png diff --git a/example/Default-568h@2x.png b/example/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 diff --git a/example/KKPasscodeLock/RootViewController.xib b/example/KKPasscodeLock/RootViewController.xib index 114be7c..401cc80 100755 --- a/example/KKPasscodeLock/RootViewController.xib +++ b/example/KKPasscodeLock/RootViewController.xib @@ -1,21 +1,21 @@ - 1280 - 11C74 - 1938 - 1138.23 - 567.00 + 1536 + 12C3006 + 2844 + 1187.34 + 625.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin - 933 + 1930 YES + IBProxyObject IBUIButton - IBUIView IBUILabel - IBProxyObject + IBUIView YES @@ -46,14 +46,13 @@ {{53, 132}, {215, 37}} - NO IBCocoaTouchFramework 0 0 1 Show Settings Controller - + 3 MQA @@ -155,70 +154,14 @@ 14 16 + 280 {{0, 20}, {320, 460}} - - 10 - - 549453824 - {512, 1} - - YES - - YES - - - - TU0AKgAACAjFzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ -xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ -y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ -xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ -y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ -xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ -y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ -xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/ -y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/ -y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/ -xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/ -xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/ -xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/ -xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/ -xczS/8vS2P/L0tj/xczU/wANAQAAAwAAAAECAAAAAQEAAwAAAAEAAQAAAQIAAwAAAAQAAAiqAQMAAwAA -AAEAAQAAAQYAAwAAAAEAAgAAAREABAAAAAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEABAAAARYAAwAA -AAEAAQAAARcABAAAAAEAAAgAARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAQAAAiyAAAAAAAI -AAgACAAIAAEAAQABAAE - - - - - - - groupTableViewBackgroundColor - + IBCocoaTouchFramework @@ -307,7 +250,7 @@ AAgACAAIAAEAAQABAAE 8.IBPluginDependency 9.IBPluginDependency - + YES RootViewController com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -361,7 +304,7 @@ AAgACAAIAAEAAQABAAE IBCocoaTouchFramework com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS - + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 @@ -369,6 +312,6 @@ AAgACAAIAAEAAQABAAE YES 3 - 933 + 1930 diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index f2a369c..03c7b35 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5303095E16611BF90004810F /* Default-568h@2x.png */; }; 6D3E345214C4F54E0003B72B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345114C4F54E0003B72B /* UIKit.framework */; }; 6D3E345414C4F54E0003B72B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345314C4F54E0003B72B /* Foundation.framework */; }; 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */; }; @@ -29,6 +30,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5303095E16611BF90004810F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -104,6 +106,7 @@ 6D3E344214C4F54D0003B72B = { isa = PBXGroup; children = ( + 5303095E16611BF90004810F /* Default-568h@2x.png */, 6D3E345714C4F54E0003B72B /* KKPasscodeLock */, 6D2F0BD414C51CCA00C1862D /* Demo App */, 6D3E345014C4F54E0003B72B /* Frameworks */, @@ -233,6 +236,7 @@ 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */, + 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 246c4eceb4c42f15e1920f64cb4c6dc8e5a38473 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 24 Nov 2012 11:05:40 -0500 Subject: [PATCH 36/62] Reworked localization to work with the provided bundle --- .../NSBundle+KKPasscodeLockAdditions.h | 17 ------ .../NSBundle+KKPasscodeLockAdditions.m | 23 ------- .../KKPasscodeLock/de.lproj/InfoPlist.strings | 2 + .../KKPasscodeLock/nl.lproj/InfoPlist.strings | 2 + .../project.pbxproj | 10 ++-- ...sscodeLock.strings => Localizable.strings} | Bin ...sscodeLock.strings => Localizable.strings} | Bin ...sscodeLock.strings => Localizable.strings} | Bin src/KKPasscodeLock.h | 7 +++ src/KKPasscodeLock.m | 14 +++++ src/KKPasscodeSettingsViewController.m | 2 +- src/KKPasscodeViewController.m | 1 - .../project.pbxproj | 56 +++++++++--------- 13 files changed, 60 insertions(+), 74 deletions(-) delete mode 100644 example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h delete mode 100644 example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m create mode 100644 example/KKPasscodeLock/de.lproj/InfoPlist.strings create mode 100644 example/KKPasscodeLock/nl.lproj/InfoPlist.strings rename src/KKPasscodeLock.bundle/de.lproj/{KKPasscodeLock.strings => Localizable.strings} (100%) rename src/KKPasscodeLock.bundle/en.lproj/{KKPasscodeLock.strings => Localizable.strings} (100%) rename src/KKPasscodeLock.bundle/nl.lproj/{KKPasscodeLock.strings => Localizable.strings} (100%) diff --git a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h deleted file mode 100644 index 4498ea2..0000000 --- a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// NSBundle+KKPasscodeLockAdditions.h -// KKPasscodeLockDemo -// -// Created by Hannes Käufler on 08.11.12. -// Copyright (c) 2012 Kosher Penguin LLC. All rights reserved. -// - -#import - -#define KKPasscodeLockLocalizedString(key, comment) [[NSBundle KKPasscodeLockBundle] localizedStringForKey:(key) value:@"" table:@"KKPasscodeLock"] - -@interface NSBundle (KKPasscodeLockAdditions) - -+(NSBundle *)KKPasscodeLockBundle; - -@end diff --git a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m b/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m deleted file mode 100644 index fde445c..0000000 --- a/example/KKPasscodeLock/NSBundle+KKPasscodeLockAdditions.m +++ /dev/null @@ -1,23 +0,0 @@ -// -// NSBundle+KKPasscodeLockAdditions.m -// KKPasscodeLockDemo -// -// Created by Hannes Käufler on 08.11.12. -// Copyright (c) 2012 Kosher Penguin LLC. All rights reserved. -// - -#import "NSBundle+KKPasscodeLockAdditions.h" - -@implementation NSBundle (KKPasscodeLockAdditions) - -+ (NSBundle *)KKPasscodeLockBundle { - static NSBundle *bundle = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"KKPasscodeLock.bundle"]; - bundle = [[NSBundle alloc] initWithPath:bundlePath]; - }); - return bundle; -} - -@end diff --git a/example/KKPasscodeLock/de.lproj/InfoPlist.strings b/example/KKPasscodeLock/de.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/example/KKPasscodeLock/de.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/example/KKPasscodeLock/nl.lproj/InfoPlist.strings b/example/KKPasscodeLock/nl.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/example/KKPasscodeLock/nl.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index 03c7b35..073a5a4 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -18,7 +18,6 @@ 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */; }; 6D3E34CF14C4F9910003B72B /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E34CC14C4F9910003B72B /* RootViewController.m */; }; 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D3E34CD14C4F9910003B72B /* RootViewController.xib */; }; - 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6DE61E6614E091FC008E1DB0 /* Localizable.strings */; }; 6DF13A5B14C686FC0069BBA5 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */; }; 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */; }; 6DF13A6914C6870B0069BBA5 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */; }; @@ -31,6 +30,8 @@ /* Begin PBXFileReference section */ 5303095E16611BF90004810F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 5303097E16611F510004810F /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = ""; }; + 5303097F16611F580004810F /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = ""; }; 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -46,7 +47,6 @@ 6D3E34CB14C4F9910003B72B /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; 6D3E34CC14C4F9910003B72B /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; }; 6D3E34CD14C4F9910003B72B /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; }; - 6DE61E6614E091FC008E1DB0 /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; 6DF13A5814C686FC0069BBA5 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; }; 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; }; 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsViewController.xib; sourceTree = ""; }; @@ -98,7 +98,6 @@ 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */, 6D3E345D14C4F54E0003B72B /* main.m */, 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */, - 6DE61E6614E091FC008E1DB0 /* Localizable.strings */, ); name = "Supporting Files"; sourceTree = ""; @@ -215,6 +214,8 @@ hasScannedForEncodings = 0; knownRegions = ( en, + nl, + de, ); mainGroup = 6D3E344214C4F54D0003B72B; productRefGroup = 6D3E344E14C4F54E0003B72B /* Products */; @@ -235,7 +236,6 @@ 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */, 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, - 6DE61E6714E091FC008E1DB0 /* Localizable.strings in Resources */, 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -265,6 +265,8 @@ isa = PBXVariantGroup; children = ( 6D3E345B14C4F54E0003B72B /* en */, + 5303097E16611F510004810F /* nl */, + 5303097F16611F580004810F /* de */, ); name = InfoPlist.strings; sourceTree = ""; diff --git a/src/KKPasscodeLock.bundle/de.lproj/KKPasscodeLock.strings b/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings similarity index 100% rename from src/KKPasscodeLock.bundle/de.lproj/KKPasscodeLock.strings rename to src/KKPasscodeLock.bundle/de.lproj/Localizable.strings diff --git a/src/KKPasscodeLock.bundle/en.lproj/KKPasscodeLock.strings b/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings similarity index 100% rename from src/KKPasscodeLock.bundle/en.lproj/KKPasscodeLock.strings rename to src/KKPasscodeLock.bundle/en.lproj/Localizable.strings diff --git a/src/KKPasscodeLock.bundle/nl.lproj/KKPasscodeLock.strings b/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings similarity index 100% rename from src/KKPasscodeLock.bundle/nl.lproj/KKPasscodeLock.strings rename to src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 880c37b..b33122f 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -15,9 +15,12 @@ // limitations under the License. // +#define KKPasscodeLockLocalizedString(key, comment) [[KKPasscodeLock sharedLock] localizedStringForKey:(key) value:@""] + #import #import "KKPasscodeViewController.h" + @interface KKPasscodeLock : NSObject { // whatever the erase option is enabled in the passcode settings @@ -37,6 +40,10 @@ */ - (BOOL)isPasscodeRequired; +/** + * returns a localized string from the framework's bundle + */ +- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value NS_FORMAT_ARGUMENT(1); /** * set the initial settings of the passcode settings diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 5aed4cc..a04e2ec 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -55,5 +55,19 @@ - (void)setDefaultSettings } } +- (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value +{ + static NSBundle *bundle = nil; + if (bundle == nil) + { + NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"KKPasscodeLock" ofType:@"bundle"]; + bundle = [NSBundle bundleWithPath:bundlePath] ?: [NSBundle mainBundle]; + } + + value = [bundle localizedStringForKey:key value:value table:nil]; + return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; +} + + @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index a03dbc5..a37f9b8 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -19,7 +19,6 @@ #import "KKKeychain.h" #import "KKPasscodeViewController.h" #import "KKPasscodeLock.h" -#import "NSBundle+KKPasscodeLockAdditions.h" @implementation KKPasscodeSettingsViewController @@ -156,6 +155,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI #else cell.textLabel.textAlignment = NSTextAlignmentCenter; #endif + cell.selectionStyle = UITableViewCellSelectionStyleNone; if (!_passcodeLockOn) { cell.textLabel.textColor = [UIColor grayColor]; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 2bed3a8..1c2aa3b 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -19,7 +19,6 @@ #import "KKKeychain.h" #import "KKPasscodeSettingsViewController.h" #import "KKPasscodeLock.h" -#import "NSBundle+KKPasscodeLockAdditions.h" #import #import diff --git a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj index bfaebdd..34ff6b6 100644 --- a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj +++ b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj @@ -7,16 +7,16 @@ objects = { /* Begin PBXBuildFile section */ + 5303097416611E650004810F /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */; }; + 5303097516611E650004810F /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096A16611E650004810F /* KKPasscodeViewController.m */; }; + 5303097716611E650004810F /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5303096D16611E650004810F /* KKPasscodeLock.bundle */; }; + 5303097816611E650004810F /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096F16611E650004810F /* KKKeychain.m */; }; + 5303097916611E650004810F /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303097016611E650004810F /* KKPasscodeLock.m */; }; 6D2394C81548CA89004DF3B7 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */; }; 6D2394CA1548CA89004DF3B7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C91548CA89004DF3B7 /* UIKit.framework */; }; 6D2394CB1548CA89004DF3B7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394B91548CA89004DF3B7 /* Foundation.framework */; }; 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */; }; 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */; }; - 6D2394E91548CAA8004DF3B7 /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */; }; - 6D2394EC1548CAA8004DF3B7 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */; }; - 6D2394EF1548CAA8004DF3B7 /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */; }; - 6D2394F21548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */; }; - 6D2394F51548CAA8004DF3B7 /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */; }; 6D2394F81548CBAA004DF3B7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */; }; 6D2394F91548CBAA004DF3B7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */; }; 6D2394FB1548CBAE004DF3B7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394FA1548CBAE004DF3B7 /* Security.framework */; }; @@ -24,6 +24,15 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; }; + 5303096A16611E650004810F /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; }; + 5303096D16611E650004810F /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; }; + 5303096E16611E650004810F /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; }; + 5303096F16611E650004810F /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = ../../src/KKKeychain.m; sourceTree = ""; }; + 5303097016611E650004810F /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; }; + 5303097116611E650004810F /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; }; + 5303097216611E650004810F /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = ../../src/KKKeychain.h; sourceTree = ""; }; + 5303097316611E650004810F /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; 6D2394B91548CA89004DF3B7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 6D2394BD1548CA89004DF3B7 /* KKPasscodeLock-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLock-Prefix.pch"; sourceTree = ""; }; 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KKPasscodeLock.octest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -33,15 +42,6 @@ 6D2394D31548CA89004DF3B7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 6D2394D51548CA89004DF3B7 /* KKPasscodeLockTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KKPasscodeLockTests.h; sourceTree = ""; }; 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KKPasscodeLockTests.m; sourceTree = ""; }; - 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.bundle; sourceTree = ""; }; - 6D2394E11548CAA8004DF3B7 /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKKeychain.h; sourceTree = ""; }; - 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKKeychain.m; sourceTree = ""; }; - 6D2394E31548CAA8004DF3B7 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.h; sourceTree = ""; }; - 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeLock.m; sourceTree = ""; }; - 6D2394E51548CAA8004DF3B7 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; }; - 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; }; - 6D2394E71548CAA8004DF3B7 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeViewController.h; sourceTree = ""; }; - 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = /Users/hadarporat/Desktop/projects/KKPasscodeLock/example/KKPasscodeLock/../../src/KKPasscodeViewController.m; sourceTree = ""; }; 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 6D2394FA1548CBAE004DF3B7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; @@ -101,15 +101,15 @@ 6D2394BB1548CA89004DF3B7 /* KKPasscodeLock */ = { isa = PBXGroup; children = ( - 6D2394E01548CAA8004DF3B7 /* KKPasscodeLock.bundle */, - 6D2394E11548CAA8004DF3B7 /* KKKeychain.h */, - 6D2394E21548CAA8004DF3B7 /* KKKeychain.m */, - 6D2394E31548CAA8004DF3B7 /* KKPasscodeLock.h */, - 6D2394E41548CAA8004DF3B7 /* KKPasscodeLock.m */, - 6D2394E51548CAA8004DF3B7 /* KKPasscodeSettingsViewController.h */, - 6D2394E61548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m */, - 6D2394E71548CAA8004DF3B7 /* KKPasscodeViewController.h */, - 6D2394E81548CAA8004DF3B7 /* KKPasscodeViewController.m */, + 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */, + 5303096A16611E650004810F /* KKPasscodeViewController.m */, + 5303096D16611E650004810F /* KKPasscodeLock.bundle */, + 5303096E16611E650004810F /* KKPasscodeViewController.h */, + 5303096F16611E650004810F /* KKKeychain.m */, + 5303097116611E650004810F /* KKPasscodeLock.h */, + 5303097016611E650004810F /* KKPasscodeLock.m */, + 5303097216611E650004810F /* KKKeychain.h */, + 5303097316611E650004810F /* KKPasscodeSettingsViewController.h */, 6D2394BC1548CA89004DF3B7 /* Supporting Files */, ); path = KKPasscodeLock; @@ -195,7 +195,7 @@ buildActionMask = 2147483647; files = ( 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */, - 6D2394E91548CAA8004DF3B7 /* KKPasscodeLock.bundle in Resources */, + 5303097716611E650004810F /* KKPasscodeLock.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -223,10 +223,10 @@ buildActionMask = 2147483647; files = ( 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */, - 6D2394EC1548CAA8004DF3B7 /* KKKeychain.m in Sources */, - 6D2394EF1548CAA8004DF3B7 /* KKPasscodeLock.m in Sources */, - 6D2394F21548CAA8004DF3B7 /* KKPasscodeSettingsViewController.m in Sources */, - 6D2394F51548CAA8004DF3B7 /* KKPasscodeViewController.m in Sources */, + 5303097416611E650004810F /* KKPasscodeSettingsViewController.m in Sources */, + 5303097516611E650004810F /* KKPasscodeViewController.m in Sources */, + 5303097816611E650004810F /* KKKeychain.m in Sources */, + 5303097916611E650004810F /* KKPasscodeLock.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From ceb6ae42814977dd3a0f1365235d3fdbaf2b6175 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Sat, 24 Nov 2012 11:17:16 -0500 Subject: [PATCH 37/62] added Hebrew Localization --- .../KKPasscodeLock/he.lproj/InfoPlist.strings | 2 ++ .../KKPasscodeLockDemo.xcodeproj/project.pbxproj | 3 +++ .../he.lproj/Localizable.strings | Bin 0 -> 2450 bytes 3 files changed, 5 insertions(+) create mode 100644 example/KKPasscodeLock/he.lproj/InfoPlist.strings create mode 100644 src/KKPasscodeLock.bundle/he.lproj/Localizable.strings diff --git a/example/KKPasscodeLock/he.lproj/InfoPlist.strings b/example/KKPasscodeLock/he.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/example/KKPasscodeLock/he.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index 073a5a4..f2811ea 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 5303095E16611BF90004810F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 5303097E16611F510004810F /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = ""; }; 5303097F16611F580004810F /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = ""; }; + 5303098816612A310004810F /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; }; 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -216,6 +217,7 @@ en, nl, de, + he, ); mainGroup = 6D3E344214C4F54D0003B72B; productRefGroup = 6D3E344E14C4F54E0003B72B /* Products */; @@ -267,6 +269,7 @@ 6D3E345B14C4F54E0003B72B /* en */, 5303097E16611F510004810F /* nl */, 5303097F16611F580004810F /* de */, + 5303098816612A310004810F /* he */, ); name = InfoPlist.strings; sourceTree = ""; diff --git a/src/KKPasscodeLock.bundle/he.lproj/Localizable.strings b/src/KKPasscodeLock.bundle/he.lproj/Localizable.strings new file mode 100644 index 0000000000000000000000000000000000000000..362f668a393e1c655c84d4d0f189f5e834e9e656 GIT binary patch literal 2450 zcmb_e%T60X5bVob_=?d=97B|IlmjB<6e&@{B}ZfIBuczSu@T}gF|1=Oj4>z*EFY1i zYKGpKT^oBNSu5{j9^KW|HQoOEXG0QsFAeG8YD!lQq$O6~;;kv)FlXfzeu>P?tr?q% z$&8hOxidp^j<++6Mczh?NQEN9G=H-g}1898o`DBsXVx8y8=+t&C)t^PJE>SxICESX1!X z0{Xz{0P8MbWAeyeBD+}CkbM_pSeF6kZE2PAM3y{*%v|cC=RM|}*;K~Y%c(MT>Nrt` zXZRYL8DhHvD~niOAG73kPmZ7wDr{cG@1UV}iSY}k1CMw)}y zRqz=qn8zBjorAl~Jckxn+uSWqjFs20&hr*5X@262XoMeuf;y>k7Ixp60aWL4C{wCz zwGw#hI;NM|8$j!m751oqJ@Zc^^Cz($LoX2H8?X}UM%AvBZTJjzBQU_d)bR~|Lvvj^ z_sYN~EdQ^EUX&xhKX{oHH6>IS^;JdAT6zHgtd=RxKl9mfDriD$Tlm_8K2Gp#Ky~CG zE!D(oR(;K*>R9Ej3@ywMy{eJQ9AhTbwK!j_^hCoG$Ew|OxwNRo<=#T8pMdrV&nD*5 z0z3CS!*~x*-!J&=VNJ)4%v%b%%FHFu-9&X*waRMEdX%|%SbKa{A6!P+&vL{x#obpc z#y(tNN26xViQ_(Tv9L>3@x|!aJL)MmwoOj!S*_+$HS@u7>T}_HX&t;H^AjB0KO$!D zS=8UuM~paF@1iqNnf35LRXy3W*-fuYJyL5#@RlOZ Date: Sun, 25 Nov 2012 22:41:24 -0600 Subject: [PATCH 38/62] Fixed ARC-related memory leak in setString:forKey: CFDictionaryRef objects passed to SecItem* should be simply bridged; __bridge_retain is not necessary. The function will make use of the dictionary and pass it back without changing its retain count. --- src/KKKeychain.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/KKKeychain.m b/src/KKKeychain.m index 0e28cd0..e2b235e 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -50,21 +50,21 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService]; [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount]; - OSStatus res = SecItemCopyMatching((__bridge_retained CFDictionaryRef) existsQueryDictionary, NULL); + OSStatus res = SecItemCopyMatching((__bridge CFDictionaryRef) existsQueryDictionary, NULL); if (res == errSecItemNotFound) { if (string != nil) { NSMutableDictionary *addDict = existsQueryDictionary; [addDict setObject:data forKey:(__bridge id)kSecValueData]; - res = SecItemAdd((__bridge_retained CFDictionaryRef)addDict, NULL); + res = SecItemAdd((__bridge CFDictionaryRef)addDict, NULL); NSAssert1(res == errSecSuccess, @"Recieved %ld from SecItemAdd!", res); } } else if (res == errSecSuccess) { // Modify an existing one // Actually pull it now of the keychain at this point. NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(__bridge id)kSecValueData]; - res = SecItemUpdate((__bridge_retained CFDictionaryRef)existsQueryDictionary, (__bridge_retained CFDictionaryRef)attributeDict); + res = SecItemUpdate((__bridge CFDictionaryRef)existsQueryDictionary, (__bridge CFDictionaryRef)attributeDict); NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %ld!", res); } else { NSAssert1(NO, @"Received %ld from SecItemCopyMatching!", res); From 89e4be492da4f97430f1334d7b84659720db00a6 Mon Sep 17 00:00:00 2001 From: Aaron London Date: Fri, 4 Jan 2013 12:54:53 -0700 Subject: [PATCH 39/62] Use smaller and tighter layout for landscape mode on iPhone. --- src/KKPasscodeViewController.m | 81 +++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 1c2aa3b..3a848b3 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -23,6 +23,12 @@ #import #import +@interface KKPasscodeViewController () + +@property(nonatomic,assign) BOOL isSmallLandscape; + +@end + @interface KKPasscodeViewController (Private) - (UITextField*)passcodeTextField; @@ -39,6 +45,7 @@ @implementation KKPasscodeViewController @synthesize delegate = _delegate; @synthesize mode = _mode; +@synthesize isSmallLandscape; #pragma mark - #pragma mark UIViewController @@ -104,8 +111,8 @@ - (void)viewWillAppear:(BOOL)animated _textFields = [[NSMutableArray alloc] init]; _boxes = [[NSMutableArray alloc] init]; - - + // Need to make sure everything is visible in landscape mode on small devices. + self.isSmallLandscape = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsLandscape(self.interfaceOrientation)); if (_mode == KKPasscodeModeSet) { self.navigationItem.title = KKPasscodeLockLocalizedString(@"Set Passcode", @""); @@ -248,8 +255,8 @@ - (void)incrementFailedAttemptsLabel } else { _failedAttemptsLabel.text = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"%i Failed Passcode Attempts", @""), _failedAttemptsCount]; } - CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:14.0]]; - _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + 40.0)) / 2, 150, size.width + 40.0, size.height + 10.0); + CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:self.isSmallLandscape ? 10.0f : 14.0f]]; + _failedAttemptsLabel.frame = _failedAttemptsView.frame = CGRectMake((self.view.bounds.size.width - (size.width + (self.isSmallLandscape ? 20.0f : 40.0f))) / 2, self.isSmallLandscape ? 75.0f : 150.0f, size.width + (self.isSmallLandscape ? 20.0f : 40.0f), size.height + (self.isSmallLandscape ? 5.0f : 10.0f)); CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = _failedAttemptsView.bounds; @@ -532,7 +539,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField { [self.view addSubview:textField]; UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)]; - UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 28.0, self.view.bounds.size.width, 30.0)]; + UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 2.0f : 28.0f, self.view.bounds.size.width, 30.0)]; headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; headerLabel.backgroundColor = [UIColor clearColor]; @@ -542,12 +549,12 @@ - (UIView*)headerViewForTextField:(UITextField*)textField headerLabel.textAlignment = NSTextAlignmentCenter; #endif - headerLabel.font = [UIFont boldSystemFontOfSize:17.0]; + headerLabel.font = [UIFont boldSystemFontOfSize:self.isSmallLandscape ? 12.0f : 17.0f]; headerLabel.shadowOffset = CGSizeMake(0, 1.0); headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; if ([textField isEqual:_setPasscodeTextField]) { - _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0)]; + _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 73.0f : 146.0, self.view.bounds.size.width, 30.0)]; _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; @@ -578,7 +585,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _failedAttemptsLabel.backgroundColor = [UIColor clearColor]; _failedAttemptsLabel.textColor = [UIColor whiteColor]; _failedAttemptsLabel.text = @""; - _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:14.0]; + _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:self.isSmallLandscape ? 10.0f : 14.0f]; #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 _failedAttemptsLabel.textAlignment = UITextAlignmentCenter; @@ -588,7 +595,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; - _failedAttemptsView.layer.cornerRadius = 14; + _failedAttemptsView.layer.cornerRadius = self.isSmallLandscape ? 7.0f : 14.0f; _failedAttemptsView.layer.borderWidth = 1.0; _failedAttemptsView.layer.borderColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.25] CGColor]; @@ -601,30 +608,30 @@ - (UIView*)headerViewForTextField:(UITextField*)textField [headerView addSubview:_failedAttemptsLabel]; } - if (_mode == KKPasscodeModeSet) { - if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); - } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter a passcode", @""); - } else if ([textField isEqual:_confirmPasscodeTextField]) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your passcode", @""); - } - } else if (_mode == KKPasscodeModeDisabled) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); - } else if (_mode == KKPasscodeModeChange) { - if ([textField isEqual:_enterPasscodeTextField]) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your old passcode", @""); - } else if ([textField isEqual:_setPasscodeTextField]) { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your new passcode", @""); - } else { - headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your new passcode", @""); - } - } else { - headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); - } + if (_mode == KKPasscodeModeSet) { + if ([textField isEqual:_enterPasscodeTextField]) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); + } else if ([textField isEqual:_setPasscodeTextField]) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter a passcode", @""); + } else if ([textField isEqual:_confirmPasscodeTextField]) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your passcode", @""); + } + } else if (_mode == KKPasscodeModeDisabled) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); + } else if (_mode == KKPasscodeModeChange) { + if ([textField isEqual:_enterPasscodeTextField]) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your old passcode", @""); + } else if ([textField isEqual:_setPasscodeTextField]) { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your new passcode", @""); + } else { + headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your new passcode", @""); + } + } else { + headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @""); + } - headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; - [headerView addSubview:headerLabel]; + headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; + [headerView addSubview:headerLabel]; return headerView; } @@ -634,13 +641,16 @@ - (NSArray*)boxes { NSMutableArray* squareViews = [NSMutableArray array]; - CGFloat squareX = 0.0; + CGFloat squareX = self.isSmallLandscape ? 60.0f : 0.0f; + + CGFloat width = self.isSmallLandscape ? kPasscodeBoxWidth * 0.6f : kPasscodeBoxWidth; + CGFloat height = self.isSmallLandscape ? kPasscodeBoxHeight * 0.6f : kPasscodeBoxHeight; for (int i = 0; i < kPasscodeBoxesCount; i++) { UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; - square.frame = CGRectMake(squareX, 74.0, kPasscodeBoxWidth, kPasscodeBoxHeight); + square.frame = CGRectMake(squareX, self.isSmallLandscape ? 32.0f : 74.0, width, height); [squareViews addObject:square]; - squareX += 71.0; + squareX += self.isSmallLandscape ? 42.0f : 71.0; } return [NSArray arrayWithArray:squareViews]; } @@ -729,5 +739,4 @@ - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { #pragma mark - #pragma mark Memory management - @end From 99af8df33655c2c7e86f13056ae25659abc6e87f Mon Sep 17 00:00:00 2001 From: Aaron London Date: Fri, 4 Jan 2013 13:10:45 -0700 Subject: [PATCH 40/62] Add requires_arc to podspec. --- KKPasscodeLock.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/KKPasscodeLock.podspec b/KKPasscodeLock.podspec index 4c145c2..3d08802 100644 --- a/KKPasscodeLock.podspec +++ b/KKPasscodeLock.podspec @@ -11,4 +11,5 @@ Pod::Spec.new do |s| s.resources = "src/KKPasscodeLock.bundle" s.clean_paths = "Classes", "*.{plist,pch,md,m,xcodeproj}", "SampleApp" s.frameworks = 'QuartzCore', 'AudioToolbox', 'Security' + s.requires_arc = true end From 19befedfa88816c76fa665b0aecec4060da6b235 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 16 Jan 2013 22:00:42 -0500 Subject: [PATCH 41/62] fix launch warnings on sample demo app. closes #13 --- example/Default.png | Bin 0 -> 6540 bytes example/Default@2x.png | Bin 0 -> 16107 bytes example/KKPasscodeLock/AppDelegate.m | 4 ++-- .../project.pbxproj | 8 ++++++++ .../project.pbxproj | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 example/Default.png create mode 100644 example/Default@2x.png diff --git a/example/Default.png b/example/Default.png new file mode 100644 index 0000000000000000000000000000000000000000..4c8ca6f693f96d511e9113c0eb59eec552354e42 GIT binary patch literal 6540 zcmeAS@N?(olHy`uVBq!ia0y~yU~~ZD2OMlbkt;o0To@QwR5G2N13aCb6#|O#(=u~X z85k@CTSM>X-wqM6>&y>YB4)1;;ojbLbbV-W^iFB1wa3^zCog^LCAReC4K0-?R_2{6 zrP*)4+_uWUy3w5N52M3PW_}MFMP9a~>YLvVZ1D_k*IMQ2QT^fwzoOb(*3gH$%aYWC zkHmcab=va2<#X%jakpJ;<1@F;k__#bwtC&%^D0v(FBh9K&$sK+<}2RJS609D)17$w ztdQP8(eLM8Ka}m_IQ@3wyMKP)l=oM4-?`YS_*P?4V_ORLPxsj&7Ju#kH;>6^Kp?T7~ zl+q?{UOOqV==?+d{=)5s|M~T1mwtH@+Z^$G&eEO9JNP^AX@3jZ*J*!!>lc|1-W%fA z@AOQpXZ_Lt>rxFXrGp*zLPiW@uo_c7C{As>j zWeX)wi+LTp_)@KYZCX{j;H?|1yXT4DnlS(Fr8gyP5|uaX_gLvaW0ScZdnG7o+u{T6 zFI-%d{ls*WuCDa5UJ@|RXv&ejZe}*BMkiWY51&pnRPw(hlykSzvj6e%mYz-GdvzBD zF10?szF_~!jS=?2HyQuPCvARXAe}C}WP|yQ*>5~~=*Nxq8+HHW1~FMDRCP^TcacKuk$ z(U#REVv)D!PhJ*ecH-ELFUrfyV&*)Z)>UCOuS?yd^L@Afk>ihynYPc{^CRwu+JHX+#$@YsC4c|l0tGigsn@jy) zXD($Ouk>H+V(Mr6NQT0S9BFM~V6nkj;1OBOz`zY;a|<&v%$g$sEJPk;hD4M^`1)8S z=jZArrsOB3>Q&?x097+E*i={nnYpPYi3%0DIeEoa6}C!X6;?ntNLXJ<0j#7X+g2&U zH$cHTzbI9~RL@Y)NXd>%K|#T$C?(A*$i)q+9mum)$|xx*u+rBrFE7_CH`dE9O4m2E zw6xSWFw!?N(gmu}Ew0QfNvzP#D^`XW0yD=YwK%ybv!En1KTiQ3|)OBHVcpi zp&D%TL4k-AsNfg_g$9~9p}$+4Ynr|VULLgiakg&)DD)EWO!OHC@snXr}UI${nVUP zpr1>Mf#G6^ng~;pt%^&NvQm>vU@-wn)!_JWN=(;B61LIDR86%A1?G9U(@`={MPdPF zbOKdd`R1o&rd7HmmZaJl85kPr8kp-EnTHsfS{ayIfdU*&4N@e5WSomq6HD@oLh|!- z?7;Dr3*ssm=^5w&a}>G?yzvAH17L|`#|6|0E4}QvA~xC{V_*wu2^AHZU}H9f($4F$btFf{}TLQXUhF5fht1@YV$^ z9BUdFV+73^nIsvRXRM40U}6b7z_6}kHbY}i1LK(xT@6Mi?F5GKBfbp|ZU-3BR*6kv zXcRSQ(0-)mprD+wTr)o_4I;(%zOu)+jEgNB)_SXCVoSa}|F?cfwR!69+L=W3IX z!UiU`0@ph%94Rb33Cpq^IY*r_8XBW%V>G9XmK&p`=xCiXTEmXEH%41uqixaAmicH0 zVYIt6!aI*K%s=kP-v##6IXGZ2Cama>{@)81;C?K-P&M2k<0!GL}5+H~XTq*@SQi|Ft z2*0X`$`8S!qO#)xBeJRkf?;t189=ZB6Imw-h=`q;FP(2UpWZvmJ@=k-@45M(dtb7r zyVEiaLk$=Vw#>zu;st}j6Jf9=m1+nXCFe!$1PrEZ%5Ze_ba8YX_9-*rJujiLuQmJo&2v+Cxes}ec zU|qeux&7*yz#W=X_|wGQskL7*OHNjwFs@sEC+64Hb$Z(#H21Gh$Pe2WzOubdr6fzg z{l{!k%OD?N5Z7j33SoK?YdV6Scm>})U+MIQLNRgIvkZQEc^mP9XBPg%y|S$~Br|;N zk?-!-(Qqh_mQ|6WINQ{hHAjBRV#O#!FkAJ+oxy`L#f8V45*VvWMJFBB5m zG6vOLtDvgoDjHlSq-*h5xM56O>Jjau2f2IxKItIb@coX4XTyf$^{LZG&lI|D95wN1 z!fo0)q>WV7-V;q|A?HR!*bgozJw%j98-~gwBKVV0;=hZIF>7oJSr2YjOWO*rSxz#& z;KXnDrJVZp;Yduiy1-H%s$ZFz6Q=x@$V_B@Tqwl?>6e;EHt|MiK<(#hXQMuj@Jseeh&eN{FxsQ$iw>D1aX1HMMlUbh?Z zmhY4eHffn5&LUbL_}o8|$JYz&$WFiLWmEg0ZPX+;W>@CxQz-%{E5+P7dH9&ey_y$R z@Zzje>2B%z!i!7Brqi{t5Y)~5>vpqRs~2aXD8DVE8vKl=`k(`duI1-k@?!pJ^HA6S zS;3WpuhjQHyoC>X>Xf8gze%_8^#+^RTV>V9&YPAWMjd~%xpSg?ON?kK^X*Pb(o8jR zz;DmaOWMMr6=M~K?MFx4_xDkARTxLJ@W@ohAx z5RD0jGgk?QL@H`VubD2k4}?VtB8@g`%hHBA$2pJ(gK5g1HMNysXEF_BNu-p!&+Qa8_APgopHWnRgg=TZZF*sXWTMQPD z!Q(Au5|+F;7M~`tWbsU98~NA{h0Y7%GB|t&n}w9OOABU4^X*V5xuN;rY(M#ouuqm) zyt!e?28fY!FgP?8GvBsMl_aM^UUVKiGFsleFN?t^<46kO#pF-cX0;sIOb(aM z)^jQgX^Z6pKA9mC@N)_aiHj9HxD2|?A@Y9B_h}(*v3%ek8CXc1Qy^jFPF&zrMa1OZ zSVaF{&ZY|(|H0XE&X>-XQz1`=fF2n@VKC_|h3jlKVM&-jmyMavllcYr`6LVtfq2ou zd+8zkkCB+2)rxq0Lkq_&Ad@g(O8;pAm96>tu79?81T@Z<;gm^3ZtPG-SR94Mr<3tm z9NrR3u*4I5aMlo(09g@8m_;%Rf+XiSa_KZao9n}7N0JrsV#;5Ucr+F*TTzQ8{%f3O zeIUy?WDS|-$LvMc@Z7320)tr}bfIka5hx9H;8H|%our=C+Do0CSFRWue14o5#r8v2 zw=|&r4*eMX%lgCV(ka?*j%H^UuP4LmBC(ON`)&7>NF-|PDRU{-7o`CU0HNbd&c~))@yl9IKu_ zXA+A-!khpP_yx=f#qt2_0ptmgBf4gF!{Y)MW6R$cC1d7@$Yb?+_j zYwfE^5_e`vhT zX=u3r>4$fsxP&apbm@Rcbyuc2T=giqZiMo9@9=oua6#YH0hO-1ak9^rJTPMM qY4Yr5Cu^v99p{E9VdroUHKlRW;M8#BJ^AOQE?e9wSHJo8(7yq;BYKSh literal 0 HcmV?d00001 diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index e3b8e0f..9036dc8 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -36,7 +36,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; _navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; - [self.window addSubview:_navigationController.view]; + [self.window setRootViewController:_navigationController]; [self.window makeKeyAndVisible]; return YES; @@ -64,7 +64,7 @@ - (void)applicationDidBecomeActive:(UIApplication *)application nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle; } - [_navigationController presentModalViewController:nav animated:YES]; + [_navigationController presentModalViewController:nav animated:NO]; }); } diff --git a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj index f2811ea..8362a85 100644 --- a/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj +++ b/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5303095E16611BF90004810F /* Default-568h@2x.png */; }; + 53DD2F8816A79FDB002582A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 53DD2F8616A79FDB002582A0 /* Default.png */; }; + 53DD2F8916A79FDB002582A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 53DD2F8716A79FDB002582A0 /* Default@2x.png */; }; 6D3E345214C4F54E0003B72B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345114C4F54E0003B72B /* UIKit.framework */; }; 6D3E345414C4F54E0003B72B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345314C4F54E0003B72B /* Foundation.framework */; }; 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */; }; @@ -33,6 +35,8 @@ 5303097E16611F510004810F /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = ""; }; 5303097F16611F580004810F /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = ""; }; 5303098816612A310004810F /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; }; + 53DD2F8616A79FDB002582A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 53DD2F8716A79FDB002582A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -106,6 +110,8 @@ 6D3E344214C4F54D0003B72B = { isa = PBXGroup; children = ( + 53DD2F8616A79FDB002582A0 /* Default.png */, + 53DD2F8716A79FDB002582A0 /* Default@2x.png */, 5303095E16611BF90004810F /* Default-568h@2x.png */, 6D3E345714C4F54E0003B72B /* KKPasscodeLock */, 6D2F0BD414C51CCA00C1862D /* Demo App */, @@ -239,6 +245,8 @@ 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */, 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */, 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */, + 53DD2F8816A79FDB002582A0 /* Default.png in Resources */, + 53DD2F8916A79FDB002582A0 /* Default@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj index 34ff6b6..6966be1 100644 --- a/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj +++ b/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj @@ -295,6 +295,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = KKPasscodeLock; WRAPPER_EXTENSION = octest; }; @@ -311,6 +312,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch"; INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = KKPasscodeLock; WRAPPER_EXTENSION = octest; }; From 6ed13445d36db742bf4feda18af1285498dcbdba Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Wed, 16 Jan 2013 22:14:35 -0500 Subject: [PATCH 42/62] merge "Turn Passcode" & "Change Passcode" into a single tableview section --- example/KKPasscodeLock/AppDelegate.m | 1 + src/KKPasscodeSettingsViewController.m | 52 +++++++++++++++----------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/example/KKPasscodeLock/AppDelegate.m b/example/KKPasscodeLock/AppDelegate.m index 9036dc8..13d992e 100644 --- a/example/KKPasscodeLock/AppDelegate.m +++ b/example/KKPasscodeLock/AppDelegate.m @@ -29,6 +29,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( { [[KKPasscodeLock sharedLock] setDefaultSettings]; + [KKPasscodeLock sharedLock].eraseOption = NO; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index a37f9b8..c24552d 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -93,20 +93,24 @@ - (void)eraseDataSwitchChanged:(id)sender - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { if ([[KKPasscodeLock sharedLock] eraseOption]) { - return 3; + return 2; } - return 2; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + if (section==0) { + return 2; + } + return 1; } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { - if (section == 2) { + if (section == 1) { return [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];; } else { return @""; @@ -136,31 +140,35 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI if (indexPath.section == 0) { + if (indexPath.row == 0) { + #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 - cell.textLabel.textAlignment = UITextAlignmentCenter; + cell.textLabel.textAlignment = UITextAlignmentCenter; #else - cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textAlignment = NSTextAlignmentCenter; #endif - - if (_passcodeLockOn) { - cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode Off", @""); - } else { - cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode On", @""); - } - } else if (indexPath.section == 1) { - cell.textLabel.text = KKPasscodeLockLocalizedString(@"Change Passcode", @""); - + + if (_passcodeLockOn) { + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode Off", @""); + } else { + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode On", @""); + } + } else { + cell.textLabel.text = KKPasscodeLockLocalizedString(@"Change Passcode", @""); + #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 - cell.textLabel.textAlignment = UITextAlignmentCenter; + cell.textLabel.textAlignment = UITextAlignmentCenter; #else - cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.textAlignment = NSTextAlignmentCenter; #endif - - cell.selectionStyle = UITableViewCellSelectionStyleNone; - if (!_passcodeLockOn) { - cell.textLabel.textColor = [UIColor grayColor]; - } - } else if (indexPath.section == 2) { + + cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (!_passcodeLockOn) { + cell.textLabel.textColor = [UIColor grayColor]; + } + + } + } else if (indexPath.section == 1) { cell.textLabel.text = KKPasscodeLockLocalizedString(@"Erase Data", @""); cell.accessoryView = _eraseDataSwitch; cell.selectionStyle = UITableViewCellSelectionStyleNone; From 1cb4b520ffb835847ecbb6f01503d8d651e5c68b Mon Sep 17 00:00:00 2001 From: Ivan Tse Date: Fri, 25 Jan 2013 15:51:06 -0800 Subject: [PATCH 43/62] fixing where selecting 'Change Passcode' was actually selecting 'Turn Passcode Off' --- src/KKPasscodeSettingsViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index c24552d..6470706 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -189,7 +189,7 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { - if (indexPath.section == 0) { + if (indexPath.section == 0 && indexPath.row == 0) { KKPasscodeViewController* vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; @@ -219,7 +219,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) [self.navigationController presentViewController:nav animated:YES completion:nil]; #endif - } else if (indexPath.section == 1 && _passcodeLockOn) { + } else if (indexPath.section == 0 && indexPath.row == 1 && _passcodeLockOn) { KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; From ef3225deb0db1663f5c40525479f6fe3a2e17b95 Mon Sep 17 00:00:00 2001 From: Martin Baker Date: Mon, 28 Jan 2013 15:02:45 +0000 Subject: [PATCH 44/62] Tweaked empty and filled box images to horizontally align black circle. --- src/KKPasscodeLock.bundle/box_empty.png | Bin 1699 -> 692 bytes src/KKPasscodeLock.bundle/box_empty@2x.png | Bin 2429 -> 973 bytes src/KKPasscodeLock.bundle/box_filled.png | Bin 2403 -> 1156 bytes src/KKPasscodeLock.bundle/box_filled@2x.png | Bin 3220 -> 1673 bytes 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/KKPasscodeLock.bundle/box_empty.png mode change 100755 => 100644 src/KKPasscodeLock.bundle/box_empty@2x.png mode change 100755 => 100644 src/KKPasscodeLock.bundle/box_filled.png mode change 100755 => 100644 src/KKPasscodeLock.bundle/box_filled@2x.png diff --git a/src/KKPasscodeLock.bundle/box_empty.png b/src/KKPasscodeLock.bundle/box_empty.png old mode 100755 new mode 100644 index 3c5c529203f387693bb484cbc9155a8754d38570..09744d0ee2247edbf738640d86a796e2a3ccc6ee GIT binary patch delta 679 zcmV;Y0$BZ{4YUQ28Gix*004bcbkhI;02y>eSaefwW^{L9a%BKPWN%_+AW3auXJt}l zVPtu6$z?nM00LG?L_t(|+SHoMu7WTShM6)dn5YRXd=VeOcXw@k6QfZna=@N}VpDF$ zOElA2kfJWWj{i*mQeeGaBO(BJj)YPw&vP7&Myu6oJRU<8%zud~vMk$fx9I!+Y&M%t zr<8RXvqdN3q9`cSNsdr@Sa?ZW0NhM^O|6fe?cJ5q8)Bx7#gEQ^GqO4y8`$BPz|wWJ1t10nYlS zD{<=Xhx%U-Re#VuU3qd-z71r_c~`w-A&l@^!;E(W!OfV{(s~ipE%>+$l5@P&oliS?iL$% zzkW^MYGAhT6@B+`w~XTR;`{oR6uj;V~G7vQGQ_Q`)&XIv#MzK@A`(lv$7L}Llfd@WqbBJ{H<)me|v6*tK7)l z#15=(&VTB}?&r+?Nl#t6vM)9(`jGzyR?>dtzZvf@p^GQ@E4w$X=A1;iQJ2uFOGi#h z3@6$;sUF)ieeR==&Ws|k-ceW*=%;ZT@VEP-{$0YYwt_kRnN0t7t{kHvJJ|YYf{TwndO+GfCENHtX&twWWyU;?XMJMeU&n z|9~EP@MJGag<3@@-m55Lp%*Rj&2CJ#rRu=We)HZp?|pA}-+urNa?&*QfCS_X$5NsZ zX>5E#YW#=*j-m-cG$mEr>`o*GL4$Mod*|4C4}n`&!+ZO8vUjbT(zcohg#AF^N1E9x zu3rn}7Ut74&?PWBFvy`A)aPP5)V!Xd&78LdA?xQ(9m zjMYElVd13a#D+Z_7&Y|xU=_C-srWU*6kiZcC!$nw*)9$7n6CX+@=AhmkT}X@VSsa5 zNKe;HZuq)~1$`#h6R+ZTR#D-3j}vF!)ZOnz+5)dI4u2gC8Vs5ZNKg<(1Ywx4P(X$} z8Zk7oaz7)h1{;%mGIb0elo`y@REhV0!YX7mow*Kg`j6Yk{C^kZ_loDAC;~5R;K-S}ZBudY5TRwI zZgZ{z7r)Vc@V0JiqkcI21Xw()7Ohe>pCG&e9Cn9#9_T5U)0URaIZ}r#pOd=j%3@N? zP}@UNQr9KdWlI*bnN?!xcG#KI9c~<G)7`T49;*?vwM)`6G$ zZ-2nN{YAidi-`aL010qNS#tmY3ljhU3ljkVnw%H_00Ub|L_t(&1?8IUa_S%uhBq2L zj@HrX)IZ*ZcjBdcBRcilS~Z7v$>Ii6wg0+ECqjT^c=iiI$tIIY(QGy;%Q8wm6-7bk z^O5cs$ZW*>W@>h;=$028Ms96wKh$NPpmK zwVdlZ-kfWk89)-aP>DR11Wju;<_mD?#IAt!Q{k%86av>zlu><%;^4z7;0P z0pp<^@GB)B$b=Z|?t)Z&)Uzy%!gFAvjxZP+fU*h;xq0n-QsEK3B5#PTW4Tt>L3g%V zj=8SU+bYpBpTfw#H%Piu}`N4dQVvpKsisl zFR*f99!urk3oNwN@s#uQ)!s$xEQBZkSbz*;Ed5w3Qv^_5oP;N?flXD}D&A38ScXCh zA_-e`k4GD`-OSUef!FcWnm0P8=F{39D$rUgx~v~CQ&v7LERqNFmI}$uz<)g$sPIUR z?qP9)8{L5WRFdYx#|N7?3Ob<^e7ahzd;I+}cE5xp9nkh0WOTO-1@Ea=~`$34==D-h=Q|bV)KT|Mg11}o*lC= z2A}4C;3Wtj6skNmK=T)tYIs(9Ci*!p<|_vq7AK;5G@|SSnF*x&L4TH;{rI0elJKGI z16kRC3fV5vow(lGk65kbYW!^8@aI=bA$q?Obe=W555t@rnLjaT-n1hPYA&$lhy8(8 zs}&y>#fjkke$P86bt{?ZU4Q--fH)?JbKW=%yI!y9a5zvlolXm!_kMeO<3ppV9&!il oX0xH?a!Hvx3;kMA%oo|`f2vNyX7O+kl>h($07*qoM6N<$f`@NCCIA2c diff --git a/src/KKPasscodeLock.bundle/box_empty@2x.png b/src/KKPasscodeLock.bundle/box_empty@2x.png old mode 100755 new mode 100644 index 2a6e74f610789e361a27a1e03c07595b27787be3..515072e418f255d12b2660687c325f22012ee733 GIT binary patch delta 962 zcmV;z13mox63qvY8Gix*008{$(kK7`02y>eSaefwW^{L9a%BKPWN%_+AW3auXJt}l zVPtu6$z?nM00VDHL_t(|+U%X%a;iWSL;=U+C0~@c{BXX*Us4e`?QEP_mchy}Gn|uJ z{eWD|%d)HK4QT3*kBl!EtH4MWeZXteue{Y(m_J0C;LeRrahr^-oduNE9 zbF0tevB~#d^2f8S!9qa7W`dQ@38{^VuL@vs*8MyWMX0`@NQ%%|_5e zl*2A2Ol|=p(0`}X>3BS9r+ALI&D~=C_V#APWpEJ(cQkIXmaoNH7_~>6#`(IT7x5M4 z;BhlJxaZ)OwdH7IE$#+$bhmH|u@P5@YX#ghaT{x;int5!=x%EuIwro>Pc~i_->{32 z5C_(Zlt6Oq-IgcT|J+U1Phb}zONDF8_MpQwbH#0kt$(Qmg*U-2I#2F-h9L%^MKxX# z3=_@$Fv*xRM^8!O?y|8C0&s&H<-^U@*HkCTZ*haT0D8iN>;^YVIaNNy4O3;3)PC)5 z5N9P$n3Twfg-u*AR8!wkRXS#_qDW5^|azdCabgJYgP9|SZO_i|DKIR~L zH@zEWayQB(_oJjoDW^*KW-2FBUlsv+rWW{Q%z<@2Yggg19z34g*VV*hJ+RJ1oFYi? zrgx)c?gneIG;gMh3rg4m$?ipm_=ZtZksrUaQs0SlbGUaJOKdPAB7O z(9Ph^eEs?Px%FCm3AFt)dDulLq($p>^g9xC?Ht3zj)||mukix+9Ndz{vSjX-YVD#6 k=BEEe_CP)4Tx0C)j~RL^S@K@|QrZmG~B2wH0nvUrdpNm;9CMbtL^5n^i$+aIn^?(HA4aZWV5ov6ELTdbo0FI&wK{O>*+w4vx20?>!`FrQsdJlnHR>OPy zcd~b_n$otK2Za4V;76L-DzNVtaSB-y0*E}{p()372;bw_^6ZZ}PI-92wGS&j#91PI zKs7DSe@(bk%_Y-7gGe}(^>I=@oY#w#*Bu9GZf3^F5WP>3rn}7Ut74&?PWBFvy`A)a zPP5)V!Xd&78LdA?xQ(9mjMYElVd13a#D+Z_7&Y|xU=_C-srWU*6kiZcC!$nw*)9$7 zn6CX+@=AhmkT}X@VSsa5NKe;HZuq)~1$`#h6R+ZTR#D-3j}vF!)ZOnz+5)dI4jl{{ z44Mr{P!L4~VVJN`K!!XTF*LGrKO?IK8z<8w`3e3jI8lUGNUta*C8 zn(P`s>{pjD=7Kek#B;Fw@hxAK%$F&Q6vg9J^Xf~4by_hu-=A!MJ3Znq&n~srbFGPs zH&&aMXZ>nO`|hf|ljc?VPhR!${AbO?W8x_>CU%PFA&Hm8F7cAsOREdwU~R_;ot1_u z(ruCYB-LPGn!NQdT|ZlRy+(fw^-+`=%+gee_kY4FWHg<*4sZI8+sFJD270UUORdLHO0nA4V) z%{fwsET5CQ>B?eK%uw4yQc~9?*JVo2}ze(;aRcp*ceL#HUJSllrgm5wQKR zQu+C;QrUh^8rFfA`ftFz{YAidi-`aL010qNS#tmY3ljhU3ljkVnw%H_00uQlL_t(| z0qvdHR^u=bMC~jjEI-2oZ~XrYA4K*{N=yk^mgPVa(z46v2wAJU>#AitWSIK(_4Qck z7`y_rl!tX)r>a#~hyurBJ9ZstfPH&=t0t34g>!;tUWk9AHZub~hyprVW%iToO%=kvLT4bTquq^>6Q#I~m+x9)H}!99G#1>pUD zU+s1~#}H))8bBW&9(+P%Gcn>vuBB=BxlIEu(`K`Akii!14bV?dPaZa+8{4^yYCW8p z2aTvj1aG(73Xs9>^YimNq5%@=@$s>GetvfOVzH=@{8m2I)@_;eVgI#N1M+&kb_tMi zknfBq*t!Ax<>kfY%jMEVH(;ZW4!a5R(q3XLD%?Q^yzg=hiwJG2&{5PgCf3QpeO8{TxGO@VfHt~viw)b017G)zkC{=705A5g3b-F>!vJ&0$uDJ z=&nXdSH1#dn~do4-IE8g0$I>l4O|iNK$Yz%a1N&|XgjXRl1mlvpcT27N@;I=$h7eu z4O3I^%;5lg?#QB8ffPd@(Q#*$howLRbQrne`LJ9bt~VjG@EjgDKvROa6YG`RSD=es z6107HWZ_R0$b!b|=vpB^y^#9fPJwecWkKK0G|l|i3JCOHD}JZzwcevsc4+%fsZv&* zk7&YVUX~lOHdKHN!w*h8=&&Qs!%lIV$~G0qF>8S4N?>l&9a)uAfb5vFum1u+E8;x2 zO5(mM-$#KyMu6Uk=-AA7RmANo+fks8RTi`zH)P4B3JCP23KlY6@6m;Ty3|Y;(S7^- zr5Dlo`zb)St*x64%#I)>x^Fgytvb+PlH z;c_?t;hpc`@ww;<5NW!vzq6SVHj z4V{W8@p7qM@C~yv=Ea))w?YJdNQVR63 zYJomyb)+t&Iy(xa7`8ye+`iRe$0b=3E6~MGpNz#y4YZt$=z;n=YPSS>B=`kdphu#> zNZeFJj}dg&qxnd*7?hha%g%_N)L%{UfI+D-5NF7U%u;Uo_vqvCSncFNhl*bH(5HdP#w_BGsn~m#-iFDXi0C2&I+z1-=n^Le#cEL>VHmleuL)9KXx ztufvM#x18^?*WrrHlup=A3DIJuCaAv1)zb0@LLchfwl`7mJu|#F}jgs3r8DLeWLw+ v$36`bRNGL`wGME@qdrwMYreSaefwW^{L9a%BKPWN%_+AW3auXJt}l zVPtu6$z?nM00bsUL_t(|+SFQ2OY1-s&5YA(B5G*`7b+;OL=gplKtbFH?!~POUARzi zuekINsQ5<&-H1Cu1Qjf}bt$5#O`Epnon-RTeAPEi@?df)VSj37CTDKWz4y#iQZAPn zV}uYTBW9Xrv)N?1TyAl3F`v&9+ayN}GYsSQ_LlYZ^b8CPXqpDEqb)6TAa1o<@N~6W z1x}!4gM)*mQb|))md_DIR@{o&G#XW1e|vjl+=hmRMn*>9byZa@*rt4_ZB)9he|~;8 zTP+7SNCN1^Vt=u(ua8oSHzFNuLVkXJYPA~Ry}!R(Ji(t3n!UZf0F4F6%x_$QlV?B1 z-vYG_-*J@_H~j5_v~d1qea4Ksyw4tPH}}b0cU)||K_!RV$(S!k5^D{1=lG))mPb*jrkv=%R2x*o`O+x(U+3U(tyCW5=o9M=B-VhK0h^}B$H&vt)8pggz}?Nw&8@Ai+1XhvCdE2W0@aA;a?y`% z0DWVipz_&d<+5A#b@5oZkztT`$9L!Ky#PA5IVK`Bqj|3WY+a`aC>5 zyt=x2b8~~vykdxcqNqjPMZ{ws5I_(^%O4yZ;42!Dx*7KR`ikrR{yzF(NDO9rLDERy zbW7`phX-&#r2pmR<^BCVhIETNfQ?4q?uL0tbAQjz&*BIwl?t}y&IYARen;r4U}%aJ zFg)Hc3_uabjVy^FT~LK6;R-{O7acqviCMfqK*!eKZGI;&knr62__+8GbdDF7UV%je zI?Gv>aNXJ;ayPfkuICnqr^20w%OyPf;u8uHrO+S<;}&hOo}x3|~V z*EvIyY>oZ*N-rinhx1*yYsH^_|{&wf+be7x1a7y0o-ZE|)=T-hVCjgF5; z*ZwJ;L!@*x!}0N70o?b?YfXwL1?+eEl4Jqi_)C6V8mLog`ul&lpyPfgyp@ple9#Mz z%73C6sjgULGFGHohMk4}&2Q;^@5kdiN6yeuvTxsDDrPp~k_6&1BfpfmIGL9x{By9v zj!T)qn$Dr7H})96;g#s}#ibIK*_4x8$(m*LcPUCJ@tWlM#5JZ@bqM^Aj}OSsdc7|5 z{}t%E4xHcL-)OK>sdRmPeRp>Ubua(_&D3f&c)3_C610>I+8+T10G`&Xne-*ZEC2ui M07*qoM6N<$f^dyD)&Kwi literal 2403 zcmV-p37qzcP)4Tx0C)j~RL^S@K@|QrZmG~B2wH0nvUrdpNm;9CMbtL^5n^i$+aIn^?(HA4aZWV5ov6ELTdbo0FI&wK{O>*+w4vx20?>!`FrQsdJlnHR>OPy zcd~b_n$otK2Za4V;76L-DzNVtaSB-y0*E}{p()372;bw_^6ZZ}PI-92wGS&j#91PI zKs7DSe@(bk%_Y-7gGe}(^>I=@oY#w#*Bu9GZf3^F5WP>3rn}7Ut74&?PWBFvy`A)a zPP5)V!Xd&78LdA?xQ(9mjMYElVd13a#D+Z_7&Y|xU=_C-srWU*6kiZcC!$nw*)9$7 zn6CX+@=AhmkT}X@VSsa5NKe;HZuq)~1$`#h6R+ZTR#D-3j}vF!)ZOnz+5)dI4jl{{ z44Mr{P!L4~VVJN`K!!XTF*LGrKO?IK8z<8w`3e3jI8lUGNUta*C8 zn(P`s>{pjD=7Kek#B;Fw@hxAK%$F&Q6vg9J^Xf~4by_hu-=A!MJ3Znq&n~srbFGPs zH&&aMXZ>nO`|hf|ljc?VPhR!${AbO?W8x_>CU%PFA&Hm8F7cAsOREdwU~R_;ot1_u z(ruCYB-LPGn!NQdT|ZlRy+(fw^-+`=%+gee_kY4FWHg<*4sZI8+sFJD270UUORdLHO0nA4V) z%{fwsET5CQ>B?eK%uw4yQc~9?*JVo2}ze(;aRcp*ceL#HUJSllrgm5wQKR zQu+C;QrUh^8rFfA`ftFz{YAidi-`aL010qNS#tmY3ljhU3ljkVnw%H_00tXLL_t(& z1?5`HFDy+IKQqSrEhOTRSP~HtA=YAHB^Dx)*o&Q5uwW-4cH&=PCHw&vVk?M92urc{ z8jta2zWSY>Q&ZE^*PZFxzI(eJ>8a|fQ>V`FoT^ig7V7Bei09h ziYOulobvMW7U-~7NCl7h z6=_(;I<{+03?{Q*^LAXx=v% z-KCwK9lnmj9Tns|fj}ARaJx}oUr+n{``i{&!-+pr;7)kbKtq^j#1L`wBxGP2IypIk zNcJSsuK-9LhB)Zx=!l2Act0y$RC|qsr6qq-=CsLV=9BCh=9HnJ=*!Csot~a@Bdo!h zlJLS{kYTRrnaW@TC71<^q}tO`AZfC zR!EuK6pF(`jg5^g0{Kh`ItVY?y7IEEBNG=6A6E1>$AW4gOm3z#+JF#|5y;xw+V~v- zDHDRR&<@nz-p+Z6^x5cx_JRX>lPvR#rm995B{i8d%|jgKG?eY^?Br(m_xHR;W5~+z zwaY`FxQ>oJ#JCD=Ap^3q)kh$i?KrP0Qsy*V?-ii~%;)CjW?Ecaq`SL2s;#Zn>u{Pf zs$-OaCwd#D`T2QjX=z~@Ca)X)(B726p4J84Vb;1~`57A6SEnB0nqaDGBq?b(89ukS*`Oh z0%&@Anx>|v_)99*c^pOmgfKl!<3d&nXuC!Jq%&y?nNS{|i{|F$XkcJ~Ha9nEYio=5 z)u>0{>h0~N{{DXI>gwX5h&Ep7W0#{r+bcwAFH*<`2vAQ?4<8*TCnr-x<0B$Qm;^en z^)cmX(4v7^DP>-yA{Unk$m2r6B)(8kQ^8H7Hs#p!(l5#-&!FW+8ra{Z+>2D^sI0vr z)5|y_GLhQnGs@CDjl%zfzSFS3(?4w+`ZtyNow9D~fya(1Wpm<2s9)L$aHNjI8x=ek zRO(w&K~dwdfp7#39*9kGvJgd;!T>$;4$pzR80GAM#cpOH`mhylpaZx!-=ov6344 z^YF%e{z;^x_fG;H35BgWjNu$s-;9v@erVe~XyO94$n(=P-(TT#3a(r6^$;f>r_+f| z)<6FWfH=+JRtETRImt)c!NI{e{@)u{I=I0I>OZ*y?8CzYe=QBE|AqcpQA~}`{{W^8 V7Ddpn{%8OI002ovPDHLkV1nOUlpFv6 diff --git a/src/KKPasscodeLock.bundle/box_filled@2x.png b/src/KKPasscodeLock.bundle/box_filled@2x.png old mode 100755 new mode 100644 index d2665783308b2459931196bc98baf954bbae63cd..dc0b6834208baa61241d3d903b4532a1b972c623 GIT binary patch delta 1667 zcmV-}27LLH8Ho*$8Gix*008{$(kK7`02y>eSaefwW^{L9a%BKPWN%_+AW3auXJt}l zVPtu6$z?nM00t{bL_t(|+U%XnFEe`>$J?4xb&0r>SRgEjkO(3nEL0-SLWIa!o!5Cq z`~#BrSctWajRlFF4RJ{%lGlCX8bsuH6B|S0Ew2=lL$G zooRnDAK!lGd1ihy^tH9MI+9xAd|vDIdV(UOc%Jvg4Tvi%D-8yNUJyZ-5j5}B=H{l` z?dA|M$8ix65l9>#33}+DfiFISkSB+H0k_d;MB*r&UT4r7h@AwvdAE+&xxI3^Tu!GG z*uoPI;YJEV;(sVHSV$7w4RU$qa5xY$EcCb=SVu=kBXQB@gj+IhG_^y}%gYNwe$8(9 z0dP$wli6&B$Ec_%fG$Qkv6B)e-T(p6&(F_xyB!t+PY-T%H?WS0i9zCEa3D^&CF2Ix z;A>zF7-0##M9!}-;0N#p%A&{7;DkFA++b~RG_nTn2!GS#ZomzQkvN1nJR#g6;zrhx zD!?7^dfbf_2&@CXSf4}*!uTe35(J1v)(|NoNl)F4d4lyH=M~l`#7=@R6<(`s0kqi7 zyyC{ySgD8--$d*r=gC{1ViQ9^Rh8$6pxDv8Z6>MB2}OQMlDpN7bwWV62{%bO+;sF+ zuASt&xPJ+;3g{_JD7y(aNzSg)CvK>#lqI!;yPFUzN}R$(-R!0rJgV9J^(gnJqK70o zwS#n(L`@0el-=6Z-DGN|ZO#Q?P4s0aZlK_%Hs?Rx=7b$$yWRfu^c0Thxv=qg@x>I2>0Hff)UFvEG+c(_3iKP z|GMfy(CO*v%F0SlPft-%QEzW=V`C!=Mh?Ha`|RutY}?e-?DzTath-x%-GAKN?C$O=G4hYUe_UQ(h5>FhYgH)P@U{rD zi|2XxLuyrb2kI&{EK6WN8K#4Oq&Nw5v4|$ntyXK84*u~f&`+DAmBH`t@56NPk6T+O zPV3R!qNAg~{q;@WF}u6FV`F34*+$<}!`hzH`TFPA zva&L{Mk^^P>FVmzu%8Tc$A`CkwSUT!$jHcvi3wRE1#0cd$w`H(oln)>Okc(dH8NmI zNJt1}khr+G@$vDjtSr{Hj+FzjZ&hAizP7fOmzO7Pld`k3aheJX6CW6Db9|JapTEAo z-qzOk*;s3CZr<3~C@3gkbGz7`v<7)HIy$<&z1`5z5EMGRp}xL;Yinz4Y=0~%DT&#Q z;<|H)}qZJ zYpY{$>MGUkDyb|{t*g}0T{2ZBPPc7Tl{+=@s(PHdN-YXO65%G?B*IO&Nx^Va9il=x z`0gI;f&eA}M3P7q ziGw(_HiCW;6cG`Dtnmp+g1Z6c^Yb(EMCfR64t+f}HDwZH6a=90pUD$D2@=!7A;>NW zpu<8>nBY3#i|;cCBHW?i24O6N(A^;Y+j|KUUxn!ZQ<+detEry?3;=EOo4dp0j@|$O N002ovPDHLkV1jl9E@uD$ literal 3220 zcmV;F3~Td=P)4Tx0C)j~RL^S@K@|QrZmG~B2wH0nvUrdpNm;9CMbtL^5n^i$+aIn^?(HA4aZWV5ov6ELTdbo0FI&wK{O>*+w4vx20?>!`FrQsdJlnHR>OPy zcd~b_n$otK2Za4V;76L-DzNVtaSB-y0*E}{p()372;bw_^6ZZ}PI-92wGS&j#91PI zKs7DSe@(bk%_Y-7gGe}(^>I=@oY#w#*Bu9GZf3^F5WP>3rn}7Ut74&?PWBFvy`A)a zPP5)V!Xd&78LdA?xQ(9mjMYElVd13a#D+Z_7&Y|xU=_C-srWU*6kiZcC!$nw*)9$7 zn6CX+@=AhmkT}X@VSsa5NKe;HZuq)~1$`#h6R+ZTR#D-3j}vF!)ZOnz+5)dI4jl{{ z44Mr{P!L4~VVJN`K!!XTF*LGrKO?IK8z<8w`3e3jI8lUGNUta*C8 zn(P`s>{pjD=7Kek#B;Fw@hxAK%$F&Q6vg9J^Xf~4by_hu-=A!MJ3Znq&n~srbFGPs zH&&aMXZ>nO`|hf|ljc?VPhR!${AbO?W8x_>CU%PFA&Hm8F7cAsOREdwU~R_;ot1_u z(ruCYB-LPGn!NQdT|ZlRy+(fw^-+`=%+gee_kY4FWHg<*4sZI8+sFJD270UUORdLHO0nA4V) z%{fwsET5CQ>B?eK%uw4yQc~9?*JVo2}ze(;aRcp*ceL#HUJSllrgm5wQKR zQu+C;QrUh^8rFfA`ftFz{YAidi-`aL010qNS#tmY3ljhU3ljkVnw%H_00~ScY+HQ42Zcxau?#ljkp#358Nnj z6chzr z4I9QuLgp<{Flm^}5G7Y%A4G#}Hkiiz^9?&yp z%y41DyRn=*UM(kQ)`N!E!h?VP`bB^Yc0Ygq{O!>IiEaAy=`?fZOebz>X(4RxQr;v> zx6P!-MkkkQKrWR^&IZT`%(uWhSh@jw)~s1h+}hgecsF39js$xx0B>ebE*6W9Cqr7~ zF<ZkRcg^hBsr$MgU|mWp?f{8lDTV@MK=bu`eF&*v;w>2F;Lh ztOj&uhZE|u%PYWEful0cz$Msg0i0>8ka02wZk*?Wh6-?T07W4x@do!7(Dp)xWB`o- zPiDYi2Bv&@?A`)JMtbWO}^U#9}vJ|;DhNI=)btoC&p2s(%Fq9-o5B-m{M zFaoQf;Gu{I4CD+u$Xw|t14I2`5fA8es3B5TVgUhNiPcirMnIakkg z*Xv2z9t#9Ok_+ZGk+`0FKkGj!3UsfSDo=^=PiFb|Cw9 zSs)6dK+yU{w_WOqG^z!{SOtPsJCgl$Tc8Ydlw}~@DraAM6GP8+w5bBjB42FSJvs2W zuO4)kWgg89^opD>vAq@uVrB##)WBXfMKV~xkDUYBuQ2PT`|;xkeINRsX*HRx=NO%3 zjh{SuLN{;Tr2hVXdh_NDef|2ChK7b5mGLXm*|TTUvSrI?+qP}A@6UbI(cY0Ma|D9M zY~UG@R;{mIy-MfKouij8U;3&5;Mm^1dq^H`%SFh;Uv18QU-cHY+J@c!UntT^@+C5jb`0d-b zY5Vr=^z`XdHM^qy=g*(h&Ye5y`t|D-wNJ8<%Cv0hHeEBT4U!Z*%Gj4LU#9NvZs+w5 zQR+vjgX8&;BS+}VmoIem=+P)m60Kum=z4UblEpOm!-o&4r>7@Y$SfLuSbpl%DY|#> z9%rR0_JCGBSKUv8MxQ@_c21o5Ou7~_<8tiKp+ofH!-raQUv-}8rGq5Z?(N&RbmhvGx($Er+BF&+9IV@T zaSRj)8neT1hQu*=Tzy=)aKXL#5m%o<{ovJ3xYo8MMBx+&+7?B^r1_wPF|X{p!(6*j~RVsNQt zgH58S;DUz02pmUgY(t%ToN4>%ndI1hG9jNCsy9wt(0W6)l3r$08ec>t6>I|?#LNSl zX9CAb8E`7&e*5-qD%E4Ho8;JjiZDBlxt{v~KWFH1&@9pGCXt>$e|{3fI%6g|wyJa( zBS80fwAvW^`mE5)ZAdR#v?wt#k{nxCI*e5yXuUHV(<@f2NKCBd%aJ?O1l zw>oblo~q*2*2jx+@tt>CLfQAxCc(p&1yh@P<>5v0>(;F!{OwOY!`iiLY2Lhf^&GOQ zu^f-K8Dtdg_WrRqO0`()?Afy?*8XbM8M7^0y19VkS_u$mzbF4XNedP%h_lPUzUI!I zOTB;h2G&WUkeP9;%1{PcElkTk9@jn5eWGsSc6D{poVGc28!wK5T+r&Zn7VJ89dQgC zcOShyy@catt;3o%Yn(@lYCXU&Y9pj=4mb(>(={oS=|SJi*~f}0`_ z9z3uXa#Ti{1P$dEE?h{rZr!53fBLAivvW$o@kb;ZH*R!RhC6re(Bj35quSHjdcI4y zelWLIgAl=s~F9P0xZLF<(yoqh|r$7sw1zuDlIpMLeTtAWl_JUY9qJ(>w(R^? zv>cZ`c1lGeh*{`!-9e30p?w1g8O8|ZWge|IQuiCcUa3}5Wu@-3Qe~h~V5-OsB(~cE ze(a2(?N&vktHc8C4U?e8ezPQ~jg;AC0mq{Sq+L+rl!n=QmhLn?G8CsVve=i-(gQk+ z3X4vY7H~nci;H2hV*!<^3tCq%>>tMU`jSrG0zu4tL9^KUTF?0s+hc(!i~>Qcu5XW8 zB8kZYVXVqPN0}X_fh5l!3z!&|frhwYv%?;hL=xQse(dDVm~N?zri~t*QC%BaEdkvi z_yx3pZV(GJh??TjjR@NB)Vx7#ktsEGmcAaH&rKHT4Kihoj3~p5n3+i}_c|KC6UJNR zvEfw-BO@bjTqwBJOnpdR!WK|jfgN)MQw{|rRLH1=e{I7yJUr~wLq`(qwE*CP6?0?I z$Y;Ket1@U*ES8GYQfeXgVnF77dsS_0$-u~AS1eMgRB{+1jeM|0$ZgrOWxTn$ned)2 zY^|-Wgfuq1%L6ya`54gH=CoIPz~m*Hy}I~6bbv>mXX(ZaKmj)bWC3k2V3v$QgByD{ zVl3e(! Date: Mon, 28 Jan 2013 16:41:08 +0000 Subject: [PATCH 45/62] Boxes are now centred within the view. Previously box count multiplied by 71.0 was used which made the box view 10pts wider than it really is, leaving more gap on the right than the left. --- src/KKPasscodeViewController.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 3a848b3..b616391 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -135,7 +135,7 @@ - (void)viewWillAppear:(BOOL)animated self.navigationItem.title = KKPasscodeLockLocalizedString(@"Enter Passcode", @""); } - + CGFloat totalBoxesWidth = (71.0 * kPasscodeBoxesCount) - 10.0; if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) { if (_passcodeLockOn) { @@ -143,7 +143,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -156,7 +156,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_setPasscodeTableView]; [_textFields addObject:_setPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -167,7 +167,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_confirmPasscodeTableView]; [_textFields addObject:_confirmPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesConfirmView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; + UIView *boxesConfirmView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)]; boxesConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesConfirmView addSubview:[[_boxes lastObject] objectAtIndex:i]]; @@ -178,7 +178,7 @@ - (void)viewWillAppear:(BOOL)animated [_tableViews addObject:_enterPasscodeTableView]; [_textFields addObject:_enterPasscodeTextField]; [_boxes addObject:[self boxes]]; - UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width * 0.5 - 71.0 * kPasscodeBoxesCount * 0.5, 0, 71.0 * kPasscodeBoxesCount, kPasscodeBoxHeight)]; + UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)]; boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; for (int i = 0; i < [[_boxes lastObject] count]; i++) { [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]]; From cbb9c2c5eba7d07fbc33a11beff1671864f547c9 Mon Sep 17 00:00:00 2001 From: Martin Baker Date: Tue, 29 Jan 2013 22:42:51 +0000 Subject: [PATCH 46/62] Boxes now vertically centred on 4" screen devices. The empty tableView is necessary to avoid white background showing through. Position of boxes on iPad not changed. --- src/KKPasscodeViewController.m | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index b616391..2edf217 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -55,8 +55,18 @@ - (void)loadView [super loadView]; self.view.backgroundColor = [UIColor whiteColor]; + + CGRect tableViewFrame = self.view.bounds; + if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad && [[UIScreen mainScreen] bounds].size.height > 480) { + // is running on device with 4" screen so add background tableView + UITableView *backgroundTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped]; + [self.view addSubview:backgroundTableView]; + + //and move other tableViews down so boxes are vertically centered + tableViewFrame.origin.y += 44.0; + } - _enterPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; + _enterPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped]; _enterPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _enterPasscodeTableView.delegate = self; _enterPasscodeTableView.dataSource = self; @@ -64,7 +74,7 @@ - (void)loadView _enterPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_enterPasscodeTableView]; - _setPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; + _setPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped]; _setPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _setPasscodeTableView.delegate = self; _setPasscodeTableView.dataSource = self; @@ -72,7 +82,7 @@ - (void)loadView _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.view addSubview:_setPasscodeTableView]; - _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped]; + _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped]; _confirmPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _confirmPasscodeTableView.delegate = self; _confirmPasscodeTableView.dataSource = self; From 5322126377a7dd62b03097fec1045d6fe6474457 Mon Sep 17 00:00:00 2001 From: Hannes Kaeufler Date: Tue, 7 May 2013 12:04:42 +0200 Subject: [PATCH 47/62] Update podspec --- KKPasscodeLock.podspec | 1 - 1 file changed, 1 deletion(-) diff --git a/KKPasscodeLock.podspec b/KKPasscodeLock.podspec index 3d08802..5ddff98 100644 --- a/KKPasscodeLock.podspec +++ b/KKPasscodeLock.podspec @@ -9,7 +9,6 @@ Pod::Spec.new do |s| s.platform = :ios s.source_files = 'src/*.{h,m}' s.resources = "src/KKPasscodeLock.bundle" - s.clean_paths = "Classes", "*.{plist,pch,md,m,xcodeproj}", "SampleApp" s.frameworks = 'QuartzCore', 'AudioToolbox', 'Security' s.requires_arc = true end From ea9ac0fb2d9652eec0b091a8793faebace08f058 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 22 May 2013 22:32:52 +0100 Subject: [PATCH 48/62] added method to reset passcode settings --- src/KKPasscodeLock.h | 5 +++++ src/KKPasscodeLock.m | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index b33122f..201aa47 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -50,6 +50,11 @@ */ - (void)setDefaultSettings; +/** + * reset the passcode settings + */ +- (void)resetSettings; + @property (nonatomic,assign) BOOL eraseOption; @property (nonatomic,assign) NSUInteger attemptsAllowed; diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index a04e2ec..6134164 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -55,6 +55,12 @@ - (void)setDefaultSettings } } +- (void)resetSettings +{ + [KKKeychain setString:@"NO" forKey:@"passcode_on"]; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; +} + - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value { static NSBundle *bundle = nil; From 04e88c92328e50493602e961b1d7f253c2f36178 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 22 May 2013 22:37:20 +0100 Subject: [PATCH 49/62] fixed tableview cell selection/deselection bug --- src/KKPasscodeSettingsViewController.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 6470706..1bf49cf 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -161,9 +161,9 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI #else cell.textLabel.textAlignment = NSTextAlignmentCenter; #endif - - cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (!_passcodeLockOn) { + cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.textLabel.textColor = [UIColor grayColor]; } @@ -244,8 +244,9 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) #else [self.navigationController presentViewController:nav animated:YES completion:nil]; #endif - [tableView deselectRowAtIndexPath:indexPath animated:YES]; } + + [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (void)didSettingsChanged:(KKPasscodeViewController*)viewController From 6f77d867c38606cc030a5bcff367bfa99ad6e2e5 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 22 May 2013 22:51:05 +0100 Subject: [PATCH 50/62] added class property to be able to instantiate any subclass of KKPasscodeViewController for customization purposes --- src/KKPasscodeSettingsViewController.h | 2 + src/KKPasscodeSettingsViewController.m | 51 ++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index 511dd90..f6c6df5 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -46,6 +46,8 @@ BOOL _eraseDataOn; } +@property (nonatomic) Class passcodeViewControllerClass; + @property (nonatomic, unsafe_unretained) id delegate; @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 1bf49cf..0d8fb2a 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -26,6 +26,51 @@ @implementation KKPasscodeSettingsViewController @synthesize delegate = _delegate; +#pragma mark - +#pragma mark Properties + +- (void)setPasscodeViewControllerClass:(Class)passcodeViewControllerClass +{ + if ([passcodeViewControllerClass isSubclassOfClass:[KKPasscodeViewController class]]) { + _passcodeViewControllerClass = passcodeViewControllerClass; + } +} + +#pragma mark - +#pragma mark Initialization + +- (id)init +{ + if (self = [super init]) { + self.passcodeViewControllerClass = [KKPasscodeViewController class]; + } + return self; +} + +- (id)initWithStyle:(UITableViewStyle)style +{ + if (self = [super initWithStyle:style]) { + self.passcodeViewControllerClass = [KKPasscodeViewController class]; + } + return self; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + self.passcodeViewControllerClass = [KKPasscodeViewController class]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + if (self = [super initWithCoder:aDecoder]) { + self.passcodeViewControllerClass = [KKPasscodeViewController class]; + } + return self; +} + #pragma mark - #pragma mark UIViewController methods @@ -190,8 +235,8 @@ - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSI - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath { if (indexPath.section == 0 && indexPath.row == 0) { - KKPasscodeViewController* vc = [[KKPasscodeViewController alloc] initWithNibName:nil - bundle:nil]; + KKPasscodeViewController* vc = [[self.passcodeViewControllerClass alloc] initWithNibName:nil + bundle:nil]; vc.delegate = self; if (_passcodeLockOn) { @@ -220,7 +265,7 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) #endif } else if (indexPath.section == 0 && indexPath.row == 1 && _passcodeLockOn) { - KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil]; + KKPasscodeViewController *vc = [[self.passcodeViewControllerClass alloc] initWithNibName:nil bundle:nil]; vc.delegate = self; vc.mode = KKPasscodeModeChange; From 9d0753c7b65a04b562b20fc4d54cafa8526d16a0 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 22 May 2013 23:01:13 +0100 Subject: [PATCH 51/62] failedAttemptsCount stored in the keychain to avoid to be reset killing the app --- src/KKPasscodeLock.m | 5 +++++ src/KKPasscodeViewController.h | 3 --- src/KKPasscodeViewController.m | 11 ++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 6134164..65a0337 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -53,12 +53,17 @@ - (void)setDefaultSettings if (![KKKeychain getStringForKey:@"erase_data_on"]) { [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; } + + if (![KKKeychain getStringForKey:@"failedAttemptsCount"]) { + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; + } } - (void)resetSettings { [KKKeychain setString:@"NO" forKey:@"passcode_on"]; [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; } - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 15d5d10..2d95eb9 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -74,9 +74,6 @@ typedef NSUInteger KKPasscodeMode; UILabel* _passcodeConfirmationWarningLabel; UIView* _failedAttemptsView; UILabel* _failedAttemptsLabel; - - // failed attements coutner - NSInteger _failedAttemptsCount; // the current panel that being displayed NSUInteger _currentPanel; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 2edf217..79c646c 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -259,7 +259,12 @@ - (void)incrementFailedAttemptsLabel [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; } - _failedAttemptsCount += 1; + NSInteger _failedAttemptsCount = [[KKKeychain getStringForKey:@"failedAttemptsCount"] integerValue]; + + _failedAttemptsCount++; + + [KKKeychain setString:[NSString stringWithFormat:@"%d", _failedAttemptsCount] forKey:@"failedAttemptsCount"]; + if (_failedAttemptsCount == 1) { _failedAttemptsLabel.text = KKPasscodeLockLocalizedString(@"1 Failed Passcode Attempt", @""); } else { @@ -292,6 +297,8 @@ - (void)incrementFailedAttemptsLabel [_delegate didPasscodeEnteredIncorrectly:self]; } } + + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; } } @@ -459,6 +466,8 @@ - (void)vaildatePasscode:(UITextField*)textField if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self]; } + + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000 [self dismissModalViewControllerAnimated:YES]; From 1034b211e902754545b11e89d034e7667d672eab Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Wed, 22 May 2013 23:46:35 +0100 Subject: [PATCH 52/62] implemented passcode block feature --- src/KKPasscodeLock.h | 18 +++++++++++ src/KKPasscodeLock.m | 55 ++++++++++++++++++++++++++++++++++ src/KKPasscodeViewController.h | 1 + src/KKPasscodeViewController.m | 6 ++++ 4 files changed, 80 insertions(+) diff --git a/src/KKPasscodeLock.h b/src/KKPasscodeLock.h index 201aa47..a14e0b8 100644 --- a/src/KKPasscodeLock.h +++ b/src/KKPasscodeLock.h @@ -20,6 +20,7 @@ #import #import "KKPasscodeViewController.h" +extern CGFloat const kPasscodeBlockDisabled; @interface KKPasscodeLock : NSObject { @@ -28,6 +29,9 @@ // how many attemepts is user is allowed to have before the screen is locked NSUInteger _attemptsAllowed; + + // the minimum time interval (in seconds) that has to pass before isPasscodeBlocked return FALSE again + NSTimeInterval _passcodeBlockInterval; } /** @@ -40,6 +44,16 @@ */ - (BOOL)isPasscodeRequired; +/** + * checks if the passcode has been blocked due to too many failed attempts + */ +- (BOOL)isPasscodeBlocked; + +/** + * return an interval <= 0 if the passcode is not blocked or a value > 0 indicating the time remaining until the passcode can be unlocked + */ +- (NSTimeInterval)passcodeBlockedRemainingTime; + /** * returns a localized string from the framework's bundle */ @@ -59,4 +73,8 @@ @property (nonatomic,assign) NSUInteger attemptsAllowed; +@property (nonatomic,assign) NSTimeInterval passcodeBlockInterval; + +@property (nonatomic, strong, readonly) NSDateFormatter *dateFormatter; + @end diff --git a/src/KKPasscodeLock.m b/src/KKPasscodeLock.m index 65a0337..40e3dcc 100644 --- a/src/KKPasscodeLock.m +++ b/src/KKPasscodeLock.m @@ -19,13 +19,21 @@ #import "KKKeychain.h" #import "KKPasscodeViewController.h" +CGFloat const kPasscodeBlockDisabled = MAXFLOAT; + static KKPasscodeLock *sharedLock = nil; +@interface KKPasscodeLock () + +@property (nonatomic, strong, readwrite) NSDateFormatter *dateFormatter; + +@end @implementation KKPasscodeLock @synthesize eraseOption = _eraseOption; @synthesize attemptsAllowed = _attemptsAllowed; +@synthesize passcodeBlockInterval = _passcodeBlockInterval; + (KKPasscodeLock*)sharedLock { @@ -34,16 +42,58 @@ + (KKPasscodeLock*)sharedLock sharedLock = [[self alloc] init]; sharedLock.eraseOption = YES; sharedLock.attemptsAllowed = 5; + sharedLock.passcodeBlockInterval = 600.0f; // 10 minutes default, kPasscodeBlockDisabled means disabled } } return sharedLock; } +- (void)setPasscodeBlockInterval:(NSTimeInterval)passcodeBlockInterval +{ + _passcodeBlockInterval = passcodeBlockInterval; + if (_passcodeBlockInterval == kPasscodeBlockDisabled) { + [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"]; + } +} + +- (NSDateFormatter *)dateFormatter +{ + if (!_dateFormatter) { + _dateFormatter = [[NSDateFormatter alloc] init]; + _dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss'Z'"; + _dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"]; + _dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; + } + return _dateFormatter; +} + - (BOOL)isPasscodeRequired { return [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; } +- (BOOL)isPasscodeBlocked +{ + return [self passcodeBlockedRemainingTime] > 0.0f; +} + +- (NSTimeInterval)passcodeBlockedRemainingTime +{ + if (self.passcodeBlockInterval == kPasscodeBlockDisabled) { + return 0.0f; // Disabled, we don't need to check + } else { + NSString *lastPasscodeLock = [KKKeychain getStringForKey:@"incorrect_passcode_datetime"]; + + NSDate *lastPasscodeLockDate = lastPasscodeLock.length ? [self.dateFormatter dateFromString:lastPasscodeLock] : nil; + + if (lastPasscodeLockDate) { + return self.passcodeBlockInterval - [[NSDate date] timeIntervalSinceDate:lastPasscodeLockDate]; + } else { + return 0.0f; // Passcode is not blocked + } + } +} + - (void)setDefaultSettings { if (![KKKeychain getStringForKey:@"passcode_on"]) { @@ -57,6 +107,10 @@ - (void)setDefaultSettings if (![KKKeychain getStringForKey:@"failedAttemptsCount"]) { [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; } + + if (![KKKeychain getStringForKey:@"incorrect_passcode_datetime"]) { + [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"]; + } } - (void)resetSettings @@ -64,6 +118,7 @@ - (void)resetSettings [KKKeychain setString:@"NO" forKey:@"passcode_on"]; [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; + [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"]; } - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value diff --git a/src/KKPasscodeViewController.h b/src/KKPasscodeViewController.h index 2d95eb9..1c36f97 100755 --- a/src/KKPasscodeViewController.h +++ b/src/KKPasscodeViewController.h @@ -60,6 +60,7 @@ typedef NSUInteger KKPasscodeMode; - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController; - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController; +- (void)shouldLockApplication:(KKPasscodeViewController*)viewController; - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController; - (void)didSettingsChanged:(KKPasscodeViewController*)viewController; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 79c646c..8c6ec73 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -296,6 +296,12 @@ - (void)incrementFailedAttemptsLabel if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { [_delegate didPasscodeEnteredIncorrectly:self]; } + + [KKKeychain setString:[[KKPasscodeLock sharedLock].dateFormatter stringFromDate:[NSDate date]] forKey:@"incorrect_passcode_datetime"]; + + if ([_delegate respondsToSelector:@selector(shouldLockApplication:)]) { + [_delegate shouldLockApplication:self]; + } } [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; From fcc09be6aba37e33017a8d6df5b4e359f95a7fc0 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 23 May 2013 00:29:08 +0100 Subject: [PATCH 53/62] added extra delegate to settings view controller to be able to reproduce the same app logic redirected delegates method to extra delegate in settings view controller improved passcode view controller appearance on iPad (presented as form sheet) --- src/KKPasscodeSettingsViewController.h | 2 +- src/KKPasscodeSettingsViewController.m | 33 +++++++++++++++++- src/KKPasscodeViewController.m | 48 ++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.h b/src/KKPasscodeSettingsViewController.h index f6c6df5..8677acb 100755 --- a/src/KKPasscodeSettingsViewController.h +++ b/src/KKPasscodeSettingsViewController.h @@ -49,5 +49,5 @@ @property (nonatomic) Class passcodeViewControllerClass; @property (nonatomic, unsafe_unretained) id delegate; - +@property (nonatomic, unsafe_unretained) id passcodeViewControllerDelegate; @end diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 0d8fb2a..acc275b 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -294,6 +294,34 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) [tableView deselectRowAtIndexPath:indexPath animated:YES]; } +- (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController +{ + if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) { + [_passcodeViewControllerDelegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:viewController]; + } +} + +- (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController +{ + if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) { + [_passcodeViewControllerDelegate performSelector:@selector(didPasscodeEnteredIncorrectly:) withObject:viewController]; + } +} + +- (void)shouldLockApplication:(KKPasscodeViewController*)viewController +{ + if ([_passcodeViewControllerDelegate respondsToSelector:@selector(shouldLockApplication:)]) { + [_passcodeViewControllerDelegate performSelector:@selector(shouldLockApplication:) withObject:viewController]; + } +} + +- (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController +{ + if ([_passcodeViewControllerDelegate respondsToSelector:@selector(shouldEraseApplicationData:)]) { + [_passcodeViewControllerDelegate performSelector:@selector(shouldEraseApplicationData:) withObject:viewController]; + } +} + - (void)didSettingsChanged:(KKPasscodeViewController*)viewController { _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"]; @@ -305,7 +333,10 @@ - (void)didSettingsChanged:(KKPasscodeViewController*)viewController if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } - + + if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didSettingsChanged:)]) { + [_passcodeViewControllerDelegate performSelector:@selector(didSettingsChanged:) withObject:viewController]; + } } diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 8c6ec73..86e589e 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -26,6 +26,7 @@ @interface KKPasscodeViewController () @property(nonatomic,assign) BOOL isSmallLandscape; +@property(nonatomic,strong) UIView *dimView; @end @@ -50,6 +51,30 @@ @implementation KKPasscodeViewController #pragma mark - #pragma mark UIViewController +- (id)init +{ + if (self = [super init]) { + self.modalPresentationStyle = UIModalPresentationFormSheet; + } + return self; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { + self.modalPresentationStyle = UIModalPresentationFormSheet; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + if (self = [super initWithCoder:aDecoder]) { + self.modalPresentationStyle = UIModalPresentationFormSheet; + } + return self; +} + - (void)loadView { [super loadView]; @@ -222,6 +247,18 @@ - (void)viewWillAppear:(BOOL)animated self.view.bounds.size.width, self.view.bounds.size.height); } + + if (!self.dimView) { + id appDelegate = [[UIApplication sharedApplication] delegate]; + self.dimView = [[UIView alloc] initWithFrame:appDelegate.window.rootViewController.view.bounds]; + self.dimView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.dimView.backgroundColor = [UIColor scrollViewTexturedBackgroundColor]; + self.dimView.alpha = 0.0f; + [appDelegate.window.rootViewController.view addSubview:self.dimView]; + [UIView animateWithDuration:0.3f animations:^{ + self.dimView.alpha = 1.0f; + }]; + } } } @@ -233,6 +270,17 @@ - (void)viewWillDisappear:(BOOL)animated { [_enterPasscodeTextField resignFirstResponder]; [_setPasscodeTextField resignFirstResponder]; [_confirmPasscodeTextField resignFirstResponder]; + + if (self.dimView) { + [UIView animateWithDuration:0.3f + animations:^{ + self.dimView.alpha = 0.0f; + } + completion:^(BOOL finished) { + [self.dimView removeFromSuperview]; + self.dimView = nil; + }]; + } } From 0c84bf45ae8b00364f15732b85c3063c201f4f22 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 23 May 2013 11:37:02 +0100 Subject: [PATCH 54/62] navigation controller of passcode view controller now respects customised navigationbar and toolbar classes --- src/KKPasscodeSettingsViewController.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index 6470706..dbedff0 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -200,7 +200,10 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) vc.mode = KKPasscodeModeSet; } - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + UINavigationController *nav = [[UINavigationController alloc] + initWithNavigationBarClass:[self.navigationController.navigationBar class] + toolbarClass:[self.navigationController.toolbar class]]; + nav.viewControllers = @[vc]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { nav.modalPresentationStyle = UIModalPresentationFormSheet; @@ -225,8 +228,10 @@ - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*) vc.mode = KKPasscodeModeChange; - UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; - + UINavigationController *nav = [[UINavigationController alloc] + initWithNavigationBarClass:[self.navigationController.navigationBar class] + toolbarClass:[self.navigationController.toolbar class]]; + nav.viewControllers = @[vc]; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { nav.modalPresentationStyle = UIModalPresentationFormSheet; From 8648db8091a24c5490a1b1b388f81bff517591b9 Mon Sep 17 00:00:00 2001 From: Adar Porat Date: Thu, 29 Aug 2013 10:26:22 -0400 Subject: [PATCH 55/62] Update README.mdown --- README.mdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.mdown b/README.mdown index e12d26d..5c7b108 100644 --- a/README.mdown +++ b/README.mdown @@ -1,4 +1,8 @@

What is KKPasscodeLock?

+ +![](http://cocoapod-badges.herokuapp.com/v/KKPasscodeLock/badge.png)   ![](http://cocoapod-badges.herokuapp.com/p/KKPasscodeLock/badge.png) + + KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passcode settings in ios apps. ![](https://github.com/aporat/KKPasscodeLock/raw/master/screenshots/iphone-1.png) From a11b42f2bc4eb22974b2c35bcda77bfc6d62d41b Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 10 Oct 2013 10:43:15 +0100 Subject: [PATCH 56/62] added new boxes images to fit iOS7 style --- src/KKPasscodeLock.bundle/box_empty_ios7.png | Bin 0 -> 1188 bytes .../box_empty_ios7@2x.png | Bin 0 -> 2987 bytes src/KKPasscodeLock.bundle/box_filled_ios7.png | Bin 0 -> 1401 bytes .../box_filled_ios7@2x.png | Bin 0 -> 3387 bytes src/KKPasscodeViewController.m | 31 ++++++++++++++---- 5 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 src/KKPasscodeLock.bundle/box_empty_ios7.png create mode 100644 src/KKPasscodeLock.bundle/box_empty_ios7@2x.png create mode 100644 src/KKPasscodeLock.bundle/box_filled_ios7.png create mode 100644 src/KKPasscodeLock.bundle/box_filled_ios7@2x.png diff --git a/src/KKPasscodeLock.bundle/box_empty_ios7.png b/src/KKPasscodeLock.bundle/box_empty_ios7.png new file mode 100644 index 0000000000000000000000000000000000000000..5f927ecd33c1f3cb2bdfa84fad27c3340ce4780a GIT binary patch literal 1188 zcmbVMTWHf@6pl`Yx4EZzeaYgBx8~L~O~R^nO{+yaM^~{ZNVDYM8rED){@II&;0*-v zNgqVmoG1fDeem+&1rZ-aWa0z`hYUnv1Fut2R0RKYYn?DA7?S*#obUV2IsZ91(%Q12 zZtl{#7>3owH_AyghR_q3U5nnIm{$kUumncau+8d#dBp)(ShLyz9ygRukOYcW-1Pu7 zVOUL8Po-fxu~||rgH${lvS8QaADaR(X&?-b^A+#lm z%IEWB-cMRiC&h@O=y9;D4_Wx!q6w9P&vchp7-Zn8j&4KUGI5VlX}7vzh(Ml>hhW%= zM3vZdClZBHMimsBVn~`Y3@@&-wF{Hrj~i23yQ!iLs3dT$ZbwDu(XqS&M!B0_$TLLV zNLw5o9g32ZEw$SKCXCA=0(~JhU6W{5Kv@iObdaTafnkIQ!^w0sB80h!AjY@~$5hx@ z*w01%u`nw(BaWzFpv9;d4DexD2u2t_R>8(i7b>O-D!Mw-oxqCIVx@=!6lggq%gR+M zpfzhj%gtIg9%bkRcR=Iu%D~Zg11;uQ242pvq)*|&zat;VYX6fp3OPf0 znzslw3P=XdAa!?8n(I^oymvl% zfdww!tg*(ebdN`?w*mxr?(bM#?{dq@6TQ9Ie)s?|Cd-* e{zvcUh78v5Gw|$tf6W>1zY&kN$d{Tk`+ox+ij9;2 literal 0 HcmV?d00001 diff --git a/src/KKPasscodeLock.bundle/box_empty_ios7@2x.png b/src/KKPasscodeLock.bundle/box_empty_ios7@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ce79453a686ae5831dfe6d921159cdf2de0bd1d6 GIT binary patch literal 2987 zcmZ`*XHXOB68#XQH|a&ZAP9&+=tzfzUIl^)O_~rCk*YMogkBUxq#Fd4UZhAc6r~AB z2~BD!(gg&s6oXRoxO3mUd;h$dvwP;-+3%d${j~|#%ng|6`RD-vOh$&fR;L_#8n$0Dyu0ub==q&v^i#x3~p^UAyM#6X+A*>EkPC1cM3s`ulj?y5kN& z@HEyM1-D-3(jd+4K~3V(&rE!*IB5l~ph;+sR8a{bI#%O&p@Jz+%eHfRdQ|*9`SFy= z$>>L%mXeH#^piBpLNAk}Ud1Q&9xjBv@)~a@tqz>jPiU@H>|*N%XLma29*GIttL(gX}O0 zVE;^rlOjJA2(r7!>jF@n)8aF`nD!TSgKTsqZ{Q< z6ERj~VCy0YfSo3vw$I|UlxWYWg~1^5cdcWC{7V4sVf54wfE&6Z((v9ot!`QXbn`J1 z)jIrpZ9I~#)aTpI&a^QcIV(j&MLOG|tWf%!==1*0mn$Nn;;{qO0us)U&)NbCt(Km# zX}-+T?Kbb2HGElqyU^yfi8o{DsC0U0*KF!Ub&%1$H$2&X=r^XS^#HlZqu6Ex*=LwqOO4Nr^)P&iGGDa*ONODF zfwDO%T=}^}{%`p-9w`;94V8PcOs8nVx@B6w^3ce4-jR{+>VVc#Mm~!C2nK zSAD&LvMFKTZLlVYiVdUJN~c5>1Qm3-pks(MMVe0^Z^gRhxiDffaHnPNGky5mveytzCyJSg5Eo;O*hMZBX)yxnjaW!cTFwQQDb z9~-0uPT~P)YA=1dak^+azXSwcT2@pxSH@toYtsi$DZODGUZrm%Z@pAX_c^27rVM*+ z)0*EJRjO7JSB5I_for{vusu$ow(T(Ouzvy|m`@I26*ZcV&6b2lP!j^q2~#moFf z3Z{5jcL%SsjLZyVxna3wxxr?OQq@*5wx~s~$@UP#tkZ2Q<{)N(N+F!Zu31l6&lb}c zbD3$V?pH~dc@^>(H0cI?xLdrPmG}MzI?vRncrK)6?f3a`$T9rb`*-oa0V9&Sj!}e~ z$VlK(|ETEaqb>mHCjPL5Id*8n3SH7&G8dv#@x$t`#`GWSvpl-h<*+2OP{+*#COE~tv%bmBd*14kwC~g!!AZj;0DZwPNPdZamI+wp|wx?y;IB?(3aUpbM zADdg3+rCvoe6y{zeQP^z=0(54i_3Yo@&Q8~J+Lp9E5lk0FVbba<|`sBU=|ou{hBbu z4U&qeoTzRn3@RhJeCO8uspNpneEc}{N5)~R2)wV|h>&!WR8&nade_E4C7lN?GO z2F2)06e!9Bj1I>B%;7=k1ECMeTB=0%pS4q4I*;=4I-EKwk(H4vZIwcvJ>Q;G3X#^b z2&sfy%rVy@zK##kxU9M)bwn_V#l*!RVzrWe|@#ayM*Y?7)O+NSa5SD*ckcGN}4u+nh+B+NnL zg87c2gjwj*Z>i0SAtE2;3nf?Z(PE`fnoXHZXLD8axN`0bddq33w#Y_3O?~1AEfX?J z!=W}%s~-3JD%@jgPd?sFYJglwr}^Yn_oU*itrR^DTJ#leCq5xTQ;Tv(czhU0=vB!m z&$}|P)nC_3e4_mP`wQ|GTRYprQ(R%J2|`K$x!O{3TcuXrFN8?H#Ci5g>~-o2^>>Ll z3GXqB@-0MWRYZ$usF@e$Mq6)WTRnx>CW8(AN=*3X%*2+X1rlOAU+?le7R#^6nUGk; zLFCTld^jmS6THG7=hOQkd*<2O((+FH%|VY5kM-3#sXTk;jIzwtOy;{xQ`2vm=C8lq z+W)CXgk%ng6Pu!NF#M|z>hGG}i$4(t)U@EQ;d}7kaHZ{$*?O0WgS*4q{9(;M6~2uT z?VCx*nxEbiZ76Ka#yrN{4~-7%NLp11W$OnShu)5r=H7l=-IODg$27vsxC#8{F@X^c zxK+ydl}!WY?myn2V7~`RF)1{`#7~7m63}+1&WbS09eeixzc)ZcN z$@_-b)!udC{ik4g*&BP;54YNaW`YF1znW*USbiY*P@L@ft7hMNsQ56AH!Y1!MVYmG zxQ%;Uec{uWYw{bw5Xzm8U}fi7AzZCsS=07??9MLn2Bde0{8v^Kf6`()~Xj@TAnpKdC8`Lf!&sHg;q@=(~U%$M( zT(8_%FTW^V-_X+15@d#vkuFe$ZgFK^Nn(X=Ua>OF1ees}t-3#_`hBq$Z(46Le)Ln;eW^@CE2 z^Gl18f$@>14ATq@JNy=b6armi#;x)!4$o($&)3 z)XdSv!ra-=%nhd3Gq1QLF)uk4W^X3YUZ`Fdyn3yii&7Iy@{2<9^K)P+ARr^ZB)>Q# zzd*q`*i1pgH!(Rg4 zck{*QO%Gid5U?%x`g=LX%?Ug_O#(k2FvT=^@OLfpc>1~WY2`efmkJyq8zVyc9>4JY zyOA->q5kj%%ME<%4yf(mI~?$A>NcI#YCOL-R3@zZ5I>VCJwZ~&^p4`9d6~6;=Bl;S zU*i6Dpyi4FrpgUBlH9xV8KW1KOy3zgIYr3Fdx{*>W6fX2LQB~l%v|e37M1v)+NT`& zOSWd|3w!S=bp|SDdtF{K%u#!@Z>G5D#Lr*!D!gv&o~%{Nf9*gz_uS$Qy0w{=OkxL; zg_HRY3jGk+`Jm%*#MQOaw*1hIFkQdwaB1)@ZH>m-f;FpmEuTL9t=F>H|1K*+v`&5h zdn;?T;<}0FW@)}XYQwhQZ^r9gTGLOTob>Pf!~7JqKmv!?u9Y?11`Kf~F~wH>#eYGC Np{J{#%Q~loCIDj_@&f<> literal 0 HcmV?d00001 diff --git a/src/KKPasscodeLock.bundle/box_filled_ios7@2x.png b/src/KKPasscodeLock.bundle/box_filled_ios7@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..92b0732dd4981f411320c0f972610d8ba102fead GIT binary patch literal 3387 zcmZ{mWmMFQ*2e#Ybax1cF6lhf05fz73^J4w!hlF4DL8Z~h)6RCDjg!o;E+Ruz)+Gy zhm;IQLQv{*?mG9q?|RpIKkWT`_Otevz1RM*lkS@8QB!bG002O3ps#Il!?2rpL`HIx z1JZP!-GJOz-zES6C>j3_0wAw|4FD+2JRp#}cinvgeFEHle0dBY5FTHDA2*N3t^g1+ zkFxC%ujiG3P*0B2j88 z;yJUqI8`#mEa?XC+tiqMiOFBiSHs_VPPd+Z8@Xzn0c}+uAsa?XF=SL(`f}z92&xJ& zH~mUXe^1})hNNZ`g@7+WN7nF=H{g<=062?OQ@g{5A#Dc;LMAE60E|gKM*4QbHSI1q z*PZ|oOMnSX|I>&J!31cArGiTVOI?8&0j0%u8 zPmB`OJNp2CW0qY$m zMJGb1JWa{2&|G%eD0$kIqhSCjN@u>A_UJMMOH+%*DyE`n9!TtVkX-XQJFj1Dj#l|< z0>Elul?35+^;Qs1?0%oJ=*ek{TRp92BT%$6Z++zZ_il8GU!v#cHa9kA z4ST?LPG77euHan{FxHoke?_WYoSv+-uL(rSIz;IapRIHa9~+n49(_d~>%8zSP4A+K z^7?{nlCQ_W84VL-S~q9#OV!SMek5DMmjr$#+ABD5{cvqr{G151tN_$K0uh9#OO!jf z5dAa~rh^4y)=mN7u*IkIs|Xnp!aZhnH2C^J<5I6k5J0#Yyz&Ep``QAM&@T-d{bT^3 zT@)o&r^R{P$tI2=x!rkdp_B5$Q85-Q(9;E`15-Ri-1c`At&RqZ#E;Z*i8)Gr)#Q@L zn7hYk_|iyrS$(Ea_oe;qL{``-(i%lhtTjN!=)^mpNZ_0d<4+}H&5b+b?bIh`ND<%} zOk^_WGfG#`m$68O@>uC}9jf~iDks?MHm9o&0J6~+@vV9?ucPYC)xT0TLeS+(9I?7@ zDaRfL%H*Z76y=Zkf8tPou2{S^R^?7Rp9X^TOJla#NacDSOH1~3gFpT$PM+a1^pUTc zs;ZBp?p`%fOVWwU=*M7UhA15jxgv2en8%4*OCM$oGo95h=eaE)Pd`ttL{1cI-X+YJ zQEv1}sG0s(51X^BOae?_oPU}jjZum&JQ32PB*2gakrhV2BsBQ=9y-A=p*!Ji!M`J3 zkuR^$!JjcW|Io9ZRQa_y&z*s|4dh1mhTI0{2JfLA1=3m5@BNwOnux`hM~3X1ber;< zB(6EKT2}A!EEda)q4WxAw&0p#l*I@0gmOmtCwa;vF)Ri~B{gp|Cpp|%-A_F}YzH>e zFJ^L^W{+7<4DIM`XKxc72UAhUGspBN!bRBg*+|*o?7?gwa*RvaCsWw_q0&k+dpTRV zw7EW3Ffo+aQ|9z96q$yZLYbUmQqYRZ(#oYuN~@DP$<(%bW z8ATb3iMq;3tz@NV31@MOc5sJx89t}5{XU}5*r#kMv~BD6?Fgw$=%v^1vJ*Wj7)b+_ z011u?%cj<=;OC>pCDo7nVGeQV)`XNeWjbZA#-^jk)!t3%zR;z8?$KwzF0k&^=hgR4 zh(w52$jD^Z1fOSNf-V&;RW(*M?jIQ*c{?(ltB|iQGb6i|zm-3ezue?#8)7StDo1^G zHK^aPEw#a;TD{|Jm2FC3R<;fex;4le!ReNomNNP>v}uNERpB(eyY2^S5LMB{Ubi_* zf~!S&p(32%&aCjJ-r8<_Mq5TibHs~FbyDhtIhraiTdv4}PyS3Q_f(ehumyOHh~DF@ z9Vs|$lx}oZZXLxqB--PFw9KE>gR{cX0Wn93DM?1rLz3Ab$$ZYf#eudB!@v_iht;r& z6J&lve%F3E?gL&C?}1NPcrz^jMzqjIE?}&C0J37fIj%wZCR5sTxjNDeVipB&+~SvV zkxI9&nW<|k39dYKI$#C;1o^*N2d%3qEy*s~JQ!BOGz~NjnRWXVK8Ra}JmbH9cpY{< z4wNAT3E)IYQCd-Ugy&~rPkB31HB@k}KkMiAwVoHDwV1WiqHCfzJ8O8|2fn|o;XU2T z!KPz9XyWchZcmSqI(>6W>5illj!THMj@L-_O@wib%VaAAk1s$1mbHItXK63x!)45r zKS&rVh=D34AF0hNHOn_^^hvte3{Sz3FoVZNx0NNuY8Aa7w=ZApA0@0I*C^M+S#zWY z9DGBIv0cY;Wh@nv4B{$Tn#PHyf4=@pi%zVZ<+c7Gf{P zZF;CLW)k-5dwQ!vs6ek=iTEZuR=DD2t1-3lV!lctOI{F4|lb8>ljJ;qMTJ# zcxPmPxZw-#rBcDco9lgsE{4@tsFHXiYY8scx3=m>%Jph~p*V_l=395-?~zoieNIM+ zc}`9}~JoJ;Bv zIPWk|H{UYv+|Jpq*=!gzKE1mXcASiFmmksk95mAfu1@G&r);UVs$%UAKL;Mx<2D(sKU?R0Pl`(17 z-%`+$SBtjyMB~HS8pGXAcQ^}`u#3lSp+8uzr>6>))fd~2!hBA9PfwOv79;(IFR?={ zbHT#+npU&c2gjQGT62)ageeWXtA*Kvg=dd2!9_>o3woy{aWSJ;=_hHlkXvcFX+!bU z@q2}Tf|QllH2g1jF3KRI4@ZRxS+Cw+4b`%;NJXAa?ag4vbHR zauT?kf0M^W-@@eP4;2IeL<|7@y1wBK06dWffL%ubP{{!RR-ac7dUXMS(9J+w3mP*2 z9oJ#VZ_cLqV|`84y-};v6qSc{zGcL#9%b=9kEp?eMkiDpAA4mE+dP0xyrMBN= z6OkaybVKg~pLn@B9Djk{Ld3CcF+O|f5C7a?&U9<~8uUwwZa!AA*u(2KVpV5RRGsUH%4*&kbrV3#q6oZ>#-V-o^h&UWDXG1ir_MC>{2C_vNYT z#MRast;npk_DfF=RSigp1bg=FM$`BZ;eS(S1gwa46;w%67Uz2ypaq+-nZDd^;&I+6 zWnT-%Anw$~Uu}yKa~KVxD~l15tEtH+K8k;x?ijpK-rOJ5Xgx?Tn3`%#+X!5dI~VpH z*`uAid_z0;qd<*PID<9k3oXCiIEi3!MKS{8# NSFoundationVersionNumber_iOS_6_1) { + return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty_ios7"]; + } else { + return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty"]; + } +} + +- (UIImage *)boxFilled +{ + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { + return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled_ios7"]; + } else { + return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled"]; + } +} - (void)cancelButtonPressed:(id)sender { @@ -304,7 +321,7 @@ - (void)incrementFailedAttemptsLabel _enterPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } NSInteger _failedAttemptsCount = [[KKKeychain getStringForKey:@"failedAttemptsCount"] integerValue]; @@ -370,7 +387,7 @@ - (void)moveToNextTableView oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } [UIView beginAnimations:@"" context:nil]; @@ -395,7 +412,7 @@ - (void)moveToPreviousTableView newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } [UIView beginAnimations:@"" context:nil]; @@ -543,7 +560,7 @@ - (void)vaildatePasscode:(UITextField*)textField if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; for (int i = 0; i < kPasscodeBoxesCount; i++) { - [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); @@ -720,7 +737,7 @@ - (NSArray*)boxes CGFloat height = self.isSmallLandscape ? kPasscodeBoxHeight * 0.6f : kPasscodeBoxHeight; for (int i = 0; i < kPasscodeBoxesCount; i++) { - UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]]; + UIImageView *square = [[UIImageView alloc] initWithImage:[self boxEmpty]]; square.frame = CGRectMake(squareX, self.isSmallLandscape ? 32.0f : 74.0, width, height); [squareViews addObject:square]; squareX += self.isSmallLandscape ? 42.0f : 71.0; @@ -790,9 +807,9 @@ - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange for (int i = 0; i < kPasscodeBoxesCount; i++) { UIImageView *square = [[_boxes objectAtIndex:_currentPanel] objectAtIndex:i]; if (i < [result length]) { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"]; + square.image = [self boxFilled]; } else { - square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]; + square.image = [self boxEmpty]; } } From 474ecb39b8face3d66e672791143157dd1dfbcc0 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 10 Oct 2013 10:44:30 +0100 Subject: [PATCH 57/62] removed the constant to make the project compatible with older Xcode versions --- src/KKPasscodeViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 3bd366f..e436e9b 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -289,7 +289,7 @@ - (void)viewWillDisappear:(BOOL)animated { - (UIImage *)boxEmpty { - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { + if (floor(NSFoundationVersionNumber) > 993.00) { return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty_ios7"]; } else { return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty"]; @@ -298,7 +298,7 @@ - (UIImage *)boxEmpty - (UIImage *)boxFilled { - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) { + if (floor(NSFoundationVersionNumber) > 993.00) { return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled_ios7"]; } else { return [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled"]; From c99003c9905858ed18de03a6d6f643835f54b8f6 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 10 Oct 2013 10:57:58 +0100 Subject: [PATCH 58/62] fixed broken animation on iOS7 added padding to passcode warning label removed shadow from every label when running on iOS7 --- src/KKPasscodeViewController.m | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index e436e9b..7ef1764 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -392,8 +392,8 @@ - (void)moveToNextTableView [UIView beginAnimations:@"" context:nil]; [UIView setAnimationDuration:0.25]; - oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - newTableView.frame = self.view.frame; + newTableView.frame = oldTableView.frame; + oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); [UIView commitAnimations]; _shouldReleaseFirstResponser = YES; @@ -417,8 +417,8 @@ - (void)moveToPreviousTableView [UIView beginAnimations:@"" context:nil]; [UIView setAnimationDuration:0.25]; + newTableView.frame = oldTableView.frame; oldTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height); - newTableView.frame = self.view.frame; [UIView commitAnimations]; _shouldReleaseFirstResponser = YES; @@ -471,10 +471,10 @@ - (void)nextDigitPressed if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -563,10 +563,10 @@ - (void)vaildatePasscode:(UITextField*)textField [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -640,8 +640,11 @@ - (UIView*)headerViewForTextField:(UITextField*)textField #endif headerLabel.font = [UIFont boldSystemFontOfSize:self.isSmallLandscape ? 12.0f : 17.0f]; - headerLabel.shadowOffset = CGSizeMake(0, 1.0); - headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + + if ((floor(NSFoundationVersionNumber) <= 993.00)) { + headerLabel.shadowOffset = CGSizeMake(0, 1.0); + headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + } if ([textField isEqual:_setPasscodeTextField]) { _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 73.0f : 146.0, self.view.bounds.size.width, 30.0)]; @@ -655,8 +658,10 @@ - (UIView*)headerViewForTextField:(UITextField*)textField #endif _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0]; - _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0); - _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + if ((floor(NSFoundationVersionNumber) <= 993.00)) { + _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0); + _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; + } _passcodeConfirmationWarningLabel.text = @""; _passcodeConfirmationWarningLabel.numberOfLines = 0; @@ -682,10 +687,11 @@ - (UIView*)headerViewForTextField:(UITextField*)textField #else _failedAttemptsLabel.textAlignment = NSTextAlignmentCenter; #endif - - _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); - _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; - _failedAttemptsView.layer.cornerRadius = self.isSmallLandscape ? 7.0f : 14.0f; + if ((floor(NSFoundationVersionNumber) <= 993.00)) { + _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0); + _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0]; + } + _failedAttemptsView.layer.cornerRadius = self.isSmallLandscape ? 7.0f : 14.0f; _failedAttemptsView.layer.borderWidth = 1.0; _failedAttemptsView.layer.borderColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.25] CGColor]; From 7e34b6e765b485ae6eb5363a2f1cce911caab78e Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 13 Mar 2014 14:18:55 +0000 Subject: [PATCH 59/62] fixed warning when compiling for arm64 architecture --- src/KKKeychain.m | 8 ++++---- src/KKPasscodeViewController.m | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/KKKeychain.m b/src/KKKeychain.m index e2b235e..5d54618 100755 --- a/src/KKKeychain.m +++ b/src/KKKeychain.m @@ -58,16 +58,16 @@ + (BOOL)setString:(NSString*)string forKey:(NSString*)key [addDict setObject:data forKey:(__bridge id)kSecValueData]; res = SecItemAdd((__bridge CFDictionaryRef)addDict, NULL); - NSAssert1(res == errSecSuccess, @"Recieved %ld from SecItemAdd!", res); + NSAssert1(res == errSecSuccess, @"Recieved %ld from SecItemAdd!", (long) res); } } else if (res == errSecSuccess) { // Modify an existing one // Actually pull it now of the keychain at this point. NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(__bridge id)kSecValueData]; res = SecItemUpdate((__bridge CFDictionaryRef)existsQueryDictionary, (__bridge CFDictionaryRef)attributeDict); - NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %ld!", res); + NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %ld!", (long) res); } else { - NSAssert1(NO, @"Received %ld from SecItemCopyMatching!", res); + NSAssert1(NO, @"Received %ld from SecItemCopyMatching!", (long) res); } return YES; } @@ -93,7 +93,7 @@ + (NSString*)getStringForKey:(NSString*)key NSString *string = [[NSString alloc] initWithData:(__bridge NSData*)data encoding:NSUTF8StringEncoding]; return string; } else { - NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %ld!", res); + NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %ld!", (long) res); } return nil; diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 7ef1764..454e2ec 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -328,7 +328,7 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsCount++; - [KKKeychain setString:[NSString stringWithFormat:@"%d", _failedAttemptsCount] forKey:@"failedAttemptsCount"]; + [KKKeychain setString:[NSString stringWithFormat:@"%lu", _failedAttemptsCount] forKey:@"failedAttemptsCount"]; if (_failedAttemptsCount == 1) { _failedAttemptsLabel.text = KKPasscodeLockLocalizedString(@"1 Failed Passcode Attempt", @""); From fc979fc1bac1ede0c0890b275d13ccbaf500b4ee Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Thu, 13 Mar 2014 14:29:36 +0000 Subject: [PATCH 60/62] fixed more warnings --- src/KKPasscodeViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 454e2ec..36a0b22 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -328,7 +328,7 @@ - (void)incrementFailedAttemptsLabel _failedAttemptsCount++; - [KKKeychain setString:[NSString stringWithFormat:@"%lu", _failedAttemptsCount] forKey:@"failedAttemptsCount"]; + [KKKeychain setString:[NSString stringWithFormat:@"%ld", (long)_failedAttemptsCount] forKey:@"failedAttemptsCount"]; if (_failedAttemptsCount == 1) { _failedAttemptsLabel.text = KKPasscodeLockLocalizedString(@"1 Failed Passcode Attempt", @""); From 59b9945a2e262efa81556718c3f6d73f4058f080 Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Fri, 24 Oct 2014 10:49:55 +0100 Subject: [PATCH 61/62] fixed confirmationWarningLabel alignment --- src/KKPasscodeViewController.m | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/KKPasscodeViewController.m b/src/KKPasscodeViewController.m index 36a0b22..c92ad68 100755 --- a/src/KKPasscodeViewController.m +++ b/src/KKPasscodeViewController.m @@ -283,6 +283,16 @@ - (void)viewWillDisappear:(BOOL)animated { } } +- (void)viewDidLayoutSubviews +{ + [super viewDidLayoutSubviews]; + + CGRect frame = _passcodeConfirmationWarningLabel.frame; + frame.origin.x = 10.0f; + frame.size.width = self.view.frame.size.width - 10.0f*2; + + _passcodeConfirmationWarningLabel.frame = frame; +} #pragma mark - #pragma mark Private methods @@ -471,10 +481,10 @@ - (void)nextDigitPressed if ([passcode isEqualToString:_setPasscodeTextField.text]) { _setPasscodeTextField.text = @""; _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); - _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0*2, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0*2, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -512,6 +522,8 @@ - (void)vaildatePasscode:(UITextField*)textField [KKKeychain setString:@"" forKey:@"passcode"]; } + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; + if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) { [_delegate performSelector:@selector(didSettingsChanged:) withObject:self]; } @@ -552,6 +564,7 @@ - (void)vaildatePasscode:(UITextField*)textField NSString *passcode = [KKKeychain getStringForKey:@"passcode"]; if ([textField isEqual:_enterPasscodeTextField]) { if ([passcode isEqualToString:_enterPasscodeTextField.text]) { + [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"]; [self moveToNextTableView]; } else { [self incrementFailedAttemptsLabel]; @@ -563,10 +576,10 @@ - (void)vaildatePasscode:(UITextField*)textField [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[self boxEmpty]]; } _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @""); - _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0, 60.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 132.0, self.view.bounds.size.width - 10.0*2, 60.0); } else { _passcodeConfirmationWarningLabel.text = @""; - _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0, 30.0); + _passcodeConfirmationWarningLabel.frame = CGRectMake(10.0, 146.0, self.view.bounds.size.width - 10.0*2, 30.0); [self moveToNextTableView]; } } else if ([textField isEqual:_confirmPasscodeTextField]) { @@ -647,7 +660,7 @@ - (UIView*)headerViewForTextField:(UITextField*)textField } if ([textField isEqual:_setPasscodeTextField]) { - _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 73.0f : 146.0, self.view.bounds.size.width, 30.0)]; + _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0, self.isSmallLandscape ? 73.0f : 146.0, self.view.frame.size.width - 10.0*2, 30.0)]; _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0]; _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor]; From ef6ca35a85c22fb33b7e9b75a80e74bc6763198b Mon Sep 17 00:00:00 2001 From: Valerio Mazzeo Date: Fri, 24 Oct 2014 13:43:05 +0100 Subject: [PATCH 62/62] added support for iOS 8 alert controller --- src/KKPasscodeSettingsViewController.m | 43 +++++++++++++++++++++----- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/KKPasscodeSettingsViewController.m b/src/KKPasscodeSettingsViewController.m index fdf1986..9eb6fa1 100755 --- a/src/KKPasscodeSettingsViewController.m +++ b/src/KKPasscodeSettingsViewController.m @@ -110,13 +110,10 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { - _eraseDataOn = YES; - [KKKeychain setString:@"YES" forKey:@"erase_data_on"]; + [self enableEraseDataHandler]; } else { - _eraseDataOn = NO; - [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + [self disableEraseDataHandler]; } - [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; } - (void)eraseDataSwitchChanged:(id)sender @@ -124,14 +121,46 @@ - (void)eraseDataSwitchChanged:(id)sender if (_eraseDataSwitch.on) { NSString* title = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]]; - UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:KKPasscodeLockLocalizedString(@"Cancel", @"") destructiveButtonTitle:KKPasscodeLockLocalizedString(@"Enable", @"") otherButtonTitles:nil]; - [sheet showInView:self.view]; + if ((floor(NSFoundationVersionNumber) <= 1047.25)) { + UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:KKPasscodeLockLocalizedString(@"Cancel", @"") destructiveButtonTitle:KKPasscodeLockLocalizedString(@"Enable", @"") otherButtonTitles:nil]; + [sheet showInView:self.view]; + } else { + + UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title + message:nil + preferredStyle:UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? UIAlertControllerStyleAlert : UIAlertControllerStyleActionSheet]; + + [alertController addAction:[UIAlertAction actionWithTitle:KKPasscodeLockLocalizedString(@"Enable", @"") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { + [self enableEraseDataHandler]; + }]]; + + [alertController addAction:[UIAlertAction actionWithTitle:KKPasscodeLockLocalizedString(@"Cancel", @"") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { + [self disableEraseDataHandler]; + }]]; + + [self presentViewController:alertController animated:YES completion:nil]; + } + } else { _eraseDataOn = NO; [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; } } +- (void)enableEraseDataHandler +{ + _eraseDataOn = YES; + [KKKeychain setString:@"YES" forKey:@"erase_data_on"]; + [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; +} + +- (void)disableEraseDataHandler +{ + _eraseDataOn = NO; + [KKKeychain setString:@"NO" forKey:@"erase_data_on"]; + [_eraseDataSwitch setOn:_eraseDataOn animated:YES]; +} + #pragma mark - #pragma mark UITableViewDataSource methods