Commit 4ce6bf01 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

Modified passcode lock behavior (close #10630)

If the app enters background state during playback, it is stopped if lock is activated
parent fc485ae9
......@@ -34,10 +34,9 @@
VLCDownloadViewController *_downloadViewController;
int _idleCounter;
VLCMovieViewController *_movieViewController;
BOOL _passcodeValidated;
}
@property (nonatomic) BOOL passcodeValidated;
@end
@implementation VLCAppDelegate
......@@ -153,26 +152,24 @@
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
[self validatePasscode];
}
- (void)applicationWillResignActive:(UIApplication *)application
{
self.passcodeValidated = NO;
_passcodeValidated = NO;
[self validatePasscode];
[[MLMediaLibrary sharedMediaLibrary] applicationWillExit];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
[self validatePasscode];
[[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
[self updateMediaList];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
self.passcodeValidated = NO;
_passcodeValidated = NO;
[[NSUserDefaults standardUserDefaults] synchronize];
}
......@@ -272,27 +269,32 @@
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *passcode = [defaults objectForKey:kVLCSettingPasscodeKey];
if ([passcode isEqualToString:@""] || ![[defaults objectForKey:kVLCSettingPasscodeOnKey] boolValue]) {
self.passcodeValidated = YES;
_passcodeValidated = YES;
return;
}
if (!self.passcodeValidated) {
if (!_passcodeValidated) {
_passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionEnter];
_passcodeLockController.delegate = self;
_passcodeLockController.passcode = passcode;
self.window.rootViewController = _passcodeLockController;
if (self.window.rootViewController.presentedViewController)
[self.window.rootViewController dismissViewControllerAnimated:NO completion:nil];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_passcodeLockController];
navCon.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window.rootViewController presentViewController:navCon animated:NO completion:nil];
}
}
- (void)PAPasscodeViewControllerDidEnterPasscode:(PAPasscodeViewController *)controller
{
// TODO add transition animation, i.e. fade
self.window.rootViewController = self.revealController;
[self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
}
- (void)PAPasscodeViewController:(PAPasscodeViewController *)controller didFailToEnterPasscode:(NSInteger)attempts
{
// TODO handle error attempts
// FIXME: handle countless failed passcode attempts
}
#pragma mark - idle timer preventer
......
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