VLCAddMediaViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. @interface VLCAddMediaViewController () {
  15. VLCHTTPUploaderController *_uploadController;
  16. }
  17. @end
  18. @implementation VLCAddMediaViewController
  19. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  20. {
  21. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  22. return self;
  23. }
  24. - (void)viewDidLoad
  25. {
  26. [super viewDidLoad];
  27. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  28. self.dismissButton.titleLabel.text = NSLocalizedString(@"BUTTON_DONE", @"");
  29. self.aboutButton.titleLabel.text = NSLocalizedString(@"ABOUT_APP", @"");
  30. self.openNetworkStreamButton.titleLabel.text = NSLocalizedString(@"OPEN_NETWORK", @"");
  31. self.downloadFromHTTPServerButton.titleLabel.text = NSLocalizedString(@"DOWNLOAD_FROM_HTTP", @"");
  32. }
  33. - (void)viewWillAppear:(BOOL)animated
  34. {
  35. [super viewWillAppear:animated];
  36. }
  37. - (void)_hideAnimated:(BOOL)animated
  38. {
  39. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
  40. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  41. [appDelegate.playlistViewController.addMediaPopoverController dismissPopoverAnimated:YES];
  42. } else
  43. [self dismissViewControllerAnimated:animated completion:NULL];
  44. }
  45. - (IBAction)dismiss:(id)sender
  46. {
  47. [self _hideAnimated:YES];
  48. }
  49. - (IBAction)openAboutPanel:(id)sender
  50. {
  51. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  52. if (!appDelegate.playlistViewController.aboutViewController)
  53. appDelegate.playlistViewController.aboutViewController = [[VLCAboutViewController alloc] initWithNibName:@"VLCAboutViewController" bundle:nil];
  54. [appDelegate.playlistViewController.navigationController pushViewController:appDelegate.playlistViewController.aboutViewController animated:YES];
  55. [self _hideAnimated:NO];
  56. }
  57. - (IBAction)openNetworkStream:(id)sender
  58. {
  59. if ([[UIPasteboard generalPasteboard] containsPasteboardTypes:[NSArray arrayWithObjects:@"public.url", @"public.text", nil]]) {
  60. _pasteURL = [[UIPasteboard generalPasteboard] valueForPasteboardType:@"public.url"];
  61. if (!_pasteURL || [[_pasteURL absoluteString] isEqualToString:@""]) {
  62. NSString * pasteString = [[UIPasteboard generalPasteboard] valueForPasteboardType:@"public.text"];
  63. _pasteURL = [NSURL URLWithString:pasteString];
  64. }
  65. if (_pasteURL && ![[_pasteURL scheme] isEqualToString:@""] && ![[_pasteURL absoluteString] isEqualToString:@""]) {
  66. NSString * messageString = [NSString stringWithFormat:@"Do you want to open %@?", [_pasteURL absoluteString]];
  67. UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"OPEN_URL", @"") message:messageString delegate:self cancelButtonTitle:NSLocalizedString(@"BUTTON_CANCEL", @"") otherButtonTitles:NSLocalizedString(@"BUTTON_OPEN", @""), nil];
  68. [alert show];
  69. }
  70. }
  71. }
  72. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  73. {
  74. if (buttonIndex == 1) {
  75. VLCAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
  76. [appDelegate.playlistViewController openMovieFromURL:_pasteURL];
  77. }
  78. [self _hideAnimated:NO];
  79. }
  80. - (IBAction)downloadFromHTTPServer:(id)sender
  81. {
  82. //TODO
  83. }
  84. - (IBAction)showSettings:(id)sender
  85. {
  86. }
  87. - (IBAction)showInformationOnHTTPServer:(id)sender
  88. {
  89. }
  90. - (IBAction)toggleHTTPServer:(UISwitch *)sender
  91. {
  92. _uploadController = [[VLCHTTPUploaderController alloc] init];
  93. [_uploadController changeHTTPServerState: sender.on];
  94. }
  95. @end