VLCAboutViewController.m 4.6 KB

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