KKPasscodeViewController.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #import <UIKit/UIKit.h>
  18. #define kPasscodeBoxesCount 4
  19. #define kPasscodeBoxWidth 61.0
  20. #define kPasscodeBoxHeight 53.0
  21. // The mode which controls the passcode view behavior
  22. enum {
  23. /**
  24. * Displays the passcode enter view, which the user has to enter the correct passcode
  25. */
  26. KKPasscodeModeEnter = 0,
  27. /**
  28. * Creates a new passcode. This allows the user to enter a new passcode then
  29. * imediately verify it.
  30. */
  31. KKPasscodeModeSet = 1,
  32. /**
  33. * Disables an existing passcode. This allows the user to disable the passcode lock by
  34. * entering the passcode
  35. */
  36. KKPasscodeModeDisabled = 2,
  37. /**
  38. * Changes an existing passcode. This allows the user to change the passcode by
  39. * entering the existing passcode, followed by a new passcode
  40. */
  41. KKPasscodeModeChange = 3
  42. };
  43. typedef NSUInteger KKPasscodeMode;
  44. @class KKPasscodeViewController;
  45. @protocol KKPasscodeViewControllerDelegate <NSObject>
  46. @optional
  47. - (void)didPasscodeEnteredCorrectly:(KKPasscodeViewController*)viewController;
  48. - (void)didPasscodeEnteredIncorrectly:(KKPasscodeViewController*)viewController;
  49. - (void)shouldEraseApplicationData:(KKPasscodeViewController*)viewController;
  50. - (void)didSettingsChanged:(KKPasscodeViewController*)viewController;
  51. - (void)didPasscodeViewDismiss:(KKPasscodeViewController*)viewController;
  52. @end
  53. @interface KKPasscodeViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate> {
  54. // delegate which called when major events happens
  55. id<KKPasscodeViewControllerDelegate> __unsafe_unretained _delegate;
  56. UILabel* _passcodeConfirmationWarningLabel;
  57. UIView* _failedAttemptsView;
  58. UILabel* _failedAttemptsLabel;
  59. // failed attements coutner
  60. NSInteger _failedAttemptsCount;
  61. // the current panel that being displayed
  62. NSUInteger _currentPanel;
  63. // used to transition between table views
  64. NSMutableArray* _tableViews;
  65. // array of passcode entry text fields
  66. NSMutableArray* _textFields;
  67. NSMutableArray* _boxes;
  68. UITableView* _enterPasscodeTableView;
  69. UITextField* _enterPasscodeTextField;
  70. UITableView* _setPasscodeTableView;
  71. UITextField* _setPasscodeTextField;
  72. UITableView* _confirmPasscodeTableView;
  73. UITextField* _confirmPasscodeTextField;
  74. // readwrite override for passlock mode
  75. KKPasscodeMode _mode;
  76. // whatever the passcode lock is turned on or off
  77. BOOL _passcodeLockOn;
  78. // whatever the erase data option is turned on or off
  79. BOOL _eraseData;
  80. // Used to make sure we do not release the keyboard when on iPad
  81. BOOL _shouldReleaseFirstResponser;
  82. }
  83. @property (nonatomic, unsafe_unretained) id <KKPasscodeViewControllerDelegate> delegate;
  84. @property (nonatomic, assign) KKPasscodeMode mode;
  85. @end