Browse Source

fix regression introduced in 2.4.x: we displayed the library contents on launch while the it was still unlocked

Felix Paul Kühne 10 years ago
parent
commit
802882579f
3 changed files with 21 additions and 8 deletions
  1. 3 2
      Sources/VLCAppDelegate.h
  2. 13 6
      Sources/VLCAppDelegate.m
  3. 5 0
      Sources/VLCPlaylistViewController.m

+ 3 - 2
Sources/VLCAppDelegate.h

@@ -2,7 +2,7 @@
  * VLCAppDelegate.h
  * VLC for iOS
  *****************************************************************************
- * Copyright (c) 2013-2014 VideoLAN. All rights reserved.
+ * Copyright (c) 2013-2015 VideoLAN. All rights reserved.
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne # videolan.org>
@@ -13,6 +13,7 @@
  *
  * Refer to the COPYING file of the official project for license.
  *****************************************************************************/
+
 #import "VLCDropboxTableViewController.h"
 #import "VLCHTTPUploaderController.h"
 #import "GHRevealViewController.h"
@@ -20,7 +21,6 @@
 #import "VLCDownloadViewController.h"
 
 @class VLCPlaylistViewController;
-@class PAPasscodeViewController;
 @interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
 
 - (void)updateMediaList;
@@ -48,5 +48,6 @@
 @property (nonatomic, strong) VLCMenuTableViewController *menuViewController;
 
 @property (nonatomic) VLCHTTPUploaderController *uploadController;
+@property (nonatomic, readonly) BOOL passcodeValidated;
 
 @end

+ 13 - 6
Sources/VLCAppDelegate.m

@@ -95,10 +95,8 @@
 
     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
     // enable crash preventer
-     void (^setupBlock)() = ^ {
-        [[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
-
-        _playlistViewController = [[VLCPlaylistViewController alloc] init];
+     void (^setupBlock)() = ^{
+         _playlistViewController = [[VLCPlaylistViewController alloc] init];
         UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:_playlistViewController];
         [navCon loadTheme];
 
@@ -113,11 +111,13 @@
         _revealController.contentViewController.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
         [self.window makeKeyAndVisible];
 
+        [self validatePasscode];
+
+        [[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
+
         VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance];
         [discoverer addObserver:self];
         [discoverer startDiscovering:[self directoryPath]];
-
-        [self validatePasscode];
     };
 
     NSError *error = nil;
@@ -466,6 +466,11 @@
 
 #pragma mark - pass code validation
 
+- (BOOL)passcodeValidated
+{
+    return _passcodeValidated;
+}
+
 - (void)validatePasscode
 {
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
@@ -491,6 +496,8 @@
 
 - (void)PAPasscodeViewControllerDidEnterPasscode:(PAPasscodeViewController *)controller
 {
+    _passcodeValidated = YES;
+    [self.playlistViewController updateViewContents];
     [self.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
 }
 

+ 5 - 0
Sources/VLCPlaylistViewController.m

@@ -454,6 +454,11 @@ static NSString *kDisplayedFirstSteps = @"Did we display the first steps tutoria
 {
     _foundMedia = [[NSMutableArray alloc] init];
 
+    if (![(VLCAppDelegate *)[UIApplication sharedApplication].delegate passcodeValidated]) {
+        APLog(@"library is locked, won't show contents");
+        return;
+    }
+
     self.navigationItem.leftBarButtonItem = _menuButton;
     if (_libraryMode == VLCLibraryModeAllAlbums)
         self.title = NSLocalizedString(@"LIBRARY_MUSIC", nil);