linphone-ios/Classes/AboutView.m
Gautier Pelloux-Prayer 61d5e68241 major mv part 2
2015-09-09 17:03:19 +02:00

152 lines
4.8 KiB
Objective-C

/* AboutViewController.m
*
* Copyright (C) 2009 Belledonne Comunications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "PhoneMainView.h"
#import "LinphoneManager.h"
#include "linphone/lpconfig.h"
#include "LinphoneIOSVersion.h"
@implementation AboutView
@synthesize linphoneCoreVersionLabel;
@synthesize linphoneLabel;
@synthesize linphoneIphoneVersionLabel;
@synthesize contentView;
@synthesize linkTapGestureRecognizer;
@synthesize linkLabel;
@synthesize licensesView;
@synthesize licenseLabel;
@synthesize copyrightLabel;
#pragma mark - Lifecycle Functions
- (id)init {
self = [super initWithNibName:NSStringFromClass(self.class) bundle:[NSBundle mainBundle]];
if (self != nil) {
self->linkTapGestureRecognizer =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onLinkTap:)];
}
return self;
}
#pragma mark - ViewController Functions
- (void)viewDidLoad {
[super viewDidLoad];
[linkLabel addGestureRecognizer:linkTapGestureRecognizer];
UIScrollView *scrollView = (UIScrollView *)self.view;
[scrollView addSubview:contentView];
[scrollView setContentSize:[contentView bounds].size];
[linphoneLabel setText:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
[linphoneIphoneVersionLabel
setText:[NSString stringWithFormat:@"%@ iPhone %@",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
[NSString stringWithUTF8String:LINPHONE_IOS_VERSION]]];
[linphoneCoreVersionLabel
setText:[NSString stringWithFormat:@"%@ Core %s",
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"],
linphone_core_get_version()]];
if ([LinphoneManager runningOnIpad]) {
[LinphoneUtils adjustFontSize:self.view mult:2.22f];
}
[AboutView removeBackground:licensesView];
// Create a request to the resource
NSURLRequest *request =
[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[LinphoneManager bundleFile:@"licenses.html"]]];
// Load the resource using the request
[licensesView setDelegate:self];
[licensesView loadRequest:request];
[[AboutView defaultScrollView:licensesView] setScrollEnabled:FALSE];
}
#pragma mark - UICompositeViewDelegate Functions
static UICompositeViewDescription *compositeDescription = nil;
+ (UICompositeViewDescription *)compositeViewDescription {
if (compositeDescription == nil) {
compositeDescription = [[UICompositeViewDescription alloc] init:self.class
stateBar:StatusBarView.class
tabBar:TabBarView.class
fullscreen:false
landscapeMode:[LinphoneManager runningOnIpad]
portraitMode:true];
}
return compositeDescription;
}
#pragma mark -
+ (void)removeBackground:(UIView *)view {
for (UIView *subview in [view subviews]) {
[subview setOpaque:NO];
[subview setBackgroundColor:[UIColor clearColor]];
}
[view setOpaque:NO];
[view setBackgroundColor:[UIColor clearColor]];
}
+ (UIScrollView *)defaultScrollView:(UIWebView *)webView {
return webView.scrollView;
}
#pragma mark - Action Functions
- (IBAction)onLinkTap:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:linkLabel.text]];
}
#pragma mark - UIWebViewDelegate Functions
- (void)webViewDidFinishLoad:(UIWebView *)webView {
CGSize size = [webView sizeThatFits:CGSizeMake(self.view.bounds.size.width, 10000.0f)];
float diff = size.height - webView.bounds.size.height;
UIScrollView *scrollView = (UIScrollView *)self.view;
CGRect contentFrame = [contentView bounds];
contentFrame.size.height += diff;
[contentView setAutoresizesSubviews:FALSE];
[contentView setFrame:contentFrame];
[contentView setAutoresizesSubviews:TRUE];
[scrollView setContentSize:contentFrame.size];
CGRect licensesViewFrame = [licensesView frame];
licensesViewFrame.size.height += diff;
[licensesView setFrame:licensesViewFrame];
}
- (BOOL)webView:(UIWebView *)inWeb
shouldStartLoadWithRequest:(NSURLRequest *)inRequest
navigationType:(UIWebViewNavigationType)inType {
if (inType == UIWebViewNavigationTypeLinkClicked) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
@end