From cb7d2f4aaf4686f00013f8ea4988a876974a8ea6 Mon Sep 17 00:00:00 2001 From: Dasmer Singh Date: Fri, 5 Dec 2014 15:11:39 -0500 Subject: [PATCH 1/4] Make passcode view title and character colors configurable --- .../VENTouchLockPasscodeViewController.m | 2 ++ VENTouchLock/Models/VENTouchLockAppearance.h | 2 ++ VENTouchLock/Models/VENTouchLockAppearance.m | 6 ++++-- .../Views/VENTouchLockPasscodeCharacterView.h | 5 +++++ .../Views/VENTouchLockPasscodeCharacterView.m | 9 +++++++++ VENTouchLock/Views/VENTouchLockPasscodeView.h | 10 ++++++++++ VENTouchLock/Views/VENTouchLockPasscodeView.m | 14 ++++++++++++++ 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m b/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m index 51ada3b..11403e3 100644 --- a/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m +++ b/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m @@ -60,6 +60,8 @@ - (void)configureNavigationItems - (void)configurePasscodeView { VENTouchLockPasscodeView *passcodeView = [[VENTouchLockPasscodeView alloc] init]; + passcodeView.titleColor = self.touchLock.appearance.passcodeViewControllerTitleColor; + passcodeView.characterColor = self.touchLock.appearance.passcodeViewControllerCharacterColor; [self.view addSubview:passcodeView]; self.passcodeView = passcodeView; } diff --git a/VENTouchLock/Models/VENTouchLockAppearance.h b/VENTouchLock/Models/VENTouchLockAppearance.h index 49a5f4d..fecb5bc 100644 --- a/VENTouchLock/Models/VENTouchLockAppearance.h +++ b/VENTouchLock/Models/VENTouchLockAppearance.h @@ -7,6 +7,8 @@ * @description Passcode View Controller Preferences * ----------------------------------------------------------------------------- */ +@property (strong, nonatomic) UIColor *passcodeViewControllerTitleColor; +@property (strong, nonatomic) UIColor *passcodeViewControllerCharacterColor; @property (strong, nonatomic) UIColor *passcodeViewControllerBackgroundColor; @property (strong, nonatomic) NSString *cancelBarButtonItemTitle; diff --git a/VENTouchLock/Models/VENTouchLockAppearance.m b/VENTouchLock/Models/VENTouchLockAppearance.m index 3f2e3b0..93c529b 100644 --- a/VENTouchLock/Models/VENTouchLockAppearance.m +++ b/VENTouchLock/Models/VENTouchLockAppearance.m @@ -6,9 +6,11 @@ - (instancetype)init { self = [super init]; if (self) { // Set default values + _passcodeViewControllerTitleColor = [UIColor blackColor]; + _passcodeViewControllerCharacterColor = [UIColor blackColor]; _passcodeViewControllerBackgroundColor = [UIColor colorWithRed:239/255.0f green:239/255.0f blue:244/255.0f alpha:1.0f]; - _cancelBarButtonItemTitle = NSLocalizedString(@"Cancel",nil); - _createPasscodeInitialLabelText = NSLocalizedString(@"Enter a new passcode",nil); + _cancelBarButtonItemTitle = NSLocalizedString(@"Cancel", nil); + _createPasscodeInitialLabelText = NSLocalizedString(@"Enter a new passcode", nil); _createPasscodeConfirmLabelText = NSLocalizedString(@"Please re-enter your passcode", nil); _createPasscodeMismatchedLabelText = NSLocalizedString(@"Passwords did not match. Try again", nil); _createPasscodeViewControllerTitle = NSLocalizedString(@"Set Passcode", nil); diff --git a/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.h b/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.h index 2c97460..bcb006d 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.h +++ b/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.h @@ -7,4 +7,9 @@ */ @property (assign, nonatomic) BOOL isEmpty; +/** + * The fill color of the passcode character. + */ +@property (strong, nonatomic) UIColor *fillColor; + @end \ No newline at end of file diff --git a/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.m b/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.m index 94f1cdf..d7b13e7 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.m +++ b/VENTouchLock/Views/VENTouchLockPasscodeCharacterView.m @@ -89,5 +89,14 @@ - (void)setIsEmpty:(BOOL)isEmpty { [self redraw]; } } +- (void)setFillColor:(UIColor *)fillColor +{ + _fillColor = fillColor; + CGColorRef cgColor = fillColor.CGColor; + self.hyphen.fillColor = cgColor; + self.hyphen.strokeColor = cgColor; + self.circle.fillColor = cgColor; + self.circle.strokeColor = cgColor; +} @end \ No newline at end of file diff --git a/VENTouchLock/Views/VENTouchLockPasscodeView.h b/VENTouchLock/Views/VENTouchLockPasscodeView.h index 5fa5d22..1831436 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeView.h +++ b/VENTouchLock/Views/VENTouchLockPasscodeView.h @@ -12,6 +12,16 @@ */ @property (strong, nonatomic) NSArray *characters; +/** + The color of the title text. + */ +@property (strong, nonatomic) UIColor *titleColor; + +/** + The color of the passcode characters. + */ +@property (strong, nonatomic) UIColor *characterColor; + /** Creates a passcode view controller with the given title and frame. */ diff --git a/VENTouchLock/Views/VENTouchLockPasscodeView.m b/VENTouchLock/Views/VENTouchLockPasscodeView.m index 8796c8a..4d16816 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeView.m +++ b/VENTouchLock/Views/VENTouchLockPasscodeView.m @@ -70,4 +70,18 @@ - (void)setTitle:(NSString *)title self.titleLabel.text = _title; } +- (void)setCharacterColor:(UIColor *)characterColor +{ + _characterColor = characterColor; + for (VENTouchLockPasscodeCharacterView *characterView in self.characters) { + characterView.fillColor = characterColor; + } +} + +- (void)setTitleColor:(UIColor *)titleColor +{ + _titleColor = titleColor; + self.titleLabel.textColor = titleColor; +} + @end \ No newline at end of file From 98fb85197993ef3fb518c63747f0fb6a94b59d48 Mon Sep 17 00:00:00 2001 From: Dasmer Singh Date: Fri, 5 Dec 2014 16:00:10 -0500 Subject: [PATCH 2/4] Set passcode view appearance colors each time it is created by a passcode view controller --- ...VENTouchLockCreatePasscodeViewController.m | 33 +++++++++++-------- VENTouchLock/Views/VENTouchLockPasscodeView.h | 5 +++ VENTouchLock/Views/VENTouchLockPasscodeView.m | 13 +++++++- .../VENTouchLockAutoLockTests.m | 1 - 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/VENTouchLock/Controllers/VENTouchLockCreatePasscodeViewController.m b/VENTouchLock/Controllers/VENTouchLockCreatePasscodeViewController.m index e5d1d6c..2272388 100644 --- a/VENTouchLock/Controllers/VENTouchLockCreatePasscodeViewController.m +++ b/VENTouchLock/Controllers/VENTouchLockCreatePasscodeViewController.m @@ -51,18 +51,21 @@ - (void)showConfirmPasscodeView VENTouchLockPasscodeView *firstPasscodeView = self.passcodeView; CGFloat passcodeViewWidth = CGRectGetWidth(firstPasscodeView.frame); CGRect confirmInitialFrame = CGRectMake(passcodeViewWidth, - CGRectGetMinY(firstPasscodeView.frame), - passcodeViewWidth, - CGRectGetHeight(firstPasscodeView.frame)); + CGRectGetMinY(firstPasscodeView.frame), + passcodeViewWidth, + CGRectGetHeight(firstPasscodeView.frame)); CGRect confirmEndFrame = firstPasscodeView.frame; CGRect firstEndFrame = CGRectMake(-passcodeViewWidth, - CGRectGetMinY(firstPasscodeView.frame), - passcodeViewWidth, - CGRectGetHeight(firstPasscodeView.frame)); - NSString *confirmPasscodeTitle = [self.touchLock appearance].createPasscodeConfirmLabelText; + CGRectGetMinY(firstPasscodeView.frame), + passcodeViewWidth, + CGRectGetHeight(firstPasscodeView.frame)); + VENTouchLockAppearance *appearance = [self.touchLock appearance]; + NSString *confirmPasscodeTitle = appearance.createPasscodeConfirmLabelText; VENTouchLockPasscodeView *confirmPasscodeView = [[VENTouchLockPasscodeView alloc] initWithTitle:confirmPasscodeTitle - frame:confirmInitialFrame]; + frame:confirmInitialFrame + titleColor:appearance.passcodeViewControllerTitleColor + characterColor:appearance.passcodeViewControllerCharacterColor]; [self.view addSubview:confirmPasscodeView]; [UIView animateWithDuration: VENTouchLockCreatePasscodeViewControllerAnimationDuration delay: 0.0 @@ -75,7 +78,6 @@ - (void)showConfirmPasscodeView [firstPasscodeView removeFromSuperview]; self.passcodeView = confirmPasscodeView; }]; - } - (void)showFirstPasscodeView @@ -83,17 +85,20 @@ - (void)showFirstPasscodeView VENTouchLockPasscodeView *confirmPasscodeView = self.passcodeView; CGFloat passcodeViewWidth = CGRectGetWidth(confirmPasscodeView.frame); CGRect firstInitialFrame = CGRectMake(-passcodeViewWidth, - CGRectGetMinY(confirmPasscodeView.frame), - passcodeViewWidth, - CGRectGetHeight(confirmPasscodeView.frame)); + CGRectGetMinY(confirmPasscodeView.frame), + passcodeViewWidth, + CGRectGetHeight(confirmPasscodeView.frame)); CGRect firstEndFrame = confirmPasscodeView.frame; CGRect confirmEndFrame = CGRectMake(passcodeViewWidth, CGRectGetMinY(confirmPasscodeView.frame), passcodeViewWidth, CGRectGetHeight(confirmPasscodeView.frame)); - NSString *firstPasscodeTitle = [self.touchLock appearance].createPasscodeMismatchedLabelText; + VENTouchLockAppearance *appearance = [self.touchLock appearance]; + NSString *firstPasscodeTitle = appearance.createPasscodeMismatchedLabelText; VENTouchLockPasscodeView *firstPasscodeView = [[VENTouchLockPasscodeView alloc] initWithTitle:firstPasscodeTitle - frame:firstInitialFrame]; + frame:firstInitialFrame + titleColor:appearance.passcodeViewControllerTitleColor + characterColor:appearance.passcodeViewControllerCharacterColor]; [self.view addSubview:firstPasscodeView]; [UIView animateWithDuration: VENTouchLockCreatePasscodeViewControllerAnimationDuration delay: 0.0 diff --git a/VENTouchLock/Views/VENTouchLockPasscodeView.h b/VENTouchLock/Views/VENTouchLockPasscodeView.h index 1831436..13bc56c 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeView.h +++ b/VENTouchLock/Views/VENTouchLockPasscodeView.h @@ -27,6 +27,11 @@ */ - (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame; +/** + Creates a passcode view controller with the given title and frame. + */ +- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame titleColor:(UIColor *)titleColor characterColor:(UIColor *)characterColor; + /** Shakes the reciever and vibrates the device. @param completionBlock called after shake and vibrate complete diff --git a/VENTouchLock/Views/VENTouchLockPasscodeView.m b/VENTouchLock/Views/VENTouchLockPasscodeView.m index 4d16816..9cf382e 100644 --- a/VENTouchLock/Views/VENTouchLockPasscodeView.m +++ b/VENTouchLock/Views/VENTouchLockPasscodeView.m @@ -14,7 +14,7 @@ @interface VENTouchLockPasscodeView () @implementation VENTouchLockPasscodeView -- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame +- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame titleColor:(UIColor *)titleColor characterColor:(UIColor *)characterColor { NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil]; @@ -24,11 +24,22 @@ - (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin; _title = title; _titleLabel.text = title; + _titleColor = titleColor; + _titleLabel.textColor = titleColor; + _characterColor = characterColor; _characters = @[_firstCharacter, _secondCharacter, _thirdCharacter, _fourthCharacter]; + for (VENTouchLockPasscodeCharacterView *characterView in _characters) { + characterView.fillColor = characterColor; + } } return self; } +- (instancetype)initWithTitle:(NSString *)title frame:(CGRect)frame; +{ + return [self initWithTitle:title frame:frame titleColor:[UIColor blackColor] characterColor:[UIColor blackColor]]; +} + - (instancetype)initWithFrame:(CGRect)frame { return [self initWithTitle:@"" frame:frame]; diff --git a/VENTouchLockSample/VENTouchLockSampleTests/VENTouchLockAutoLockTests.m b/VENTouchLockSample/VENTouchLockSampleTests/VENTouchLockAutoLockTests.m index 31775e6..6966182 100644 --- a/VENTouchLockSample/VENTouchLockSampleTests/VENTouchLockAutoLockTests.m +++ b/VENTouchLockSample/VENTouchLockSampleTests/VENTouchLockAutoLockTests.m @@ -140,7 +140,6 @@ - (void)dismissAndResetLock } [VENTouchLock sharedInstance].backgroundLockVisible = NO; [[VENTouchLock sharedInstance] deletePasscode]; - [VENTouchLock sharedInstance].appearance = [[VENTouchLockAppearance alloc] init]; } - (void)simulateAppBackgroundThenForeground From fa8b62d08f4c18a55d3c79efdf8fb7bf5c752027 Mon Sep 17 00:00:00 2001 From: dasmer Date: Wed, 10 Dec 2014 17:34:32 -0500 Subject: [PATCH 3/4] Resign keyboard on viewWillDisappear --- .../VENTouchLockPasscodeViewController.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m b/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m index 51ada3b..514c8f7 100644 --- a/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m +++ b/VENTouchLock/Controllers/VENTouchLockPasscodeViewController.m @@ -41,6 +41,22 @@ - (void)viewDidLoad [self configurePasscodeView]; } +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + if (![self.invisiblePasscodeField isFirstResponder]) { + [self.invisiblePasscodeField becomeFirstResponder]; + } +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + if ([self.invisiblePasscodeField isFirstResponder]) { + [self.invisiblePasscodeField resignFirstResponder]; + } +} + - (void)configureInvisiblePasscodeField { self.invisiblePasscodeField = [[UITextField alloc] init]; @@ -49,7 +65,6 @@ - (void)configureInvisiblePasscodeField self.invisiblePasscodeField.delegate = self; [self.invisiblePasscodeField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; [self.view addSubview:self.invisiblePasscodeField]; - [self.invisiblePasscodeField becomeFirstResponder]; } - (void)configureNavigationItems From eb4a9da9dc23a0c4298da36470a40d3513936826 Mon Sep 17 00:00:00 2001 From: Ian Ynda-Hummel Date: Tue, 16 Dec 2014 19:15:08 -0500 Subject: [PATCH 4/4] Ensure that the splash screen starts with a background color --- .../Controllers/VENTouchLockSplashViewController.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/VENTouchLock/Controllers/VENTouchLockSplashViewController.m b/VENTouchLock/Controllers/VENTouchLockSplashViewController.m index 59871b0..d12ccad 100644 --- a/VENTouchLock/Controllers/VENTouchLockSplashViewController.m +++ b/VENTouchLock/Controllers/VENTouchLockSplashViewController.m @@ -45,6 +45,15 @@ - (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibB return self; } +- (void)viewDidLoad +{ + [super viewDidLoad]; + + if (!self.view.backgroundColor) { + self.view.backgroundColor = [UIColor whiteColor]; + } +} + - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated];