├── .gitignore
├── KKPasscodeLock.podspec
├── LICENSE
├── NOTICE
├── README.mdown
├── example
├── Default-568h@2x.png
├── Default.png
├── Default@2x.png
├── KKPasscodeLock
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── KKPasscodeLockDemo-Info.plist
│ ├── KKPasscodeLockDemo-Prefix.pch
│ ├── RootViewController.h
│ ├── RootViewController.m
│ ├── RootViewController.xib
│ ├── SettingsViewController.h
│ ├── SettingsViewController.m
│ ├── SettingsViewController.xib
│ ├── de.lproj
│ │ ├── InfoPlist.strings
│ │ └── Localizable.strings
│ ├── en.lproj
│ │ ├── InfoPlist.strings
│ │ └── Localizable.strings
│ ├── he.lproj
│ │ └── InfoPlist.strings
│ ├── main.m
│ └── nl.lproj
│ │ └── InfoPlist.strings
└── KKPasscodeLockDemo.xcodeproj
│ └── project.pbxproj
├── screenshots
├── ipad-1.png
├── iphone-1.png
└── iphone-2.png
├── src
├── KKKeychain.h
├── KKKeychain.m
├── KKPasscodeLock.bundle
│ ├── box_empty.png
│ ├── box_empty@2x.png
│ ├── box_filled.png
│ ├── box_filled@2x.png
│ ├── de.lproj
│ │ └── Localizable.strings
│ ├── en.lproj
│ │ └── Localizable.strings
│ ├── he.lproj
│ │ └── Localizable.strings
│ └── nl.lproj
│ │ └── Localizable.strings
├── KKPasscodeLock.h
├── KKPasscodeLock.m
├── KKPasscodeSettingsViewController.h
├── KKPasscodeSettingsViewController.m
├── KKPasscodeViewController.h
└── KKPasscodeViewController.m
└── tests
├── KKPasscodeLock
└── KKPasscodeLock-Prefix.pch
├── KKPasscodeLockTests.xcodeproj
└── project.pbxproj
└── KKPasscodeLockTests
├── KKPasscodeLock-Info.plist
├── KKPasscodeLockTests.h
├── KKPasscodeLockTests.m
└── en.lproj
└── InfoPlist.strings
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.pyc
3 | build/
4 | docs/output/
5 | docs/output-docset/
6 | xcuserdata
7 | *.xcworkspace
8 | node_modules
9 |
--------------------------------------------------------------------------------
/KKPasscodeLock.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |s|
2 | s.name = 'KKPasscodeLock'
3 | s.version = '0.1.5'
4 | s.license = 'Apache 2.0'
5 | s.summary = 'KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passcode settings in ios apps'
6 | s.homepage = 'https://github.com/aporat/KKPasscodeLock.git'
7 | s.author = { 'Adar Porat' => 'adar.porat@gmail.com' }
8 | s.source = { :git => 'https://github.com/aporat/KKPasscodeLock.git' }
9 | s.platform = :ios
10 | s.source_files = 'src/*.{h,m}'
11 | s.resources = "src/KKPasscodeLock.bundle"
12 | s.frameworks = 'QuartzCore', 'AudioToolbox', 'Security'
13 | s.requires_arc = true
14 | end
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | Copyright 2011 Adar Porat
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 |
--------------------------------------------------------------------------------
/README.mdown:
--------------------------------------------------------------------------------
1 |
What is KKPasscodeLock?
2 |
3 |  
4 |
5 |
6 | KKPasscodeLock is an iOS toolkit for adding a passcode view controller and passcode settings in ios apps.
7 |
8 | 
9 |
10 | 
11 |
12 | 
13 |
14 |
15 |
16 | Main Features in KKPasscodeLock
17 | - Either a simple 4 digit passcode (using a numeric keyboard) or a free-text passcode (in development)
18 | - Supports universal apps (both iPhone and iPad)
19 | - Advanced passcode settings controller: set & change passcode, turn off/on passcode and passcode tries allowed
20 | - Passcode is saved securly in the device keychain
21 |
22 |
23 | Using KKPasscodeLock
24 |
25 | Using this framework is really easy.
26 |
27 | - Add all the source files under the src folder, including KKPasscodeLock.bundle
28 | - `#import "KKPasscodeLock.h"` where you need it.
29 | - Add the `AudioToolbox.framework`, `Security.framework` and the `QuartzCore.framework` into your project
30 | - See the usage of the passcode lock from the sample app
31 |
32 | Terms of Use
33 | - Provided under the Apache 2.0 License
34 |
--------------------------------------------------------------------------------
/example/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/example/Default-568h@2x.png
--------------------------------------------------------------------------------
/example/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/example/Default.png
--------------------------------------------------------------------------------
/example/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/example/Default@2x.png
--------------------------------------------------------------------------------
/example/KKPasscodeLock/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 | #import "KKPasscodeLock.h"
20 |
21 | @interface AppDelegate : UIResponder
22 |
23 | @property (strong, nonatomic) UIWindow *window;
24 | @property (nonatomic) IBOutlet UINavigationController *navigationController;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "AppDelegate.h"
19 | #import "RootViewController.h"
20 | #import "KKPasscodeLock.h"
21 |
22 | @implementation AppDelegate
23 |
24 | @synthesize window = _window;
25 | @synthesize navigationController=_navigationController;
26 |
27 |
28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
29 | {
30 |
31 | [[KKPasscodeLock sharedLock] setDefaultSettings];
32 | [KKPasscodeLock sharedLock].eraseOption = NO;
33 |
34 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
35 | self.window.backgroundColor = [UIColor whiteColor];
36 |
37 | RootViewController* vc = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
38 |
39 | _navigationController = [[UINavigationController alloc] initWithRootViewController:vc];
40 | [self.window setRootViewController:_navigationController];
41 | [self.window makeKeyAndVisible];
42 |
43 | return YES;
44 | }
45 |
46 |
47 | - (void)applicationDidBecomeActive:(UIApplication *)application
48 | {
49 | if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
50 | KKPasscodeViewController *vc = [[KKPasscodeViewController alloc] initWithNibName:nil bundle:nil];
51 | vc.mode = KKPasscodeModeEnter;
52 | vc.delegate = self;
53 |
54 | dispatch_async(dispatch_get_main_queue(),^ {
55 | UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
56 |
57 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
58 | nav.modalPresentationStyle = UIModalPresentationFormSheet;
59 | nav.navigationBar.barStyle = UIBarStyleBlack;
60 | nav.navigationBar.opaque = NO;
61 | } else {
62 | nav.navigationBar.tintColor = _navigationController.navigationBar.tintColor;
63 | nav.navigationBar.translucent = _navigationController.navigationBar.translucent;
64 | nav.navigationBar.opaque = _navigationController.navigationBar.opaque;
65 | nav.navigationBar.barStyle = _navigationController.navigationBar.barStyle;
66 | }
67 |
68 | [_navigationController presentModalViewController:nav animated:NO];
69 | });
70 |
71 | }
72 | }
73 |
74 | - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController
75 | {
76 | 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];
77 | [alert show];
78 | }
79 |
80 | - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController
81 | {
82 | UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"You have entered an incorrect passcode too many times." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
83 | [alert show];
84 | }
85 |
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/KKPasscodeLockDemo-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFiles
12 |
13 | CFBundleIdentifier
14 | com.kosherpenguin.passcode.demo.${PRODUCT_NAME:rfc1034identifier}
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | ${PRODUCT_NAME}
19 | CFBundlePackageType
20 | APPL
21 | CFBundleShortVersionString
22 | 1.0
23 | CFBundleSignature
24 | ????
25 | CFBundleVersion
26 | 1.0
27 | LSRequiresIPhoneOS
28 |
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'KKPasscodeLock' target in the 'KKPasscodeLock' project
3 | //
4 |
5 | #import
6 |
7 | #ifndef __IPHONE_3_0
8 | #warning "This project uses features only available in iOS SDK 3.0 and later."
9 | #endif
10 |
11 | #ifdef __OBJC__
12 | #import
13 | #import
14 | #endif
15 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/RootViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 | #import "KKPasscodeViewController.h"
20 |
21 | @interface RootViewController : UIViewController
22 |
23 | - (IBAction)showPasscode:(id)sender;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/RootViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "RootViewController.h"
19 | #import "SettingsViewController.h"
20 |
21 | @implementation RootViewController
22 |
23 | - (IBAction)showPasscode:(id)sender {
24 |
25 | SettingsViewController* settingsViewController = [[SettingsViewController alloc]
26 | initWithNibName:@"SettingsViewController" bundle:nil];
27 |
28 | UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
29 |
30 | [self presentModalViewController:navController animated:YES];
31 |
32 | }
33 |
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/RootViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1536
5 | 12C3006
6 | 2844
7 | 1187.34
8 | 625.00
9 |
10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
11 | 1930
12 |
13 |
14 | YES
15 | IBProxyObject
16 | IBUIButton
17 | IBUILabel
18 | IBUIView
19 |
20 |
21 | YES
22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
23 |
24 |
25 | PluginDependencyRecalculationVersion
26 |
27 |
28 |
29 | YES
30 |
31 | IBFilesOwner
32 | IBCocoaTouchFramework
33 |
34 |
35 | IBFirstResponder
36 | IBCocoaTouchFramework
37 |
38 |
39 |
40 | 292
41 |
42 | YES
43 |
44 |
45 | 292
46 | {{53, 132}, {215, 37}}
47 |
48 |
49 | NO
50 | IBCocoaTouchFramework
51 | 0
52 | 0
53 | 1
54 | Show Settings Controller
55 |
56 | 3
57 | MQA
58 |
59 |
60 | 1
61 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA
62 |
63 |
64 | 3
65 | MC41AA
66 |
67 |
68 | Helvetica-Bold
69 | Helvetica
70 | 2
71 | 15
72 |
73 |
74 | Helvetica-Bold
75 | 15
76 | 16
77 |
78 |
79 |
80 |
81 | 292
82 | {{20, 20}, {280, 31}}
83 |
84 |
85 |
86 |
87 | 3
88 | MCAwAA
89 |
90 | NO
91 | YES
92 | 7
93 | NO
94 | IBCocoaTouchFramework
95 | Passcode Sample
96 |
97 | 1
98 | MC4yNTg4MjM1Mjk0IDAuMzMzMzMzMzMzMyAwLjQAA
99 |
100 |
101 |
102 | 1
103 | MSAxIDEAA
104 |
105 | {0, 1}
106 | 1
107 | 10
108 | 1
109 |
110 | Helvetica-Bold
111 | Helvetica
112 | 2
113 | 17
114 |
115 |
116 | Helvetica-Bold
117 | 17
118 | 16
119 |
120 |
121 |
122 |
123 | 292
124 | {{20, 59}, {280, 55}}
125 |
126 |
127 |
128 |
129 | NO
130 | YES
131 | 7
132 | NO
133 | IBCocoaTouchFramework
134 | Click the button below to show a generic settings controller, which include a section for passcode settings
135 |
136 | 1
137 | MC4yNTg4MjM1Mjk0IDAuMzMzMzMzMzMzMyAwLjQAA
138 |
139 |
140 |
141 | {0, 1}
142 | 1
143 | 10
144 | 0
145 | 1
146 |
147 | Helvetica
148 | Helvetica
149 | 0
150 | 14
151 |
152 |
153 | Helvetica
154 | 14
155 | 16
156 |
157 | 280
158 |
159 |
160 | {{0, 20}, {320, 460}}
161 |
162 |
163 |
164 |
165 |
166 | IBCocoaTouchFramework
167 |
168 |
169 |
170 |
171 | YES
172 |
173 |
174 | view
175 |
176 |
177 |
178 | 14
179 |
180 |
181 |
182 | showPasscode:
183 |
184 |
185 | 7
186 |
187 | 13
188 |
189 |
190 |
191 |
192 | YES
193 |
194 | 0
195 |
196 | YES
197 |
198 |
199 |
200 |
201 |
202 | -1
203 |
204 |
205 | File's Owner
206 |
207 |
208 | -2
209 |
210 |
211 |
212 |
213 | 6
214 |
215 |
216 | YES
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 | 7
225 |
226 |
227 |
228 |
229 | 8
230 |
231 |
232 |
233 |
234 | 9
235 |
236 |
237 |
238 |
239 |
240 |
241 | YES
242 |
243 | YES
244 | -1.CustomClassName
245 | -1.IBPluginDependency
246 | -2.CustomClassName
247 | -2.IBPluginDependency
248 | 6.IBPluginDependency
249 | 7.IBPluginDependency
250 | 8.IBPluginDependency
251 | 9.IBPluginDependency
252 |
253 |
254 | YES
255 | RootViewController
256 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
257 | UIResponder
258 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
259 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
260 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
261 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
262 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
263 |
264 |
265 |
266 | YES
267 |
268 |
269 |
270 |
271 |
272 | YES
273 |
274 |
275 |
276 |
277 | 14
278 |
279 |
280 |
281 | YES
282 |
283 | RootViewController
284 | UIViewController
285 |
286 | showPasscode:
287 | id
288 |
289 |
290 | showPasscode:
291 |
292 | showPasscode:
293 | id
294 |
295 |
296 |
297 | IBProjectSource
298 | ./Classes/RootViewController.h
299 |
300 |
301 |
302 |
303 | 0
304 | IBCocoaTouchFramework
305 |
306 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
307 |
308 |
309 |
310 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
311 |
312 |
313 | YES
314 | 3
315 | 1930
316 |
317 |
318 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/SettingsViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 | #import "KKPasscodeSettingsViewController.h"
20 |
21 | @interface SettingsViewController : UITableViewController
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/SettingsViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "SettingsViewController.h"
19 | #import "KKPasscodeSettingsViewController.h"
20 | #import "KKPasscodeLock.h"
21 |
22 | @implementation SettingsViewController
23 |
24 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
25 | return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
26 | }
27 |
28 | - (void)doneButtonPressed:(id)sender {
29 | [self dismissModalViewControllerAnimated:YES];
30 | }
31 |
32 | #pragma mark - View lifecycle
33 |
34 | - (void)viewDidLoad {
35 | [super viewDidLoad];
36 | self.navigationItem.title = NSLocalizedString(@"Settings", nil);
37 |
38 |
39 | UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];
40 |
41 | self.navigationItem.rightBarButtonItem = doneButton;
42 | }
43 |
44 | #pragma mark - Table view data source
45 |
46 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
47 | return @"";
48 | }
49 |
50 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
51 | return 1;
52 | }
53 |
54 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
55 | return 1;
56 | }
57 |
58 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
59 |
60 | static NSString *CellIdentifier = @"Cell";
61 |
62 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
63 | if (cell == nil) {
64 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
65 | }
66 |
67 | if (indexPath.section == 0) {
68 | cell.textLabel.text = NSLocalizedString(@"Passcode Lock", nil);
69 | if ([[KKPasscodeLock sharedLock] isPasscodeRequired]) {
70 | cell.detailTextLabel.text = NSLocalizedString(@"On", nil);
71 | } else {
72 | cell.detailTextLabel.text = NSLocalizedString(@"Off", nil);
73 | }
74 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
75 | }
76 | return cell;
77 | }
78 |
79 | #pragma mark - Table view delegate
80 |
81 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
82 | if (indexPath.section == 0) {
83 | KKPasscodeSettingsViewController *vc = [[KKPasscodeSettingsViewController alloc] initWithStyle:UITableViewStyleGrouped];
84 | vc.delegate = self;
85 | [self.navigationController pushViewController:vc animated:YES];
86 | }
87 | }
88 |
89 | - (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController
90 | {
91 | [self.tableView reloadData];
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/SettingsViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1024
5 | 10J567
6 | 1305
7 | 1038.35
8 | 462.00
9 |
10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
11 | 300
12 |
13 |
14 | YES
15 | IBProxyObject
16 | IBUITableView
17 |
18 |
19 | YES
20 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
21 |
22 |
23 | YES
24 |
25 | YES
26 |
27 |
28 |
29 |
30 | YES
31 |
32 | IBFilesOwner
33 | IBCocoaTouchFramework
34 |
35 |
36 | IBFirstResponder
37 | IBCocoaTouchFramework
38 |
39 |
40 |
41 | 274
42 | {{0, 20}, {320, 460}}
43 |
44 |
45 |
46 | 10
47 |
48 | 549453824
49 | {84, 1}
50 |
51 | YES
52 |
53 | YES
54 |
55 |
56 |
57 | TU0AKgAAAVjFzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/
58 | y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/
59 | xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/
60 | xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/
61 | xczU/8XM1P/FzNL/y9LY/8vS2P/FzNT/xczU/8XM1P/FzNT/xczS/8vS2P/L0tj/xczU/8XM1P/FzNT/
62 | xczU/8XM0v/L0tj/y9LY/8XM1P/FzNT/xczU/8XM1P/FzNL/y9LY/8vS2P8ADQEAAAMAAAABAFQAAAEB
63 | AAMAAAABAAEAAAECAAMAAAAEAAAB+gEDAAMAAAABAAEAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAES
64 | AAMAAAABAAEAAAEVAAMAAAABAAQAAAEWAAMAAAABAAEAAAEXAAQAAAABAAABUAEcAAMAAAABAAEAAAFS
65 | AAMAAAABAAEAAAFTAAMAAAAEAAACAgAAAAAACAAIAAgACAABAAEAAQABA
66 |
67 |
68 |
69 |
70 |
71 | 3
72 | MCAwAA
73 |
74 |
75 | groupTableViewBackgroundColor
76 |
77 | NO
78 | YES
79 | NO
80 |
81 | IBCocoaTouchFramework
82 | NO
83 | 1
84 | 1
85 | 0
86 | YES
87 | 44
88 | 10
89 | 10
90 |
91 |
92 |
93 |
94 | YES
95 |
96 |
97 | view
98 |
99 |
100 |
101 | 5
102 |
103 |
104 |
105 | dataSource
106 |
107 |
108 |
109 | 6
110 |
111 |
112 |
113 | delegate
114 |
115 |
116 |
117 | 7
118 |
119 |
120 |
121 |
122 | YES
123 |
124 | 0
125 |
126 |
127 |
128 |
129 |
130 | -1
131 |
132 |
133 | File's Owner
134 |
135 |
136 | -2
137 |
138 |
139 |
140 |
141 | 4
142 |
143 |
144 |
145 |
146 |
147 |
148 | YES
149 |
150 | YES
151 | -1.CustomClassName
152 | -2.CustomClassName
153 | 4.IBEditorWindowLastContentRect
154 | 4.IBPluginDependency
155 |
156 |
157 | YES
158 | SettingsViewController
159 | UIResponder
160 | {{329, 504}, {320, 480}}
161 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
162 |
163 |
164 |
165 | YES
166 |
167 |
168 |
169 |
170 |
171 | YES
172 |
173 |
174 |
175 |
176 | 7
177 |
178 |
179 |
180 | YES
181 |
182 | SettingsViewController
183 | UITableViewController
184 |
185 | IBProjectSource
186 | ./Classes/SettingsViewController.h
187 |
188 |
189 |
190 |
191 | 0
192 | IBCocoaTouchFramework
193 |
194 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS
195 |
196 |
197 |
198 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
199 |
200 |
201 | YES
202 | 3
203 | 300
204 |
205 |
206 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/de.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/de.lproj/Localizable.strings:
--------------------------------------------------------------------------------
1 | "Passcode Lock" = "Code-Sperre";
2 |
3 | /* No comment provided by engineer. */
4 | "Off" = "Aus";
5 |
6 | /* No comment provided by engineer. */
7 | "On" = "An";
8 |
9 | /* No comment provided by engineer. */
10 | "Settings" = "Einstellungen";
11 |
12 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/en.lproj/Localizable.strings:
--------------------------------------------------------------------------------
1 | "Passcode Lock" = "Passcode Lock";
2 |
3 | /* No comment provided by engineer. */
4 | "Off" = "Off";
5 |
6 | /* No comment provided by engineer. */
7 | "On" = "On";
8 |
9 | /* No comment provided by engineer. */
10 | "Settings" = "Settings";
11 |
12 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/he.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 |
20 | #import "AppDelegate.h"
21 |
22 | int main(int argc, char *argv[])
23 | {
24 | @autoreleasepool {
25 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/example/KKPasscodeLock/nl.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/example/KKPasscodeLockDemo.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 5303095E16611BF90004810F /* Default-568h@2x.png */; };
11 | 53DD2F8816A79FDB002582A0 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 53DD2F8616A79FDB002582A0 /* Default.png */; };
12 | 53DD2F8916A79FDB002582A0 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 53DD2F8716A79FDB002582A0 /* Default@2x.png */; };
13 | 6D3E345214C4F54E0003B72B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345114C4F54E0003B72B /* UIKit.framework */; };
14 | 6D3E345414C4F54E0003B72B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345314C4F54E0003B72B /* Foundation.framework */; };
15 | 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */; };
16 | 6D3E345C14C4F54E0003B72B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */; };
17 | 6D3E345E14C4F54E0003B72B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E345D14C4F54E0003B72B /* main.m */; };
18 | 6D3E346214C4F54E0003B72B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E346114C4F54E0003B72B /* AppDelegate.m */; };
19 | 6D3E34BC14C4F90B0003B72B /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E34BA14C4F90B0003B72B /* Security.framework */; };
20 | 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */; };
21 | 6D3E34CF14C4F9910003B72B /* RootViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D3E34CC14C4F9910003B72B /* RootViewController.m */; };
22 | 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6D3E34CD14C4F9910003B72B /* RootViewController.xib */; };
23 | 6DF13A5B14C686FC0069BBA5 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */; };
24 | 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */; };
25 | 6DF13A6914C6870B0069BBA5 /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */; };
26 | 6DF13A6A14C6870B0069BBA5 /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */; };
27 | 6DF13A6B14C6870B0069BBA5 /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */; };
28 | 6DF13A6C14C6870B0069BBA5 /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */; };
29 | 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */; };
30 | 6DFE344414CFBE8400E6EEA4 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */; };
31 | /* End PBXBuildFile section */
32 |
33 | /* Begin PBXFileReference section */
34 | 5303095E16611BF90004810F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; };
35 | 5303097E16611F510004810F /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/InfoPlist.strings; sourceTree = ""; };
36 | 5303097F16611F580004810F /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = ""; };
37 | 5303098816612A310004810F /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; };
38 | 53DD2F8616A79FDB002582A0 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; };
39 | 53DD2F8716A79FDB002582A0 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; };
40 | 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KKPasscodeLockDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
41 | 6D3E345114C4F54E0003B72B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
42 | 6D3E345314C4F54E0003B72B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
43 | 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
44 | 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KKPasscodeLockDemo-Info.plist"; sourceTree = ""; };
45 | 6D3E345B14C4F54E0003B72B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
46 | 6D3E345D14C4F54E0003B72B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
47 | 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLockDemo-Prefix.pch"; sourceTree = ""; };
48 | 6D3E346014C4F54E0003B72B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
49 | 6D3E346114C4F54E0003B72B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AppDelegate.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
50 | 6D3E34BA14C4F90B0003B72B /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
51 | 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
52 | 6D3E34CB14C4F9910003B72B /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; };
53 | 6D3E34CC14C4F9910003B72B /* RootViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootViewController.m; sourceTree = ""; };
54 | 6D3E34CD14C4F9910003B72B /* RootViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RootViewController.xib; sourceTree = ""; };
55 | 6DF13A5814C686FC0069BBA5 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = ""; };
56 | 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SettingsViewController.m; sourceTree = ""; };
57 | 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SettingsViewController.xib; sourceTree = ""; };
58 | 6DF13A5D14C6870B0069BBA5 /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = ../../src/KKKeychain.h; sourceTree = ""; };
59 | 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = ../../src/KKKeychain.m; sourceTree = ""; };
60 | 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; };
61 | 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; };
62 | 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; };
63 | 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; };
64 | 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; };
65 | 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; };
66 | 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; };
67 | 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
68 | /* End PBXFileReference section */
69 |
70 | /* Begin PBXFrameworksBuildPhase section */
71 | 6D3E344A14C4F54D0003B72B /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | 6D3E345214C4F54E0003B72B /* UIKit.framework in Frameworks */,
76 | 6D3E345414C4F54E0003B72B /* Foundation.framework in Frameworks */,
77 | 6D3E345614C4F54E0003B72B /* CoreGraphics.framework in Frameworks */,
78 | 6D3E34BC14C4F90B0003B72B /* Security.framework in Frameworks */,
79 | 6D3E34BD14C4F90B0003B72B /* QuartzCore.framework in Frameworks */,
80 | 6DFE344414CFBE8400E6EEA4 /* AudioToolbox.framework in Frameworks */,
81 | );
82 | runOnlyForDeploymentPostprocessing = 0;
83 | };
84 | /* End PBXFrameworksBuildPhase section */
85 |
86 | /* Begin PBXGroup section */
87 | 6D2F0BD414C51CCA00C1862D /* Demo App */ = {
88 | isa = PBXGroup;
89 | children = (
90 | 6D3E34D314C4FC850003B72B /* Settings Controller */,
91 | 6D3E34D214C4FB8C0003B72B /* Demo Root Controller */,
92 | 6D3E34D114C4FB7B0003B72B /* App Delegate */,
93 | 6D2F0BD614C51D0300C1862D /* Supporting Files */,
94 | );
95 | name = "Demo App";
96 | path = KKPasscodeLock;
97 | sourceTree = "";
98 | };
99 | 6D2F0BD614C51D0300C1862D /* Supporting Files */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 6D3E345914C4F54E0003B72B /* KKPasscodeLockDemo-Info.plist */,
103 | 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */,
104 | 6D3E345D14C4F54E0003B72B /* main.m */,
105 | 6D3E345F14C4F54E0003B72B /* KKPasscodeLockDemo-Prefix.pch */,
106 | );
107 | name = "Supporting Files";
108 | sourceTree = "";
109 | };
110 | 6D3E344214C4F54D0003B72B = {
111 | isa = PBXGroup;
112 | children = (
113 | 53DD2F8616A79FDB002582A0 /* Default.png */,
114 | 53DD2F8716A79FDB002582A0 /* Default@2x.png */,
115 | 5303095E16611BF90004810F /* Default-568h@2x.png */,
116 | 6D3E345714C4F54E0003B72B /* KKPasscodeLock */,
117 | 6D2F0BD414C51CCA00C1862D /* Demo App */,
118 | 6D3E345014C4F54E0003B72B /* Frameworks */,
119 | 6D3E344E14C4F54E0003B72B /* Products */,
120 | );
121 | sourceTree = "";
122 | };
123 | 6D3E344E14C4F54E0003B72B /* Products */ = {
124 | isa = PBXGroup;
125 | children = (
126 | 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */,
127 | );
128 | name = Products;
129 | sourceTree = "";
130 | };
131 | 6D3E345014C4F54E0003B72B /* Frameworks */ = {
132 | isa = PBXGroup;
133 | children = (
134 | 6DFE344314CFBE8400E6EEA4 /* AudioToolbox.framework */,
135 | 6D3E34BA14C4F90B0003B72B /* Security.framework */,
136 | 6D3E34BB14C4F90B0003B72B /* QuartzCore.framework */,
137 | 6D3E345114C4F54E0003B72B /* UIKit.framework */,
138 | 6D3E345314C4F54E0003B72B /* Foundation.framework */,
139 | 6D3E345514C4F54E0003B72B /* CoreGraphics.framework */,
140 | );
141 | name = Frameworks;
142 | sourceTree = "";
143 | };
144 | 6D3E345714C4F54E0003B72B /* KKPasscodeLock */ = {
145 | isa = PBXGroup;
146 | children = (
147 | 6DFE33F614CF879E00E6EEA4 /* KKPasscodeLock.bundle */,
148 | 6DF13A5D14C6870B0069BBA5 /* KKKeychain.h */,
149 | 6DF13A5E14C6870B0069BBA5 /* KKKeychain.m */,
150 | 6DF13A5F14C6870B0069BBA5 /* KKPasscodeLock.h */,
151 | 6DF13A6014C6870B0069BBA5 /* KKPasscodeLock.m */,
152 | 6DF13A6114C6870B0069BBA5 /* KKPasscodeSettingsViewController.h */,
153 | 6DF13A6214C6870B0069BBA5 /* KKPasscodeSettingsViewController.m */,
154 | 6DF13A6314C6870B0069BBA5 /* KKPasscodeViewController.h */,
155 | 6DF13A6414C6870B0069BBA5 /* KKPasscodeViewController.m */,
156 | );
157 | path = KKPasscodeLock;
158 | sourceTree = "";
159 | };
160 | 6D3E34D114C4FB7B0003B72B /* App Delegate */ = {
161 | isa = PBXGroup;
162 | children = (
163 | 6D3E346014C4F54E0003B72B /* AppDelegate.h */,
164 | 6D3E346114C4F54E0003B72B /* AppDelegate.m */,
165 | );
166 | name = "App Delegate";
167 | sourceTree = "";
168 | };
169 | 6D3E34D214C4FB8C0003B72B /* Demo Root Controller */ = {
170 | isa = PBXGroup;
171 | children = (
172 | 6D3E34CB14C4F9910003B72B /* RootViewController.h */,
173 | 6D3E34CC14C4F9910003B72B /* RootViewController.m */,
174 | 6D3E34CD14C4F9910003B72B /* RootViewController.xib */,
175 | );
176 | name = "Demo Root Controller";
177 | sourceTree = "";
178 | };
179 | 6D3E34D314C4FC850003B72B /* Settings Controller */ = {
180 | isa = PBXGroup;
181 | children = (
182 | 6DF13A5814C686FC0069BBA5 /* SettingsViewController.h */,
183 | 6DF13A5914C686FC0069BBA5 /* SettingsViewController.m */,
184 | 6DF13A5A14C686FC0069BBA5 /* SettingsViewController.xib */,
185 | );
186 | name = "Settings Controller";
187 | sourceTree = "";
188 | };
189 | /* End PBXGroup section */
190 |
191 | /* Begin PBXNativeTarget section */
192 | 6D3E344C14C4F54D0003B72B /* KKPasscodeLockDemo */ = {
193 | isa = PBXNativeTarget;
194 | buildConfigurationList = 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLockDemo" */;
195 | buildPhases = (
196 | 6D3E344914C4F54D0003B72B /* Sources */,
197 | 6D3E344A14C4F54D0003B72B /* Frameworks */,
198 | 6D3E344B14C4F54D0003B72B /* Resources */,
199 | );
200 | buildRules = (
201 | );
202 | dependencies = (
203 | );
204 | name = KKPasscodeLockDemo;
205 | productName = KKPasscodeLock;
206 | productReference = 6D3E344D14C4F54E0003B72B /* KKPasscodeLockDemo.app */;
207 | productType = "com.apple.product-type.application";
208 | };
209 | /* End PBXNativeTarget section */
210 |
211 | /* Begin PBXProject section */
212 | 6D3E344414C4F54D0003B72B /* Project object */ = {
213 | isa = PBXProject;
214 | attributes = {
215 | LastUpgradeCheck = 0430;
216 | ORGANIZATIONNAME = "Kosher Penguin LLC";
217 | };
218 | buildConfigurationList = 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLockDemo" */;
219 | compatibilityVersion = "Xcode 3.2";
220 | developmentRegion = English;
221 | hasScannedForEncodings = 0;
222 | knownRegions = (
223 | en,
224 | nl,
225 | de,
226 | he,
227 | );
228 | mainGroup = 6D3E344214C4F54D0003B72B;
229 | productRefGroup = 6D3E344E14C4F54E0003B72B /* Products */;
230 | projectDirPath = "";
231 | projectRoot = "";
232 | targets = (
233 | 6D3E344C14C4F54D0003B72B /* KKPasscodeLockDemo */,
234 | );
235 | };
236 | /* End PBXProject section */
237 |
238 | /* Begin PBXResourcesBuildPhase section */
239 | 6D3E344B14C4F54D0003B72B /* Resources */ = {
240 | isa = PBXResourcesBuildPhase;
241 | buildActionMask = 2147483647;
242 | files = (
243 | 6D3E345C14C4F54E0003B72B /* InfoPlist.strings in Resources */,
244 | 6D3E34D014C4F9910003B72B /* RootViewController.xib in Resources */,
245 | 6DF13A5C14C686FC0069BBA5 /* SettingsViewController.xib in Resources */,
246 | 6DFE33F714CF879E00E6EEA4 /* KKPasscodeLock.bundle in Resources */,
247 | 5303095F16611BF90004810F /* Default-568h@2x.png in Resources */,
248 | 53DD2F8816A79FDB002582A0 /* Default.png in Resources */,
249 | 53DD2F8916A79FDB002582A0 /* Default@2x.png in Resources */,
250 | );
251 | runOnlyForDeploymentPostprocessing = 0;
252 | };
253 | /* End PBXResourcesBuildPhase section */
254 |
255 | /* Begin PBXSourcesBuildPhase section */
256 | 6D3E344914C4F54D0003B72B /* Sources */ = {
257 | isa = PBXSourcesBuildPhase;
258 | buildActionMask = 2147483647;
259 | files = (
260 | 6D3E345E14C4F54E0003B72B /* main.m in Sources */,
261 | 6D3E346214C4F54E0003B72B /* AppDelegate.m in Sources */,
262 | 6D3E34CF14C4F9910003B72B /* RootViewController.m in Sources */,
263 | 6DF13A5B14C686FC0069BBA5 /* SettingsViewController.m in Sources */,
264 | 6DF13A6914C6870B0069BBA5 /* KKKeychain.m in Sources */,
265 | 6DF13A6A14C6870B0069BBA5 /* KKPasscodeLock.m in Sources */,
266 | 6DF13A6B14C6870B0069BBA5 /* KKPasscodeSettingsViewController.m in Sources */,
267 | 6DF13A6C14C6870B0069BBA5 /* KKPasscodeViewController.m in Sources */,
268 | );
269 | runOnlyForDeploymentPostprocessing = 0;
270 | };
271 | /* End PBXSourcesBuildPhase section */
272 |
273 | /* Begin PBXVariantGroup section */
274 | 6D3E345A14C4F54E0003B72B /* InfoPlist.strings */ = {
275 | isa = PBXVariantGroup;
276 | children = (
277 | 6D3E345B14C4F54E0003B72B /* en */,
278 | 5303097E16611F510004810F /* nl */,
279 | 5303097F16611F580004810F /* de */,
280 | 5303098816612A310004810F /* he */,
281 | );
282 | name = InfoPlist.strings;
283 | sourceTree = "";
284 | };
285 | /* End PBXVariantGroup section */
286 |
287 | /* Begin XCBuildConfiguration section */
288 | 6D3E346314C4F54E0003B72B /* Debug */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ALWAYS_SEARCH_USER_PATHS = NO;
292 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
294 | COPY_PHASE_STRIP = NO;
295 | GCC_C_LANGUAGE_STANDARD = gnu99;
296 | GCC_DYNAMIC_NO_PIC = NO;
297 | GCC_OPTIMIZATION_LEVEL = 0;
298 | GCC_PREPROCESSOR_DEFINITIONS = (
299 | "DEBUG=1",
300 | "$(inherited)",
301 | );
302 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
303 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
304 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
305 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
306 | GCC_WARN_UNUSED_VARIABLE = YES;
307 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
308 | SDKROOT = iphoneos;
309 | TARGETED_DEVICE_FAMILY = "1,2";
310 | };
311 | name = Debug;
312 | };
313 | 6D3E346414C4F54E0003B72B /* Release */ = {
314 | isa = XCBuildConfiguration;
315 | buildSettings = {
316 | ALWAYS_SEARCH_USER_PATHS = NO;
317 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
318 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
319 | COPY_PHASE_STRIP = YES;
320 | GCC_C_LANGUAGE_STANDARD = gnu99;
321 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
322 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
323 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
324 | GCC_WARN_UNUSED_VARIABLE = YES;
325 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
326 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
327 | SDKROOT = iphoneos;
328 | TARGETED_DEVICE_FAMILY = "1,2";
329 | VALIDATE_PRODUCT = YES;
330 | };
331 | name = Release;
332 | };
333 | 6D3E346614C4F54E0003B72B /* Debug */ = {
334 | isa = XCBuildConfiguration;
335 | buildSettings = {
336 | CLANG_ENABLE_OBJC_ARC = YES;
337 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
338 | GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch";
339 | INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist";
340 | IPHONEOS_DEPLOYMENT_TARGET = 4.0;
341 | PRODUCT_NAME = KKPasscodeLockDemo;
342 | WRAPPER_EXTENSION = app;
343 | };
344 | name = Debug;
345 | };
346 | 6D3E346714C4F54E0003B72B /* Release */ = {
347 | isa = XCBuildConfiguration;
348 | buildSettings = {
349 | CLANG_ENABLE_OBJC_ARC = YES;
350 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
351 | GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLockDemo-Prefix.pch";
352 | INFOPLIST_FILE = "KKPasscodeLock/KKPasscodeLockDemo-Info.plist";
353 | IPHONEOS_DEPLOYMENT_TARGET = 4.0;
354 | PRODUCT_NAME = KKPasscodeLockDemo;
355 | WRAPPER_EXTENSION = app;
356 | };
357 | name = Release;
358 | };
359 | /* End XCBuildConfiguration section */
360 |
361 | /* Begin XCConfigurationList section */
362 | 6D3E344714C4F54D0003B72B /* Build configuration list for PBXProject "KKPasscodeLockDemo" */ = {
363 | isa = XCConfigurationList;
364 | buildConfigurations = (
365 | 6D3E346314C4F54E0003B72B /* Debug */,
366 | 6D3E346414C4F54E0003B72B /* Release */,
367 | );
368 | defaultConfigurationIsVisible = 0;
369 | defaultConfigurationName = Release;
370 | };
371 | 6D3E346514C4F54E0003B72B /* Build configuration list for PBXNativeTarget "KKPasscodeLockDemo" */ = {
372 | isa = XCConfigurationList;
373 | buildConfigurations = (
374 | 6D3E346614C4F54E0003B72B /* Debug */,
375 | 6D3E346714C4F54E0003B72B /* Release */,
376 | );
377 | defaultConfigurationIsVisible = 0;
378 | defaultConfigurationName = Release;
379 | };
380 | /* End XCConfigurationList section */
381 | };
382 | rootObject = 6D3E344414C4F54D0003B72B /* Project object */;
383 | }
384 |
--------------------------------------------------------------------------------
/screenshots/ipad-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/screenshots/ipad-1.png
--------------------------------------------------------------------------------
/screenshots/iphone-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/screenshots/iphone-1.png
--------------------------------------------------------------------------------
/screenshots/iphone-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/screenshots/iphone-2.png
--------------------------------------------------------------------------------
/src/KKKeychain.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 |
20 | @interface KKKeychain : NSObject
21 |
22 | + (BOOL)setString:(NSString*)string forKey:(NSString*)key;
23 |
24 | + (NSString*)getStringForKey:(NSString*)key;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/src/KKKeychain.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "KKKeychain.h"
19 | #import
20 |
21 | @implementation KKKeychain
22 |
23 | + (NSString*)appName
24 | {
25 | NSBundle *bundle = [NSBundle bundleForClass:[self class]];
26 | NSString *appName = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
27 | if (!appName) {
28 | appName = [bundle objectForInfoDictionaryKey:@"CFBundleName"];
29 | }
30 | return appName;
31 | }
32 |
33 | + (BOOL)setString:(NSString*)string forKey:(NSString*)key
34 | {
35 | if (string == nil || key == nil) {
36 | return NO;
37 | }
38 |
39 | key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key];
40 |
41 | // First check if it already exists, by creating a search dictionary and requesting that
42 | // nothing be returned, and performing the search anyway.
43 | NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary];
44 |
45 | NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
46 |
47 | [existsQueryDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass];
48 |
49 | // Add the keys to the search dict
50 | [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService];
51 | [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount];
52 |
53 | OSStatus res = SecItemCopyMatching((__bridge CFDictionaryRef) existsQueryDictionary, NULL);
54 |
55 | if (res == errSecItemNotFound) {
56 | if (string != nil) {
57 | NSMutableDictionary *addDict = existsQueryDictionary;
58 | [addDict setObject:data forKey:(__bridge id)kSecValueData];
59 |
60 | res = SecItemAdd((__bridge CFDictionaryRef)addDict, NULL);
61 | NSAssert1(res == errSecSuccess, @"Recieved %ld from SecItemAdd!", res);
62 | }
63 | } else if (res == errSecSuccess) {
64 | // Modify an existing one
65 | // Actually pull it now of the keychain at this point.
66 | NSDictionary *attributeDict = [NSDictionary dictionaryWithObject:data forKey:(__bridge id)kSecValueData];
67 | res = SecItemUpdate((__bridge CFDictionaryRef)existsQueryDictionary, (__bridge CFDictionaryRef)attributeDict);
68 | NSAssert1(res == errSecSuccess, @"SecItemUpdated returned %ld!", res);
69 | } else {
70 | NSAssert1(NO, @"Received %ld from SecItemCopyMatching!", res);
71 | }
72 | return YES;
73 | }
74 |
75 | + (NSString*)getStringForKey:(NSString*)key
76 | {
77 | key = [NSString stringWithFormat:@"%@ - %@", [KKKeychain appName], key];
78 | NSMutableDictionary *existsQueryDictionary = [NSMutableDictionary dictionary];
79 | [existsQueryDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass];
80 |
81 | // Add the keys to the search dict
82 | [existsQueryDictionary setObject:@"service" forKey:(__bridge id)kSecAttrService];
83 | [existsQueryDictionary setObject:key forKey:(__bridge id)kSecAttrAccount];
84 |
85 | // We want the data back!
86 | CFTypeRef data = nil;
87 |
88 | [existsQueryDictionary setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData];
89 |
90 | OSStatus res = SecItemCopyMatching((__bridge CFDictionaryRef)existsQueryDictionary, &data);
91 |
92 | if (res == errSecSuccess) {
93 | NSString *string = [[NSString alloc] initWithData:(__bridge NSData*)data encoding:NSUTF8StringEncoding];
94 | return string;
95 | } else {
96 | NSAssert1(res == errSecItemNotFound, @"SecItemCopyMatching returned %ld!", res);
97 | }
98 |
99 | return nil;
100 | }
101 |
102 |
103 | @end
104 |
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/box_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/box_empty.png
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/box_empty@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/box_empty@2x.png
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/box_filled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/box_filled.png
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/box_filled@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/box_filled@2x.png
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/de.lproj/Localizable.strings
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/en.lproj/Localizable.strings
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/he.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/he.lproj/Localizable.strings
--------------------------------------------------------------------------------
/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aporat/KKPasscodeLock/5d06bfaffc108a20242e45fd5ad45bef94525522/src/KKPasscodeLock.bundle/nl.lproj/Localizable.strings
--------------------------------------------------------------------------------
/src/KKPasscodeLock.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #define KKPasscodeLockLocalizedString(key, comment) [[KKPasscodeLock sharedLock] localizedStringForKey:(key) value:@""]
19 |
20 | #import
21 | #import "KKPasscodeViewController.h"
22 |
23 | extern CGFloat const kPasscodeBlockDisabled;
24 |
25 | @interface KKPasscodeLock : NSObject {
26 |
27 | // whatever the erase option is enabled in the passcode settings
28 | BOOL _eraseOption;
29 |
30 | // how many attemepts is user is allowed to have before the screen is locked
31 | NSUInteger _attemptsAllowed;
32 |
33 | // the minimum time interval (in seconds) that has to pass before isPasscodeBlocked return FALSE again
34 | NSTimeInterval _passcodeBlockInterval;
35 | }
36 |
37 | /**
38 | * a shared object which can change the passcode settings and perform generic actions
39 | */
40 | + (KKPasscodeLock*)sharedLock;
41 |
42 | /**
43 | * checks if a passcode has to be displayed
44 | */
45 | - (BOOL)isPasscodeRequired;
46 |
47 | /**
48 | * checks if the passcode has been blocked due to too many failed attempts
49 | */
50 | - (BOOL)isPasscodeBlocked;
51 |
52 | /**
53 | * return an interval <= 0 if the passcode is not blocked or a value > 0 indicating the time remaining until the passcode can be unlocked
54 | */
55 | - (NSTimeInterval)passcodeBlockedRemainingTime;
56 |
57 | /**
58 | * returns a localized string from the framework's bundle
59 | */
60 | - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value NS_FORMAT_ARGUMENT(1);
61 |
62 | /**
63 | * set the initial settings of the passcode settings
64 | */
65 | - (void)setDefaultSettings;
66 |
67 | /**
68 | * reset the passcode settings
69 | */
70 | - (void)resetSettings;
71 |
72 | @property (nonatomic,assign) BOOL eraseOption;
73 |
74 | @property (nonatomic,assign) NSUInteger attemptsAllowed;
75 |
76 | @property (nonatomic,assign) NSTimeInterval passcodeBlockInterval;
77 |
78 | @property (nonatomic, strong, readonly) NSDateFormatter *dateFormatter;
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/src/KKPasscodeLock.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "KKPasscodeLock.h"
19 | #import "KKKeychain.h"
20 | #import "KKPasscodeViewController.h"
21 |
22 | CGFloat const kPasscodeBlockDisabled = MAXFLOAT;
23 |
24 | static KKPasscodeLock *sharedLock = nil;
25 |
26 | @interface KKPasscodeLock ()
27 |
28 | @property (nonatomic, strong, readwrite) NSDateFormatter *dateFormatter;
29 |
30 | @end
31 |
32 | @implementation KKPasscodeLock
33 |
34 | @synthesize eraseOption = _eraseOption;
35 | @synthesize attemptsAllowed = _attemptsAllowed;
36 | @synthesize passcodeBlockInterval = _passcodeBlockInterval;
37 |
38 | + (KKPasscodeLock*)sharedLock
39 | {
40 | @synchronized(self) {
41 | if (sharedLock == nil) {
42 | sharedLock = [[self alloc] init];
43 | sharedLock.eraseOption = YES;
44 | sharedLock.attemptsAllowed = 5;
45 | sharedLock.passcodeBlockInterval = 600.0f; // 10 minutes default, kPasscodeBlockDisabled means disabled
46 | }
47 | }
48 | return sharedLock;
49 | }
50 |
51 | - (void)setPasscodeBlockInterval:(NSTimeInterval)passcodeBlockInterval
52 | {
53 | _passcodeBlockInterval = passcodeBlockInterval;
54 | if (_passcodeBlockInterval == kPasscodeBlockDisabled) {
55 | [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"];
56 | }
57 | }
58 |
59 | - (NSDateFormatter *)dateFormatter
60 | {
61 | if (!_dateFormatter) {
62 | _dateFormatter = [[NSDateFormatter alloc] init];
63 | _dateFormatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss'Z'";
64 | _dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
65 | _dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
66 | }
67 | return _dateFormatter;
68 | }
69 |
70 | - (BOOL)isPasscodeRequired
71 | {
72 | return [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"];
73 | }
74 |
75 | - (BOOL)isPasscodeBlocked
76 | {
77 | return [self passcodeBlockedRemainingTime] > 0.0f;
78 | }
79 |
80 | - (NSTimeInterval)passcodeBlockedRemainingTime
81 | {
82 | if (self.passcodeBlockInterval == kPasscodeBlockDisabled) {
83 | return 0.0f; // Disabled, we don't need to check
84 | } else {
85 | NSString *lastPasscodeLock = [KKKeychain getStringForKey:@"incorrect_passcode_datetime"];
86 |
87 | NSDate *lastPasscodeLockDate = lastPasscodeLock.length ? [self.dateFormatter dateFromString:lastPasscodeLock] : nil;
88 |
89 | if (lastPasscodeLockDate) {
90 | return self.passcodeBlockInterval - [[NSDate date] timeIntervalSinceDate:lastPasscodeLockDate];
91 | } else {
92 | return 0.0f; // Passcode is not blocked
93 | }
94 | }
95 | }
96 |
97 | - (void)setDefaultSettings
98 | {
99 | if (![KKKeychain getStringForKey:@"passcode_on"]) {
100 | [KKKeychain setString:@"NO" forKey:@"passcode_on"];
101 | }
102 |
103 | if (![KKKeychain getStringForKey:@"erase_data_on"]) {
104 | [KKKeychain setString:@"NO" forKey:@"erase_data_on"];
105 | }
106 |
107 | if (![KKKeychain getStringForKey:@"failedAttemptsCount"]) {
108 | [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"];
109 | }
110 |
111 | if (![KKKeychain getStringForKey:@"incorrect_passcode_datetime"]) {
112 | [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"];
113 | }
114 | }
115 |
116 | - (void)resetSettings
117 | {
118 | [KKKeychain setString:@"NO" forKey:@"passcode_on"];
119 | [KKKeychain setString:@"NO" forKey:@"erase_data_on"];
120 | [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"];
121 | [KKKeychain setString:[self.dateFormatter stringFromDate:[NSDate dateWithTimeIntervalSince1970:0]] forKey:@"incorrect_passcode_datetime"];
122 | }
123 |
124 | - (NSString *)localizedStringForKey:(NSString *)key value:(NSString *)value
125 | {
126 | static NSBundle *bundle = nil;
127 | if (bundle == nil)
128 | {
129 | NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"KKPasscodeLock" ofType:@"bundle"];
130 | bundle = [NSBundle bundleWithPath:bundlePath] ?: [NSBundle mainBundle];
131 | }
132 |
133 | value = [bundle localizedStringForKey:key value:value table:nil];
134 | return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil];
135 | }
136 |
137 |
138 |
139 | @end
140 |
--------------------------------------------------------------------------------
/src/KKPasscodeSettingsViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 | #import "KKPasscodeViewController.h"
20 |
21 | @class KKPasscodeSettingsViewController;
22 |
23 | @protocol KKPasscodeSettingsViewControllerDelegate
24 |
25 | @optional
26 |
27 | /**
28 | * called when the passcode settings (either turned on/off) is changed
29 | */
30 | - (void)didSettingsChanged:(KKPasscodeSettingsViewController*)viewController;
31 |
32 | @end
33 |
34 | @interface KKPasscodeSettingsViewController : UITableViewController {
35 |
36 | // delegate which notified then the passcode is turned on/off
37 | id __unsafe_unretained _delegate;
38 |
39 | // the erase content switch.
40 | UISwitch* _eraseDataSwitch;
41 |
42 | // whatever the passcode lock is turned on or off
43 | BOOL _passcodeLockOn;
44 |
45 | // whatever the erase data option is turned on or off
46 | BOOL _eraseDataOn;
47 | }
48 |
49 | @property (nonatomic) Class passcodeViewControllerClass;
50 |
51 | @property (nonatomic, unsafe_unretained) id delegate;
52 | @property (nonatomic, unsafe_unretained) id passcodeViewControllerDelegate;
53 | @end
54 |
--------------------------------------------------------------------------------
/src/KKPasscodeSettingsViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "KKPasscodeSettingsViewController.h"
19 | #import "KKKeychain.h"
20 | #import "KKPasscodeViewController.h"
21 | #import "KKPasscodeLock.h"
22 |
23 |
24 | @implementation KKPasscodeSettingsViewController
25 |
26 |
27 | @synthesize delegate = _delegate;
28 |
29 | #pragma mark -
30 | #pragma mark Properties
31 |
32 | - (void)setPasscodeViewControllerClass:(Class)passcodeViewControllerClass
33 | {
34 | if ([passcodeViewControllerClass isSubclassOfClass:[KKPasscodeViewController class]]) {
35 | _passcodeViewControllerClass = passcodeViewControllerClass;
36 | }
37 | }
38 |
39 | #pragma mark -
40 | #pragma mark Initialization
41 |
42 | - (id)init
43 | {
44 | if (self = [super init]) {
45 | self.passcodeViewControllerClass = [KKPasscodeViewController class];
46 | }
47 | return self;
48 | }
49 |
50 | - (id)initWithStyle:(UITableViewStyle)style
51 | {
52 | if (self = [super initWithStyle:style]) {
53 | self.passcodeViewControllerClass = [KKPasscodeViewController class];
54 | }
55 | return self;
56 | }
57 |
58 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
59 | {
60 | if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
61 | self.passcodeViewControllerClass = [KKPasscodeViewController class];
62 | }
63 | return self;
64 | }
65 |
66 | - (id)initWithCoder:(NSCoder *)aDecoder
67 | {
68 | if (self = [super initWithCoder:aDecoder]) {
69 | self.passcodeViewControllerClass = [KKPasscodeViewController class];
70 | }
71 | return self;
72 | }
73 |
74 | #pragma mark -
75 | #pragma mark UIViewController methods
76 |
77 | - (void)viewDidLoad
78 | {
79 | [super viewDidLoad];
80 | self.navigationItem.title = KKPasscodeLockLocalizedString(@"Passcode Lock", @"");
81 |
82 | _eraseDataSwitch = [[UISwitch alloc] init];
83 | [_eraseDataSwitch addTarget:self action:@selector(eraseDataSwitchChanged:) forControlEvents:UIControlEventValueChanged];
84 | }
85 |
86 | - (void)viewDidUnload
87 | {
88 | _eraseDataSwitch = nil;
89 |
90 | [super viewDidUnload];
91 | }
92 |
93 | - (void)viewWillAppear:(BOOL)animated
94 | {
95 | [super viewWillAppear:animated];
96 |
97 | _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"];
98 | _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"];
99 | _eraseDataSwitch.on = _eraseDataOn;
100 | }
101 |
102 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
103 | {
104 | return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) || (toInterfaceOrientation == UIInterfaceOrientationPortrait);
105 | }
106 |
107 | #pragma mark -
108 | #pragma mark UIActionSheetDelegate methods
109 |
110 | - (void)actionSheet:(UIActionSheet*)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
111 | {
112 | if (buttonIndex == 0) {
113 | _eraseDataOn = YES;
114 | [KKKeychain setString:@"YES" forKey:@"erase_data_on"];
115 | } else {
116 | _eraseDataOn = NO;
117 | [KKKeychain setString:@"NO" forKey:@"erase_data_on"];
118 | }
119 | [_eraseDataSwitch setOn:_eraseDataOn animated:YES];
120 | }
121 |
122 | - (void)eraseDataSwitchChanged:(id)sender
123 | {
124 | if (_eraseDataSwitch.on) {
125 | NSString* title = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"All data in this app will be erased after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];
126 |
127 | UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:title delegate:self cancelButtonTitle:KKPasscodeLockLocalizedString(@"Cancel", @"") destructiveButtonTitle:KKPasscodeLockLocalizedString(@"Enable", @"") otherButtonTitles:nil];
128 | [sheet showInView:self.view];
129 | } else {
130 | _eraseDataOn = NO;
131 | [KKKeychain setString:@"NO" forKey:@"erase_data_on"];
132 | }
133 | }
134 |
135 | #pragma mark -
136 | #pragma mark UITableViewDataSource methods
137 |
138 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
139 | {
140 | if ([[KKPasscodeLock sharedLock] eraseOption]) {
141 | return 2;
142 | }
143 |
144 | return 1;
145 | }
146 |
147 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
148 | {
149 | if (section==0) {
150 | return 2;
151 | }
152 |
153 | return 1;
154 | }
155 |
156 | - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
157 | {
158 | if (section == 1) {
159 | return [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"Erase all content in the app after %d failed passcode attempts.", @""), [[KKPasscodeLock sharedLock] attemptsAllowed]];;
160 | } else {
161 | return @"";
162 | }
163 | }
164 |
165 | - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
166 | {
167 | static NSString *CellIdentifier = @"KKPasscodeSettingsCell";
168 |
169 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
170 | if (cell == nil) {
171 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
172 | }
173 |
174 | cell.accessoryView = nil;
175 | cell.selectionStyle = UITableViewCellSelectionStyleBlue;
176 |
177 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
178 | cell.textLabel.textAlignment = UITextAlignmentLeft;
179 | #else
180 | cell.textLabel.textAlignment = NSTextAlignmentLeft;
181 | #endif
182 |
183 | cell.textLabel.textColor = [UIColor blackColor];
184 |
185 |
186 | if (indexPath.section == 0) {
187 |
188 | if (indexPath.row == 0) {
189 |
190 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
191 | cell.textLabel.textAlignment = UITextAlignmentCenter;
192 | #else
193 | cell.textLabel.textAlignment = NSTextAlignmentCenter;
194 | #endif
195 |
196 | if (_passcodeLockOn) {
197 | cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode Off", @"");
198 | } else {
199 | cell.textLabel.text = KKPasscodeLockLocalizedString(@"Turn Passcode On", @"");
200 | }
201 | } else {
202 | cell.textLabel.text = KKPasscodeLockLocalizedString(@"Change Passcode", @"");
203 |
204 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
205 | cell.textLabel.textAlignment = UITextAlignmentCenter;
206 | #else
207 | cell.textLabel.textAlignment = NSTextAlignmentCenter;
208 | #endif
209 |
210 | if (!_passcodeLockOn) {
211 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
212 | cell.textLabel.textColor = [UIColor grayColor];
213 | }
214 |
215 | }
216 | } else if (indexPath.section == 1) {
217 | cell.textLabel.text = KKPasscodeLockLocalizedString(@"Erase Data", @"");
218 | cell.accessoryView = _eraseDataSwitch;
219 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
220 | if (_passcodeLockOn) {
221 | cell.textLabel.textColor = [UIColor blackColor];
222 | _eraseDataSwitch.enabled = YES;
223 | } else {
224 | cell.textLabel.textColor = [UIColor grayColor];
225 | _eraseDataSwitch.enabled = NO;
226 | }
227 | }
228 |
229 | return cell;
230 | }
231 |
232 | #pragma mark -
233 | #pragma mark UITableViewDelegate methods
234 |
235 | - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
236 | {
237 | if (indexPath.section == 0 && indexPath.row == 0) {
238 | KKPasscodeViewController* vc = [[self.passcodeViewControllerClass alloc] initWithNibName:nil
239 | bundle:nil];
240 | vc.delegate = self;
241 |
242 | if (_passcodeLockOn) {
243 | vc.mode = KKPasscodeModeDisabled;
244 | } else {
245 | vc.mode = KKPasscodeModeSet;
246 | }
247 |
248 | UINavigationController *nav = [[UINavigationController alloc]
249 | initWithNavigationBarClass:[self.navigationController.navigationBar class]
250 | toolbarClass:[self.navigationController.toolbar class]];
251 | nav.viewControllers = @[vc];
252 |
253 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
254 | nav.modalPresentationStyle = UIModalPresentationFormSheet;
255 | nav.navigationBar.barStyle = UIBarStyleBlack;
256 | nav.navigationBar.opaque = NO;
257 | } else {
258 | nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
259 | nav.navigationBar.translucent = self.navigationController.navigationBar.translucent;
260 | nav.navigationBar.opaque = self.navigationController.navigationBar.opaque;
261 | nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
262 | }
263 |
264 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
265 | [self.navigationController presentModalViewController:nav animated:YES];
266 | #else
267 | [self.navigationController presentViewController:nav animated:YES completion:nil];
268 | #endif
269 |
270 | } else if (indexPath.section == 0 && indexPath.row == 1 && _passcodeLockOn) {
271 | KKPasscodeViewController *vc = [[self.passcodeViewControllerClass alloc] initWithNibName:nil bundle:nil];
272 | vc.delegate = self;
273 |
274 | vc.mode = KKPasscodeModeChange;
275 |
276 | UINavigationController *nav = [[UINavigationController alloc]
277 | initWithNavigationBarClass:[self.navigationController.navigationBar class]
278 | toolbarClass:[self.navigationController.toolbar class]];
279 | nav.viewControllers = @[vc];
280 |
281 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
282 | nav.modalPresentationStyle = UIModalPresentationFormSheet;
283 | nav.navigationBar.barStyle = UIBarStyleBlack;
284 | nav.navigationBar.opaque = NO;
285 | } else {
286 | nav.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
287 | nav.navigationBar.translucent = self.navigationController.navigationBar.translucent;
288 | nav.navigationBar.opaque = self.navigationController.navigationBar.opaque;
289 | nav.navigationBar.barStyle = self.navigationController.navigationBar.barStyle;
290 | }
291 |
292 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
293 | [self.navigationController presentModalViewController:nav animated:YES];
294 | #else
295 | [self.navigationController presentViewController:nav animated:YES completion:nil];
296 | #endif
297 | }
298 |
299 | [tableView deselectRowAtIndexPath:indexPath animated:YES];
300 | }
301 |
302 | - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController
303 | {
304 | if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) {
305 | [_passcodeViewControllerDelegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:viewController];
306 | }
307 | }
308 |
309 | - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController
310 | {
311 | if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) {
312 | [_passcodeViewControllerDelegate performSelector:@selector(didPasscodeEnteredIncorrectly:) withObject:viewController];
313 | }
314 | }
315 |
316 | - (void)shouldLockApplication:(KKPasscodeViewController*)viewController
317 | {
318 | if ([_passcodeViewControllerDelegate respondsToSelector:@selector(shouldLockApplication:)]) {
319 | [_passcodeViewControllerDelegate performSelector:@selector(shouldLockApplication:) withObject:viewController];
320 | }
321 | }
322 |
323 | - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController
324 | {
325 | if ([_passcodeViewControllerDelegate respondsToSelector:@selector(shouldEraseApplicationData:)]) {
326 | [_passcodeViewControllerDelegate performSelector:@selector(shouldEraseApplicationData:) withObject:viewController];
327 | }
328 | }
329 |
330 | - (void)didSettingsChanged:(KKPasscodeViewController*)viewController
331 | {
332 | _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"];
333 | _eraseDataOn = [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"];
334 | _eraseDataSwitch.on = _eraseDataOn;
335 |
336 | [self.tableView reloadData];
337 |
338 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
339 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
340 | }
341 |
342 | if ([_passcodeViewControllerDelegate respondsToSelector:@selector(didSettingsChanged:)]) {
343 | [_passcodeViewControllerDelegate performSelector:@selector(didSettingsChanged:) withObject:viewController];
344 | }
345 | }
346 |
347 |
348 | @end
349 |
350 |
--------------------------------------------------------------------------------
/src/KKPasscodeViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 |
20 |
21 | #define kPasscodeBoxesCount 4
22 |
23 | #define kPasscodeBoxWidth 61.0
24 | #define kPasscodeBoxHeight 53.0
25 |
26 |
27 | // The mode which controls the passcode view behavior
28 | enum {
29 | /**
30 | * Displays the passcode enter view, which the user has to enter the correct passcode
31 | */
32 | KKPasscodeModeEnter = 0,
33 |
34 | /**
35 | * Creates a new passcode. This allows the user to enter a new passcode then
36 | * imediately verify it.
37 | */
38 | KKPasscodeModeSet = 1,
39 |
40 | /**
41 | * Disables an existing passcode. This allows the user to disable the passcode lock by
42 | * entering the passcode
43 | */
44 | KKPasscodeModeDisabled = 2,
45 |
46 | /**
47 | * Changes an existing passcode. This allows the user to change the passcode by
48 | * entering the existing passcode, followed by a new passcode
49 | */
50 | KKPasscodeModeChange = 3
51 | };
52 | typedef NSUInteger KKPasscodeMode;
53 |
54 |
55 | @class KKPasscodeViewController;
56 |
57 | @protocol KKPasscodeViewControllerDelegate
58 |
59 | @optional
60 |
61 | - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController;
62 | - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController;
63 | - (void)shouldLockApplication:(KKPasscodeViewController*)viewController;
64 | - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController;
65 | - (void)didSettingsChanged:(KKPasscodeViewController*)viewController;
66 |
67 | @end
68 |
69 |
70 | @interface KKPasscodeViewController : UIViewController {
71 |
72 | // delegate which called when major events happens
73 | id __unsafe_unretained _delegate;
74 |
75 | UILabel* _passcodeConfirmationWarningLabel;
76 | UIView* _failedAttemptsView;
77 | UILabel* _failedAttemptsLabel;
78 |
79 | // the current panel that being displayed
80 | NSUInteger _currentPanel;
81 |
82 | // used to transition between table views
83 | NSMutableArray* _tableViews;
84 |
85 | // array of passcode entry text fields
86 | NSMutableArray* _textFields;
87 |
88 | NSMutableArray* _boxes;
89 |
90 | UITableView* _enterPasscodeTableView;
91 | UITextField* _enterPasscodeTextField;
92 |
93 | UITableView* _setPasscodeTableView;
94 | UITextField* _setPasscodeTextField;
95 |
96 | UITableView* _confirmPasscodeTableView;
97 | UITextField* _confirmPasscodeTextField;
98 |
99 | // readwrite override for passlock mode
100 | KKPasscodeMode _mode;
101 |
102 | // whatever the passcode lock is turned on or off
103 | BOOL _passcodeLockOn;
104 |
105 | // whatever the erase data option is turned on or off
106 | BOOL _eraseData;
107 |
108 | // Used to make sure we do not release the keyboard when on iPad
109 | BOOL _shouldReleaseFirstResponser;
110 |
111 | }
112 |
113 | @property (nonatomic, unsafe_unretained) id delegate;
114 | @property (nonatomic, assign) KKPasscodeMode mode;
115 |
116 |
117 | @end
118 |
119 |
--------------------------------------------------------------------------------
/src/KKPasscodeViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "KKPasscodeViewController.h"
19 | #import "KKKeychain.h"
20 | #import "KKPasscodeSettingsViewController.h"
21 | #import "KKPasscodeLock.h"
22 |
23 | #import
24 | #import
25 |
26 | @interface KKPasscodeViewController ()
27 |
28 | @property(nonatomic,assign) BOOL isSmallLandscape;
29 | @property(nonatomic,strong) UIView *dimView;
30 |
31 | @end
32 |
33 | @interface KKPasscodeViewController (Private)
34 |
35 | - (UITextField*)passcodeTextField;
36 | - (NSArray*)boxes;
37 | - (UIView*)headerViewForTextField:(UITextField*)textField;
38 | - (void)moveToNextTableView;
39 | - (void)moveToPreviousTableView;
40 | - (void)incrementFailedAttemptsLabel;
41 |
42 | @end
43 |
44 |
45 | @implementation KKPasscodeViewController
46 |
47 | @synthesize delegate = _delegate;
48 | @synthesize mode = _mode;
49 | @synthesize isSmallLandscape;
50 |
51 | #pragma mark -
52 | #pragma mark UIViewController
53 |
54 | - (id)init
55 | {
56 | if (self = [super init]) {
57 | self.modalPresentationStyle = UIModalPresentationFormSheet;
58 | }
59 | return self;
60 | }
61 |
62 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
63 | {
64 | if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
65 | self.modalPresentationStyle = UIModalPresentationFormSheet;
66 | }
67 | return self;
68 | }
69 |
70 | - (id)initWithCoder:(NSCoder *)aDecoder
71 | {
72 | if (self = [super initWithCoder:aDecoder]) {
73 | self.modalPresentationStyle = UIModalPresentationFormSheet;
74 | }
75 | return self;
76 | }
77 |
78 | - (void)loadView
79 | {
80 | [super loadView];
81 |
82 | self.view.backgroundColor = [UIColor whiteColor];
83 |
84 | CGRect tableViewFrame = self.view.bounds;
85 | if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad && [[UIScreen mainScreen] bounds].size.height > 480) {
86 | // is running on device with 4" screen so add background tableView
87 | UITableView *backgroundTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped];
88 | [self.view addSubview:backgroundTableView];
89 |
90 | //and move other tableViews down so boxes are vertically centered
91 | tableViewFrame.origin.y += 44.0;
92 | }
93 |
94 | _enterPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped];
95 | _enterPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
96 | _enterPasscodeTableView.delegate = self;
97 | _enterPasscodeTableView.dataSource = self;
98 | _enterPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
99 | _enterPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
100 | [self.view addSubview:_enterPasscodeTableView];
101 |
102 | _setPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped];
103 | _setPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
104 | _setPasscodeTableView.delegate = self;
105 | _setPasscodeTableView.dataSource = self;
106 | _setPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
107 | _setPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
108 | [self.view addSubview:_setPasscodeTableView];
109 |
110 | _confirmPasscodeTableView = [[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStyleGrouped];
111 | _confirmPasscodeTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
112 | _confirmPasscodeTableView.delegate = self;
113 | _confirmPasscodeTableView.dataSource = self;
114 | _confirmPasscodeTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
115 | _confirmPasscodeTableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
116 | [self.view addSubview:_confirmPasscodeTableView];
117 |
118 | _shouldReleaseFirstResponser = NO;
119 |
120 | }
121 |
122 |
123 | - (void)viewWillAppear:(BOOL)animated
124 | {
125 | [super viewWillAppear:animated];
126 |
127 | _passcodeLockOn = [[KKKeychain getStringForKey:@"passcode_on"] isEqualToString:@"YES"];
128 | _eraseData = [[KKPasscodeLock sharedLock] eraseOption] && [[KKKeychain getStringForKey:@"erase_data_on"] isEqualToString:@"YES"];
129 |
130 | _enterPasscodeTextField = [[UITextField alloc] init];
131 | _enterPasscodeTextField.delegate = self;
132 | _enterPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad;
133 | _enterPasscodeTextField.hidden = YES;
134 |
135 | _setPasscodeTextField = [[UITextField alloc] init];
136 | _setPasscodeTextField.delegate = self;
137 | _setPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad;
138 | _setPasscodeTextField.hidden = YES;
139 |
140 | _confirmPasscodeTextField = [[UITextField alloc] init];
141 | _confirmPasscodeTextField.delegate = self;
142 | _confirmPasscodeTextField.keyboardType = UIKeyboardTypeNumberPad;
143 | _confirmPasscodeTextField.hidden = YES;
144 |
145 | _tableViews = [[NSMutableArray alloc] init];
146 | _textFields = [[NSMutableArray alloc] init];
147 | _boxes = [[NSMutableArray alloc] init];
148 |
149 | // Need to make sure everything is visible in landscape mode on small devices.
150 | self.isSmallLandscape = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && UIInterfaceOrientationIsLandscape(self.interfaceOrientation));
151 |
152 | if (_mode == KKPasscodeModeSet) {
153 | self.navigationItem.title = KKPasscodeLockLocalizedString(@"Set Passcode", @"");
154 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
155 | target:self
156 | action:@selector(cancelButtonPressed:)];
157 | } else if (_mode == KKPasscodeModeChange) {
158 | self.navigationItem.title = KKPasscodeLockLocalizedString(@"Change Passcode", @"");
159 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
160 | target:self
161 | action:@selector(cancelButtonPressed:)];
162 |
163 | } else if (_mode == KKPasscodeModeDisabled) {
164 | self.navigationItem.title = KKPasscodeLockLocalizedString(@"Turn off Passcode", @"");
165 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
166 | target:self
167 | action:@selector(cancelButtonPressed:)];
168 |
169 | } else {
170 | self.navigationItem.title = KKPasscodeLockLocalizedString(@"Enter Passcode", @"");
171 | }
172 |
173 | CGFloat totalBoxesWidth = (71.0 * kPasscodeBoxesCount) - 10.0;
174 |
175 | if (_mode == KKPasscodeModeSet || _mode == KKPasscodeModeChange) {
176 | if (_passcodeLockOn) {
177 | _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField];
178 | [_tableViews addObject:_enterPasscodeTableView];
179 | [_textFields addObject:_enterPasscodeTextField];
180 | [_boxes addObject:[self boxes]];
181 | UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)];
182 | boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
183 | for (int i = 0; i < [[_boxes lastObject] count]; i++) {
184 | [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]];
185 | }
186 | [_enterPasscodeTableView.tableHeaderView addSubview:boxesView];
187 | }
188 |
189 | _setPasscodeTableView.tableHeaderView = [self headerViewForTextField:_setPasscodeTextField];
190 |
191 | [_tableViews addObject:_setPasscodeTableView];
192 | [_textFields addObject:_setPasscodeTextField];
193 | [_boxes addObject:[self boxes]];
194 | UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)];
195 | boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
196 | for (int i = 0; i < [[_boxes lastObject] count]; i++) {
197 | [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]];
198 | }
199 | [_setPasscodeTableView.tableHeaderView addSubview:boxesView];
200 |
201 | _confirmPasscodeTableView.tableHeaderView = [self headerViewForTextField:_confirmPasscodeTextField];
202 | [_tableViews addObject:_confirmPasscodeTableView];
203 | [_textFields addObject:_confirmPasscodeTextField];
204 | [_boxes addObject:[self boxes]];
205 | UIView *boxesConfirmView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)];
206 | boxesConfirmView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
207 | for (int i = 0; i < [[_boxes lastObject] count]; i++) {
208 | [boxesConfirmView addSubview:[[_boxes lastObject] objectAtIndex:i]];
209 | }
210 | [_confirmPasscodeTableView.tableHeaderView addSubview:boxesConfirmView];
211 | } else {
212 | _enterPasscodeTableView.tableHeaderView = [self headerViewForTextField:_enterPasscodeTextField];
213 | [_tableViews addObject:_enterPasscodeTableView];
214 | [_textFields addObject:_enterPasscodeTextField];
215 | [_boxes addObject:[self boxes]];
216 | UIView *boxesView = [[UIView alloc] initWithFrame:CGRectMake((self.view.bounds.size.width - totalBoxesWidth) * 0.5, 0, totalBoxesWidth, kPasscodeBoxHeight)];
217 | boxesView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
218 | for (int i = 0; i < [[_boxes lastObject] count]; i++) {
219 | [boxesView addSubview:[[_boxes lastObject] objectAtIndex:i]];
220 | }
221 | [_enterPasscodeTableView.tableHeaderView addSubview:boxesView];
222 | }
223 |
224 | [self.view addSubview:[_tableViews objectAtIndex:0]];
225 |
226 | for (int i = 1; i < [_tableViews count]; i++) {
227 | UITableView *tableView = [_tableViews objectAtIndex:i];
228 | tableView.frame = CGRectMake(tableView.frame.origin.x + self.view.bounds.size.width,
229 | tableView.frame.origin.y,
230 | tableView.frame.size.width,
231 | tableView.frame.size.height);
232 | [self.view addSubview:tableView];
233 | }
234 |
235 | [[_textFields objectAtIndex:0] becomeFirstResponder];
236 | [[_tableViews objectAtIndex:0] reloadData];
237 | [[_textFields objectAtIndex:[_tableViews count] - 1] setReturnKeyType:UIReturnKeyDone];
238 |
239 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
240 | if ([_tableViews count] > 1) {
241 | [self moveToNextTableView];
242 | [self moveToPreviousTableView];
243 | } else {
244 | UITableView *tableView = [_tableViews objectAtIndex:0];
245 | tableView.frame = CGRectMake(tableView.frame.origin.x,
246 | tableView.frame.origin.y,
247 | self.view.bounds.size.width,
248 | self.view.bounds.size.height);
249 | }
250 |
251 | if (!self.dimView) {
252 | id appDelegate = [[UIApplication sharedApplication] delegate];
253 | self.dimView = [[UIView alloc] initWithFrame:appDelegate.window.rootViewController.view.bounds];
254 | self.dimView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
255 | self.dimView.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
256 | self.dimView.alpha = 0.0f;
257 | [appDelegate.window.rootViewController.view addSubview:self.dimView];
258 | [UIView animateWithDuration:0.3f animations:^{
259 | self.dimView.alpha = 1.0f;
260 | }];
261 | }
262 | }
263 | }
264 |
265 |
266 | - (void)viewWillDisappear:(BOOL)animated {
267 | [super viewWillDisappear:animated];
268 |
269 | _shouldReleaseFirstResponser = YES;
270 | [_enterPasscodeTextField resignFirstResponder];
271 | [_setPasscodeTextField resignFirstResponder];
272 | [_confirmPasscodeTextField resignFirstResponder];
273 |
274 | if (self.dimView) {
275 | [UIView animateWithDuration:0.3f
276 | animations:^{
277 | self.dimView.alpha = 0.0f;
278 | }
279 | completion:^(BOOL finished) {
280 | [self.dimView removeFromSuperview];
281 | self.dimView = nil;
282 | }];
283 | }
284 | }
285 |
286 |
287 | #pragma mark -
288 | #pragma mark Private methods
289 |
290 |
291 | - (void)cancelButtonPressed:(id)sender
292 | {
293 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
294 | [self dismissModalViewControllerAnimated:YES];
295 | #else
296 | [self dismissViewControllerAnimated:YES completion:nil];
297 | #endif
298 | }
299 |
300 |
301 | - (void)incrementFailedAttemptsLabel
302 | {
303 | AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
304 |
305 | _enterPasscodeTextField.text = @"";
306 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
307 | [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]];
308 | }
309 |
310 | NSInteger _failedAttemptsCount = [[KKKeychain getStringForKey:@"failedAttemptsCount"] integerValue];
311 |
312 | _failedAttemptsCount++;
313 |
314 | [KKKeychain setString:[NSString stringWithFormat:@"%d", _failedAttemptsCount] forKey:@"failedAttemptsCount"];
315 |
316 | if (_failedAttemptsCount == 1) {
317 | _failedAttemptsLabel.text = KKPasscodeLockLocalizedString(@"1 Failed Passcode Attempt", @"");
318 | } else {
319 | _failedAttemptsLabel.text = [NSString stringWithFormat:KKPasscodeLockLocalizedString(@"%i Failed Passcode Attempts", @""), _failedAttemptsCount];
320 | }
321 | CGSize size = [_failedAttemptsLabel.text sizeWithFont:[UIFont boldSystemFontOfSize:self.isSmallLandscape ? 10.0f : 14.0f]];
322 | _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));
323 |
324 | CAGradientLayer *gradient = [CAGradientLayer layer];
325 | gradient.frame = _failedAttemptsView.bounds;
326 | gradient.colors = [NSArray arrayWithObjects:
327 | (id)[[UIColor colorWithRed:0.7 green:0.05 blue:0.05 alpha:1.0] CGColor],
328 | (id)[[UIColor colorWithRed:0.8 green:0.2 blue:0.2 alpha:1.0] CGColor], nil];
329 | [_failedAttemptsView.layer insertSublayer:gradient atIndex:0];
330 | _failedAttemptsView.layer.masksToBounds = YES;
331 |
332 | _failedAttemptsLabel.hidden = NO;
333 | _failedAttemptsView.hidden = NO;
334 |
335 | if (_failedAttemptsCount == [[KKPasscodeLock sharedLock] attemptsAllowed]) {
336 |
337 | _enterPasscodeTextField.delegate = nil;
338 |
339 | if (_eraseData) {
340 | if ([_delegate respondsToSelector:@selector(shouldEraseApplicationData:)]) {
341 | [_delegate shouldEraseApplicationData:self];
342 | }
343 | } else {
344 | if ([_delegate respondsToSelector:@selector(didPasscodeEnteredIncorrectly:)]) {
345 | [_delegate didPasscodeEnteredIncorrectly:self];
346 | }
347 |
348 | [KKKeychain setString:[[KKPasscodeLock sharedLock].dateFormatter stringFromDate:[NSDate date]] forKey:@"incorrect_passcode_datetime"];
349 |
350 | if ([_delegate respondsToSelector:@selector(shouldLockApplication:)]) {
351 | [_delegate shouldLockApplication:self];
352 | }
353 | }
354 |
355 | [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"];
356 | }
357 |
358 | }
359 |
360 | - (void)moveToNextTableView
361 | {
362 | _currentPanel += 1;
363 |
364 | UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel - 1];
365 | UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel];
366 |
367 | newTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width,
368 | oldTableView.frame.origin.y,
369 | oldTableView.frame.size.width,
370 | oldTableView.frame.size.height);
371 |
372 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
373 | [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]];
374 | }
375 |
376 | [UIView beginAnimations:@"" context:nil];
377 | [UIView setAnimationDuration:0.25];
378 | oldTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height);
379 | newTableView.frame = self.view.frame;
380 | [UIView commitAnimations];
381 |
382 | _shouldReleaseFirstResponser = YES;
383 | [[_textFields objectAtIndex:_currentPanel - 1] resignFirstResponder];
384 | _shouldReleaseFirstResponser = NO;
385 | [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder];
386 | }
387 |
388 |
389 | - (void)moveToPreviousTableView
390 | {
391 | _currentPanel -= 1;
392 |
393 | UITableView *oldTableView = [_tableViews objectAtIndex:_currentPanel + 1];
394 | UITableView *newTableView = [_tableViews objectAtIndex:_currentPanel];
395 | newTableView.frame = CGRectMake(oldTableView.frame.origin.x - self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height);
396 |
397 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
398 | [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]];
399 | }
400 |
401 | [UIView beginAnimations:@"" context:nil];
402 | [UIView setAnimationDuration:0.25];
403 | oldTableView.frame = CGRectMake(oldTableView.frame.origin.x + self.view.bounds.size.width, oldTableView.frame.origin.y, oldTableView.frame.size.width, oldTableView.frame.size.height);
404 | newTableView.frame = self.view.frame;
405 | [UIView commitAnimations];
406 |
407 | _shouldReleaseFirstResponser = YES;
408 | [[_textFields objectAtIndex:_currentPanel + 1] resignFirstResponder];
409 | _shouldReleaseFirstResponser = NO;
410 | [[_textFields objectAtIndex:_currentPanel] becomeFirstResponder];
411 | }
412 |
413 |
414 | - (void)nextDigitPressed
415 | {
416 | UITextField* textField = [_textFields objectAtIndex:_currentPanel];
417 |
418 | if (![textField.text isEqualToString:@""]) {
419 |
420 | if (_mode == KKPasscodeModeSet) {
421 | if ([textField isEqual:_setPasscodeTextField]) {
422 | [self moveToNextTableView];
423 | } else if ([textField isEqual:_confirmPasscodeTextField]) {
424 | if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) {
425 | _confirmPasscodeTextField.text = @"";
426 | _setPasscodeTextField.text = @"";
427 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @"");
428 | [self moveToPreviousTableView];
429 | } else {
430 | if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) {
431 | [KKKeychain setString:@"YES" forKey:@"passcode_on"];
432 | }
433 |
434 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
435 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
436 | }
437 |
438 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
439 | [self dismissModalViewControllerAnimated:YES];
440 | #else
441 | [self dismissViewControllerAnimated:YES completion:nil];
442 | #endif
443 | }
444 | }
445 | } else if (_mode == KKPasscodeModeChange) {
446 | NSString* passcode = [KKKeychain getStringForKey:@"passcode"];
447 | if ([textField isEqual:_enterPasscodeTextField]) {
448 | if ([passcode isEqualToString:_enterPasscodeTextField.text]) {
449 | [self moveToNextTableView];
450 | } else {
451 | [self incrementFailedAttemptsLabel];
452 | }
453 | } else if ([textField isEqual:_setPasscodeTextField]) {
454 | if ([passcode isEqualToString:_setPasscodeTextField.text]) {
455 | _setPasscodeTextField.text = @"";
456 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @"");
457 | _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0);
458 | } else {
459 | _passcodeConfirmationWarningLabel.text = @"";
460 | _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0);
461 | [self moveToNextTableView];
462 | }
463 | } else if ([textField isEqual:_confirmPasscodeTextField]) {
464 | if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) {
465 | _confirmPasscodeTextField.text = @"";
466 | _setPasscodeTextField.text = @"";
467 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", "");
468 | [self moveToPreviousTableView];
469 | } else {
470 | if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) {
471 | [KKKeychain setString:@"YES" forKey:@"passcode_on"];
472 | }
473 |
474 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
475 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
476 | }
477 |
478 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
479 | [self dismissModalViewControllerAnimated:YES];
480 | #else
481 | [self dismissViewControllerAnimated:YES completion:nil];
482 | #endif
483 | }
484 | }
485 | }
486 | }
487 | }
488 |
489 | - (void)vaildatePasscode:(UITextField*)textField
490 | {
491 | if (_mode == KKPasscodeModeDisabled) {
492 | NSString *passcode = [KKKeychain getStringForKey:@"passcode"];
493 | if ([_enterPasscodeTextField.text isEqualToString:passcode]) {
494 | if ([KKKeychain setString:@"NO" forKey:@"passcode_on"]) {
495 | [KKKeychain setString:@"" forKey:@"passcode"];
496 | }
497 |
498 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
499 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
500 | }
501 |
502 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
503 | [self dismissModalViewControllerAnimated:YES];
504 | #else
505 | [self dismissViewControllerAnimated:YES completion:nil];
506 | #endif
507 | } else {
508 | [self incrementFailedAttemptsLabel];
509 | }
510 | } else if (_mode == KKPasscodeModeEnter) {
511 | NSString *passcode = [KKKeychain getStringForKey:@"passcode"];
512 | if ([_enterPasscodeTextField.text isEqualToString:passcode]) {
513 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
514 | [UIView beginAnimations:@"fadeIn" context:nil];
515 | [UIView setAnimationDelay:0.25];
516 | [UIView setAnimationDuration:0.5];
517 |
518 | [UIView commitAnimations];
519 | }
520 | if ([_delegate respondsToSelector:@selector(didPasscodeEnteredCorrectly:)]) {
521 | [_delegate performSelector:@selector(didPasscodeEnteredCorrectly:) withObject:self];
522 | }
523 |
524 | [KKKeychain setString:@"0" forKey:@"failedAttemptsCount"];
525 |
526 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
527 | [self dismissModalViewControllerAnimated:YES];
528 | #else
529 | [self dismissViewControllerAnimated:YES completion:nil];
530 | #endif
531 | } else {
532 | [self incrementFailedAttemptsLabel];
533 | }
534 | } else if (_mode == KKPasscodeModeChange) {
535 | NSString *passcode = [KKKeychain getStringForKey:@"passcode"];
536 | if ([textField isEqual:_enterPasscodeTextField]) {
537 | if ([passcode isEqualToString:_enterPasscodeTextField.text]) {
538 | [self moveToNextTableView];
539 | } else {
540 | [self incrementFailedAttemptsLabel];
541 | }
542 | } else if ([textField isEqual:_setPasscodeTextField]) {
543 | if ([passcode isEqualToString:_setPasscodeTextField.text]) {
544 | _setPasscodeTextField.text = @"";
545 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
546 | [[[_boxes objectAtIndex:_currentPanel] objectAtIndex:i] setImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]];
547 | }
548 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Enter a different passcode. You cannot re-use the same passcode.", @"");
549 | _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 132.0, self.view.bounds.size.width, 60.0);
550 | } else {
551 | _passcodeConfirmationWarningLabel.text = @"";
552 | _passcodeConfirmationWarningLabel.frame = CGRectMake(0.0, 146.0, self.view.bounds.size.width, 30.0);
553 | [self moveToNextTableView];
554 | }
555 | } else if ([textField isEqual:_confirmPasscodeTextField]) {
556 | if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) {
557 | _confirmPasscodeTextField.text = @"";
558 | _setPasscodeTextField.text = @"";
559 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @"");
560 | [self moveToPreviousTableView];
561 | } else {
562 | if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) {
563 | [KKKeychain setString:@"YES" forKey:@"passcode_on"];
564 | }
565 |
566 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
567 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
568 | }
569 |
570 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
571 | [self dismissModalViewControllerAnimated:YES];
572 | #else
573 | [self dismissViewControllerAnimated:YES completion:nil];
574 | #endif
575 | }
576 | }
577 | } else if ([textField isEqual:_setPasscodeTextField]) {
578 | [self moveToNextTableView];
579 | } else if ([textField isEqual:_confirmPasscodeTextField]) {
580 | if (![_confirmPasscodeTextField.text isEqualToString:_setPasscodeTextField.text]) {
581 | _confirmPasscodeTextField.text = @"";
582 | _setPasscodeTextField.text = @"";
583 | _passcodeConfirmationWarningLabel.text = KKPasscodeLockLocalizedString(@"Passcodes did not match. Try again.", @"");
584 | [self moveToPreviousTableView];
585 | } else {
586 | if ([KKKeychain setString:_setPasscodeTextField.text forKey:@"passcode"]) {
587 | [KKKeychain setString:@"YES" forKey:@"passcode_on"];
588 | }
589 |
590 | if ([_delegate respondsToSelector:@selector(didSettingsChanged:)]) {
591 | [_delegate performSelector:@selector(didSettingsChanged:) withObject:self];
592 | }
593 |
594 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
595 | [self dismissModalViewControllerAnimated:YES];
596 | #else
597 | [self dismissViewControllerAnimated:YES completion:nil];
598 | #endif
599 | }
600 | }
601 | }
602 |
603 |
604 | - (void)doneButtonPressed
605 | {
606 | UITextField *textField = [_textFields objectAtIndex:_currentPanel];
607 | [self vaildatePasscode:textField];
608 | }
609 |
610 |
611 | - (UIView*)headerViewForTextField:(UITextField*)textField
612 | {
613 | [self.view addSubview:textField];
614 | UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, 70.0)];
615 | UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 2.0f : 28.0f, self.view.bounds.size.width, 30.0)];
616 | headerLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0];
617 | headerLabel.backgroundColor = [UIColor clearColor];
618 |
619 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
620 | headerLabel.textAlignment = UITextAlignmentCenter;
621 | #else
622 | headerLabel.textAlignment = NSTextAlignmentCenter;
623 | #endif
624 |
625 | headerLabel.font = [UIFont boldSystemFontOfSize:self.isSmallLandscape ? 12.0f : 17.0f];
626 | headerLabel.shadowOffset = CGSizeMake(0, 1.0);
627 | headerLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
628 |
629 | if ([textField isEqual:_setPasscodeTextField]) {
630 | _passcodeConfirmationWarningLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, self.isSmallLandscape ? 73.0f : 146.0, self.view.bounds.size.width, 30.0)];
631 | _passcodeConfirmationWarningLabel.textColor = [UIColor colorWithRed:0.3 green:0.3 blue:0.4 alpha:1.0];
632 | _passcodeConfirmationWarningLabel.backgroundColor = [UIColor clearColor];
633 |
634 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
635 | _passcodeConfirmationWarningLabel.textAlignment = UITextAlignmentCenter;
636 | #else
637 | _passcodeConfirmationWarningLabel.textAlignment = NSTextAlignmentCenter;
638 | #endif
639 |
640 | _passcodeConfirmationWarningLabel.font = [UIFont systemFontOfSize:14.0];
641 | _passcodeConfirmationWarningLabel.shadowOffset = CGSizeMake(0, 1.0);
642 | _passcodeConfirmationWarningLabel.shadowColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
643 | _passcodeConfirmationWarningLabel.text = @"";
644 | _passcodeConfirmationWarningLabel.numberOfLines = 0;
645 |
646 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
647 | _passcodeConfirmationWarningLabel.lineBreakMode = UILineBreakModeWordWrap;
648 | #else
649 | _passcodeConfirmationWarningLabel.lineBreakMode = NSLineBreakByWordWrapping;
650 | #endif
651 |
652 | [headerView addSubview:_passcodeConfirmationWarningLabel];
653 | }
654 |
655 | if ([textField isEqual:_enterPasscodeTextField]) {
656 | _failedAttemptsView = [[UIView alloc] init];
657 | _failedAttemptsLabel = [[UILabel alloc] init];
658 | _failedAttemptsLabel.backgroundColor = [UIColor clearColor];
659 | _failedAttemptsLabel.textColor = [UIColor whiteColor];
660 | _failedAttemptsLabel.text = @"";
661 | _failedAttemptsLabel.font = [UIFont boldSystemFontOfSize:self.isSmallLandscape ? 10.0f : 14.0f];
662 |
663 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < 60000
664 | _failedAttemptsLabel.textAlignment = UITextAlignmentCenter;
665 | #else
666 | _failedAttemptsLabel.textAlignment = NSTextAlignmentCenter;
667 | #endif
668 |
669 | _failedAttemptsLabel.shadowOffset = CGSizeMake(0, -1.0);
670 | _failedAttemptsLabel.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0];
671 | _failedAttemptsView.layer.cornerRadius = self.isSmallLandscape ? 7.0f : 14.0f;
672 | _failedAttemptsView.layer.borderWidth = 1.0;
673 | _failedAttemptsView.layer.borderColor = [[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.25] CGColor];
674 |
675 | _failedAttemptsLabel.hidden = YES;
676 | _failedAttemptsView.hidden = YES;
677 |
678 | _failedAttemptsView.layer.masksToBounds = YES;
679 |
680 | [headerView addSubview:_failedAttemptsView];
681 | [headerView addSubview:_failedAttemptsLabel];
682 | }
683 |
684 | if (_mode == KKPasscodeModeSet) {
685 | if ([textField isEqual:_enterPasscodeTextField]) {
686 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @"");
687 | } else if ([textField isEqual:_setPasscodeTextField]) {
688 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter a passcode", @"");
689 | } else if ([textField isEqual:_confirmPasscodeTextField]) {
690 | headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your passcode", @"");
691 | }
692 | } else if (_mode == KKPasscodeModeDisabled) {
693 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @"");
694 | } else if (_mode == KKPasscodeModeChange) {
695 | if ([textField isEqual:_enterPasscodeTextField]) {
696 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your old passcode", @"");
697 | } else if ([textField isEqual:_setPasscodeTextField]) {
698 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your new passcode", @"");
699 | } else {
700 | headerLabel.text = KKPasscodeLockLocalizedString(@"Re-enter your new passcode", @"");
701 | }
702 | } else {
703 | headerLabel.text = KKPasscodeLockLocalizedString(@"Enter your passcode", @"");
704 | }
705 |
706 | headerLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
707 | [headerView addSubview:headerLabel];
708 |
709 | return headerView;
710 | }
711 |
712 |
713 | - (NSArray*)boxes
714 | {
715 | NSMutableArray* squareViews = [NSMutableArray array];
716 |
717 | CGFloat squareX = self.isSmallLandscape ? 60.0f : 0.0f;
718 |
719 | CGFloat width = self.isSmallLandscape ? kPasscodeBoxWidth * 0.6f : kPasscodeBoxWidth;
720 | CGFloat height = self.isSmallLandscape ? kPasscodeBoxHeight * 0.6f : kPasscodeBoxHeight;
721 |
722 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
723 | UIImageView *square = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"]];
724 | square.frame = CGRectMake(squareX, self.isSmallLandscape ? 32.0f : 74.0, width, height);
725 | [squareViews addObject:square];
726 | squareX += self.isSmallLandscape ? 42.0f : 71.0;
727 | }
728 | return [NSArray arrayWithArray:squareViews];
729 | }
730 |
731 | #pragma mark -
732 | #pragma mark UITableViewDataSource methods
733 |
734 | - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
735 | {
736 | return 0;
737 | }
738 |
739 |
740 | - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
741 | {
742 | return 1;
743 | }
744 |
745 |
746 | - (UITableViewCell*)tableView:(UITableView*)aTableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
747 | {
748 | static NSString* CellIdentifier = @"KKPasscodeViewControllerCell";
749 |
750 | UITableViewCell* cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
751 | if (cell == nil) {
752 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
753 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
754 | }
755 |
756 | if ([aTableView isEqual:_enterPasscodeTableView]) {
757 | cell.accessoryView = _enterPasscodeTextField;
758 | } else if ([aTableView isEqual:_setPasscodeTableView]) {
759 | cell.accessoryView = _setPasscodeTextField;
760 | } else if ([aTableView isEqual:_confirmPasscodeTableView]) {
761 | cell.accessoryView = _confirmPasscodeTextField;
762 | }
763 |
764 | return cell;
765 | }
766 |
767 |
768 | #pragma mark -
769 | #pragma mark UITextFieldDelegate methods
770 |
771 | - (BOOL)textFieldShouldReturn:(UITextField*)textField
772 | {
773 | if ([textField isEqual:[_textFields lastObject]]) {
774 | [self doneButtonPressed];
775 | } else {
776 | [self nextDigitPressed];
777 | }
778 | return NO;
779 | }
780 |
781 |
782 |
783 |
784 |
785 | - (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string
786 | {
787 | NSString *result = [textField.text stringByReplacingCharactersInRange:range withString:string];
788 | textField.text = result;
789 |
790 | for (int i = 0; i < kPasscodeBoxesCount; i++) {
791 | UIImageView *square = [[_boxes objectAtIndex:_currentPanel] objectAtIndex:i];
792 | if (i < [result length]) {
793 | square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_filled.png"];
794 | } else {
795 | square.image = [UIImage imageNamed:@"KKPasscodeLock.bundle/box_empty.png"];
796 | }
797 | }
798 |
799 | if ([result length] == kPasscodeBoxesCount) {
800 | [self vaildatePasscode:textField];
801 | }
802 |
803 | return NO;
804 | }
805 |
806 |
807 |
808 | - (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
809 | return _shouldReleaseFirstResponser;
810 | }
811 |
812 | #pragma mark -
813 | #pragma mark Memory management
814 |
815 | @end
816 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLock/KKPasscodeLock-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'KKPasscodeLock' target in the 'KKPasscodeLock' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLockTests.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 5303097416611E650004810F /* KKPasscodeSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */; };
11 | 5303097516611E650004810F /* KKPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096A16611E650004810F /* KKPasscodeViewController.m */; };
12 | 5303097716611E650004810F /* KKPasscodeLock.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5303096D16611E650004810F /* KKPasscodeLock.bundle */; };
13 | 5303097816611E650004810F /* KKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303096F16611E650004810F /* KKKeychain.m */; };
14 | 5303097916611E650004810F /* KKPasscodeLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 5303097016611E650004810F /* KKPasscodeLock.m */; };
15 | 6D2394C81548CA89004DF3B7 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */; };
16 | 6D2394CA1548CA89004DF3B7 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394C91548CA89004DF3B7 /* UIKit.framework */; };
17 | 6D2394CB1548CA89004DF3B7 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394B91548CA89004DF3B7 /* Foundation.framework */; };
18 | 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */; };
19 | 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */; };
20 | 6D2394F81548CBAA004DF3B7 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */; };
21 | 6D2394F91548CBAA004DF3B7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */; };
22 | 6D2394FB1548CBAE004DF3B7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394FA1548CBAE004DF3B7 /* Security.framework */; };
23 | 6D2394FD1548CBC5004DF3B7 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */; };
24 | /* End PBXBuildFile section */
25 |
26 | /* Begin PBXFileReference section */
27 | 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeSettingsViewController.m; path = ../../src/KKPasscodeSettingsViewController.m; sourceTree = ""; };
28 | 5303096A16611E650004810F /* KKPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeViewController.m; path = ../../src/KKPasscodeViewController.m; sourceTree = ""; };
29 | 5303096D16611E650004810F /* KKPasscodeLock.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKPasscodeLock.bundle; path = ../../src/KKPasscodeLock.bundle; sourceTree = ""; };
30 | 5303096E16611E650004810F /* KKPasscodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeViewController.h; path = ../../src/KKPasscodeViewController.h; sourceTree = ""; };
31 | 5303096F16611E650004810F /* KKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKKeychain.m; path = ../../src/KKKeychain.m; sourceTree = ""; };
32 | 5303097016611E650004810F /* KKPasscodeLock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KKPasscodeLock.m; path = ../../src/KKPasscodeLock.m; sourceTree = ""; };
33 | 5303097116611E650004810F /* KKPasscodeLock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeLock.h; path = ../../src/KKPasscodeLock.h; sourceTree = ""; };
34 | 5303097216611E650004810F /* KKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKKeychain.h; path = ../../src/KKKeychain.h; sourceTree = ""; };
35 | 5303097316611E650004810F /* KKPasscodeSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KKPasscodeSettingsViewController.h; path = ../../src/KKPasscodeSettingsViewController.h; sourceTree = ""; };
36 | 6D2394B91548CA89004DF3B7 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
37 | 6D2394BD1548CA89004DF3B7 /* KKPasscodeLock-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KKPasscodeLock-Prefix.pch"; sourceTree = ""; };
38 | 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KKPasscodeLock.octest; sourceTree = BUILT_PRODUCTS_DIR; };
39 | 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
40 | 6D2394C91548CA89004DF3B7 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
41 | 6D2394D11548CA89004DF3B7 /* KKPasscodeLock-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "KKPasscodeLock-Info.plist"; sourceTree = ""; };
42 | 6D2394D31548CA89004DF3B7 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
43 | 6D2394D51548CA89004DF3B7 /* KKPasscodeLockTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KKPasscodeLockTests.h; sourceTree = ""; };
44 | 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KKPasscodeLockTests.m; sourceTree = ""; };
45 | 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
46 | 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
47 | 6D2394FA1548CBAE004DF3B7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
48 | 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
49 | /* End PBXFileReference section */
50 |
51 | /* Begin PBXFrameworksBuildPhase section */
52 | 6D2394C21548CA89004DF3B7 /* Frameworks */ = {
53 | isa = PBXFrameworksBuildPhase;
54 | buildActionMask = 2147483647;
55 | files = (
56 | 6D2394FD1548CBC5004DF3B7 /* QuartzCore.framework in Frameworks */,
57 | 6D2394FB1548CBAE004DF3B7 /* Security.framework in Frameworks */,
58 | 6D2394F81548CBAA004DF3B7 /* AudioToolbox.framework in Frameworks */,
59 | 6D2394F91548CBAA004DF3B7 /* CoreGraphics.framework in Frameworks */,
60 | 6D2394C81548CA89004DF3B7 /* SenTestingKit.framework in Frameworks */,
61 | 6D2394CA1548CA89004DF3B7 /* UIKit.framework in Frameworks */,
62 | 6D2394CB1548CA89004DF3B7 /* Foundation.framework in Frameworks */,
63 | );
64 | runOnlyForDeploymentPostprocessing = 0;
65 | };
66 | /* End PBXFrameworksBuildPhase section */
67 |
68 | /* Begin PBXGroup section */
69 | 6D2394AB1548CA89004DF3B7 = {
70 | isa = PBXGroup;
71 | children = (
72 | 6D2394BB1548CA89004DF3B7 /* KKPasscodeLock */,
73 | 6D2394CF1548CA89004DF3B7 /* KKPasscodeLockTests */,
74 | 6D2394B81548CA89004DF3B7 /* Frameworks */,
75 | 6D2394B71548CA89004DF3B7 /* Products */,
76 | );
77 | sourceTree = "";
78 | };
79 | 6D2394B71548CA89004DF3B7 /* Products */ = {
80 | isa = PBXGroup;
81 | children = (
82 | 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */,
83 | );
84 | name = Products;
85 | sourceTree = "";
86 | };
87 | 6D2394B81548CA89004DF3B7 /* Frameworks */ = {
88 | isa = PBXGroup;
89 | children = (
90 | 6D2394FC1548CBC5004DF3B7 /* QuartzCore.framework */,
91 | 6D2394FA1548CBAE004DF3B7 /* Security.framework */,
92 | 6D2394F61548CBAA004DF3B7 /* AudioToolbox.framework */,
93 | 6D2394F71548CBAA004DF3B7 /* CoreGraphics.framework */,
94 | 6D2394B91548CA89004DF3B7 /* Foundation.framework */,
95 | 6D2394C71548CA89004DF3B7 /* SenTestingKit.framework */,
96 | 6D2394C91548CA89004DF3B7 /* UIKit.framework */,
97 | );
98 | name = Frameworks;
99 | sourceTree = "";
100 | };
101 | 6D2394BB1548CA89004DF3B7 /* KKPasscodeLock */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 5303096916611E650004810F /* KKPasscodeSettingsViewController.m */,
105 | 5303096A16611E650004810F /* KKPasscodeViewController.m */,
106 | 5303096D16611E650004810F /* KKPasscodeLock.bundle */,
107 | 5303096E16611E650004810F /* KKPasscodeViewController.h */,
108 | 5303096F16611E650004810F /* KKKeychain.m */,
109 | 5303097116611E650004810F /* KKPasscodeLock.h */,
110 | 5303097016611E650004810F /* KKPasscodeLock.m */,
111 | 5303097216611E650004810F /* KKKeychain.h */,
112 | 5303097316611E650004810F /* KKPasscodeSettingsViewController.h */,
113 | 6D2394BC1548CA89004DF3B7 /* Supporting Files */,
114 | );
115 | path = KKPasscodeLock;
116 | sourceTree = "";
117 | };
118 | 6D2394BC1548CA89004DF3B7 /* Supporting Files */ = {
119 | isa = PBXGroup;
120 | children = (
121 | 6D2394BD1548CA89004DF3B7 /* KKPasscodeLock-Prefix.pch */,
122 | );
123 | name = "Supporting Files";
124 | sourceTree = "";
125 | };
126 | 6D2394CF1548CA89004DF3B7 /* KKPasscodeLockTests */ = {
127 | isa = PBXGroup;
128 | children = (
129 | 6D2394D51548CA89004DF3B7 /* KKPasscodeLockTests.h */,
130 | 6D2394D61548CA89004DF3B7 /* KKPasscodeLockTests.m */,
131 | 6D2394D01548CA89004DF3B7 /* Supporting Files */,
132 | );
133 | path = KKPasscodeLockTests;
134 | sourceTree = "";
135 | };
136 | 6D2394D01548CA89004DF3B7 /* Supporting Files */ = {
137 | isa = PBXGroup;
138 | children = (
139 | 6D2394D11548CA89004DF3B7 /* KKPasscodeLock-Info.plist */,
140 | 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */,
141 | );
142 | name = "Supporting Files";
143 | sourceTree = "";
144 | };
145 | /* End PBXGroup section */
146 |
147 | /* Begin PBXNativeTarget section */
148 | 6D2394C51548CA89004DF3B7 /* KKPasscodeLockTests */ = {
149 | isa = PBXNativeTarget;
150 | buildConfigurationList = 6D2394DD1548CA89004DF3B7 /* Build configuration list for PBXNativeTarget "KKPasscodeLockTests" */;
151 | buildPhases = (
152 | 6D2394C11548CA89004DF3B7 /* Sources */,
153 | 6D2394C21548CA89004DF3B7 /* Frameworks */,
154 | 6D2394C31548CA89004DF3B7 /* Resources */,
155 | 6D2394C41548CA89004DF3B7 /* ShellScript */,
156 | );
157 | buildRules = (
158 | );
159 | dependencies = (
160 | );
161 | name = KKPasscodeLockTests;
162 | productName = KKPasscodeLockTests;
163 | productReference = 6D2394C61548CA89004DF3B7 /* KKPasscodeLock.octest */;
164 | productType = "com.apple.product-type.bundle";
165 | };
166 | /* End PBXNativeTarget section */
167 |
168 | /* Begin PBXProject section */
169 | 6D2394AD1548CA89004DF3B7 /* Project object */ = {
170 | isa = PBXProject;
171 | attributes = {
172 | LastUpgradeCheck = 0430;
173 | ORGANIZATIONNAME = "Kosher Penguin LLC";
174 | };
175 | buildConfigurationList = 6D2394B01548CA89004DF3B7 /* Build configuration list for PBXProject "KKPasscodeLockTests" */;
176 | compatibilityVersion = "Xcode 3.2";
177 | developmentRegion = English;
178 | hasScannedForEncodings = 0;
179 | knownRegions = (
180 | en,
181 | );
182 | mainGroup = 6D2394AB1548CA89004DF3B7;
183 | productRefGroup = 6D2394B71548CA89004DF3B7 /* Products */;
184 | projectDirPath = "";
185 | projectRoot = "";
186 | targets = (
187 | 6D2394C51548CA89004DF3B7 /* KKPasscodeLockTests */,
188 | );
189 | };
190 | /* End PBXProject section */
191 |
192 | /* Begin PBXResourcesBuildPhase section */
193 | 6D2394C31548CA89004DF3B7 /* Resources */ = {
194 | isa = PBXResourcesBuildPhase;
195 | buildActionMask = 2147483647;
196 | files = (
197 | 6D2394D41548CA89004DF3B7 /* InfoPlist.strings in Resources */,
198 | 5303097716611E650004810F /* KKPasscodeLock.bundle in Resources */,
199 | );
200 | runOnlyForDeploymentPostprocessing = 0;
201 | };
202 | /* End PBXResourcesBuildPhase section */
203 |
204 | /* Begin PBXShellScriptBuildPhase section */
205 | 6D2394C41548CA89004DF3B7 /* ShellScript */ = {
206 | isa = PBXShellScriptBuildPhase;
207 | buildActionMask = 2147483647;
208 | files = (
209 | );
210 | inputPaths = (
211 | );
212 | outputPaths = (
213 | );
214 | runOnlyForDeploymentPostprocessing = 0;
215 | shellPath = /bin/sh;
216 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n";
217 | };
218 | /* End PBXShellScriptBuildPhase section */
219 |
220 | /* Begin PBXSourcesBuildPhase section */
221 | 6D2394C11548CA89004DF3B7 /* Sources */ = {
222 | isa = PBXSourcesBuildPhase;
223 | buildActionMask = 2147483647;
224 | files = (
225 | 6D2394D71548CA89004DF3B7 /* KKPasscodeLockTests.m in Sources */,
226 | 5303097416611E650004810F /* KKPasscodeSettingsViewController.m in Sources */,
227 | 5303097516611E650004810F /* KKPasscodeViewController.m in Sources */,
228 | 5303097816611E650004810F /* KKKeychain.m in Sources */,
229 | 5303097916611E650004810F /* KKPasscodeLock.m in Sources */,
230 | );
231 | runOnlyForDeploymentPostprocessing = 0;
232 | };
233 | /* End PBXSourcesBuildPhase section */
234 |
235 | /* Begin PBXVariantGroup section */
236 | 6D2394D21548CA89004DF3B7 /* InfoPlist.strings */ = {
237 | isa = PBXVariantGroup;
238 | children = (
239 | 6D2394D31548CA89004DF3B7 /* en */,
240 | );
241 | name = InfoPlist.strings;
242 | sourceTree = "";
243 | };
244 | /* End PBXVariantGroup section */
245 |
246 | /* Begin XCBuildConfiguration section */
247 | 6D2394D81548CA89004DF3B7 /* Debug */ = {
248 | isa = XCBuildConfiguration;
249 | buildSettings = {
250 | ALWAYS_SEARCH_USER_PATHS = NO;
251 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
252 | COPY_PHASE_STRIP = NO;
253 | GCC_C_LANGUAGE_STANDARD = gnu99;
254 | GCC_DYNAMIC_NO_PIC = NO;
255 | GCC_OPTIMIZATION_LEVEL = 0;
256 | GCC_PREPROCESSOR_DEFINITIONS = (
257 | "DEBUG=1",
258 | "$(inherited)",
259 | );
260 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
261 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
262 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
263 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
264 | GCC_WARN_UNUSED_VARIABLE = YES;
265 | IPHONEOS_DEPLOYMENT_TARGET = 5.1;
266 | SDKROOT = iphoneos;
267 | };
268 | name = Debug;
269 | };
270 | 6D2394D91548CA89004DF3B7 /* Release */ = {
271 | isa = XCBuildConfiguration;
272 | buildSettings = {
273 | ALWAYS_SEARCH_USER_PATHS = NO;
274 | ARCHS = "$(ARCHS_STANDARD_32_BIT)";
275 | COPY_PHASE_STRIP = YES;
276 | GCC_C_LANGUAGE_STANDARD = gnu99;
277 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
278 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
279 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
280 | GCC_WARN_UNUSED_VARIABLE = YES;
281 | IPHONEOS_DEPLOYMENT_TARGET = 5.1;
282 | SDKROOT = iphoneos;
283 | VALIDATE_PRODUCT = YES;
284 | };
285 | name = Release;
286 | };
287 | 6D2394DE1548CA89004DF3B7 /* Debug */ = {
288 | isa = XCBuildConfiguration;
289 | buildSettings = {
290 | CLANG_ENABLE_OBJC_ARC = YES;
291 | FRAMEWORK_SEARCH_PATHS = (
292 | "$(SDKROOT)/Developer/Library/Frameworks",
293 | "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
294 | );
295 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
296 | GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch";
297 | INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist";
298 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
299 | PRODUCT_NAME = KKPasscodeLock;
300 | WRAPPER_EXTENSION = octest;
301 | };
302 | name = Debug;
303 | };
304 | 6D2394DF1548CA89004DF3B7 /* Release */ = {
305 | isa = XCBuildConfiguration;
306 | buildSettings = {
307 | CLANG_ENABLE_OBJC_ARC = YES;
308 | FRAMEWORK_SEARCH_PATHS = (
309 | "$(SDKROOT)/Developer/Library/Frameworks",
310 | "$(DEVELOPER_LIBRARY_DIR)/Frameworks",
311 | );
312 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
313 | GCC_PREFIX_HEADER = "KKPasscodeLock/KKPasscodeLock-Prefix.pch";
314 | INFOPLIST_FILE = "KKPasscodeLockTests/KKPasscodeLock-Info.plist";
315 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
316 | PRODUCT_NAME = KKPasscodeLock;
317 | WRAPPER_EXTENSION = octest;
318 | };
319 | name = Release;
320 | };
321 | /* End XCBuildConfiguration section */
322 |
323 | /* Begin XCConfigurationList section */
324 | 6D2394B01548CA89004DF3B7 /* Build configuration list for PBXProject "KKPasscodeLockTests" */ = {
325 | isa = XCConfigurationList;
326 | buildConfigurations = (
327 | 6D2394D81548CA89004DF3B7 /* Debug */,
328 | 6D2394D91548CA89004DF3B7 /* Release */,
329 | );
330 | defaultConfigurationIsVisible = 0;
331 | defaultConfigurationName = Release;
332 | };
333 | 6D2394DD1548CA89004DF3B7 /* Build configuration list for PBXNativeTarget "KKPasscodeLockTests" */ = {
334 | isa = XCConfigurationList;
335 | buildConfigurations = (
336 | 6D2394DE1548CA89004DF3B7 /* Debug */,
337 | 6D2394DF1548CA89004DF3B7 /* Release */,
338 | );
339 | defaultConfigurationIsVisible = 0;
340 | defaultConfigurationName = Release;
341 | };
342 | /* End XCConfigurationList section */
343 | };
344 | rootObject = 6D2394AD1548CA89004DF3B7 /* Project object */;
345 | }
346 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLockTests/KKPasscodeLock-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | ${EXECUTABLE_NAME}
9 | CFBundleIdentifier
10 | com.kosherpenguin.${PRODUCT_NAME:rfc1034identifier}
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundlePackageType
14 | BNDL
15 | CFBundleShortVersionString
16 | 1.0
17 | CFBundleSignature
18 | ????
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLockTests/KKPasscodeLockTests.h:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import
19 |
20 | @interface KKPasscodeLockTests : SenTestCase
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLockTests/KKPasscodeLockTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright 2011-2012 Kosher Penguin LLC
3 | // Created by Adar Porat (https://github.com/aporat) on 1/16/2012.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the "License");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | //
9 | // http://www.apache.org/licenses/LICENSE-2.0
10 | //
11 | // Unless required by applicable law or agreed to in writing, software
12 | // distributed under the License is distributed on an "AS IS" BASIS,
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | // See the License for the specific language governing permissions and
15 | // limitations under the License.
16 | //
17 |
18 | #import "KKPasscodeLockTests.h"
19 | #import "KKPasscodeLock.h"
20 |
21 | @implementation KKPasscodeLockTests
22 |
23 | - (void)setUp
24 | {
25 | [super setUp];
26 |
27 | // Set-up code here.
28 | }
29 |
30 | - (void)tearDown
31 | {
32 | // Tear-down code here.
33 |
34 | [super tearDown];
35 | }
36 |
37 | - (void)testDefaultSettings
38 | {
39 | KKPasscodeLock* sharedLock = [KKPasscodeLock sharedLock];
40 |
41 | STAssertEquals(sharedLock.eraseOption, YES, @"Erase option is default to YES");
42 | STAssertEquals(sharedLock.attemptsAllowed, (NSUInteger)5, @"attemptsAllowed default to 5 tries");
43 |
44 |
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/tests/KKPasscodeLockTests/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------