VLCAboutViewController.m 3.7 KB

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