VLCAboutViewController.m 3.6 KB

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