VLCPasscodeLockViewController.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // VLCPasscodeLockViewController.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 18.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. #import "VLCPasscodeLockViewController.h"
  9. #import "VLCAppDelegate.h"
  10. #import "VLCPlaylistViewController.h"
  11. @implementation VLCPasscodeLockViewController
  12. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  13. {
  14. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  15. return self;
  16. }
  17. - (void)viewDidLoad
  18. {
  19. [super viewDidLoad];
  20. self.enterCodeField.secureTextEntry = YES;
  21. }
  22. - (void)viewWillAppear:(BOOL)animated
  23. {
  24. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
  25. _passcode = [defaults objectForKey:@"Passcode"];
  26. [self.navigationController setNavigationBarHidden:YES animated:NO];
  27. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  28. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
  29. self.enterCodeField.text = @"";
  30. [self.enterCodeField becomeFirstResponder];
  31. [super viewWillAppear:animated];
  32. }
  33. - (void)viewWillDisappear:(BOOL)animated
  34. {
  35. [self.navigationController setNavigationBarHidden:NO animated:YES];
  36. [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
  37. [super viewWillDisappear:animated];
  38. }
  39. - (IBAction)textFieldValueChanged:(id)sender
  40. {
  41. if (self.enterCodeField.text.length == 4) {
  42. if ([self.enterCodeField.text isEqualToString:_passcode]) {
  43. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  44. appDelegate.playlistViewController.nextPasscodeCheckDate = [NSDate dateWithTimeIntervalSinceNow:300]; // five min
  45. appDelegate.playlistViewController.passcodeValidated = YES;
  46. [self.navigationController popViewControllerAnimated:YES];
  47. }
  48. }
  49. }
  50. @end