VLCAboutViewController.m 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // VLCAboutViewController.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 07.04.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCAboutViewController.h"
  11. #import "VLCAppDelegate.h"
  12. #import "UIBarButtonItem+Theme.h"
  13. @implementation VLCAboutViewController
  14. - (void)viewDidLoad
  15. {
  16. [super viewDidLoad];
  17. self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title"]];
  18. UIBarButtonItem *contributeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CONTRIBUTE",@"") style:UIBarButtonItemStyleBordered target:self action:@selector(openContributePage:)];
  19. if (SYSTEM_RUNS_IOS7_OR_LATER)
  20. contributeButton.tintColor = [UIColor whiteColor];
  21. else {
  22. [contributeButton setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  23. [contributeButton setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  24. }
  25. self.navigationItem.rightBarButtonItem = contributeButton;
  26. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
  27. self.view.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  28. self.webView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  29. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  30. [htmlContent replaceOccurrencesOfString:@"VLCFORIOSVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@"<br /><i>%@</i>", kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  31. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  32. [self.webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  33. htmlContent = nil;
  34. self.webView.delegate = self;
  35. }
  36. - (BOOL)shouldAutorotate
  37. {
  38. UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  39. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  40. return NO;
  41. return YES;
  42. }
  43. - (IBAction)goBack:(id)sender
  44. {
  45. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  46. }
  47. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  48. {
  49. NSURL *requestURL = request.URL;
  50. if (![requestURL.scheme isEqualToString:@""])
  51. return ![[UIApplication sharedApplication] openURL:requestURL];
  52. else
  53. return YES;
  54. }
  55. - (void)webViewDidFinishLoad:(UIWebView *)webView
  56. {
  57. webView.alpha = 0.;
  58. CGFloat alpha = 1.;
  59. void (^animationBlock)() = ^() {
  60. webView.alpha = alpha;
  61. };
  62. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  63. webView.hidden = NO;
  64. };
  65. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  66. }
  67. - (IBAction)openContributePage:(id)sender
  68. {
  69. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  70. }
  71. @end