2013-02-14 17:59:12 +04:00
|
|
|
/*
|
|
|
|
Application info controller
|
2019-11-06 17:24:51 +03:00
|
|
|
|
2013-12-04 14:37:57 +04:00
|
|
|
Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
|
2019-11-06 17:24:51 +03:00
|
|
|
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
|
|
If a copy of the MPL was not distributed with this file, You can obtain one at
|
|
|
|
http://mozilla.org/MPL/2.0/.
|
2013-02-14 17:59:12 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import "AboutController.h"
|
|
|
|
#import "Utils.h"
|
2013-04-08 15:25:00 +04:00
|
|
|
#import "BlockAlertView.h"
|
2013-02-14 17:59:12 +04:00
|
|
|
|
|
|
|
@implementation AboutController
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// The designated initializer. Override if you create the controller programmatically and want to
|
|
|
|
// perform customization that is not appropriate for viewDidLoad.
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
|
|
{
|
|
|
|
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
|
|
|
|
{
|
2013-02-14 17:59:12 +04:00
|
|
|
|
|
|
|
// set title and tab-bar image
|
|
|
|
[self setTitle:NSLocalizedString(@"About", @"About Controller title")];
|
2019-11-06 17:24:51 +03:00
|
|
|
UIImage *tabBarIcon = [UIImage
|
|
|
|
imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about"
|
|
|
|
ofType:@"png"]];
|
|
|
|
[self setTabBarItem:[[[UITabBarItem alloc]
|
|
|
|
initWithTitle:NSLocalizedString(@"About", @"Tabbar item about")
|
|
|
|
image:tabBarIcon
|
|
|
|
tag:0] autorelease]];
|
|
|
|
|
|
|
|
last_link_clicked = nil;
|
|
|
|
}
|
|
|
|
return self;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
[super dealloc];
|
|
|
|
[last_link_clicked release];
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Implement loadView to create a view hierarchy programmatically, without using a nib.
|
2019-11-06 17:24:51 +03:00
|
|
|
- (void)loadView
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
|
|
|
webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
|
2019-11-06 17:24:51 +03:00
|
|
|
[webView
|
|
|
|
setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
|
2013-02-14 17:59:12 +04:00
|
|
|
[webView setAutoresizesSubviews:YES];
|
2019-11-06 17:24:51 +03:00
|
|
|
[webView setDelegate:self];
|
|
|
|
[webView setDataDetectorTypes:UIDataDetectorTypeNone];
|
|
|
|
[self setView:webView];
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
2019-11-06 17:24:51 +03:00
|
|
|
- (void)viewDidLoad
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
NSString *filename = (IsPhone() ? @"about_phone" : @"about");
|
|
|
|
NSString *htmlString = [[[NSString alloc]
|
|
|
|
initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
|
|
|
|
ofType:@"html"
|
|
|
|
inDirectory:@"about_page"]
|
|
|
|
encoding:NSUTF8StringEncoding
|
|
|
|
error:nil] autorelease];
|
|
|
|
|
|
|
|
[webView
|
|
|
|
loadHTMLString:[NSString stringWithFormat:htmlString, TSXAppFullVersion(),
|
|
|
|
[[UIDevice currentDevice] systemName],
|
|
|
|
[[UIDevice currentDevice] systemVersion],
|
|
|
|
[[UIDevice currentDevice] model]]
|
|
|
|
baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
|
|
|
|
stringByAppendingPathComponent:@"about_page"]]];
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Override to allow orientations other than the default portrait orientation.
|
2019-11-06 17:24:51 +03:00
|
|
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
|
|
|
{
|
|
|
|
return YES;
|
2013-02-14 17:59:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
#pragma mark UIWebView callbacks
|
2019-11-06 17:24:51 +03:00
|
|
|
- (BOOL)webView:(UIWebView *)webView
|
|
|
|
shouldStartLoadWithRequest:(NSURLRequest *)request
|
|
|
|
navigationType:(UIWebViewNavigationType)navigationType
|
|
|
|
{
|
|
|
|
if ([[request URL] isFileURL])
|
2013-02-14 17:59:12 +04:00
|
|
|
return YES;
|
2019-11-06 17:24:51 +03:00
|
|
|
|
|
|
|
if (navigationType == UIWebViewNavigationTypeLinkClicked)
|
2013-02-14 17:59:12 +04:00
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
[last_link_clicked release];
|
2013-02-14 17:59:12 +04:00
|
|
|
last_link_clicked = [[[request URL] absoluteString] retain];
|
2019-11-06 17:24:51 +03:00
|
|
|
BlockAlertView *alert = [BlockAlertView
|
|
|
|
alertWithTitle:NSLocalizedString(@"External Link", @"External Link Alert Title")
|
|
|
|
message:[NSString stringWithFormat:
|
|
|
|
NSLocalizedString(
|
|
|
|
@"Open [%@] in Browser?",
|
|
|
|
@"Open link in browser (with link as parameter)"),
|
|
|
|
last_link_clicked]];
|
|
|
|
|
|
|
|
[alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil];
|
|
|
|
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK Button")
|
|
|
|
block:^{
|
|
|
|
[[UIApplication sharedApplication]
|
|
|
|
openURL:[NSURL URLWithString:last_link_clicked]];
|
|
|
|
}];
|
|
|
|
|
|
|
|
[alert show];
|
|
|
|
|
2013-02-14 17:59:12 +04:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|