Przeglądaj źródła

Modified passcode lock behavior (close #10630)

If the app enters background state during playback, it is stopped if lock is activated
Felix Paul Kühne 11 lat temu
rodzic
commit
4ce6bf012c
1 zmienionych plików z 14 dodań i 12 usunięć
  1. 14 12
      Sources/VLCAppDelegate.m

+ 14 - 12
Sources/VLCAppDelegate.m

@@ -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