Commit 6ec312e5 authored by Felix Paul Kühne's avatar Felix Paul Kühne

expand passcode validator to serve as a way to set the code

parent d8337552
......@@ -11,6 +11,9 @@
@interface VLCPasscodeLockViewController : UIViewController
{
NSString *_passcode;
NSString *_tmpPasscode;
NSUInteger _resetStage;
}
@property (nonatomic, strong) IBOutlet UILabel *enterPasscodeLabel;
......
......@@ -30,6 +30,8 @@
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_passcode = [defaults objectForKey:@"Passcode"];
self.enterPasscodeLabel.text = NSLocalizedString(@"ENTER_PASSCODE", @"");
[self.navigationController setNavigationBarHidden:YES animated:NO];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
......@@ -48,8 +50,24 @@
- (IBAction)textFieldValueChanged:(id)sender
{
if (self.enterCodeField.text.length == 4) {
if ([self.enterCodeField.text isEqualToString:_passcode]) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
if (_resetStage == 1) {
_tmpPasscode = self.enterCodeField.text;
self.enterCodeField.text = @"";
self.enterPasscodeLabel.text = NSLocalizedString(@"REENTER_PASSCODE", @"");
_resetStage = 2;
} else if (_resetStage == 2) {
if ([self.enterCodeField.text isEqualToString:_tmpPasscode]) {
NSUserDefaults *defaults;
[defaults setObject:@1 forKey:@"PasscodeProtection"];
[defaults setObject:_tmpPasscode forKey:@"Passcode"];
_passcode = _tmpPasscode;
_resetStage = 0;
appDelegate.playlistViewController.nextPasscodeCheckDate = [NSDate dateWithTimeIntervalSinceNow:300]; // five min
appDelegate.playlistViewController.passcodeValidated = YES;
[self.view removeFromSuperview];
}
} else if ([self.enterCodeField.text isEqualToString:_passcode]) {
appDelegate.playlistViewController.nextPasscodeCheckDate = [NSDate dateWithTimeIntervalSinceNow:300]; // five min
appDelegate.playlistViewController.passcodeValidated = YES;
[self.navigationController popViewControllerAnimated:YES];
......@@ -59,7 +77,7 @@
- (void)resetPasscode
{
_resetStage = 1;
}
@end
......@@ -52,6 +52,8 @@
self.emptyLibraryLongDescriptionLabel.numberOfLines = 0;
self.emptyLibraryLongDescriptionLabel.text = NSLocalizedString(@"EMPTY_LIBRARY_LONG", @"");
[self.emptyLibraryLongDescriptionLabel sizeToFit];
self.passcodeLockViewController = [[VLCPasscodeLockViewController alloc] initWithNibName:@"VLCPasscodeLockViewController" bundle:nil];
}
- (void)viewWillAppear:(BOOL)animated
......@@ -117,9 +119,6 @@
return;
}
if (!self.passcodeLockViewController)
self.passcodeLockViewController = [[VLCPasscodeLockViewController alloc] initWithNibName:@"VLCPasscodeLockViewController" bundle:nil];
if (!self.passcodeValidated) {
if ([self.nextPasscodeCheckDate earlierDate:[NSDate date]] == self.nextPasscodeCheckDate)
[self.navigationController pushViewController:self.passcodeLockViewController animated:YES];
......
......@@ -39,6 +39,7 @@
{
if (self.passcodeLockSwitch.on) {
VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[self.view addSubview:appDelegate.playlistViewController.passcodeLockViewController.view];
[appDelegate.playlistViewController.passcodeLockViewController resetPasscode];
} else
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:@"PasscodeProtection"];
......
......@@ -161,6 +161,14 @@
</object>
<int key="connectionID">32</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">enterPasscodeLabel</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="186196614"/>
</object>
<int key="connectionID">36</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">textFieldValueChanged:</string>
......@@ -258,7 +266,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">35</int>
<int key="maxID">36</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
......
B"CHOOSE_AUDIO_TRACK"="Audiospur wählen";
......
B"CHOOSE_AUDIO_TRACK"="Choose Audio Track";
......
B"CHOOSE_AUDIO_TRACK"="Choisir Piste Audio";
......
B"CHOOSE_AUDIO_TRACK"="Выберите аудио поток";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment