diff --git a/HostingApp/AppDelegate.swift b/HostingApp/AppDelegate.swift index 9c4cef96..be7864d4 100644 --- a/HostingApp/AppDelegate.swift +++ b/HostingApp/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/HostingApp/ViewController.swift b/HostingApp/ViewController.swift index 1aeb8316..275e16a1 100644 --- a/HostingApp/ViewController.swift +++ b/HostingApp/ViewController.swift @@ -15,10 +15,10 @@ class HostingAppViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardWillShow), name: NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardDidHide), name: NSNotification.Name.UIKeyboardDidHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardWillShow), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardDidHide), name: UIResponder.keyboardDidHideNotification, object: nil) //NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillChangeFrame:"), name: UIKeyboardWillChangeFrameNotification, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardDidChangeFrame(_:)), name: NSNotification.Name.UIKeyboardDidChangeFrame, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(HostingAppViewController.keyboardDidChangeFrame(_:)), name: UIResponder.keyboardDidChangeFrameNotification, object: nil) } override func didReceiveMemoryWarning() { @@ -38,13 +38,13 @@ class HostingAppViewController: UIViewController { var secondHeightTime: TimeInterval? var referenceHeight: CGFloat = 216 - func keyboardWillShow() { + @objc func keyboardWillShow() { if startTime == nil { startTime = CACurrentMediaTime() } } - func keyboardDidHide() { + @objc func keyboardDidHide() { startTime = nil firstHeightTime = nil secondHeightTime = nil @@ -52,9 +52,9 @@ class HostingAppViewController: UIViewController { self.stats?.text = "(Waiting for keyboard...)" } - func keyboardDidChangeFrame(_ notification: Notification) { + @objc func keyboardDidChangeFrame(_ notification: Notification) { //let frameBegin: CGRect! = notification.userInfo?[UIKeyboardFrameBeginUserInfoKey]?.CGRectValue - let frameEnd: CGRect! = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as AnyObject).cgRectValue + let frameEnd: CGRect! = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as AnyObject).cgRectValue if frameEnd.height == referenceHeight { if firstHeightTime == nil { diff --git a/Keyboard/Catboard.swift b/Keyboard/Catboard.swift index bfe9034e..c0a9ec1b 100644 --- a/Keyboard/Catboard.swift +++ b/Keyboard/Catboard.swift @@ -40,7 +40,7 @@ class Catboard: KeyboardViewController { if key.type == .character || key.type == .specialCharacter { if let context = textDocumentProxy.documentContextBeforeInput { - if context.characters.count < 2 { + if context.count < 2 { textDocumentProxy.insertText(keyOutput) return } @@ -99,11 +99,11 @@ class Catboard: KeyboardViewController { return CatboardBanner(globalColors: type(of: self).globalColors, darkMode: false, solidColorMode: self.solidColorMode()) } - func takeScreenshotDelay() { + @objc func takeScreenshotDelay() { Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(Catboard.takeScreenshot), userInfo: nil, repeats: false) } - func takeScreenshot() { + @objc func takeScreenshot() { if !self.view.bounds.isEmpty { UIDevice.current.beginGeneratingDeviceOrientationNotifications() @@ -125,7 +125,7 @@ class Catboard: KeyboardViewController { let name = (self.interfaceOrientation.isPortrait ? "Screenshot-Portrait" : "Screenshot-Landscape") let imagePath = "/Users/archagon/Documents/Programming/OSX/RussianPhoneticKeyboard/External/tasty-imitation-keyboard/\(name).png" - if let pngRep = UIImagePNGRepresentation(capturedImage!) { + if let pngRep = capturedImage!.pngData() { try? pngRep.write(to: URL(fileURLWithPath: imagePath), options: [.atomic]) } @@ -137,10 +137,10 @@ class Catboard: KeyboardViewController { func randomCat() -> String { let cats = "πŸ±πŸ˜ΊπŸ˜ΈπŸ˜ΉπŸ˜½πŸ˜»πŸ˜ΏπŸ˜ΎπŸ˜ΌπŸ™€" - let numCats = cats.characters.count + let numCats = cats.count let randomCat = arc4random() % UInt32(numCats) - let index = cats.characters.index(cats.startIndex, offsetBy: Int(randomCat)) + let index = cats.index(cats.startIndex, offsetBy: Int(randomCat)) let character = cats[index] return String(character) diff --git a/Keyboard/CatboardBanner.swift b/Keyboard/CatboardBanner.swift index f15ae9d1..50ec42a1 100644 --- a/Keyboard/CatboardBanner.swift +++ b/Keyboard/CatboardBanner.swift @@ -26,7 +26,7 @@ class CatboardBanner: ExtraView { self.catSwitch.isOn = UserDefaults.standard.bool(forKey: kCatTypeEnabled) self.catSwitch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) - self.catSwitch.addTarget(self, action: #selector(CatboardBanner.respondToSwitch), for: UIControlEvents.valueChanged) + self.catSwitch.addTarget(self, action: #selector(CatboardBanner.respondToSwitch), for: UIControl.Event.valueChanged) self.updateAppearance() } @@ -47,7 +47,7 @@ class CatboardBanner: ExtraView { self.catLabel.frame.origin = CGPoint(x: self.catSwitch.frame.origin.x + self.catSwitch.frame.width + 8, y: self.catLabel.frame.origin.y) } - func respondToSwitch() { + @objc func respondToSwitch() { UserDefaults.standard.set(self.catSwitch.isOn, forKey: kCatTypeEnabled) self.updateAppearance() } diff --git a/Keyboard/DefaultSettings.swift b/Keyboard/DefaultSettings.swift index 63592172..dbd9e738 100644 --- a/Keyboard/DefaultSettings.swift +++ b/Keyboard/DefaultSettings.swift @@ -74,10 +74,10 @@ class DefaultSettings: ExtraView, UITableViewDataSource, UITableViewDelegate { rootView.translatesAutoresizingMaskIntoConstraints = false self.addSubview(rootView) - let left = NSLayoutConstraint(item: rootView, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1, constant: 0) - let right = NSLayoutConstraint(item: rootView, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.right, multiplier: 1, constant: 0) - let top = NSLayoutConstraint(item: rootView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0) - let bottom = NSLayoutConstraint(item: rootView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0) + let left = NSLayoutConstraint(item: rootView, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: 0) + let right = NSLayoutConstraint(item: rootView, attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant: 0) + let top = NSLayoutConstraint(item: rootView, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: 0) + let bottom = NSLayoutConstraint(item: rootView, attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant: 0) self.addConstraint(left) self.addConstraint(right) @@ -88,7 +88,7 @@ class DefaultSettings: ExtraView, UITableViewDataSource, UITableViewDelegate { self.tableView?.register(DefaultSettingsTableViewCell.self, forCellReuseIdentifier: "cell") self.tableView?.estimatedRowHeight = 44; - self.tableView?.rowHeight = UITableViewAutomaticDimension; + self.tableView?.rowHeight = UITableView.automaticDimension; // XXX: this is here b/c a totally transparent background does not support scrolling in blank areas self.tableView?.backgroundColor = UIColor.white.withAlphaComponent(0.01) @@ -126,7 +126,7 @@ class DefaultSettings: ExtraView, UITableViewDataSource, UITableViewDelegate { let key = self.settingsList[indexPath.section].1[indexPath.row] if cell.sw.allTargets.count == 0 { - cell.sw.addTarget(self, action: #selector(DefaultSettings.toggleSetting(_:)), for: UIControlEvents.valueChanged) + cell.sw.addTarget(self, action: #selector(DefaultSettings.toggleSetting(_:)), for: UIControl.Event.valueChanged) } cell.sw.isOn = UserDefaults.standard.bool(forKey: key) @@ -183,7 +183,7 @@ class DefaultSettings: ExtraView, UITableViewDataSource, UITableViewDelegate { } } - func toggleSetting(_ sender: UISwitch) { + @objc func toggleSetting(_ sender: UISwitch) { if let cell = sender.superview as? UITableViewCell { if let indexPath = self.tableView?.indexPath(for: cell) { let key = self.settingsList[indexPath.section].1[indexPath.row] @@ -201,7 +201,7 @@ class DefaultSettingsTableViewCell: UITableViewCell { var constraintsSetForLongLabel: Bool var cellConstraints: [NSLayoutConstraint] - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { self.sw = UISwitch() self.label = UILabel() self.longLabel = UITextView() @@ -241,20 +241,20 @@ class DefaultSettingsTableViewCell: UITableViewCell { let hasLongText = self.longLabel.text != nil && !self.longLabel.text.isEmpty if hasLongText { - let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.right, multiplier: 1, constant: -sideMargin) - let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.top, multiplier: 1, constant: margin) - let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1, constant: sideMargin) - let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: sw, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0) + let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant: -sideMargin) + let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: margin) + let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: sideMargin) + let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: sw, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: 0) self.addConstraint(switchSide) self.addConstraint(switchTop) self.addConstraint(labelSide) self.addConstraint(labelCenter) - let left = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1, constant: sideMargin) - let right = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.right, multiplier: 1, constant: -sideMargin) - let top = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: sw, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: margin) - let bottom = NSLayoutConstraint(item: longLabel, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: -margin) + let left = NSLayoutConstraint(item: longLabel, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: sideMargin) + let right = NSLayoutConstraint(item: longLabel, attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant: -sideMargin) + let top = NSLayoutConstraint(item: longLabel, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: sw, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant: margin) + let bottom = NSLayoutConstraint(item: longLabel, attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant: -margin) self.addConstraint(left) self.addConstraint(right) @@ -266,11 +266,11 @@ class DefaultSettingsTableViewCell: UITableViewCell { self.constraintsSetForLongLabel = true } else { - let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.right, multiplier: 1, constant: -sideMargin) - let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.top, multiplier: 1, constant: margin) - let switchBottom = NSLayoutConstraint(item: sw, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: -margin) - let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self, attribute: NSLayoutAttribute.left, multiplier: 1, constant: sideMargin) - let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: sw, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0) + let switchSide = NSLayoutConstraint(item: sw, attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.right, multiplier: 1, constant: -sideMargin) + let switchTop = NSLayoutConstraint(item: sw, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: margin) + let switchBottom = NSLayoutConstraint(item: sw, attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.bottom, multiplier: 1, constant: -margin) + let labelSide = NSLayoutConstraint(item: label, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: sideMargin) + let labelCenter = NSLayoutConstraint(item: label, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: sw, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: 0) self.addConstraint(switchSide) self.addConstraint(switchTop) diff --git a/Keyboard/ForwardingView.swift b/Keyboard/ForwardingView.swift index 5706487a..c134c033 100644 --- a/Keyboard/ForwardingView.swift +++ b/Keyboard/ForwardingView.swift @@ -15,7 +15,7 @@ class ForwardingView: UIView { override init(frame: CGRect) { super.init(frame: frame) - self.contentMode = UIViewContentMode.redraw + self.contentMode = UIView.ContentMode.redraw self.isMultipleTouchEnabled = true self.isUserInteractionEnabled = true self.isOpaque = false @@ -40,7 +40,7 @@ class ForwardingView: UIView { } } - func handleControl(_ view: UIView?, controlEvent: UIControlEvents) { + func handleControl(_ view: UIView?, controlEvent: UIControl.Event) { if let control = view as? UIControl { let targets = control.allTargets for target in targets { diff --git a/Keyboard/ImageKey.swift b/Keyboard/ImageKey.swift index 436432fd..a0a23dc5 100644 --- a/Keyboard/ImageKey.swift +++ b/Keyboard/ImageKey.swift @@ -18,7 +18,7 @@ class ImageKey: KeyboardKey { didSet { if let imageView = image { self.addSubview(imageView) - imageView.contentMode = UIViewContentMode.scaleAspectFit + imageView.contentMode = UIView.ContentMode.scaleAspectFit self.redrawImage() updateColors() } diff --git a/Keyboard/KeyboardInputTraits.swift b/Keyboard/KeyboardInputTraits.swift index 5b2ada50..43706db8 100644 --- a/Keyboard/KeyboardInputTraits.swift +++ b/Keyboard/KeyboardInputTraits.swift @@ -25,10 +25,10 @@ extension KeyboardViewController { // note that KVO doesn't work on textDocumentProxy, so we have to poll traitPollingTimer?.invalidate() traitPollingTimer = UIScreen.main.displayLink(withTarget: self, selector: #selector(KeyboardViewController.pollTraits)) - traitPollingTimer?.add(to: RunLoop.current, forMode: RunLoopMode.defaultRunLoopMode) + traitPollingTimer?.add(to: RunLoop.current, forMode: RunLoop.Mode.default) } - func pollTraits() { + @objc func pollTraits() { let proxy = self.textDocumentProxy if let layout = self.layout { diff --git a/Keyboard/KeyboardKey.swift b/Keyboard/KeyboardKey.swift index 58ddffbe..7c866b0a 100644 --- a/Keyboard/KeyboardKey.swift +++ b/Keyboard/KeyboardKey.swift @@ -450,7 +450,7 @@ class KeyboardKey: UIControl { } } - func hidePopup() { + @objc func hidePopup() { if self.popup != nil { self.delegate?.willHidePopup(for: self) diff --git a/Keyboard/KeyboardViewController.swift b/Keyboard/KeyboardViewController.swift index 45cbc687..6b9c3a92 100644 --- a/Keyboard/KeyboardViewController.swift +++ b/Keyboard/KeyboardViewController.swift @@ -125,7 +125,7 @@ class KeyboardViewController: UIInputViewController { NotificationCenter.default.removeObserver(self) } - func defaultsChanged(_ notification: Notification) { + @objc func defaultsChanged(_ notification: Notification) { //let defaults = notification.object as? NSUserDefaults self.updateKeyCaps(self.shiftState.uppercase()) } @@ -139,10 +139,10 @@ class KeyboardViewController: UIInputViewController { kludge.translatesAutoresizingMaskIntoConstraints = false kludge.isHidden = true - let a = NSLayoutConstraint(item: kludge, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.left, multiplier: 1, constant: 0) - let b = NSLayoutConstraint(item: kludge, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.left, multiplier: 1, constant: 0) - let c = NSLayoutConstraint(item: kludge, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0) - let d = NSLayoutConstraint(item: kludge, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0) + let a = NSLayoutConstraint(item: kludge, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: 0) + let b = NSLayoutConstraint(item: kludge, attribute: NSLayoutConstraint.Attribute.right, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: 0) + let c = NSLayoutConstraint(item: kludge, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: 0) + let d = NSLayoutConstraint(item: kludge, attribute: NSLayoutConstraint.Attribute.bottom, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: 0) self.view.addConstraints([a, b, c, d]) self.kludge = kludge @@ -199,7 +199,7 @@ class KeyboardViewController: UIInputViewController { } func solidColorMode() -> Bool { - return UIAccessibilityIsReduceTransparencyEnabled() + return UIAccessibility.isReduceTransparencyEnabled } var lastLayoutBounds: CGRect? @@ -315,7 +315,7 @@ class KeyboardViewController: UIInputViewController { for rowKeys in page.rows { // TODO: quick hack for key in rowKeys { if let keyView = self.layout?.viewForKey(key) { - keyView.removeTarget(nil, action: nil, for: UIControlEvents.allEvents) + keyView.removeTarget(nil, action: nil, for: UIControl.Event.allEvents) switch key.type { case Key.KeyType.keyboardChange: @@ -323,7 +323,7 @@ class KeyboardViewController: UIInputViewController { action: #selector(KeyboardViewController.advanceTapped(_:)), for: .touchUpInside) case Key.KeyType.backspace: - let cancelEvents: UIControlEvents = [UIControlEvents.touchUpInside, UIControlEvents.touchUpInside, UIControlEvents.touchDragExit, UIControlEvents.touchUpOutside, UIControlEvents.touchCancel, UIControlEvents.touchDragOutside] + let cancelEvents: UIControl.Event = [UIControl.Event.touchUpInside, UIControl.Event.touchUpInside, UIControl.Event.touchDragExit, UIControl.Event.touchUpOutside, UIControl.Event.touchCancel, UIControl.Event.touchDragOutside] keyView.addTarget(self, action: #selector(KeyboardViewController.backspaceDown(_:)), @@ -398,14 +398,14 @@ class KeyboardViewController: UIInputViewController { var keyWithDelayedPopup: KeyboardKey? var popupDelayTimer: Timer? - func showPopup(_ sender: KeyboardKey) { + @objc func showPopup(_ sender: KeyboardKey) { if sender == self.keyWithDelayedPopup { self.popupDelayTimer?.invalidate() } sender.showPopup() } - func hidePopupDelay(_ sender: KeyboardKey) { + @objc func hidePopupDelay(_ sender: KeyboardKey) { self.popupDelayTimer?.invalidate() if sender != self.keyWithDelayedPopup { @@ -418,7 +418,7 @@ class KeyboardViewController: UIInputViewController { } } - func hidePopupCallback() { + @objc func hidePopupCallback() { self.keyWithDelayedPopup?.hidePopup() self.keyWithDelayedPopup = nil self.popupDelayTimer = nil @@ -447,13 +447,13 @@ class KeyboardViewController: UIInputViewController { if self.heightConstraint == nil { self.heightConstraint = NSLayoutConstraint( item:self.view, - attribute:NSLayoutAttribute.height, - relatedBy:NSLayoutRelation.equal, + attribute:NSLayoutConstraint.Attribute.height, + relatedBy:NSLayoutConstraint.Relation.equal, toItem:nil, - attribute:NSLayoutAttribute.notAnAttribute, + attribute:NSLayoutConstraint.Attribute.notAnAttribute, multiplier:0, constant:height) - self.heightConstraint!.priority = 1000 + self.heightConstraint!.priority = UILayoutPriority(rawValue: 1000) self.view.addConstraint(self.heightConstraint!) // TODO: what if view already has constraint added? } @@ -471,15 +471,15 @@ class KeyboardViewController: UIInputViewController { self.settingsView?.darkMode = appearanceIsDark } - func highlightKey(_ sender: KeyboardKey) { + @objc func highlightKey(_ sender: KeyboardKey) { sender.isHighlighted = true } - func unHighlightKey(_ sender: KeyboardKey) { + @objc func unHighlightKey(_ sender: KeyboardKey) { sender.isHighlighted = false } - func keyPressedHelper(_ sender: KeyboardKey) { + @objc func keyPressedHelper(_ sender: KeyboardKey) { if let model = self.layout?.keyForView(sender) { self.keyPressed(model) @@ -518,7 +518,7 @@ class KeyboardViewController: UIInputViewController { let charactersAreInCorrectState = { () -> Bool in let previousContext = self.textDocumentProxy.documentContextBeforeInput - if previousContext == nil || (previousContext!).characters.count < 3 { + if previousContext == nil || previousContext!.count < 3 { return false } @@ -566,7 +566,7 @@ class KeyboardViewController: UIInputViewController { self.backspaceRepeatTimer = nil } - func backspaceDown(_ sender: KeyboardKey) { + @objc func backspaceDown(_ sender: KeyboardKey) { self.cancelBackspaceTimers() self.textDocumentProxy.deleteBackward() @@ -576,23 +576,23 @@ class KeyboardViewController: UIInputViewController { self.backspaceDelayTimer = Timer.scheduledTimer(timeInterval: backspaceDelay - backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceDelayCallback), userInfo: nil, repeats: false) } - func backspaceUp(_ sender: KeyboardKey) { + @objc func backspaceUp(_ sender: KeyboardKey) { self.cancelBackspaceTimers() } - func backspaceDelayCallback() { + @objc func backspaceDelayCallback() { self.backspaceDelayTimer = nil self.backspaceRepeatTimer = Timer.scheduledTimer(timeInterval: backspaceRepeat, target: self, selector: #selector(KeyboardViewController.backspaceRepeatCallback), userInfo: nil, repeats: true) } - func backspaceRepeatCallback() { + @objc func backspaceRepeatCallback() { self.playKeySound() self.textDocumentProxy.deleteBackward() self.updateCapsIfNeeded() } - func shiftDown(_ sender: KeyboardKey) { + @objc func shiftDown(_ sender: KeyboardKey) { self.shiftStartingState = self.shiftState if let shiftStartingState = self.shiftStartingState { @@ -615,7 +615,7 @@ class KeyboardViewController: UIInputViewController { } } - func shiftUp(_ sender: KeyboardKey) { + @objc func shiftUp(_ sender: KeyboardKey) { if self.shiftWasMultitapped { // do nothing } @@ -643,7 +643,7 @@ class KeyboardViewController: UIInputViewController { self.shiftWasMultitapped = false } - func shiftDoubleTapped(_ sender: KeyboardKey) { + @objc func shiftDoubleTapped(_ sender: KeyboardKey) { self.shiftWasMultitapped = true switch self.shiftState { @@ -661,7 +661,7 @@ class KeyboardViewController: UIInputViewController { self.layout?.updateKeyCaps(false, uppercase: uppercase, characterUppercase: characterUppercase, shiftState: self.shiftState) } - func modeChangeTapped(_ sender: KeyboardKey) { + @objc func modeChangeTapped(_ sender: KeyboardKey) { if let toMode = self.layout?.viewToModel[sender]?.toMode { self.currentMode = toMode } @@ -679,7 +679,7 @@ class KeyboardViewController: UIInputViewController { self.setupKeys() } - func advanceTapped(_ sender: KeyboardKey) { + @objc func advanceTapped(_ sender: KeyboardKey) { self.forwardingView.resetTrackedViews() self.shiftStartingState = nil self.shiftWasMultitapped = false @@ -699,10 +699,10 @@ class KeyboardViewController: UIInputViewController { aSettings.translatesAutoresizingMaskIntoConstraints = false - let widthConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.width, multiplier: 1, constant: 0) - let heightConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.height, multiplier: 1, constant: 0) - let centerXConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0) - let centerYConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0) + let widthConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant: 0) + let heightConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.height, multiplier: 1, constant: 0) + let centerXConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0) + let centerYConstraint = NSLayoutConstraint(item: aSettings, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: self.view, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: 0) self.view.addConstraint(widthConstraint) self.view.addConstraint(heightConstraint) @@ -758,7 +758,7 @@ class KeyboardViewController: UIInputViewController { func stringIsWhitespace(_ string: String?) -> Bool { if string != nil { - for char in (string!).characters { + for char in (string!) { if !characterIsWhitespace(char) { return false } @@ -782,7 +782,7 @@ class KeyboardViewController: UIInputViewController { return false case .words: if let beforeContext = documentProxy.documentContextBeforeInput { - let previousCharacter = beforeContext[beforeContext.characters.index(before: beforeContext.endIndex)] + let previousCharacter = beforeContext[beforeContext.index(before: beforeContext.endIndex)] return self.characterIsWhitespace(previousCharacter) } else { @@ -791,7 +791,7 @@ class KeyboardViewController: UIInputViewController { case .sentences: if let beforeContext = documentProxy.documentContextBeforeInput { - let offset = min(3, beforeContext.characters.count) + let offset = min(3, beforeContext.count) var index = beforeContext.endIndex for i in 0 ..< offset { @@ -830,8 +830,8 @@ class KeyboardViewController: UIInputViewController { } } - // this only works if full access is enabled - func playKeySound() { + // this only works if full acce@objc ss is enabled + @objc func playKeySound() { if !UserDefaults.standard.bool(forKey: kKeyboardClicks) { return } @@ -864,7 +864,7 @@ class KeyboardViewController: UIInputViewController { func createSettings() -> ExtraView? { // note that dark mode is not yet valid here, so we just put false for clarity let settingsView = DefaultSettings(globalColors: type(of: self).globalColors, darkMode: false, solidColorMode: self.solidColorMode()) - settingsView.backButton?.addTarget(self, action: #selector(KeyboardViewController.toggleSettings), for: UIControlEvents.touchUpInside) + settingsView.backButton?.addTarget(self, action: #selector(KeyboardViewController.toggleSettings), for: UIControl.Event.touchUpInside) return settingsView } } diff --git a/TastyImitationKeyboard.xcodeproj/project.pbxproj b/TastyImitationKeyboard.xcodeproj/project.pbxproj index e7c78cf3..a071b793 100644 --- a/TastyImitationKeyboard.xcodeproj/project.pbxproj +++ b/TastyImitationKeyboard.xcodeproj/project.pbxproj @@ -393,7 +393,7 @@ TargetAttributes = { 4E807D9219461D9000D875D1 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0810; + LastSwiftMigration = 1130; }; 4E807DB819461DC700D875D1 = { CreatedOnToolsVersion = 6.0; @@ -410,6 +410,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -576,7 +577,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; METAL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -622,7 +623,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; METAL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -638,10 +639,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; INFOPLIST_FILE = HostingApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -652,10 +655,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; INFOPLIST_FILE = HostingApp/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -664,11 +669,12 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Keyboard/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.HostingApp.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Keyboard; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -677,11 +683,12 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = Keyboard/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.HostingApp.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = Keyboard; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -702,13 +709,13 @@ ); INFOPLIST_FILE = KeyboardFramework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -727,13 +734,13 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = KeyboardFramework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "Archagon.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = "";