diff --git a/1_anytime.pxd/metadata.info b/1_anytime.pxd/metadata.info index fd00a29..22dc895 100644 Binary files a/1_anytime.pxd/metadata.info and b/1_anytime.pxd/metadata.info differ diff --git a/2_copy.pxd/metadata.info b/2_copy.pxd/metadata.info index e2890de..41f172f 100644 Binary files a/2_copy.pxd/metadata.info and b/2_copy.pxd/metadata.info differ diff --git a/QR 2.pxd b/QR 2.pxd new file mode 100644 index 0000000..4341ad0 Binary files /dev/null and b/QR 2.pxd differ diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 377ea0d..182a36b 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -825,8 +825,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 40; - SHARED_VERSION = 1.9.1; + SHARED_BUILD = 41; + SHARED_VERSION = 1.9.2; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; @@ -884,8 +884,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 40; - SHARED_VERSION = 1.9.1; + SHARED_BUILD = 41; + SHARED_VERSION = 1.9.2; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; }; diff --git a/ShareExtension/ShareViewController.swift b/ShareExtension/ShareViewController.swift index 2aa6954..5a6336a 100644 --- a/ShareExtension/ShareViewController.swift +++ b/ShareExtension/ShareViewController.swift @@ -16,10 +16,10 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { private var foundDevices: [RemoteDeviceInfo] = [] private var chosenDevice: RemoteDeviceInfo? private var lastError: Error? - + private var connectionEstablished = false private var timeoutDispatchWorkItem: DispatchWorkItem? = nil - + @IBOutlet var filesIcon: NSImageView? @IBOutlet var filesLabel: NSTextField? @IBOutlet var loadingOverlay: NSStackView? @@ -35,22 +35,22 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { @IBOutlet var progressDeviceIconWrap: NSView? @IBOutlet var progressDeviceSecondaryIcon: NSImageView? @IBOutlet var dontSeeDeviceButton: NSButton? - + private var qrCodeSheetView: NSPanel? = nil private var sheetAttachedWindow: NSWindow? = nil - + override var nibName: NSNib.Name? { return NSNib.Name("ShareViewController") } - + override func loadView() { super.loadView() - + let item = extensionContext!.inputItems[0] as! NSExtensionItem if let attachments = item.attachments { if let text = item.attributedContentText?.string, attachments.isEmpty { textToSend = text - + DispatchQueue.main.async { self.zipFolderAndSetUpIcon() } @@ -65,7 +65,7 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { } else if let url = data as? NSURL { self.urls.append(url as URL) } - + if self.urls.count == attachments.count { DispatchQueue.main.async { self.zipFolderAndSetUpIcon() @@ -80,29 +80,29 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { extensionContext!.cancelRequest(withError: cancelError) return } - + contentWrap!.addSubview(listViewWrapper!) contentWrap!.addSubview(loadingOverlay!) contentWrap!.addSubview(progressView!) progressView!.isHidden = true - + listViewWrapper!.translatesAutoresizingMaskIntoConstraints = false loadingOverlay!.translatesAutoresizingMaskIntoConstraints = false progressView!.translatesAutoresizingMaskIntoConstraints = false - + NSLayoutConstraint.activate([ NSLayoutConstraint(item: listViewWrapper!, attribute: .width, relatedBy: .equal, toItem: contentWrap, attribute: .width, multiplier: 1, constant: 0), NSLayoutConstraint(item: listViewWrapper!, attribute: .height, relatedBy: .equal, toItem: contentWrap, attribute: .height, multiplier: 1, constant: 0), - + NSLayoutConstraint(item: loadingOverlay!, attribute: .width, relatedBy: .equal, toItem: contentWrap, attribute: .width, multiplier: 1, constant: 0), NSLayoutConstraint(item: loadingOverlay!, attribute: .centerY, relatedBy: .equal, toItem: contentWrap, attribute: .centerY, multiplier: 1, constant: 0), - + NSLayoutConstraint(item: progressView!, attribute: .width, relatedBy: .equal, toItem: contentWrap, attribute: .width, multiplier: 1, constant: 0), NSLayoutConstraint(item: progressView!, attribute: .centerY, relatedBy: .equal, toItem: contentWrap, attribute: .centerY, multiplier: 1, constant: 0), ]) - + largeProgress!.startAnimation(nil) - + let flowLayout = NSCollectionViewFlowLayout() flowLayout.itemSize = NSSize(width: 75, height: 90) flowLayout.sectionInset = NSEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) @@ -110,29 +110,29 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { flowLayout.minimumLineSpacing = 10 listView!.collectionViewLayout = flowLayout listView!.dataSource = self - + progressDeviceIconWrap!.wantsLayer = true progressDeviceIconWrap!.layer!.masksToBounds = false } - + override func viewDidLoad() { super.viewDidLoad() - + dicoverDevices() NearbyConnectionManager.shared.addShareExtensionDelegate(self) } - + override func viewWillDisappear() { log("ShareViewController: viewWillDisappear") - + timeoutDispatchWorkItem?.cancel() - + if chosenDevice == nil { NearbyConnectionManager.shared.stopDeviceDiscovery() } NearbyConnectionManager.shared.removeShareExtensionDelegate(self) } - + @IBAction func cancel(_: AnyObject?) { if let device = chosenDevice { NearbyConnectionManager.shared.cancelOutgoingTransfer(id: device.id!) @@ -140,44 +140,44 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { let cancelError = NSError(domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil) extensionContext!.cancelRequest(withError: cancelError) } - + @IBAction func dontSeeDeviceButton(_: AnyObject?) { openQrCodeView() } - + private func openQrCodeView() { if qrCodeSheetView == nil { let contentView = QrCodeView { self.closeQrCodeView() } - + let hostingView = NSHostingView(rootView: contentView) - + let panel = NSPanel(contentRect: NSRect(x: 0, y: 0, width: qrCodeViewSize.width, height: qrCodeViewSize.height), styleMask: [.titled, .closable, .utilityWindow], backing: .buffered, defer: false) - + panel.contentView = hostingView - + qrCodeSheetView = panel - + if let mainWindow = NSApp.mainWindow { sheetAttachedWindow = mainWindow mainWindow.beginSheet(panel) { _ in } } } } - + private func closeQrCodeView() { if let mainWindow = sheetAttachedWindow, let qrCodeView = qrCodeSheetView { mainWindow.endSheet(qrCodeView) - + qrCodeSheetView = nil sheetAttachedWindow = nil } } - + private func zipFolderAndSetUpIcon() { for url in urls { if url.isFileURL { @@ -185,38 +185,38 @@ class ShareViewController: NSViewController, ShareExtensionDelegate { if FileManager.default.fileExists(atPath: url.path, isDirectory: isDirectory) && isDirectory.pointee.boolValue { do { let zipUrl = try createZipAtTmp(zipFilename: url.lastPathComponent, fromDirectory: url) - + let index = urls.firstIndex(of: url) urls[index!] = zipUrl } catch { log("Error creating zip file: \(error)") - + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { log("Canceling share request because URL \(url) is a directory") - + let alert = NSAlert() alert.alertStyle = .critical - + alert.messageText = "TypeNotSupported".localized() alert.informativeText = "TypeNotSupportedDescription".localized() alert.addButton(withTitle: "TypeNotSupportedButton".localized()) - + alert.beginSheetModal(for: self.view.window!) { _ in let cancelError = NSError(domain: NSCocoaErrorDomain, code: NSUserCancelledError, userInfo: nil) self.extensionContext!.cancelRequest(withError: cancelError) } } - + return } } } } - + if let textToSend = textToSend { let maxLength = 50 let cleanedText = textToSend.replacingOccurrences(of: "\n", with: " ").replacingOccurrences(of: "\r", with: "") - + if cleanedText.count > maxLength { let index = cleanedText.index(cleanedText.startIndex, offsetBy: maxLength) filesLabel!.stringValue = String(cleanedText[.. Int { return 1 } - + func collectionView(_: NSCollectionView, numberOfItemsInSection _: Int) -> Int { return foundDevices.count } - + func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem { let item = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "DeviceListCell"), for: indexPath) - + guard let collectionViewItem = item as? DeviceListCell else { return item } - + let device = foundDevices[indexPath[1]] - + collectionViewItem.textField?.stringValue = getDeviceName(device: device) collectionViewItem.imageView?.image = imageForDeviceType(type: device.type) collectionViewItem.clickHandler = { self.selectDevice(device: device) } - + return collectionViewItem } - + func getDeviceName(device: RemoteDeviceInfo) -> String { if device.name.count <= 1 { return "Android"