11#import "AboutController.h"
18- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
20 if ((
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
24 [
self setTitle:NSLocalizedString(@"About", @"About Controller title")];
25 UIImage *tabBarIcon = [UIImage
26 imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about"
28 [
self setTabBarItem:[[[UITabBarItem alloc]
29 initWithTitle:NSLocalizedString(@"About", @"Tabbar item about")
33 last_link_clicked = nil;
41 [last_link_clicked release];
47 WKWebViewConfiguration *config = [[[WKWebViewConfiguration alloc] init] autorelease];
48 [config setDataDetectorTypes:WKDataDetectorTypeNone];
49 webView = [[[WKWebView alloc] initWithFrame:CGRectZero configuration:config] autorelease];
51 setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
52 [webView setAutoresizesSubviews:YES];
53 [webView setNavigationDelegate:self];
54 [
self setView:webView];
62 NSString *filename = (IsPhone() ?
@"about_phone" :
@"about");
63 NSString *htmlString = [[[NSString alloc]
64 initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename
66 inDirectory:@"about_page"]
67 encoding:NSUTF8StringEncoding
68 error:nil] autorelease];
71 loadHTMLString:[NSString stringWithFormat:htmlString, TSXAppFullVersion(),
72 [[UIDevice currentDevice] systemName],
73 [[UIDevice currentDevice] systemVersion],
74 [[UIDevice currentDevice] model]]
75 baseURL:[NSURL fileURLWithPath:[[[NSBundle mainBundle] bundlePath]
76 stringByAppendingPathComponent:@"about_page"]]];
80- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
86#pragma mark WKWebView callbacks
87- (void)webView:(WKWebView *)wv
88 decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
89 decisionHandler:(
void (^)(WKNavigationActionPolicy))decisionHandler
91 NSURLRequest *request = [navigationAction request];
93 if ([[request URL] isFileURL])
95 decisionHandler(WKNavigationActionPolicyAllow);
99 if ([navigationAction navigationType] == WKNavigationTypeLinkActivated)
101 [last_link_clicked release];
102 last_link_clicked = [[[request URL] absoluteString] retain];
103 UIAlertController *alert = [UIAlertController
104 alertControllerWithTitle:NSLocalizedString(@"External Link",
105 @"External Link Alert Title")
109 @"Open [%@] in Browser?",
110 @"Open link in browser (with link as parameter)"),
112 preferredStyle:UIAlertControllerStyleAlert];
114 [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"No", @"No Button")
115 style:UIAlertActionStyleCancel
118 addAction:[UIAlertAction
119 actionWithTitle:NSLocalizedString(@"OK", @"OK Button")
120 style:UIAlertActionStyleDefault
121 handler:^(UIAlertAction *action) {
122 [[UIApplication sharedApplication]
123 openURL:[NSURL URLWithString:last_link_clicked]
125 completionHandler:nil];
128 [
self presentViewController:alert animated:YES completion:nil];
130 decisionHandler(WKNavigationActionPolicyCancel);
134 decisionHandler(WKNavigationActionPolicyAllow);