VLCSettingsViewController.m 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // VLCSettingsViewController.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 19.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. #import "VLCSettingsViewController.h"
  9. #import "VLCPlaylistViewController.h"
  10. #import "VLCPasscodeLockViewController.h"
  11. #import "VLCAppDelegate.h"
  12. @implementation VLCSettingsViewController
  13. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  14. {
  15. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  16. return self;
  17. }
  18. - (void)viewDidLoad
  19. {
  20. [super viewDidLoad];
  21. self.dismissButton.title = NSLocalizedString(@"BUTTON_DONE", @"");
  22. self.passcodeLockLabel.text = NSLocalizedString(@"PREF_PASSCODE", @"");
  23. }
  24. - (void)viewWillAppear:(BOOL)animated
  25. {
  26. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  27. self.passcodeLockSwitch.on = [[defaults objectForKey:@"PasscodeProtection"] intValue];
  28. [super viewWillAppear:animated];
  29. }
  30. - (IBAction)togglePasscodeLockSetting:(id)sender
  31. {
  32. if (self.passcodeLockSwitch.on) {
  33. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  34. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  35. CGRect frame = self.view.frame;
  36. frame.size.height -= 44.;
  37. appDelegate.playlistViewController.passcodeLockViewController.view.frame = frame;
  38. }
  39. [self.view addSubview:appDelegate.playlistViewController.passcodeLockViewController.view];
  40. [appDelegate.playlistViewController.passcodeLockViewController resetPasscode];
  41. } else {
  42. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  43. [defaults setObject:@0 forKey:@"PasscodeProtection"];
  44. [defaults synchronize];
  45. }
  46. }
  47. - (IBAction)dismiss:(id)sender
  48. {
  49. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  50. [appDelegate.playlistViewController.navigationController dismissModalViewControllerAnimated:YES];
  51. }
  52. @end