VLCAddMediaViewController.m 4.4 KB

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