Skip to content

Commit

Permalink
Animation improved, working well aside from first presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
John Flanagan authored and John Flanagan committed Feb 27, 2012
1 parent ae97cb2 commit 893ecaa
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 33 deletions.
36 changes: 29 additions & 7 deletions MiniKeePass.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
5235D58314F8160900B0C991 /* splash.png in Resources */ = {isa = PBXBuildFile; fileRef = 5235D58214F8160900B0C991 /* splash.png */; };
5235D58514F8176300B0C991 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5235D58414F8176300B0C991 /* [email protected] */; };
523DCF2114E8E35F004A4C4F /* Monaco.dfont in Resources */ = {isa = PBXBuildFile; fileRef = 523DCF2014E8E35F004A4C4F /* Monaco.dfont */; };
52491D0C14D8F3FB00F8CBC8 /* de-createdb.html in Resources */ = {isa = PBXBuildFile; fileRef = 52491D0714D8F3FB00F8CBC8 /* de-createdb.html */; };
52491D0D14D8F3FB00F8CBC8 /* de-dropbox.html in Resources */ = {isa = PBXBuildFile; fileRef = 52491D0814D8F3FB00F8CBC8 /* de-dropbox.html */; };
Expand Down Expand Up @@ -318,6 +320,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
5235D58214F8160900B0C991 /* splash.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = splash.png; sourceTree = "<group>"; };
5235D58414F8176300B0C991 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
523DCF2014E8E35F004A4C4F /* Monaco.dfont */ = {isa = PBXFileReference; lastKnownFileType = file; path = Monaco.dfont; sourceTree = "<group>"; };
52491D0714D8F3FB00F8CBC8 /* de-createdb.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "de-createdb.html"; sourceTree = "<group>"; };
52491D0814D8F3FB00F8CBC8 /* de-dropbox.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "de-dropbox.html"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1123,6 +1127,8 @@
689D021813A42B63005EBD36 /* icon.svg */,
689D021713A42B63005EBD36 /* icon.png */,
689D021913A42B63005EBD36 /* [email protected] */,
5235D58214F8160900B0C991 /* splash.png */,
5235D58414F8176300B0C991 /* [email protected] */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -1541,6 +1547,8 @@
6802F9C814EC9C1D00ACD4C1 /* [email protected] in Resources */,
68B0A70314ECBC1E005CFE31 /* reload.png in Resources */,
68B0A70514ECBC1E005CFE31 /* [email protected] in Resources */,
5235D58314F8160900B0C991 /* splash.png in Resources */,
5235D58514F8176300B0C991 /* [email protected] in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1748,17 +1756,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CODE_SIGN_IDENTITY = "iPhone Distribution: John Flanagan";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: John Flanagan";
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PROVISIONING_PROFILE = "EEAA67EE-F308-4220-9A96-56B37CC8621E";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "EEAA67EE-F308-4220-9A96-56B37CC8621E";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
};
name = Distribution;
Expand All @@ -1767,13 +1775,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MiniKeePass/MiniKeePass-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "MiniKeePass/MiniKeePass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app;
};
Expand Down Expand Up @@ -1806,16 +1818,19 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = s;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -1824,14 +1839,17 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = /usr/include/libxml2;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
};
name = Release;
Expand All @@ -1840,6 +1858,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand All @@ -1848,6 +1867,7 @@
INFOPLIST_FILE = "MiniKeePass/MiniKeePass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
WRAPPER_EXTENSION = app;
};
name = Debug;
Expand All @@ -1856,13 +1876,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MiniKeePass/MiniKeePass-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "MiniKeePass/MiniKeePass-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app;
};
Expand Down
57 changes: 40 additions & 17 deletions MiniKeePass/PinViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,71 @@ - (id)initWithText:(NSString*)text {
if (self) {
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];

UIImage *icon = [UIImage imageNamed:@"icon"];
UIView *iconView = [[UIView alloc] initWithFrame:CGRectMake(131, 20, icon.size.width, icon.size.height)];
iconView.backgroundColor = [UIColor colorWithPatternImage:icon];
[self.view addSubview:iconView];
[iconView release];
UIImage *logo = [UIImage imageNamed:@"temp"];
UIView *logoView = [[UIView alloc] initWithFrame:CGRectMake(0, 70, logo.size.width, logo.size.height)];
logoView.backgroundColor = [UIColor colorWithPatternImage:logo];
// [self.view addSubview:logoView];
[logoView release];

// UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 95, 320, 53)];
// label.text = @"MiniKeePass";
//
// label.backgroundColor = [UIColor clearColor];
// label.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:35];
// label.textAlignment = UITextAlignmentCenter;
//
// [self.view addSubview:label];
// [label release];

textField = [[UITextField alloc] initWithFrame:CGRectMake(320, 240, 0, 0)];
textField.delegate = self;
textField.hidden = YES;
textField.secureTextEntry = YES;
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.keyboardAppearance = UIKeyboardAppearanceAlert;

[self.view addSubview:textField];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextFieldTextDidChangeNotification object:textField];

PinTextField *pinTextField1 = [[PinTextField alloc] initWithFrame:CGRectMake(26, 100, 61, 53)];
[self.view addSubview:pinTextField1];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 240, 96)];
[toolbar setBarStyle:UIBarStyleBlackTranslucent];

PinTextField *pinTextField2 = [[PinTextField alloc] initWithFrame:CGRectMake(95, 100, 61, 52)];
[self.view addSubview:pinTextField2];
PinTextField *pinTextField1 = [[PinTextField alloc] initWithFrame:CGRectMake(23, 22, 61, 53)];
[toolbar addSubview:pinTextField1];

PinTextField *pinTextField3 = [[PinTextField alloc] initWithFrame:CGRectMake(164, 100, 61, 53)];
[self.view addSubview:pinTextField3];
PinTextField *pinTextField2 = [[PinTextField alloc] initWithFrame:CGRectMake(94, 21, 61, 53)];
[toolbar addSubview:pinTextField2];

PinTextField *pinTextField3 = [[PinTextField alloc] initWithFrame:CGRectMake(165, 21, 61, 53)];
[toolbar addSubview:pinTextField3];

PinTextField *pinTextField4 = [[PinTextField alloc] initWithFrame:CGRectMake(236, 21, 61, 53)];
[toolbar addSubview:pinTextField4];

pinTextFields = [[NSArray arrayWithObjects:pinTextField1, pinTextField2, pinTextField3, pinTextField4, nil] retain];

PinTextField *pinTextField4 = [[PinTextField alloc] initWithFrame:CGRectMake(233, 100, 61, 54)];
[self.view addSubview:pinTextField4];

pinTextFields = [[NSArray arrayWithObjects:pinTextField1, pinTextField2, pinTextField3, pinTextField4, nil] retain];
textField.inputAccessoryView = toolbar;
[toolbar release];

[pinTextField1 release];
[pinTextField2 release];
[pinTextField3 release];
[pinTextField4 release];

textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 165, 320, 40)];
textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 95)];
textLabel.backgroundColor = [UIColor clearColor];
textLabel.textColor = [UIColor whiteColor];
textLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:25];
textLabel.numberOfLines = 0;
textLabel.textAlignment = UITextAlignmentCenter;
textLabel.text = text;
[self.view addSubview:textLabel];

UIToolbar *topBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 95)];
topBar.barStyle = UIBarStyleBlackTranslucent;
[topBar addSubview:textLabel];

[self.view addSubview:topBar];
}

return self;
Expand Down
40 changes: 31 additions & 9 deletions MiniKeePass/PinWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
*/

