VLCAboutViewController.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*****************************************************************************
  2. * VLCAboutViewController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. * Pierre Sagaspe <pierre.sagaspe # me.com>
  10. * Tamas Timar <ttimar.vlc # gmail.com>
  11. *
  12. * Refer to the COPYING file of the official project for license.
  13. *****************************************************************************/
  14. #import "VLCAboutViewController.h"
  15. #import "VLCAppDelegate.h"
  16. #import "UIBarButtonItem+Theme.h"
  17. @implementation VLCAboutViewController
  18. - (void)viewDidLoad
  19. {
  20. [super viewDidLoad];
  21. self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title"]];
  22. UIBarButtonItem *contributeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CONTRIBUTE",@"") style:UIBarButtonItemStyleBordered target:self action:@selector(openContributePage:)];
  23. if (SYSTEM_RUNS_IOS7_OR_LATER)
  24. contributeButton.tintColor = [UIColor whiteColor];
  25. else {
  26. [contributeButton setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  27. [contributeButton setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  28. }
  29. self.navigationItem.rightBarButtonItem = contributeButton;
  30. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
  31. self.view.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  32. self.webView.backgroundColor = [UIColor colorWithWhite:.122 alpha:1.];
  33. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  34. [htmlContent replaceOccurrencesOfString:@"VLCFORIOSVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT",@""), [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] stringByAppendingFormat:@"<br /><i>%@</i>", kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  35. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT",@""),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(0, 1000)];
  36. [self.webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  37. htmlContent = nil;
  38. self.webView.delegate = self;
  39. }
  40. - (BOOL)shouldAutorotate
  41. {
  42. UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  43. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  44. return NO;
  45. return YES;
  46. }
  47. - (IBAction)goBack:(id)sender
  48. {
  49. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  50. }
  51. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  52. {
  53. NSURL *requestURL = request.URL;
  54. if (![requestURL.scheme isEqualToString:@""])
  55. return ![[UIApplication sharedApplication] openURL:requestURL];
  56. else
  57. return YES;
  58. }
  59. - (void)webViewDidFinishLoad:(UIWebView *)webView
  60. {
  61. webView.alpha = 0.;
  62. CGFloat alpha = 1.;
  63. void (^animationBlock)() = ^() {
  64. webView.alpha = alpha;
  65. };
  66. void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
  67. webView.hidden = NO;
  68. };
  69. [UIView animateWithDuration:.3 animations:animationBlock completion:completionBlock];
  70. }
  71. - (IBAction)openContributePage:(id)sender
  72. {
  73. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  74. }
  75. @end