mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-05 23:27:40 +00:00
Use Swift 4 in KMEI
This commit is contained in:
parent
2a4d4dae41
commit
d28779f356
9 changed files with 49 additions and 47 deletions
|
|
@ -820,7 +820,7 @@
|
|||
};
|
||||
F243887D14BBD43000A3E055 = {
|
||||
DevelopmentTeam = 3YE4W86L3G;
|
||||
LastSwiftMigration = 0830;
|
||||
LastSwiftMigration = 0900;
|
||||
ProvisioningStyle = Automatic;
|
||||
SystemCapabilities = {
|
||||
com.apple.ApplicationGroups.iOS = {
|
||||
|
|
@ -1247,7 +1247,8 @@
|
|||
SDKROOT = iphoneos;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "KeymanEngine/KMEI-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
VALID_ARCHS = "arm64 armv7 armv7s";
|
||||
};
|
||||
name = Debug;
|
||||
|
|
@ -1273,7 +1274,8 @@
|
|||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "KeymanEngine/KMEI-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
|
||||
SWIFT_VERSION = 4.0;
|
||||
VALID_ARCHS = "arm64 armv7 armv7s";
|
||||
};
|
||||
name = Release;
|
||||
|
|
|
|||
|
|
@ -12,30 +12,30 @@
|
|||
}
|
||||
|
||||
class HTTPDownloadRequest: NSObject {
|
||||
let url: URL
|
||||
let typeCode: DownloadType
|
||||
let userInfo: [String: Any]
|
||||
@objc let url: URL
|
||||
@objc let typeCode: DownloadType
|
||||
@objc let userInfo: [String: Any]
|
||||
var task: URLSessionTask?
|
||||
var destinationFile: String?
|
||||
var rawResponseData: Data?
|
||||
var tag: Int = 0
|
||||
@objc var destinationFile: String?
|
||||
@objc var rawResponseData: Data?
|
||||
@objc var tag: Int = 0
|
||||
|
||||
init(url: URL, downloadType type: DownloadType, userInfo info: [String: Any]) {
|
||||
@objc init(url: URL, downloadType type: DownloadType, userInfo info: [String: Any]) {
|
||||
self.url = url
|
||||
typeCode = type
|
||||
userInfo = info
|
||||
super.init()
|
||||
}
|
||||
|
||||
convenience init(url: URL) {
|
||||
@objc convenience init(url: URL) {
|
||||
self.init(url: url, downloadType: DownloadType.downloadFile, userInfo: [:])
|
||||
}
|
||||
|
||||
convenience init(url: URL, userInfo info: [String: Any]) {
|
||||
@objc convenience init(url: URL, userInfo info: [String: Any]) {
|
||||
self.init(url: url, downloadType: DownloadType.downloadFile, userInfo: info)
|
||||
}
|
||||
|
||||
convenience init(url: URL, downloadType type: DownloadType) {
|
||||
@objc convenience init(url: URL, downloadType type: DownloadType) {
|
||||
self.init(url: url, downloadType: type, userInfo: [:])
|
||||
}
|
||||
|
||||
|
|
@ -47,21 +47,21 @@ class HTTPDownloadRequest: NSObject {
|
|||
}
|
||||
|
||||
// TODO: Remove
|
||||
var responseStatusCodeObjc: Int {
|
||||
@objc var responseStatusCodeObjc: Int {
|
||||
if let code = responseStatusCode {
|
||||
return code
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
var responseStatusMessage: String? {
|
||||
@objc var responseStatusMessage: String? {
|
||||
guard let statusCode = responseStatusCode else {
|
||||
return nil
|
||||
}
|
||||
return HTTPURLResponse.localizedString(forStatusCode: statusCode)
|
||||
}
|
||||
|
||||
var error: Error? {
|
||||
@objc var error: Error? {
|
||||
return task?.error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS
|
|||
weak var handler: HTTPDownloadDelegate?
|
||||
var currentRequest: HTTPDownloadRequest?
|
||||
var downloadSession: URLSession!
|
||||
var userInfo: [String: Any] = [:]
|
||||
@objc var userInfo: [String: Any] = [:]
|
||||
|
||||
init(_ handler: HTTPDownloadDelegate?) {
|
||||
@objc init(_ handler: HTTPDownloadDelegate?) {
|
||||
super.init()
|
||||
self.handler = handler
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS
|
|||
downloadSession = URLSession(configuration: config, delegate: self, delegateQueue: nil)
|
||||
}
|
||||
|
||||
func addRequest(_ request: HTTPDownloadRequest) {
|
||||
@objc func addRequest(_ request: HTTPDownloadRequest) {
|
||||
queue.append(request)
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS
|
|||
}
|
||||
|
||||
// Starts the queue. The queue is managed via event messages in order to process them sequentially.
|
||||
func run() {
|
||||
@objc func run() {
|
||||
if !queue.isEmpty {
|
||||
runRequest()
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS
|
|||
}
|
||||
}
|
||||
|
||||
func cancelAllOperations() {
|
||||
@objc func cancelAllOperations() {
|
||||
while !queue.isEmpty {
|
||||
_ = popRequest()
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ class HTTPDownloader: NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLS
|
|||
}
|
||||
}
|
||||
|
||||
var requestsCount: Int {
|
||||
@objc var requestsCount: Int {
|
||||
return queue.count
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class KeyboardPickerBarButtonItem: UIBarButtonItem {
|
|||
// - since the keyboard picker is modal, a UIViewController must be supplied to display it
|
||||
// - the button has default images for normal and landscape orientations
|
||||
// - these can be overridden with other images or a title
|
||||
init(presentingVC: UIViewController) {
|
||||
@objc init(presentingVC: UIViewController) {
|
||||
super.init()
|
||||
style = .plain
|
||||
action = #selector(self.showKeyboardPicker)
|
||||
|
|
@ -47,7 +47,7 @@ class KeyboardPickerBarButtonItem: UIBarButtonItem {
|
|||
presentingVC = nil
|
||||
}
|
||||
|
||||
func showKeyboardPicker() {
|
||||
@objc func showKeyboardPicker() {
|
||||
if let presentingVC = presentingVC {
|
||||
KMManager.sharedInstance().showKeyboardPicker(in: presentingVC, shouldAddKeyboard: false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import QuartzCore
|
|||
class KeyboardPickerButton: UIButton {
|
||||
weak var presentingVC: UIViewController?
|
||||
|
||||
init(presentingVC: UIViewController) {
|
||||
@objc init(presentingVC: UIViewController) {
|
||||
super.init(frame: .zero)
|
||||
self.presentingVC = presentingVC
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class KeyboardPickerButton: UIButton {
|
|||
presentingVC = nil
|
||||
}
|
||||
|
||||
func showKeyboardPicker() {
|
||||
@objc func showKeyboardPicker() {
|
||||
if let presentingVC = presentingVC {
|
||||
KMManager.sharedInstance().showKeyboardPicker(in: presentingVC, shouldAddKeyboard: false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,13 +206,13 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
switchKeyboard(indexPath.row)
|
||||
}
|
||||
|
||||
func keyboardDownloadStarted(_ notification: Notification) {
|
||||
@objc func keyboardDownloadStarted(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = false
|
||||
navigationItem.leftBarButtonItem?.isEnabled = false
|
||||
navigationItem.rightBarButtonItem?.isEnabled = false
|
||||
}
|
||||
|
||||
func keyboardDownloadFinished(_ notification: Notification) {
|
||||
@objc func keyboardDownloadFinished(_ notification: Notification) {
|
||||
if view == navigationController?.topViewController?.view {
|
||||
if updateQueue == nil {
|
||||
return
|
||||
|
|
@ -280,7 +280,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func keyboardDownloadFailed(_ notification: Notification) {
|
||||
@objc func keyboardDownloadFailed(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = true
|
||||
navigationItem.leftBarButtonItem?.isEnabled = true
|
||||
if let item = navigationItem.rightBarButtonItem {
|
||||
|
|
@ -303,7 +303,7 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
alert.show()
|
||||
}
|
||||
|
||||
func keyboardChanged(_ notification: Notification) {
|
||||
@objc func keyboardChanged(_ notification: Notification) {
|
||||
}
|
||||
|
||||
private func switchKeyboard(_ index: Int) {
|
||||
|
|
@ -359,19 +359,19 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func doneClicked(_ sender: Any) {
|
||||
@objc func doneClicked(_ sender: Any) {
|
||||
KMManager.sharedInstance().dismissKeyboardPicker(self)
|
||||
}
|
||||
|
||||
func cancelClicked(_ sender: Any) {
|
||||
@objc func cancelClicked(_ sender: Any) {
|
||||
KMManager.sharedInstance().dismissKeyboardPicker(self)
|
||||
}
|
||||
|
||||
func addClicked(_ sender: Any) {
|
||||
@objc func addClicked(_ sender: Any) {
|
||||
showAddKeyboard()
|
||||
}
|
||||
|
||||
func updateClicked(_ sender: Any) {
|
||||
@objc func updateClicked(_ sender: Any) {
|
||||
navigationController?.toolbar?.viewWithTag(toolbarButtonTag)?.removeFromSuperview()
|
||||
let toolbarFrame = navigationController!.toolbar!.frame
|
||||
let width = toolbarFrame.width * 0.95
|
||||
|
|
@ -467,11 +467,11 @@ class KeyboardPickerViewController: UITableViewController, UIAlertViewDelegate {
|
|||
KMManager.sharedInstance().languageID == languageID
|
||||
}
|
||||
|
||||
func hideToolbarDelayed(_ timer: Timer) {
|
||||
@objc func hideToolbarDelayed(_ timer: Timer) {
|
||||
navigationController?.setToolbarHidden(true, animated: true)
|
||||
}
|
||||
|
||||
func showAddKeyboard() {
|
||||
@objc func showAddKeyboard() {
|
||||
let button: UIButton? = (navigationController?.toolbar?.viewWithTag(toolbarButtonTag) as? UIButton)
|
||||
button?.isEnabled = false
|
||||
let vc = LanguageViewController()
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class LanguageDetailViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func keyboardDownloadStarted(_ notification: Notification) {
|
||||
@objc func keyboardDownloadStarted(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = false
|
||||
navigationItem.setHidesBackButton(true, animated: true)
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ class LanguageDetailViewController: UITableViewController, UIAlertViewDelegate {
|
|||
navigationController?.setToolbarHidden(false, animated: true)
|
||||
}
|
||||
|
||||
func keyboardDownloadFailed(_ notification: Notification) {
|
||||
@objc func keyboardDownloadFailed(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = true
|
||||
navigationItem.setHidesBackButton(false, animated: true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class LanguageViewController: UITableViewController, UIAlertViewDelegate {
|
|||
guard let name = item[kKeymanNameKey] as? String else {
|
||||
continue
|
||||
}
|
||||
let firstLetter = name.substring(to: name.index(after: name.startIndex))
|
||||
let firstLetter = String(name[..<name.index(after: name.startIndex)])
|
||||
if !sectionIndexTitles.contains(firstLetter) {
|
||||
sectionIndexTitles.append(firstLetter)
|
||||
indices.append(index)
|
||||
|
|
@ -209,7 +209,7 @@ class LanguageViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func languageFetchFinished() {
|
||||
@objc func languageFetchFinished() {
|
||||
dismissActivityView()
|
||||
tableView.reloadData()
|
||||
if numberOfSections(in: tableView) == 0 {
|
||||
|
|
@ -217,12 +217,12 @@ class LanguageViewController: UITableViewController, UIAlertViewDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func languageFetchFailed() {
|
||||
@objc func languageFetchFailed() {
|
||||
dismissActivityView()
|
||||
showConnectionErrorAlert()
|
||||
}
|
||||
|
||||
func keyboardDownloadStarted(_ notification: Notification) {
|
||||
@objc func keyboardDownloadStarted(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = false
|
||||
navigationItem.setHidesBackButton(true, animated: true)
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ class LanguageViewController: UITableViewController, UIAlertViewDelegate {
|
|||
navigationController?.setToolbarHidden(false, animated: true)
|
||||
}
|
||||
|
||||
func keyboardDownloadFailed(_ notification: Notification) {
|
||||
@objc func keyboardDownloadFailed(_ notification: Notification) {
|
||||
view.isUserInteractionEnabled = true
|
||||
navigationItem.setHidesBackButton(false, animated: true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import UIKit
|
|||
class PopoverView: UIView {
|
||||
let strokeWidth: CGFloat = 2.0
|
||||
let arrowWidth: CGFloat = 21.0
|
||||
let arrowHeight: CGFloat = 7.0
|
||||
@objc let arrowHeight: CGFloat = 7.0
|
||||
let borderRadius: CGFloat = 5.0
|
||||
var borderColor = UIColor(red: 125.0 / 255.0, green: 133.0 / 255.0, blue: 145.0 / 255.0, alpha: 1.0)
|
||||
@objc var borderColor = UIColor(red: 125.0 / 255.0, green: 133.0 / 255.0, blue: 145.0 / 255.0, alpha: 1.0)
|
||||
private var bgColor = UIColor(red: 175.0 / 255.0, green: 175.0 / 255.0, blue: 175.0 / 255.0, alpha: 0.75)
|
||||
var backgroundColor2 = UIColor(red: 105.0 / 255.0, green: 105.0 / 255.0, blue: 105.0 / 255.0, alpha: 0.75)
|
||||
@objc var backgroundColor2 = UIColor(red: 105.0 / 255.0, green: 105.0 / 255.0, blue: 105.0 / 255.0, alpha: 0.75)
|
||||
private var _arrowPosX: CGFloat = 0.0
|
||||
|
||||
override init(frame: CGRect) {
|
||||
|
|
@ -120,7 +120,7 @@ class PopoverView: UIView {
|
|||
}
|
||||
}
|
||||
|
||||
var arrowPosX: CGFloat {
|
||||
@objc var arrowPosX: CGFloat {
|
||||
get {
|
||||
return _arrowPosX
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue