ソースを参照

Enable and disable spotlight indexing in regard to the passcode configuration.
When a passcode is setup, indexing is disabled and the spotlight index is deleted.
fixes #15535

Tobias Conradi 9 年 前
コミット
75cdbce9c7

+ 2 - 0
Sources/VLCAppDelegate.m

@@ -133,6 +133,8 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
 
         [self validatePasscode];
 
+        BOOL spotlightEnabled = ![[VLCKeychainCoordinator defaultCoordinator] passcodeLockEnabled];
+        [[MLMediaLibrary sharedMediaLibrary] setSpotlightIndexingEnabled:spotlightEnabled];
         [[MLMediaLibrary sharedMediaLibrary] applicationWillStart];
 
         VLCMediaFileDiscoverer *discoverer = [VLCMediaFileDiscoverer sharedInstance];

+ 2 - 1
Sources/VLCLibraryViewController.m

@@ -27,6 +27,7 @@
 #import "VLCOpenInActivity.h"
 #import "VLCNavigationController.h"
 #import "VLCPlaybackController+MediaLibrary.h"
+#import "VLCKeychainCoordinator.h"
 
 #import <AssetsLibrary/AssetsLibrary.h>
 #import <CoreSpotlight/CoreSpotlight.h>
@@ -308,7 +309,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 
 - (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject
 {
-    if ([CSSearchableItemAttributeSet class] != nil && [(VLCAppDelegate *)[UIApplication sharedApplication].delegate passcodeValidated]) {
+    if ([CSSearchableItemAttributeSet class] != nil && ![[VLCKeychainCoordinator defaultCoordinator] passcodeLockEnabled]) {
         self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying];
 
         MLFile *file = nil;

+ 15 - 0
Sources/VLCSettingsController.m

@@ -50,6 +50,7 @@
             [self.viewController presentViewController:passcodeLockController animated:YES completion:nil];
         } else {
             [[VLCKeychainCoordinator defaultCoordinator] setPasscode:nil];
+            [self didChangePasscodeStatus:NO];
         }
     }
     if ([notification.object isEqual:kVLCSettingPlaybackGestures]) {
@@ -63,11 +64,24 @@
     [[VLCSidebarController sharedInstance] toggleSidebar];
 }
 
+
+- (void)didChangePasscodeStatus:(BOOL)passcodeEnabled {
+    BOOL spotlightEnabled = !passcodeEnabled;
+    [[MLMediaLibrary sharedMediaLibrary] setSpotlightIndexingEnabled:spotlightEnabled];
+    if (!spotlightEnabled) {
+        // delete whole index for VLC
+        [[CSSearchableIndex defaultSearchableIndex] deleteAllSearchableItemsWithCompletionHandler:nil];
+    } else {
+        [[MLMediaLibrary sharedMediaLibrary] ]
+    }
+}
+
 #pragma mark - PAPasscode delegate
 
 - (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller
 {
     [[VLCKeychainCoordinator defaultCoordinator] setPasscode:nil];
+    [self didChangePasscodeStatus:NO];
 
     [controller dismissViewControllerAnimated:YES completion:nil];
 }
@@ -75,6 +89,7 @@
 - (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller
 {
     [[VLCKeychainCoordinator defaultCoordinator] setPasscode:controller.passcode];
+    [self didChangePasscodeStatus:YES];
 
     [controller dismissViewControllerAnimated:YES completion:nil];
 }