VLCAddMediaViewController.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // VLCAddMediaViewController.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 "VLCAddMediaViewController.h"
  9. #import "VLCAppDelegate.h"
  10. #import "VLCPlaylistViewController.h"
  11. #import "VLCAboutViewController.h"
  12. #import "VLCMovieViewController.h"
  13. #import "VLCHTTPUploaderController.h"
  14. #import "VLCSettingsViewController.h"
  15. @interface VLCAddMediaViewController () {
  16. VLCHTTPUploaderController *_uploadController;
  17. }
  18. @end
  19. @implementation VLCAddMediaViewController
  20. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  21. {
  22. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  23. return self;
  24. }
  25. - (void)viewDidLoad
  26. {
  27. [super viewDidLoad];
  28. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  29. [self.dismissButton setTitle:NSLocalizedString(@"BUTTON_DONE", @"") forState:UIControlStateNormal];
  30. [self.aboutButton setTitle:NSLocalizedString(@"ABOUT_APP", @"") forState:UIControlStateNormal];
  31. [self.openNetworkStreamButton setTitle:NSLocalizedString(@"OPEN_NETWORK", @"") forState:UIControlStateNormal];
  32. [self.downloadFromHTTPServerButton setTitle:NSLocalizedString(@"DOWNLOAD_FROM_HTTP", @"") forState:UIControlStateNormal];
  33. [self.openURLButton setTitle:NSLocalizedString(@"BUTTON_OPEN", @"") forState:UIControlStateNormal];
  34. }
  35. - (void)viewWillAppear:(BOOL)animated
  36. {
  37. [self.openURLButton sizeToFit];
  38. if (self.openURLView.superview)
  39. [self.openURLView removeFromSuperview];
  40. [super viewWillAppear:animated];
  41. }
  42. - (void)_hideAnimated:(BOOL)animated
  43. {
  44. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  45. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  46. [appDelegate.playlistViewController.addMediaPopoverController dismissPopoverAnimated:YES];
  47. } else
  48. [self dismissViewControllerAnimated:animated completion:NULL];
  49. }
  50. - (IBAction)dismiss:(id)sender
  51. {
  52. [self _hideAnimated:YES];
  53. }
  54. - (IBAction)openAboutPanel:(id)sender
  55. {
  56. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  57. if (!appDelegate.playlistViewController.aboutViewController)
  58. appDelegate.playlistViewController.aboutViewController = [[VLCAboutViewController alloc] initWithNibName:@"VLCAboutViewController" bundle:nil];
  59. [appDelegate.playlistViewController.navigationController pushViewController:appDelegate.playlistViewController.aboutViewController animated:YES];
  60. [self _hideAnimated:NO];
  61. }
  62. - (IBAction)openNetworkStream:(id)sender
  63. {
  64. if (sender == self.openNetworkStreamButton) {
  65. if ([[UIPasteboard generalPasteboard] containsPasteboardTypes:[NSArray arrayWithObjects:@"public.url", @"public.text", nil]]) {
  66. NSURL *pasteURL = [[UIPasteboard generalPasteboard] valueForPasteboardType:@"public.url"];
  67. if (!pasteURL || [[pasteURL absoluteString] isEqualToString:@""]) {
  68. NSString *pasteString = [[UIPasteboard generalPasteboard] valueForPasteboardType:@"public.text"];
  69. pasteURL = [NSURL URLWithString:pasteString];
  70. }
  71. if (pasteURL && ![[pasteURL scheme] isEqualToString:@""] && ![[pasteURL absoluteString] isEqualToString:@""]) {
  72. self.openURLField.text = [pasteURL absoluteString];
  73. }
  74. [self.openNetworkStreamButton addSubview:self.openURLView];
  75. }
  76. } else {
  77. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  78. [appDelegate.playlistViewController openMovieFromURL:[NSURL URLWithString:self.openURLField.text]];
  79. [self _hideAnimated:YES];
  80. }
  81. }
  82. - (IBAction)downloadFromHTTPServer:(id)sender
  83. {
  84. //TODO
  85. }
  86. - (IBAction)showSettings:(id)sender
  87. {
  88. if (!self.settingsViewController)
  89. self.settingsViewController = [[VLCSettingsViewController alloc] initWithNibName:@"VLCSettingsViewController" bundle:nil];
  90. [self _hideAnimated:NO];
  91. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  92. self.settingsViewController.modalPresentationStyle = UIModalPresentationFormSheet;
  93. [appDelegate.playlistViewController.navigationController presentModalViewController:self.settingsViewController animated:YES];
  94. }
  95. - (IBAction)showInformationOnHTTPServer:(id)sender
  96. {
  97. }
  98. - (IBAction)toggleHTTPServer:(UISwitch *)sender
  99. {
  100. _uploadController = [[VLCHTTPUploaderController alloc] init];
  101. [_uploadController changeHTTPServerState: sender.on];
  102. }
  103. @end