Skip to content
This repository was archived by the owner on Apr 11, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions ABPadLockScreen/ABPadLockScreenAbstractViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,63 @@ - (void)setUpButtonMapping
}
}

- (BOOL)canBecomeFirstResponder
{
return YES;
}

- (void)handleNumberButton:(UIKeyCommand *)command
{
NSInteger key = [command.input integerValue];
for (UIButton *button in [lockScreenView buttonArray])
{
if (button.tag == key)
{
[UIView animateWithDuration:.2 delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
[button touchesBegan:[NSSet setWithArray:@[]] withEvent:nil];
} completion:^(BOOL finished) {
[button touchesEnded:[NSSet setWithArray:@[]] withEvent:nil];
}];
[self buttonSelected:button];
break;
}
}

}

- (void)handleOkButton:(UIKeyCommand *)command
{
[self okButtonSelected:lockScreenView.okButton];
}

- (void)handleCancelButton:(UIKeyCommand *)command
{
if (!lockScreenView.cancelButtonDisabled) {
[self cancelButtonSelected:lockScreenView.cancelButton];
}
}

- (void)handleDeleteButton:(UIKeyCommand *)command
{
[self deleteFromPin];
}

- (NSArray<UIKeyCommand *> * __nullable)keyCommands
{
UIKeyCommand *delete = [UIKeyCommand keyCommandWithInput:@"\b" modifierFlags:0 action:@selector(handleDeleteButton:)];
UIKeyCommand *cancel = [UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:0 action:@selector(handleCancelButton:)];
NSMutableArray *commands = [@[delete, cancel] mutableCopy];
if (self.isComplexPin)
{
[commands addObject:[UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(handleOkButton:)]];
}
for (UIButton *button in [lockScreenView buttonArray])
{
[commands addObject:[UIKeyCommand keyCommandWithInput:[NSString stringWithFormat:@"%ld", button.tag] modifierFlags:0 action:@selector(handleNumberButton:)]];
}
return commands;
}

- (void)cancelButtonDisabled:(BOOL)disabled
{
lockScreenView.cancelButtonDisabled = disabled;
Expand Down Expand Up @@ -278,4 +335,8 @@ - (void)okButtonSelected:(UIButton *)sender
[self processPin];
}

- (void)cancelButtonSelected:(UIButton *)sender
{
}

@end