VLCAboutViewController.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*****************************************************************************
  2. * VLCAboutViewController.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2013-2015 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. @interface VLCAboutViewController ()
  17. {
  18. UIWebView *_webView;
  19. }
  20. @end
  21. @implementation VLCAboutViewController
  22. - (void)loadView
  23. {
  24. self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  25. self.view.backgroundColor = [UIColor VLCDarkBackgroundColor];
  26. _webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  27. _webView.clipsToBounds = YES;
  28. _webView.delegate = self;
  29. _webView.backgroundColor = [UIColor clearColor];
  30. _webView.opaque = NO;
  31. _webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
  32. [self.view addSubview:_webView];
  33. }
  34. - (void)viewDidLoad
  35. {
  36. [super viewDidLoad];
  37. self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"title"]];
  38. UIBarButtonItem *contributeButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BUTTON_CONTRIBUTE", nil) style:UIBarButtonItemStyleBordered target:self action:@selector(openContributePage:)];
  39. if (SYSTEM_RUNS_IOS7_OR_LATER)
  40. contributeButton.tintColor = [UIColor whiteColor];
  41. else {
  42. [contributeButton setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
  43. [contributeButton setBackgroundImage:[UIImage imageNamed:@"buttonHighlight"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
  44. }
  45. self.navigationItem.rightBarButtonItem = contributeButton;
  46. self.navigationItem.leftBarButtonItem = [UIBarButtonItem themedRevealMenuButtonWithTarget:self andSelector:@selector(goBack:)];
  47. NSBundle *mainBundle = [NSBundle mainBundle];
  48. NSMutableString *htmlContent = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"About Contents" ofType:@"html"] encoding:NSUTF8StringEncoding error:nil];
  49. [htmlContent replaceOccurrencesOfString:@"VLCFORIOSVERSION" withString:[[NSString stringWithFormat:NSLocalizedString(@"VERSION_FORMAT", nil), [mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]] stringByAppendingFormat:@" (%@)<br /><i>%@</i>", [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"], kVLCVersionCodename] options:NSLiteralSearch range:NSMakeRange(800, 1000)];
  50. [htmlContent replaceOccurrencesOfString:@"MOBILEVLCKITVERSION" withString:[NSString stringWithFormat:NSLocalizedString(@"BASED_ON_FORMAT", nil),[[VLCLibrary sharedLibrary] version]] options:NSLiteralSearch range:NSMakeRange(800, 1100)];
  51. [_webView loadHTMLString:[NSString stringWithString:htmlContent] baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
  52. htmlContent = nil;
  53. }
  54. - (BOOL)shouldAutorotate
  55. {
  56. UIInterfaceOrientation toInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  57. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
  58. return NO;
  59. return YES;
  60. }
  61. - (IBAction)goBack:(id)sender
  62. {
  63. [[(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController] toggleSidebar:![(VLCAppDelegate*)[UIApplication sharedApplication].delegate revealController].sidebarShowing duration:kGHRevealSidebarDefaultAnimationDuration];
  64. }
  65. - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  66. {
  67. NSURL *requestURL = request.URL;
  68. if (![requestURL.scheme isEqualToString:@""])
  69. return ![[UIApplication sharedApplication] openURL:requestURL];
  70. else
  71. return YES;
  72. }
  73. - (void)webViewDidFinishLoad:(UIWebView *)webView
  74. {
  75. _webView.backgroundColor = [UIColor VLCDarkBackgroundColor];
  76. _webView.opaque = YES;
  77. }
  78. - (IBAction)openContributePage:(id)sender
  79. {
  80. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.videolan.org/contribute.html"]];
  81. }
  82. @end