diff --git a/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift index a7ef750489..8202b42ae6 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/InputViewController.swift @@ -27,8 +27,6 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { var globeKeyTapBehaviour = GlobeKeyTapBehaviour.switchToNextKeyboard var menuBehaviour = MenuBehaviour.showAlways - open var topBarImageView: UIImageView? - var _isSystemKeyboard: Bool var isSystemKeyboard: Bool { return _isSystemKeyboard; @@ -45,12 +43,12 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { return UIScreen.main.bounds.width < UIScreen.main.bounds.height } - open class var topBarHeight: Int { - if InputViewController.isPortrait { - return 41 - } - return UIDevice.current.userInterfaceIdiom == .phone ? 34 : 39 - } +// open class var topBarHeight: Int { +// if InputViewController.isPortrait { +// return 41 +// } +// return UIDevice.current.userInterfaceIdiom == .phone ? 34 : 39 +// } open override var hasFullAccess: Bool { return Storage.shared != nil @@ -62,7 +60,7 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { // TODO: Consider deleting this. private var expandedHeight: CGFloat { - return keymanWeb.keyboardHeight + activeTopBarHeight + return keymanWeb.keyboardHeight //+ activeTopBarHeight } public convenience init() { @@ -119,13 +117,6 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { keymanWeb.delegate = self - // Fixes debugging issue - views added later are moved to the front. - topBarImageView?.removeFromSuperview() - topBarImageView = UIImageView() - topBarImageView!.translatesAutoresizingMaskIntoConstraints = false - topBarImageView!.backgroundColor = UIColor.gray - baseView.addSubview(topBarImageView!) - baseView.addSubview(keymanWeb.view) //view = baseView @@ -293,47 +284,20 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { baseWidthConstraint.isActive = true } - public var activeTopBarHeight: CGFloat { - // If 'isSystemKeyboard' is true, always show the top bar. - return isSystemKeyboard ? CGFloat(InputViewController.topBarHeight) : 0 - } +// public var activeTopBarHeight: CGFloat { +// // If 'isSystemKeyboard' is true, always show the top bar. +// return isSystemKeyboard ? CGFloat(InputViewController.topBarHeight) : 0 +// } public var kmwHeight: CGFloat { return keymanWeb.keyboardHeight } private func setInnerConstraints() { - let topBar = topBarImageView! let container = keymanWeb.view! - - // Establish a consistent set of constraints for the top bar. - if #available(iOSApplicationExtension 11.0, *) { - topBar.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true - topBar.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true - topBar.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true - - // Allow this one to be broken if/as necessary to resolve layout issues. - let topBarWidthConstraint = topBar.widthAnchor.constraint(equalTo: view.safeAreaLayoutGuide.widthAnchor) - topBarWidthConstraint.priority = .defaultHigh - topBarWidthConstraint.isActive = true - } else { - topBar.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor).isActive = true - topBar.leftAnchor.constraint(equalTo: view.layoutMarginsGuide.leftAnchor).isActive = true - topBar.rightAnchor.constraint(equalTo: view.layoutMarginsGuide.rightAnchor).isActive = true - - // Allow this one to be broken if/as necessary to resolve layout issues. - let topBarWidthConstraint = topBar.widthAnchor.constraint(equalTo: view.layoutMarginsGuide.widthAnchor) - topBarWidthConstraint.priority = .defaultHigh - topBarWidthConstraint.isActive = true - } - - topBar.heightAnchor.constraint(equalToConstant: activeTopBarHeight).isActive = true - - // Establishes a set of constraints for the keyboard's container, supporting autoresizing of - // the keyboard's WebView via its constraints. - container.topAnchor.constraint(equalTo:topBar.bottomAnchor).isActive = true if #available(iOSApplicationExtension 11.0, *) { + container.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true container.bottomAnchor.constraint(equalTo:view.safeAreaLayoutGuide.bottomAnchor).isActive = true container.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true container.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true @@ -344,6 +308,7 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { kbdWidthConstraint.isActive = true } else { // Fallback on earlier versions + container.topAnchor.constraint(equalTo:view.layoutMarginsGuide.topAnchor).isActive = true container.bottomAnchor.constraint(equalTo:view.layoutMarginsGuide.bottomAnchor).isActive = true container.leftAnchor.constraint(equalTo:view.layoutMarginsGuide.leftAnchor).isActive = true container.rightAnchor.constraint(equalTo:view.layoutMarginsGuide.rightAnchor).isActive = true @@ -355,9 +320,9 @@ open class InputViewController: UIInputViewController, KeymanWebDelegate { } // Cannot be met by the in-app keyboard, but helps to 'force' height for the system keyboard. - let portraitHeight = container.heightAnchor.constraint(equalToConstant: keymanWeb.constraintTargetHeight(isPortrait: true)) + let portraitHeight = container.heightAnchor.constraint(equalToConstant: keymanWeb.constraintTargetHeight(isPortrait: true) + 40) portraitHeight.priority = .defaultHigh - let landscapeHeight = container.heightAnchor.constraint(equalToConstant: keymanWeb.constraintTargetHeight(isPortrait: false)) + let landscapeHeight = container.heightAnchor.constraint(equalToConstant: keymanWeb.constraintTargetHeight(isPortrait: false) + 40) landscapeHeight.priority = .defaultHigh portraitConstraint = portraitHeight diff --git a/ios/engine/KMEI/KeymanEngine/Classes/KeyPreviewView.swift b/ios/engine/KMEI/KeymanEngine/Classes/KeyPreviewView.swift index 15973ef935..547d57d6de 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/KeyPreviewView.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/KeyPreviewView.swift @@ -35,10 +35,10 @@ class KeyPreviewView: UIView { var viewPosX = keyFrame.origin.x - (viewWidth - keyFrame.width) / 2.0 var viewPosY = keyFrame.origin.y - (viewHeight - keyFrame.height) - let tbHeight = Manager.shared.inputViewController.activeTopBarHeight - if Manager.shared.isSystemKeyboard && (viewPosY < -tbHeight) { - adjY = viewPosY + tbHeight - viewPosY = CGFloat(-tbHeight) + //let tbHeight = Manager.shared.inputViewController.activeTopBarHeight + if Manager.shared.isSystemKeyboard /*&& (viewPosY < -tbHeight)*/ { + adjY = viewPosY /*+ tbHeight*/ + viewPosY = /*CGFloat(-tbHeight)*/ 0 viewHeight += adjY } else { adjY = 0 diff --git a/ios/engine/KMEI/KeymanEngine/Classes/KeyboardMenuView.swift b/ios/engine/KMEI/KeymanEngine/Classes/KeyboardMenuView.swift index 654640a858..a3fbc450c4 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/KeyboardMenuView.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/KeyboardMenuView.swift @@ -19,7 +19,7 @@ class KeyboardMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGe private let fontSize: CGFloat private let xLength: CGFloat private var adjX: CGFloat = 0 - private let topBarHeight: CGFloat + //private let topBarHeight: CGFloat private var tableView: UITableView? private let closeButtonTitle: String? @@ -65,7 +65,7 @@ class KeyboardMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGe _inputViewController = inputViewController self.closeButtonTitle = closeButtonTitle - topBarHeight = inputViewController.activeTopBarHeight + //topBarHeight = inputViewController.activeTopBarHeight keyFrame = frame rowHeight = UIDevice.current.userInterfaceIdiom == .phone ? 30 : 60 fontSize = UIDevice.current.userInterfaceIdiom == .phone ? 14 : 21 @@ -79,7 +79,7 @@ class KeyboardMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGe let containerWidth = maxWidth - strokeWidth * 2 var containerHeight = CGFloat(tableList.count) * rowHeight - let vHeight = Manager.shared.inputViewController.kmwHeight + topBarHeight + let vHeight = Manager.shared.inputViewController.kmwHeight //+ topBarHeight let bY = Manager.shared.inputViewController.kmwHeight - (keyFrame.origin.y + baseHeight) if containerHeight + baseHeight > vHeight - bY { @@ -91,7 +91,7 @@ class KeyboardMenuView: UIView, UITableViewDelegate, UITableViewDataSource, UIGe let viewWidth = maxWidth let viewHeight = baseHeight + containerHeight + strokeWidth var viewPosX = keyFrame.origin.x - (viewWidth - keyFrame.size.width) / 2.0 - let viewPosY = (keyFrame.origin.y + topBarHeight) - (viewHeight - keyFrame.size.height) + let viewPosY = (keyFrame.origin.y /*+ topBarHeight*/) - (viewHeight - keyFrame.size.height) if viewPosX < 0 { if (keyFrame.origin.x - borderRadius * 1.0) < 0 { diff --git a/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift b/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift index 8a919c70bc..a55de747b6 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/KeymanWebViewController.swift @@ -169,7 +169,8 @@ extension KeymanWebViewController { } func setOskHeight(_ height: Int) { - webView?.evaluateJavaScript("setOskHeight(\(height));", completionHandler: nil) + let h = height - 40 + webView?.evaluateJavaScript("setOskHeight(\(h));", completionHandler: nil) } func setPopupVisible(_ visible: Bool) { @@ -455,7 +456,7 @@ extension KeymanWebViewController: KeymanWebDelegate { func showKeyPreview(_ view: KeymanWebViewController, keyFrame: CGRect, preview: String) { if UIDevice.current.userInterfaceIdiom == .pad - || (Util.isSystemKeyboard && Manager.shared.inputViewController.activeTopBarHeight == 0) + || (Util.isSystemKeyboard /*&& Manager.shared.inputViewController.activeTopBarHeight == 0*/) || isSubKeysMenuVisible { return } diff --git a/ios/engine/KMEI/KeymanEngine/Classes/SubKeysView.swift b/ios/engine/KMEI/KeymanEngine/Classes/SubKeysView.swift index 8515ef70db..add2ca2ac9 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/SubKeysView.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/SubKeysView.swift @@ -58,10 +58,10 @@ class SubKeysView: UIView { } let kbHeight = Manager.shared.inputViewController.kmwHeight - let tbHeight = Manager.shared.inputViewController.activeTopBarHeight + //let tbHeight = Manager.shared.inputViewController.activeTopBarHeight var maxContainerHeight = (screenHeight - kbHeight) + keyFrame.origin.y - strokeWidth if isSystemKeyboard { - maxContainerHeight = keyFrame.origin.y + tbHeight - strokeWidth + maxContainerHeight = keyFrame.origin.y /*+ tbHeight*/ - strokeWidth } var columns = Int((screenWidth - marginX) / (maxButtonSize.width + marginX)) @@ -93,9 +93,9 @@ class SubKeysView: UIView { var viewPosY = keyFrame.origin.y - (viewHeight - keyFrame.size.height) adjX = 0 adjY = 0 - if isSystemKeyboard && (viewPosY < -tbHeight) { - adjY = viewPosY + tbHeight - viewPosY = -tbHeight + if isSystemKeyboard /*&& (viewPosY < -tbHeight)*/ { + adjY = viewPosY /*+ tbHeight*/ + viewPosY = /*-tbHeight*/ 0 viewHeight += adjY } diff --git a/ios/engine/KMEI/KeymanEngine/resources/Keyman.bundle/Contents/Resources/keyboard.html b/ios/engine/KMEI/KeymanEngine/resources/Keyman.bundle/Contents/Resources/keyboard.html index 817aa21fd1..7cd3c8b128 100644 --- a/ios/engine/KMEI/KeymanEngine/resources/Keyman.bundle/Contents/Resources/keyboard.html +++ b/ios/engine/KMEI/KeymanEngine/resources/Keyman.bundle/Contents/Resources/keyboard.html @@ -31,15 +31,27 @@ function init() { var kmw=window['keyman']; - kmw.init({'app':device,'fonts':'fonts/'}); - kmw['util']['setOption']('attachType','manual'); - kmw['oninserttext'] = insertText; - kmw['showKeyboardList'] = menuKeyDown; - kmw['hideKeyboard'] = hideKeyboard; - kmw['getOskHeight'] = getOskHeight; - kmw['getOskWidth'] = getOskWidth; - kmw['beepKeyboard'] = beepKeyboard; - kmw['setActiveElement']('ta'); + // We could convert to relying on the promise, but the underlying input element + // tends to show a bit due to the delay when we do so. + kmw.init({'app':device,'fonts':'fonts/'});//.then(function() { + kmw['util']['setOption']('attachType','manual'); + kmw['oninserttext'] = insertText; + kmw['showKeyboardList'] = menuKeyDown; + kmw['hideKeyboard'] = hideKeyboard; + kmw['getOskHeight'] = getOskHeight; + kmw['getOskWidth'] = getOskWidth; + kmw['beepKeyboard'] = beepKeyboard; + kmw['setActiveElement']('ta'); + + kmw.osk.banner.setOptions({ + 'persistentBanner': true, + 'imagePath': 'keyboard_icon.png' // Need to route the actual banner image here. This is very temp. + }); + + // // TODO: Delete this. Useful for rough exploratory testing - can show suggestion bar here with this. + // kmw.osk.banner.setBanner('suggestion') + // kmw.osk.banner.activeBanner.updateSuggestions([{displayAs: 'a'}, {displayAs: 'b'}, {displayAs: 'c'}]) + //}); } function setDeviceType(deviceType) { diff --git a/ios/keyman/Keyman/SWKeyboard/KeyboardViewController.swift b/ios/keyman/Keyman/SWKeyboard/KeyboardViewController.swift index 8ca38c84e1..897e9d6ae6 100644 --- a/ios/keyman/Keyman/SWKeyboard/KeyboardViewController.swift +++ b/ios/keyman/Keyman/SWKeyboard/KeyboardViewController.swift @@ -47,23 +47,23 @@ class KeyboardViewController: InputViewController { } func setupTopBarImage(isPortrait: Bool) { - if isPortrait { - topBarImageView?.image = #imageLiteral(resourceName: "banner-Portrait.png") - return - } - - // iPad - if UIDevice.current.userInterfaceIdiom != UIUserInterfaceIdiom.phone { - topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape.png") - return - } - - // iPhone - let screenRect = UIScreen.main.bounds - if CGFloat.maximum(screenRect.height, screenRect.width) >= 568.0 { - topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape-568h.png") - } else { - topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape.png") - } +// if isPortrait { +// topBarImageView?.image = #imageLiteral(resourceName: "banner-Portrait.png") +// return +// } +// +// // iPad +// if UIDevice.current.userInterfaceIdiom != UIUserInterfaceIdiom.phone { +// topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape.png") +// return +// } +// +// // iPhone +// let screenRect = UIScreen.main.bounds +// if CGFloat.maximum(screenRect.height, screenRect.width) >= 568.0 { +// topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape-568h.png") +// } else { +// topBarImageView?.image = #imageLiteral(resourceName: "banner-Landscape.png") +// } } } diff --git a/web/source/osk/banner.ts b/web/source/osk/banner.ts index 2bd3dad353..4624c057c6 100644 --- a/web/source/osk/banner.ts +++ b/web/source/osk/banner.ts @@ -114,12 +114,14 @@ namespace com.keyman.osk { super(0); } + console.log("Loading img with src '" + imagePath + "'"); this.img = document.createElement('img'); this.img.setAttribute('src', imagePath); let ds = this.img.style; ds.width = '100%'; ds.height = '100%'; this.getDiv().appendChild(this.img); + console.log("Image loaded."); } /** diff --git a/web/source/resources/osk/kmwosk.css b/web/source/resources/osk/kmwosk.css index 5bc8a176e5..612b8486d3 100644 --- a/web/source/resources/osk/kmwosk.css +++ b/web/source/resources/osk/kmwosk.css @@ -330,11 +330,11 @@ div.android #keytip {background-color:#f00;} height: 100% !important; } -.kmw-embedded .ios.kmw-osk-frame {top:0 !important;bottom:initial !important; width:100% !important;} +.kmw-embedded .ios.kmw-osk-frame {bottom:0 !important; width:100% !important;} .kmw-embedded .ios.kmw-osk-frame {position: absolute !important;} -.kmw-embedded .ios.kmw-osk-frame .kmw-key-layer-group {position: absolute !important; top: 0 !important; bottom: initial !important;} +.kmw-embedded .ios.kmw-osk-frame .kmw-key-layer-group {position: absolute !important; /*top: 0 !important;*/ bottom: 0 !important;} .kmw-embedded .ios.kmw-osk-frame .kmw-key-layer {position: absolute !important; top: 0 !important; bottom: initial !important;}