VLCAboutViewController.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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:NSLocalizedString(@"BUTTON_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. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedBackButtonWithTarget:self andSelector:@selector(goBack:)];
  23. } else
  24. self.navigationItem.leftBarButtonItem = contributeButton;
  25. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  26. [htmlContent replaceOccurrencesOfString:@"ASPENVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@" %@", kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  27. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  28. [self.webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  29. htmlContent = nil;
  30. self.webView.delegate = self;
  31. }
  32. - (IBAction)goBack:(id)sender
  33. {
  34. [self.navigationController popViewControllerAnimated:YES];
  35. }
  36. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  37. {
  38. NSURL *requestURL = request.URL;
  39. if (![requestURL.scheme isEqualToString:@""])
  40. return ![[UIApplication sharedApplication] openURL:requestURL];
  41. else
  42. return YES;
  43. }
  44. - (void)webViewDidFinishLoad:(UIWebView *)webView
  45. {
  46. webView.alpha = 0.;
  47. CGFloat alpha = 1.;
  48. void (^animationBlock)() = ^() {
  49. webView.alpha = alpha;
  50. };
  51. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  52. webView.hidden = NO;
  53. };
  54. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  55. }
  56. - (IBAction)openContributePage:(id)sender
  57. {
  58. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  59. }
  60. @end