#import <AudioToolbox/AudioToolbox.h>
#import <QuartzCore/QuartzCore.h>
#import "MiniKeePassAppDelegate.h"
#import "SFHFKeychainUtils.h"
#import "PinWindow.h"

#define DURATION 0.25
#define DURATION 2

@implementation PinWindow

Expand All @@ -37,15 +38,20 @@ - (id)initWithFrame:(CGRect)frame {
if (self) {
self.windowLevel = UIWindowLevelAlert;

visibleFrame = [[UIScreen mainScreen] bounds];
offScreenFrame = CGRectOffset(visibleFrame, 0, visibleFrame.size.height);
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];

visibleFrame = CGRectZero;
offScreenFrame = CGRectOffset(visibleFrame, 0, -95 - appFrame.origin.y);

pinViewController = [[PinViewController alloc] init];
pinViewController.delegate = self;
pinViewController.view.frame = visibleFrame;
pinViewController.view.frame = offScreenFrame;

self.rootViewController = pinViewController;
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default"]];
NSLog(@"init pin: %f, %f", pinViewController.view.frame.origin.x, pinViewController.view.frame.origin.y);
NSLog(@"init offset: %f, %f", offScreenFrame.origin.x, offScreenFrame.origin.y);

self.rootViewController = pinViewController;
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"splash"]];

appDelegate = (MiniKeePassAppDelegate*)[[UIApplication sharedApplication] delegate];

Expand All @@ -70,6 +76,7 @@ - (void)dealloc {
}

- (void)show {
NSLog(@"show");
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default"]];
self.hidden = NO;
}
Expand All @@ -79,17 +86,28 @@ - (void)hide {
}

- (void)lock {
NSLog(@"lock");
appDelegate.locked = YES;


pinViewController.textLabel.text = NSLocalizedString(@"Enter your PIN to unlock", nil);
[self show];

if (pinViewController.view.frame.origin.y != visibleFrame.origin.y) {
pinViewController.view.frame = offScreenFrame;
}

NSLog(@"lock offset: %f, %f", offScreenFrame.origin.x, offScreenFrame.origin.y);
NSLog(@"lock pin: %f, %f", pinViewController.view.frame.origin.x, pinViewController.view.frame.origin.y);

[UIView animateWithDuration:DURATION animations:^{
NSLog(@"animation pin: %f, %f", pinViewController.view.frame.origin.x, pinViewController.view.frame.origin.y);
pinViewController.view.frame = visibleFrame;
[pinViewController becomeFirstResponder];
}];
}

- (void)unlock {
NSLog(@"unlock");
appDelegate.locked = NO;

self.backgroundColor = [UIColor clearColor];
Expand All @@ -106,10 +124,14 @@ - (void)unlock {
}

- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"willResignActive");

[self show];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"didBecomeActive");

// Get the time when the application last exited
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDate *exitTime = [userDefaults valueForKey:@"exitTime"];
Expand All @@ -120,8 +142,8 @@ - (void)applicationDidBecomeActive:(UIApplication *)application {
NSInteger pinLockTimeout = timeoutValues[[userDefaults integerForKey:@"pinLockTimeout"]];

// Check if it's been longer then lock timeout
NSTimeInterval timeInterval = [exitTime timeIntervalSinceNow];
if (timeInterval < -pinLockTimeout) {
NSTimeInterval timeInterval = -[exitTime timeIntervalSinceNow];
if (timeInterval > pinLockTimeout) {
[self lock];
} else {
[self unlock];
Expand Down
Binary file added splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 893ecaa

Please sign in to comment.