Commit 75cdbce9 authored by Tobias's avatar Tobias

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
parent 7fca7170
......@@ -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];
......
......@@ -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;
......
......@@ -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];
}
......
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