VLCAboutViewController.m 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  33. {
  34. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  35. return NO;
  36. return YES;
  37. }
  38. - (IBAction)goBack:(id)sender
  39. {
  40. [self.navigationController popViewControllerAnimated:YES];
  41. }
  42. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  43. {
  44. NSURL *requestURL = request.URL;
  45. if (![requestURL.scheme isEqualToString:@""])
  46. return ![[UIApplication sharedApplication] openURL:requestURL];
  47. else
  48. return YES;
  49. }
  50. - (void)webViewDidFinishLoad:(UIWebView *)webView
  51. {
  52. webView.alpha = 0.;
  53. CGFloat alpha = 1.;
  54. void (^animationBlock)() = ^() {
  55. webView.alpha = alpha;
  56. };
  57. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  58. webView.hidden = NO;
  59. };
  60. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  61. }
  62. - (IBAction)openContributePage:(id)sender
  63. {
  64. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  65. }
  66. @end