mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-15 20:17:43 +00:00
Migrate KMWebBrowserViewController to Swift
This commit is contained in:
parent
4681a349ed
commit
c6caa72dae
8 changed files with 313 additions and 386 deletions
|
|
@ -85,8 +85,7 @@
|
|||
982D149D19FF462A007D4629 /* textsize_selected@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 982D148719FF462A007D4629 /* textsize_selected@3x.png */; };
|
||||
982D149F19FF462A007D4629 /* textsize_up@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 982D148819FF462A007D4629 /* textsize_up@3x.png */; };
|
||||
982D14A119FF462A007D4629 /* textsize@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 982D148919FF462A007D4629 /* textsize@3x.png */; };
|
||||
9845A7AA1A43983300544E2E /* KMWebBrowserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9845A79C1A43983300544E2E /* KMWebBrowserViewController.m */; };
|
||||
9845A7AB1A43983300544E2E /* KMWebBrowserViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9845A79D1A43983300544E2E /* KMWebBrowserViewController.xib */; };
|
||||
9845A7AB1A43983300544E2E /* WebBrowserViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9845A79D1A43983300544E2E /* WebBrowserViewController.xib */; };
|
||||
9845A7AC1A43983300544E2E /* kmwb-navbar-Landscape-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9845A79F1A43983300544E2E /* kmwb-navbar-Landscape-568h@2x.png */; };
|
||||
9845A7AD1A43983300544E2E /* kmwb-navbar-Landscape-568h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9845A7A01A43983300544E2E /* kmwb-navbar-Landscape-568h@3x.png */; };
|
||||
9845A7AE1A43983300544E2E /* kmwb-navbar-Landscape.png in Resources */ = {isa = PBXBuildFile; fileRef = 9845A7A11A43983300544E2E /* kmwb-navbar-Landscape.png */; };
|
||||
|
|
@ -189,6 +188,7 @@
|
|||
C0A1A6311F5E4F4300EAF822 /* InfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A1A6301F5E4F4300EAF822 /* InfoViewController.swift */; };
|
||||
C0A1A6331F5E749000EAF822 /* SetUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A1A6321F5E749000EAF822 /* SetUpViewController.swift */; };
|
||||
C0A1A6351F5E786A00EAF822 /* BookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A1A6341F5E786A00EAF822 /* BookmarksViewController.swift */; };
|
||||
C0A1A6371F5E8C9100EAF822 /* WebBrowserViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0A1A6361F5E8C9100EAF822 /* WebBrowserViewController.swift */; };
|
||||
C0FF769B1F5D368C00BD23C3 /* KeyboardViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FF769A1F5D368C00BD23C3 /* KeyboardViewController.swift */; };
|
||||
C0FF769E1F5D4ECB00BD23C3 /* ActivityItemProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FF769D1F5D4ECB00BD23C3 /* ActivityItemProvider.swift */; };
|
||||
CE06AA681F171CA0006D91C3 /* Keyman.h in Headers */ = {isa = PBXBuildFile; fileRef = 98D418F71769486C008D2FF3 /* Keyman.h */; };
|
||||
|
|
@ -263,9 +263,7 @@
|
|||
982D148719FF462A007D4629 /* textsize_selected@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "textsize_selected@3x.png"; path = "Keyman Icons/textsize_selected@3x.png"; sourceTree = "<group>"; };
|
||||
982D148819FF462A007D4629 /* textsize_up@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "textsize_up@3x.png"; path = "Keyman Icons/textsize_up@3x.png"; sourceTree = "<group>"; };
|
||||
982D148919FF462A007D4629 /* textsize@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "textsize@3x.png"; path = "Keyman Icons/textsize@3x.png"; sourceTree = "<group>"; };
|
||||
9845A79B1A43983300544E2E /* KMWebBrowserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMWebBrowserViewController.h; sourceTree = "<group>"; };
|
||||
9845A79C1A43983300544E2E /* KMWebBrowserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMWebBrowserViewController.m; sourceTree = "<group>"; };
|
||||
9845A79D1A43983300544E2E /* KMWebBrowserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMWebBrowserViewController.xib; sourceTree = "<group>"; };
|
||||
9845A79D1A43983300544E2E /* WebBrowserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WebBrowserViewController.xib; sourceTree = "<group>"; };
|
||||
9845A79F1A43983300544E2E /* kmwb-navbar-Landscape-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "kmwb-navbar-Landscape-568h@2x.png"; sourceTree = "<group>"; };
|
||||
9845A7A01A43983300544E2E /* kmwb-navbar-Landscape-568h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "kmwb-navbar-Landscape-568h@3x.png"; sourceTree = "<group>"; };
|
||||
9845A7A11A43983300544E2E /* kmwb-navbar-Landscape.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "kmwb-navbar-Landscape.png"; sourceTree = "<group>"; };
|
||||
|
|
@ -405,6 +403,7 @@
|
|||
C0A1A6301F5E4F4300EAF822 /* InfoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = InfoViewController.swift; sourceTree = "<group>"; tabWidth = 2; };
|
||||
C0A1A6321F5E749000EAF822 /* SetUpViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = SetUpViewController.swift; sourceTree = "<group>"; tabWidth = 2; };
|
||||
C0A1A6341F5E786A00EAF822 /* BookmarksViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = BookmarksViewController.swift; sourceTree = "<group>"; tabWidth = 2; };
|
||||
C0A1A6361F5E8C9100EAF822 /* WebBrowserViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = WebBrowserViewController.swift; sourceTree = "<group>"; tabWidth = 2; };
|
||||
C0FF76991F5D368B00BD23C3 /* SWKeyboard-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SWKeyboard-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
C0FF769A1F5D368C00BD23C3 /* KeyboardViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.swift; path = KeyboardViewController.swift; sourceTree = "<group>"; tabWidth = 2; };
|
||||
C0FF769C1F5D4ECA00BD23C3 /* Keyman-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Keyman-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
|
|
@ -454,11 +453,10 @@
|
|||
children = (
|
||||
9845A8BD1A439F1000544E2E /* Icons */,
|
||||
9845A8DC1A439FB200544E2E /* BookmarksViewController.xib */,
|
||||
9845A79B1A43983300544E2E /* KMWebBrowserViewController.h */,
|
||||
9845A79C1A43983300544E2E /* KMWebBrowserViewController.m */,
|
||||
9845A79D1A43983300544E2E /* KMWebBrowserViewController.xib */,
|
||||
9845A79D1A43983300544E2E /* WebBrowserViewController.xib */,
|
||||
9845A79E1A43983300544E2E /* NavBar */,
|
||||
C0A1A6341F5E786A00EAF822 /* BookmarksViewController.swift */,
|
||||
C0A1A6361F5E8C9100EAF822 /* WebBrowserViewController.swift */,
|
||||
);
|
||||
path = KMWebBrowser;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -1068,7 +1066,7 @@
|
|||
982D149F19FF462A007D4629 /* textsize_up@3x.png in Resources */,
|
||||
982D149119FF462A007D4629 /* 711-trash@3x.png in Resources */,
|
||||
982D148D19FF462A007D4629 /* 702-share@3x.png in Resources */,
|
||||
9845A7AB1A43983300544E2E /* KMWebBrowserViewController.xib in Resources */,
|
||||
9845A7AB1A43983300544E2E /* WebBrowserViewController.xib in Resources */,
|
||||
9822CB691A3A77D200D73CAA /* MainViewController_.xib in Resources */,
|
||||
9845A8741A439B8F00544E2E /* font-size-a.png in Resources */,
|
||||
);
|
||||
|
|
@ -1132,7 +1130,7 @@
|
|||
981AFA7B19EF44DE006706BF /* main.m in Sources */,
|
||||
9845A7CF1A439A9200544E2E /* GetStartedViewController.m in Sources */,
|
||||
981AFA7C19EF44DE006706BF /* AppDelegate.m in Sources */,
|
||||
9845A7AA1A43983300544E2E /* KMWebBrowserViewController.m in Sources */,
|
||||
C0A1A6371F5E8C9100EAF822 /* WebBrowserViewController.swift in Sources */,
|
||||
9845A7BC1A4398B200544E2E /* KMDropDownListView.m in Sources */,
|
||||
981AFA7F19EF44DE006706BF /* MainViewController.m in Sources */,
|
||||
C0A1A6351F5E786A00EAF822 /* BookmarksViewController.swift in Sources */,
|
||||
|
|
@ -1295,6 +1293,7 @@
|
|||
"-force_load",
|
||||
Keyman/libKeyman/libKeyman.a,
|
||||
);
|
||||
"OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG";
|
||||
PROVISIONING_PROFILE = "";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
|
||||
SDKROOT = iphoneos;
|
||||
|
|
@ -1377,7 +1376,6 @@
|
|||
);
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
"OTHER_SWIFT_FLAGS[arch=*]" = "-D DEBUG";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = Tavultesoft.Keyman.SWKeyboard;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE = "5d7c5750-a8be-473c-80ef-ed8773404e65";
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ let bookmarkUrlKey: String = "BookMarkUrl"
|
|||
|
||||
class BookmarksViewController:
|
||||
UIViewController, UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate {
|
||||
weak var webBrowser: KMWebBrowserViewController?
|
||||
weak var webBrowser: WebBrowserViewController?
|
||||
|
||||
@IBOutlet var tableView: UITableView!
|
||||
@IBOutlet var doneButton: UIBarButtonItem!
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// KMWebBrowserViewController.h
|
||||
// Keyman
|
||||
//
|
||||
// Created by Serkan Kurt on 9/12/2014.
|
||||
// Copyright (c) 2017 SIL International. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface KMWebBrowserViewController : UIViewController <UIWebViewDelegate>
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UIWebView *webView;
|
||||
@property (strong, nonatomic) NSString *fontFamily;
|
||||
|
||||
@end
|
||||
|
|
@ -1,347 +0,0 @@
|
|||
//
|
||||
// KMWebBrowserViewController.m
|
||||
// Keyman
|
||||
//
|
||||
// Created by Serkan Kurt on 9/12/2014.
|
||||
// Copyright (c) 2017 SIL International. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KMWebBrowserViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "UIImage+Helpers.h"
|
||||
#import "KMManager.h"
|
||||
#import <Keyman-Swift.h>
|
||||
|
||||
@interface KMWebBrowserViewController ()
|
||||
|
||||
@property (strong, nonatomic) IBOutlet UINavigationBar *navBar;
|
||||
@property (strong, nonatomic) IBOutlet UIToolbar *toolBar;
|
||||
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *navBarTopConstraint;
|
||||
@property (strong, nonatomic) UITextField *addressField;
|
||||
@property (strong, nonatomic) UIView *rightView;
|
||||
@property (strong, nonatomic) UIButton *refreshButton;
|
||||
@property (strong, nonatomic) UIButton *stopButton;
|
||||
@property (strong, nonatomic) IBOutlet UIBarButtonItem *backButton;
|
||||
@property (strong, nonatomic) IBOutlet UIBarButtonItem *forwardButton;
|
||||
@property (strong, nonatomic) IBOutlet UIBarButtonItem *bookmarksButton;
|
||||
@property (strong, nonatomic) IBOutlet UIBarButtonItem *globeButton;
|
||||
@property (strong, nonatomic) IBOutlet UIBarButtonItem *closeButton;
|
||||
@property (strong, nonatomic) NSString *nFontFamily;
|
||||
|
||||
@end
|
||||
|
||||
@implementation KMWebBrowserViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardChanged:) name:kKeymanKeyboardChangedNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardPickerDismissed:) name:kKeymanKeyboardPickerDismissedNotification object:nil];
|
||||
|
||||
self.webView.delegate = self;
|
||||
self.webView.scalesPageToFit = YES;
|
||||
|
||||
// Setup NavigationBar
|
||||
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
||||
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
|
||||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
||||
CGFloat size = screenRect.size.height > screenRect.size.width?screenRect.size.height:screenRect.size.width;
|
||||
if (size > 568.0) {
|
||||
// Navbar for iPhone 6 & 6 Plus
|
||||
UIImage *bgImg = nil;
|
||||
if (UIInterfaceOrientationIsPortrait(orientation))
|
||||
bgImg = [[UIImage imageNamed:@"kmwb-navbar-Portrait.png"]
|
||||
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
||||
resizingMode:UIImageResizingModeStretch];
|
||||
else
|
||||
bgImg = [[UIImage imageNamed:@"kmwb-navbar-Landscape-568h.png"]
|
||||
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
||||
resizingMode:UIImageResizingModeStretch];
|
||||
|
||||
[self.navBar setBackgroundImage:bgImg forBarMetrics:UIBarMetricsDefault];
|
||||
//[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Landscape-568h.png"] forBarMetrics:UIBarMetricsCompact];
|
||||
}
|
||||
else if (size == 568) {
|
||||
// Navbar for iPhone and iPod Touch with 4" Display
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Portrait.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Landscape-568h.png"] forBarMetrics:UIBarMetricsCompact];
|
||||
}
|
||||
else if (size < 568.0) {
|
||||
// Navbar for iPhone and iPod Touch with 3.5" Display
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Portrait.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Landscape.png"] forBarMetrics:UIBarMetricsCompact];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Navbar for iPad
|
||||
if (UIInterfaceOrientationIsPortrait(orientation))
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Portrait.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
else
|
||||
[self.navBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Landscape.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
}
|
||||
|
||||
// Setup address field
|
||||
CGRect addressFrame = CGRectMake(10, 4.0, self.navBar.frame.size.width - 20, 28);
|
||||
self.addressField = [[UITextField alloc] initWithFrame:addressFrame];
|
||||
self.addressField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
self.addressField.rightViewMode = UITextFieldViewModeUnlessEditing;
|
||||
self.addressField.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
self.addressField.borderStyle = UITextBorderStyleRoundedRect;
|
||||
self.addressField.autocapitalizationType = UITextAutocapitalizationTypeNone;
|
||||
self.addressField.autocorrectionType = UITextAutocorrectionTypeNo;
|
||||
self.addressField.font = [UIFont systemFontOfSize:17];
|
||||
self.addressField.placeholder = @"http://";
|
||||
self.addressField.text = @"";
|
||||
self.addressField.keyboardType = UIKeyboardTypeURL;
|
||||
[self.addressField addTarget:self
|
||||
action:@selector(loadAddress:event:)
|
||||
forControlEvents:UIControlEventEditingDidEndOnExit];
|
||||
|
||||
[self.navBar addSubview:self.addressField];
|
||||
|
||||
self.rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 28)];
|
||||
self.addressField.rightView = self.rightView;
|
||||
|
||||
UIImage *refreshIcon = [[UIImage imageNamed:@"UIButtonBarRefresh.png"]
|
||||
scaleToSize:CGSizeMake(18, 22)];
|
||||
if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)])
|
||||
refreshIcon = [refreshIcon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
self.refreshButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[self.refreshButton setImage:refreshIcon forState:UIControlStateNormal];
|
||||
[self.refreshButton setFrame:self.rightView.frame];
|
||||
[self.refreshButton addTarget:self
|
||||
action:@selector(refresh:)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.refreshButton setHidden:YES];
|
||||
[self.rightView addSubview:self.refreshButton];
|
||||
|
||||
UIImage *stopIcon = [[UIImage imageNamed:@"UIButtonBarStop.png"]
|
||||
scaleToSize:CGSizeMake(17, 17)];
|
||||
if ([UIImage instancesRespondToSelector:@selector(imageWithRenderingMode:)])
|
||||
stopIcon = [stopIcon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
|
||||
self.stopButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[self.stopButton setImage:stopIcon forState:UIControlStateNormal];
|
||||
[self.stopButton setFrame:self.rightView.frame];
|
||||
[self.stopButton addTarget:self
|
||||
action:@selector(stop:)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.stopButton setHidden:YES];
|
||||
[self.rightView addSubview:self.stopButton];
|
||||
|
||||
[self updateButtons];
|
||||
|
||||
NSUserDefaults *userData = [NSUserDefaults standardUserDefaults];
|
||||
NSString *lastUrlStr = [userData objectForKey:@"KMWebBrowserLastURL"];
|
||||
if (lastUrlStr == nil)
|
||||
lastUrlStr = @"http://www.google.com/";
|
||||
NSURL *url = [NSURL URLWithString:lastUrlStr];
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
self.navBarTopConstraint.constant = [AppDelegate statusBarHeight];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
|
||||
UIInterfaceOrientation orientation = toInterfaceOrientation;
|
||||
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
|
||||
CGRect screenRect = [[UIScreen mainScreen] bounds];
|
||||
CGFloat size = screenRect.size.height > screenRect.size.width?screenRect.size.height:screenRect.size.width;
|
||||
if (size > 568.0) {
|
||||
// Navbar for iPhone 6 & 6 Plus
|
||||
UIImage *bgImg = nil;
|
||||
if (UIInterfaceOrientationIsPortrait(orientation))
|
||||
bgImg = [[UIImage imageNamed:@"kmwb-navbar-Portrait.png"]
|
||||
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
||||
resizingMode:UIImageResizingModeStretch];
|
||||
else
|
||||
bgImg = [[UIImage imageNamed:@"kmwb-navbar-Landscape-568h.png"]
|
||||
resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)
|
||||
resizingMode:UIImageResizingModeStretch];
|
||||
|
||||
[self.navigationController.navigationBar setBackgroundImage:bgImg
|
||||
forBarMetrics:UIBarMetricsDefault];
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (UIInterfaceOrientationIsPortrait(orientation))
|
||||
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Portrait.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
else
|
||||
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"kmwb-navbar-Landscape.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
|
||||
self.navBarTopConstraint.constant = [AppDelegate statusBarHeight];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (void)loadAddress:(id)sender event:(UIEvent *)event {
|
||||
NSString *urlString = self.addressField.text;
|
||||
NSURL *url = [NSURL URLWithString:urlString];
|
||||
if (!url.scheme)
|
||||
url = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@", urlString]];
|
||||
|
||||
NSURLRequest *request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
}
|
||||
|
||||
- (void)updateAddress:(NSURLRequest*)request {
|
||||
NSURL *url = [request mainDocumentURL];
|
||||
self.addressField.text = [url absoluteString];
|
||||
NSUserDefaults *userData = [NSUserDefaults standardUserDefaults];
|
||||
[userData setObject:[url absoluteString] forKey:@"KMWebBrowserLastURL"];
|
||||
[userData synchronize];
|
||||
}
|
||||
|
||||
- (void)refresh:(id)sender {
|
||||
[self.webView reload];
|
||||
}
|
||||
|
||||
- (void)stop:(id)sender {
|
||||
[self.webView stopLoading];
|
||||
}
|
||||
|
||||
- (IBAction)back:(id)sender {
|
||||
[self.webView goBack];
|
||||
}
|
||||
|
||||
- (IBAction)forward:(id)sender {
|
||||
[self.webView goForward];
|
||||
}
|
||||
|
||||
- (IBAction)bookmarks:(id)sender {
|
||||
BookmarksViewController *bookmarksVC = [[BookmarksViewController alloc] init];
|
||||
bookmarksVC.webBrowser = self;
|
||||
[self presentViewController:bookmarksVC animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (IBAction)globe:(id)sender {
|
||||
[[KMManager sharedInstance] showKeyboardPickerInViewController:self shouldAddKeyboard:NO];
|
||||
}
|
||||
|
||||
- (IBAction)close:(id)sender {
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - UIWebViewDelegate methods
|
||||
|
||||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
||||
[self updateAddress:request];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView *)webView {
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
|
||||
[self updateButtons];
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
||||
[self appendCSSFontFamily];
|
||||
[self updateButtons];
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
|
||||
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
|
||||
[self updateButtons];
|
||||
|
||||
if (error.code == -1003 || error.code == -1009) {
|
||||
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot Open Page"
|
||||
message:error.localizedDescription
|
||||
delegate:self
|
||||
cancelButtonTitle:@"OK"
|
||||
otherButtonTitles:nil];
|
||||
[alert show];
|
||||
}
|
||||
|
||||
/*
|
||||
NSString *htmlFormat =
|
||||
@"<html>"
|
||||
@"<head>"
|
||||
@"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"
|
||||
@"<meta name=\"format-detection\" content=\"telephone=no\">"
|
||||
@"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\">"
|
||||
@"<style>"
|
||||
@"body {"
|
||||
@" -webkit-user-select: none;"
|
||||
@" -webkit-text-size-adjust: none;"
|
||||
@" font-family: -apple-system-font;"
|
||||
@" font-size: 17px;"
|
||||
@" color: rgb(125, 127, 127);"
|
||||
@" height: 100%;"
|
||||
@" margin: 0;"
|
||||
@" padding: 0;"
|
||||
@"}"
|
||||
@"p{"
|
||||
@" text-align:center;"
|
||||
@" word-wrap: break-word;"
|
||||
@" margin: 123px 50px 0 50px;"
|
||||
@"}"
|
||||
@"</style>"
|
||||
@"<title>%@</title>"
|
||||
@"</head>"
|
||||
@"<body>"
|
||||
@"<p>%@</p>"
|
||||
@"</body>"
|
||||
@"</html>";
|
||||
if (error.code == -1003 || error.code == -1009) {
|
||||
NSString *html = [NSString stringWithFormat:htmlFormat,
|
||||
@"Cannot Open Page", error.localizedDescription];
|
||||
[self.webView loadHTMLString:html baseURL:self.webView.request.URL];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
- (void)updateButtons {
|
||||
self.refreshButton.hidden = self.webView.loading;
|
||||
self.stopButton.hidden = !self.webView.loading;
|
||||
self.backButton.enabled = self.webView.canGoBack;
|
||||
self.forwardButton.enabled = self.webView.canGoForward;
|
||||
}
|
||||
|
||||
- (void)appendCSSFontFamily {
|
||||
NSString *jsStr = [NSString stringWithFormat:
|
||||
@"var style = document.createElement('style');"
|
||||
"style.type = 'text/css';"
|
||||
"style.innerHTML = '*{font-family:\"%@\" !important;}';"
|
||||
"document.getElementsByTagName('head')[0].appendChild(style);", self.fontFamily];
|
||||
[self.webView stringByEvaluatingJavaScriptFromString:jsStr];
|
||||
}
|
||||
|
||||
- (void)setFontFamily:(NSString *)fontFamily {
|
||||
_fontFamily = fontFamily;
|
||||
_nFontFamily = [NSString stringWithString:fontFamily];
|
||||
}
|
||||
|
||||
- (void)keyboardChanged:(NSNotification *)notification {
|
||||
NSDictionary *kbInfo = [[notification userInfo] objectForKey:kKeymanKeyboardInfoKey];
|
||||
NSString *kbID = [kbInfo objectForKey:kKeymanKeyboardIdKey];
|
||||
NSString *langID = [kbInfo objectForKey:kKeymanLanguageIdKey];
|
||||
NSString *fontName = [[KMManager sharedInstance] fontNameForKeyboardWithID:kbID languageID:langID];
|
||||
if (fontName != nil)
|
||||
_nFontFamily = [NSString stringWithString:fontName];
|
||||
else
|
||||
_nFontFamily = [NSString stringWithString:[UIFont systemFontOfSize:[UIFont systemFontSize]].fontName];
|
||||
}
|
||||
|
||||
- (void)keyboardPickerDismissed:(NSNotification *)notification {
|
||||
if (![_nFontFamily isEqualToString:_fontFamily]) {
|
||||
self.fontFamily = [NSString stringWithString:_nFontFamily];
|
||||
[self.webView reload];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,289 @@
|
|||
//
|
||||
// WebBrowserViewController.swift
|
||||
// Keyman
|
||||
//
|
||||
// Created by Gabriel Wong on 2017-09-05.
|
||||
// Copyright © 2017 SIL International. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
class WebBrowserViewController: UIViewController, UIWebViewDelegate, UIAlertViewDelegate {
|
||||
@IBOutlet var webView: UIWebView!
|
||||
@IBOutlet var navBar: UINavigationBar!
|
||||
@IBOutlet var toolBar: UIToolbar!
|
||||
@IBOutlet var navBarTopConstraint: NSLayoutConstraint!
|
||||
var addressField: UITextField!
|
||||
var rightView: UIView!
|
||||
var refreshButton: UIButton!
|
||||
var stopButton: UIButton!
|
||||
@IBOutlet var backButton: UIBarButtonItem!
|
||||
@IBOutlet var forwardButton: UIBarButtonItem!
|
||||
@IBOutlet var bookmarksButton: UIBarButtonItem!
|
||||
@IBOutlet var globeButton: UIBarButtonItem!
|
||||
@IBOutlet var closeButton: UIBarButtonItem!
|
||||
|
||||
var fontFamily: String = UIFont.systemFont(ofSize: UIFont.systemFontSize).fontName
|
||||
var newFontFamily: String = ""
|
||||
|
||||
let webBrowserLastURLKey = "KMWebBrowserLastURL"
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardChanged), name: NSNotification.Name.keymanKeyboardChanged, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardPickerDismissed), name: NSNotification.Name.keymanKeyboardPickerDismissed, object: nil)
|
||||
|
||||
webView.delegate = self
|
||||
webView.scalesPageToFit = true
|
||||
|
||||
// Setup NavigationBar
|
||||
let screenRect = UIScreen.main.bounds
|
||||
let orientation = UIApplication.shared.statusBarOrientation
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
let size = CGFloat.maximum(screenRect.size.height, screenRect.size.width)
|
||||
if size > 568.0 {
|
||||
// Navbar for iPhone 6 & 6 Plus
|
||||
let bgImg: UIImage?
|
||||
if UIInterfaceOrientationIsPortrait(orientation) {
|
||||
bgImg = UIImage(named: "kmwb-navbar-Portrait.png")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch)
|
||||
}
|
||||
else {
|
||||
bgImg = UIImage(named: "kmwb-navbar-Landscape-568h.png")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch)
|
||||
}
|
||||
navBar.setBackgroundImage(bgImg, for: UIBarMetrics.default)
|
||||
}
|
||||
else if size == 568 {
|
||||
// Navbar for iPhone and iPod Touch with 4" Display
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Portrait.png"), for: UIBarMetrics.default)
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Landscape-568h.png"), for: UIBarMetrics.compact)
|
||||
}
|
||||
else if size < 568.0 {
|
||||
// Navbar for iPhone and iPod Touch with 3.5" Display
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Portrait.png"), for: UIBarMetrics.default)
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Landscape.png"), for: UIBarMetrics.compact)
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Navbar for iPad
|
||||
if UIInterfaceOrientationIsPortrait(orientation) {
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Portrait.png"), for: UIBarMetrics.default)
|
||||
}
|
||||
else {
|
||||
navBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Landscape.png"), for: UIBarMetrics.default)
|
||||
}
|
||||
}
|
||||
|
||||
// Setup address field
|
||||
let addressFrame = CGRect(x: 10, y: 4.0, width: navBar.frame.size.width - 20, height: 28)
|
||||
addressField = UITextField(frame: addressFrame)
|
||||
addressField.clearButtonMode = .whileEditing
|
||||
addressField.rightViewMode = .unlessEditing
|
||||
addressField.autoresizingMask = .flexibleWidth
|
||||
addressField.borderStyle = .roundedRect
|
||||
addressField.autocapitalizationType = .none
|
||||
addressField.autocorrectionType = .no
|
||||
addressField.font = UIFont.systemFont(ofSize: 17)
|
||||
addressField.placeholder = "http://"
|
||||
addressField.text = ""
|
||||
addressField.keyboardType = UIKeyboardType.URL
|
||||
addressField.addTarget(self, action: #selector(self.loadAddress), for: .editingDidEndOnExit)
|
||||
navBar.addSubview(addressField)
|
||||
|
||||
rightView = UIView(frame: CGRect(x: 0, y: 0, width: 40, height: 28))
|
||||
addressField.rightView = rightView
|
||||
|
||||
let refreshSize = CGSize(width: 18, height: 22)
|
||||
let refreshIcon = UIImage(named: "UIButtonBarRefresh.png")?.resize(to: refreshSize).withRenderingMode(.alwaysOriginal)
|
||||
refreshButton = UIButton(type: UIButtonType.system)
|
||||
refreshButton.setImage(refreshIcon, for: .normal)
|
||||
refreshButton.frame = rightView.frame
|
||||
refreshButton.addTarget(self, action: #selector(self.refresh), for: .touchUpInside)
|
||||
refreshButton.isHidden = true
|
||||
rightView.addSubview(refreshButton)
|
||||
|
||||
let stopSize = CGSize(width: 17, height: 17)
|
||||
let stopIcon = UIImage(named: "UIButtonBarStop.png")?.resize(to: stopSize).withRenderingMode(.alwaysOriginal)
|
||||
stopButton = UIButton(type: UIButtonType.system)
|
||||
stopButton.setImage(stopIcon, for: .normal)
|
||||
stopButton.frame = rightView.frame
|
||||
stopButton.addTarget(self, action: #selector(self.stop), for: .touchUpInside)
|
||||
stopButton.isHidden = true
|
||||
rightView.addSubview(stopButton)
|
||||
|
||||
updateButtons()
|
||||
|
||||
let userData = UserDefaults.standard
|
||||
let lastUrlStr = userData.object(forKey: webBrowserLastURLKey) as? String ?? "https://www.google.com/"
|
||||
if let url = URL(string: lastUrlStr) {
|
||||
let request = URLRequest(url: url)
|
||||
webView.loadRequest(request)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
navBarTopConstraint.constant = AppDelegate.statusBarHeight()
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
|
||||
let orientation: UIInterfaceOrientation = toInterfaceOrientation
|
||||
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||
let screenRect: CGRect = UIScreen.main.bounds
|
||||
let size: CGFloat = screenRect.size.height > screenRect.size.width ? screenRect.size.height : screenRect.size.width
|
||||
if size > 568.0 {
|
||||
// Navbar for iPhone 6 & 6 Plus
|
||||
var bgImg: UIImage? = nil
|
||||
if UIInterfaceOrientationIsPortrait(orientation) {
|
||||
bgImg = UIImage(named: "kmwb-navbar-Portrait.png")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch)
|
||||
}
|
||||
else {
|
||||
bgImg = UIImage(named: "kmwb-navbar-Landscape-568h.png")?.resizableImage(withCapInsets: UIEdgeInsetsMake(0, 0, 0, 0), resizingMode: .stretch)
|
||||
}
|
||||
navigationController?.navigationBar.setBackgroundImage(bgImg, for: UIBarMetrics.default)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if UIInterfaceOrientationIsPortrait(orientation) {
|
||||
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Portrait.png"), for: UIBarMetrics.default)
|
||||
}
|
||||
else {
|
||||
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "kmwb-navbar-Landscape.png"), for: UIBarMetrics.default)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func didRotate(from fromInterfaceOrientation: UIInterfaceOrientation) {
|
||||
navBarTopConstraint.constant = AppDelegate.statusBarHeight()
|
||||
}
|
||||
|
||||
func loadAddress(_ sender: Any, event: UIEvent) {
|
||||
guard let urlString = addressField?.text, var url = URL(string: urlString) else {
|
||||
NSLog("Attempting to load invalid URL: %@", addressField?.text ?? "nil")
|
||||
return
|
||||
}
|
||||
if url.scheme == nil {
|
||||
url = URL(string: "http://\(urlString)") ?? url
|
||||
}
|
||||
let request = URLRequest(url: url)
|
||||
webView.loadRequest(request)
|
||||
}
|
||||
|
||||
func updateAddress(_ request: URLRequest) {
|
||||
let url: URL? = request.mainDocumentURL
|
||||
addressField.text = url?.absoluteString
|
||||
let userData = UserDefaults.standard
|
||||
userData.set(url?.absoluteString, forKey: "KMWebBrowserLastURL")
|
||||
userData.synchronize()
|
||||
}
|
||||
|
||||
func refresh(_ sender: Any) {
|
||||
webView.reload()
|
||||
}
|
||||
|
||||
func stop(_ sender: Any?) {
|
||||
webView.stopLoading()
|
||||
}
|
||||
|
||||
@IBAction func back(_ sender: Any) {
|
||||
webView.goBack()
|
||||
}
|
||||
|
||||
@IBAction func forward(_ sender: Any) {
|
||||
webView.goForward()
|
||||
}
|
||||
|
||||
@IBAction func bookmarks(_ sender: Any) {
|
||||
let bookmarksVC = BookmarksViewController()
|
||||
bookmarksVC.webBrowser = self
|
||||
present(bookmarksVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
@IBAction func globe(_ sender: Any) {
|
||||
KMManager.sharedInstance().showKeyboardPicker(in: self, shouldAddKeyboard: false)
|
||||
}
|
||||
|
||||
func close(_ sender: Any?) {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - UIWebViewDelegate methods
|
||||
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
|
||||
updateAddress(request)
|
||||
return true
|
||||
}
|
||||
|
||||
func webViewDidStartLoad(_ webView: UIWebView) {
|
||||
UIApplication.shared.isNetworkActivityIndicatorVisible = true
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
func webViewDidFinishLoad(_ webView: UIWebView) {
|
||||
UIApplication.shared.isNetworkActivityIndicatorVisible = false
|
||||
appendCSSFontFamily()
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
|
||||
UIApplication.shared.isNetworkActivityIndicatorVisible = false
|
||||
updateButtons()
|
||||
let alert = UIAlertView(title: "Cannot Open Page",
|
||||
message: error.localizedDescription,
|
||||
delegate: self,
|
||||
cancelButtonTitle: "OK",
|
||||
otherButtonTitles: "")
|
||||
alert.show()
|
||||
}
|
||||
|
||||
func updateButtons() {
|
||||
refreshButton.isHidden = webView.isLoading
|
||||
stopButton.isHidden = !webView.isLoading
|
||||
backButton.isEnabled = webView.canGoBack
|
||||
forwardButton.isEnabled = webView.canGoForward
|
||||
}
|
||||
|
||||
func appendCSSFontFamily() {
|
||||
let jsStr: String = "var style = document.createElement('style');" +
|
||||
"style.type = 'text/css';" +
|
||||
"style.innerHTML = '*{font-family:\"\(fontFamily)\" !important;}';" +
|
||||
"document.getElementsByTagName('head')[0].appendChild(style);"
|
||||
webView?.stringByEvaluatingJavaScript(from: jsStr)
|
||||
}
|
||||
|
||||
func keyboardChanged(_ notification: Notification) {
|
||||
let kbInfo = notification.userInfo?[kKeymanKeyboardInfoKey] as? [AnyHashable: Any] ?? [AnyHashable: Any]()
|
||||
if let kbID = kbInfo[kKeymanKeyboardIdKey] as? String, let langID = kbInfo[kKeymanLanguageIdKey] as? String {
|
||||
newFontFamily = KMManager.sharedInstance().fontNameForKeyboard(withID: kbID, languageID: langID)
|
||||
}
|
||||
else {
|
||||
newFontFamily = UIFont.systemFont(ofSize: UIFont.systemFontSize).fontName
|
||||
}
|
||||
}
|
||||
|
||||
func keyboardPickerDismissed(_ notification: Notification) {
|
||||
if !(newFontFamily == fontFamily) {
|
||||
fontFamily = newFontFamily
|
||||
webView?.reload()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIImage {
|
||||
func resize(to newSize: CGSize) -> UIImage {
|
||||
let horizontalRatio = newSize.width / size.width
|
||||
let verticalRatio = newSize.height / size.height
|
||||
|
||||
let ratio = max(horizontalRatio, verticalRatio)
|
||||
let newSize = CGSize(width: size.width * ratio, height: size.height * ratio)
|
||||
UIGraphicsBeginImageContextWithOptions(newSize, true, 0)
|
||||
draw(in: CGRect(origin: CGPoint(x: 0, y: 0), size: newSize))
|
||||
let newImage = UIGraphicsGetImageFromCurrentImageContext()
|
||||
UIGraphicsEndImageContext()
|
||||
return newImage!
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KMWebBrowserViewController">
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="WebBrowserViewController">
|
||||
<connections>
|
||||
<outlet property="backButton" destination="qz0-Ws-bAr" id="h4N-ai-HTz"/>
|
||||
<outlet property="bookmarksButton" destination="ioZ-qN-fmA" id="3AD-du-Hqx"/>
|
||||
|
|
@ -31,7 +36,7 @@
|
|||
</navigationBar>
|
||||
<webView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b82-37-gRv">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="460"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</webView>
|
||||
<toolbar opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="e8W-i1-0tJ">
|
||||
<rect key="frame" x="0.0" y="524" width="320" height="44"/>
|
||||
|
|
@ -68,7 +73,7 @@
|
|||
</items>
|
||||
</toolbar>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstItem="b82-37-gRv" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="7td-a1-zrM"/>
|
||||
<constraint firstItem="eMY-54-gDT" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="20" id="BWd-xc-GUc"/>
|
||||
|
|
@ -5,4 +5,3 @@
|
|||
#import "AppDelegate.h"
|
||||
#import "Keyman.h"
|
||||
#import "Reachability.h"
|
||||
#import "KMWebBrowserViewController.h"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#import "MainViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "GetStartedViewController.h"
|
||||
#import "KMWebBrowserViewController.h"
|
||||
#import "KMDropDownListView.h"
|
||||
#import "UIImage+Helpers.h"
|
||||
#import "CoreText/CTFontManager.h"
|
||||
|
|
@ -1534,9 +1533,9 @@ NSUInteger const minIOSVersion4FontInstall = 7;
|
|||
- (void)showKMWebBrowserView:(id)sender {
|
||||
[popover dismissPopoverAnimated:NO];
|
||||
[self dismissDropDownMenu];
|
||||
KMWebBrowserViewController *kmWebBrowserVC = [[KMWebBrowserViewController alloc] init];
|
||||
[kmWebBrowserVC setFontFamily:[[textView font] fontName]];
|
||||
[self presentViewController:kmWebBrowserVC animated:YES completion:nil];
|
||||
WebBrowserViewController *webBrowserVC = [[WebBrowserViewController alloc] init];
|
||||
[webBrowserVC setFontFamily:[[textView font] fontName]];
|
||||
[self presentViewController:webBrowserVC animated:YES completion:nil];
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue