VLCAboutViewController.m 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "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_IN_THE_FUTURE)
  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. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  28. [htmlContent replaceOccurrencesOfString:@"ASPENVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@"<br /><i>%@</i>", kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  29. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  30. [self.webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  31. htmlContent = nil;
  32. self.webView.delegate = self;
  33. }
  34. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
  35. {
  36. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  37. return NO;
  38. return YES;
  39. }
  40. - (IBAction)goBack:(id)sender
  41. {
  42. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  43. }
  44. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  45. {
  46. NSURL *requestURL = request.URL;
  47. if (![requestURL.scheme isEqualToString:@""])
  48. return ![[UIApplication sharedApplication] openURL:requestURL];
  49. else
  50. return YES;
  51. }
  52. - (void)webViewDidFinishLoad:(UIWebView *)webView
  53. {
  54. webView.alpha = 0.;
  55. CGFloat alpha = 1.;
  56. void (^animationBlock)() = ^() {
  57. webView.alpha = alpha;
  58. };
  59. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  60. webView.hidden = NO;
  61. };
  62. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  63. }
  64. - (IBAction)openContributePage:(id)sender
  65. {
  66. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  67. }
  68. @end