VLCSettingsController.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*****************************************************************************
  2. * VLCSettingsController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. * Gleb Pinigin <gpinigin # gmail.com>
  10. * Carola Nitz <nitz.carola # googlemail.com>
  11. *
  12. * Refer to the COPYING file of the official project for license.
  13. *****************************************************************************/
  14. #import "VLCSettingsController.h"
  15. #import "VLCLibraryViewController.h"
  16. #import "IASKSettingsReader.h"
  17. #import "IASKAppSettingsViewController.h"
  18. #import "PAPasscodeViewController.h"
  19. #import "VLCKeychainCoordinator.h"
  20. @interface VLCSettingsController ()<PAPasscodeViewControllerDelegate, IASKSettingsDelegate>
  21. @end
  22. @implementation VLCSettingsController
  23. - (id)init
  24. {
  25. self = [super init];
  26. if (self)
  27. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(settingDidChange:) name:kIASKAppSettingChanged object:nil];
  28. return self;
  29. }
  30. - (void)dealloc
  31. {
  32. [[NSNotificationCenter defaultCenter] removeObserver:self];
  33. }
  34. - (void)settingDidChange:(NSNotification*)notification
  35. {
  36. if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
  37. BOOL passcodeOn = [[notification.userInfo objectForKey:kVLCSettingPasscodeOnKey] boolValue];
  38. if (passcodeOn) {
  39. PAPasscodeViewController *passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
  40. passcodeLockController.delegate = self;
  41. [self.viewController presentViewController:passcodeLockController animated:YES completion:nil];
  42. } else {
  43. [[VLCKeychainCoordinator defaultCoordinator] setPasscode:nil];
  44. }
  45. }
  46. if ([notification.object isEqual:kVLCSettingPlaybackGestures]) {
  47. BOOL enabled = (BOOL)[[notification.userInfo objectForKey:@"EnableGesturesToControlPlayback"] intValue];
  48. [self.viewController setHiddenKeys:enabled ? nil : [NSSet setWithObjects:@"EnableVariableJumpDuration", nil] animated:YES];
  49. }
  50. }
  51. - (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender
  52. {
  53. [[VLCSidebarController sharedInstance] toggleSidebar];
  54. }
  55. #pragma mark - PAPasscode delegate
  56. - (void)PAPasscodeViewControllerDidCancel:(PAPasscodeViewController *)controller
  57. {
  58. [[VLCKeychainCoordinator defaultCoordinator] setPasscode:nil];
  59. [controller dismissViewControllerAnimated:YES completion:nil];
  60. }
  61. - (void)PAPasscodeViewControllerDidSetPasscode:(PAPasscodeViewController *)controller
  62. {
  63. [[VLCKeychainCoordinator defaultCoordinator] setPasscode:controller.passcode];
  64. [controller dismissViewControllerAnimated:YES completion:nil];
  65. }
  66. @end