1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /*****************************************************************************
- * VLCSettingsController.m
- * VLC for iOS
- *****************************************************************************
- * Copyright (c) 2013 VideoLAN. All rights reserved.
- * $Id$
- *
- * Authors: Felix Paul Kühne <fkuehne # videolan.org>
- * Gleb Pinigin <gpinigin # gmail.com>
- * Carola Nitz <nitz.carola # googlemail.com>
- *
- * Refer to the COPYING file of the official project for license.
- *****************************************************************************/
- #import "VLCSettingsController.h"
- #import "VLCLibraryViewController.h"
- #import "IASKSettingsReader.h"
- #import "IASKAppSettingsViewController.h"
- #import "PAPasscodeViewController.h"
- #import "VLCKeychainCoordinator.h"
- @interface VLCSettingsController ()<PAPasscodeViewControllerDelegate, IASKSettingsDelegate>
- @end
- @implementation VLCSettingsController
- - (id)init
- {
- self = [super init];
- if (self)
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(settingDidChange:) name:kIASKAppSettingChanged object:nil];
- return self;
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)settingDidChange:(NSNotification*)notification
- {
- if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
- BOOL passcodeOn = [[notification.userInfo objectForKey:kVLCSettingPasscodeOnKey] boolValue];
- if (passcodeOn) {
- PAPasscodeViewController *passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
- passcodeLockController.delegate = self;
- [self.viewController presentViewController:passcodeLockController animated:YES completion:nil];
- } else {
- [[VLCKeychainCoordinator defaultCoordinator] setPasscode:nil];
- [self didChangePasscodeStatus:NO];
- }
- }
- if ([notification.object isEqual:kVLCSettingPlaybackGestures]) {
- BOOL enabled = (BOOL)[[notification.userInfo objectForKey:@"EnableGesturesToControlPlayback"] intValue];
- [self.viewController setHiddenKeys:enabled ? nil : [NSSet setWithObjects:@"EnableVariableJumpDuration", nil] animated:YES];
- }
- }
- - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender
- {
- [[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];
- }
- - (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller
- {
- [[VLCKeychainCoordinator defaultCoordinator] setPasscode:controller.passcode];
- [self didChangePasscodeStatus:YES];
- [controller dismissViewControllerAnimated:YES completion:nil];
- }
- @end
|