VLCAboutViewController.m 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // VLCAboutViewController.m
  3. // AspenProject
  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 "UIBarButtonItem+Theme.h"
  12. @implementation VLCAboutViewController
  13. - (void)viewDidLoad
  14. {
  15. [super viewDidLoad];
  16. self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title"]];
  17. UIBarButtonItem *contributeButton = [[UIBarButtonItem alloc] initWithTitle:@"Contribute" style:UIBarButtonItemStyleBordered target:self action:@selector(openContributePage:)];
  18. [contributeButton setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  19. [contributeButton setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  20. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
  21. self.navigationItem.rightBarButtonItem = contributeButton;
  22. else
  23. self.navigationItem.leftBarButtonItem = contributeButton;
  24. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  25. [htmlContent replaceOccurrencesOfString:@"ASPENVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@" %@", kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  26. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  27. [self.webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  28. htmlContent = nil;
  29. self.webView.delegate = self;
  30. }
  31. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  32. {
  33. NSURL *requestURL = request.URL;
  34. if (![requestURL.scheme isEqualToString:@""])
  35. return ![[UIApplication sharedApplication] openURL:requestURL];
  36. else
  37. return YES;
  38. }
  39. - (void)webViewDidFinishLoad:(UIWebView *)webView
  40. {
  41. webView.alpha = 0.;
  42. CGFloat alpha = 1.;
  43. void (^animationBlock)() = ^() {
  44. webView.alpha = alpha;
  45. };
  46. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  47. webView.hidden = NO;
  48. };
  49. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  50. }
  51. - (IBAction)openContributePage:(id)sender
  52. {
  53. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  54. }
  55. @end