From bc309a9590ae9b612f7d3e24e74c9a42e2b15e3f Mon Sep 17 00:00:00 2001 From: Guillaume Louel Date: Tue, 8 Oct 2019 17:03:57 +0200 Subject: [PATCH 1/2] - Disable auto install updates in Catalina - Fix custom videos, add drop support for folders --- Aerial.xcodeproj/project.pbxproj | 8 +- .../Controllers/CustomVideoController.swift | 123 ++++++++++++++++-- Aerial/Source/Models/ManifestLoader.swift | 4 +- Aerial/Source/Views/AerialView.swift | 42 +++--- Resources/CustomVideos.xib | 74 +++++++++-- 5 files changed, 203 insertions(+), 48 deletions(-) diff --git a/Aerial.xcodeproj/project.pbxproj b/Aerial.xcodeproj/project.pbxproj index 4cf33f40..3c75c3cf 100644 --- a/Aerial.xcodeproj/project.pbxproj +++ b/Aerial.xcodeproj/project.pbxproj @@ -1185,7 +1185,7 @@ CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.6.1; + CURRENT_PROJECT_VERSION = 1.6.2; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; @@ -1193,7 +1193,7 @@ INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1214,7 +1214,7 @@ CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.6.1; + CURRENT_PROJECT_VERSION = 1.6.2; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; @@ -1222,7 +1222,7 @@ INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.9; - MARKETING_VERSION = 1.6.1; + MARKETING_VERSION = 1.6.2; OTHER_CODE_SIGN_FLAGS = "--timestamp"; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Aerial/Source/Controllers/CustomVideoController.swift b/Aerial/Source/Controllers/CustomVideoController.swift index edf9e74c..41c8c79b 100644 --- a/Aerial/Source/Controllers/CustomVideoController.swift +++ b/Aerial/Source/Controllers/CustomVideoController.swift @@ -10,8 +10,13 @@ import Foundation import AppKit import AVKit -class CustomVideoController: NSWindowController, NSWindowDelegate { +class CustomVideoController: NSWindowController, NSWindowDelegate, NSDraggingDestination { @IBOutlet var mainPanel: NSWindow! + + // This is the panel workaround for Catalina + @IBOutlet var addFolderCatalinaPanel: NSPanel! + @IBOutlet var addFolderTextField: NSTextField! + @IBOutlet var folderOutlineView: NSOutlineView! @IBOutlet var topPathControl: NSPathControl! @@ -45,6 +50,17 @@ class CustomVideoController: NSWindowController, NSWindowDelegate { var sw: NSWindow? var controller: PreferencesWindowController? + /* + func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation { + debugLog("drag entered") + return .copy + } + + func performDragOperation(_ sender: NSDraggingInfo) -> Bool { + print("bla") + return true + }*/ + // MARK: - Lifecycle required init?(coder: NSCoder) { super.init(coder: coder) @@ -62,6 +78,13 @@ class CustomVideoController: NSWindowController, NSWindowDelegate { debugLog("cvcawake") folderOutlineView.dataSource = self folderOutlineView.delegate = self + + if #available(OSX 10.13, *) { + folderOutlineView.registerForDraggedTypes([.fileURL, .URL]) + } else { + // Fallback on earlier versions + } + poiTableView.dataSource = self poiTableView.delegate = self @@ -117,20 +140,35 @@ class CustomVideoController: NSWindowController, NSWindowDelegate { // MARK: - Add a new folder of videos to parse @IBAction func addFolderButton(_ sender: NSButton) { - let addFolderPanel = NSOpenPanel() - addFolderPanel.allowsMultipleSelection = false - addFolderPanel.canChooseDirectories = true - addFolderPanel.canCreateDirectories = false - addFolderPanel.canChooseFiles = false - addFolderPanel.title = "Select a folder containing videos" - - addFolderPanel.begin { (response) in - if response.rawValue == NSFileHandlingPanelOKButton { - self.processPathForVideos(url: addFolderPanel.url!) + if #available(OSX 10.15, *) { + // On Catalina, we can't use NSOpenPanel right now + addFolderTextField.stringValue = "" + addFolderCatalinaPanel.makeKeyAndOrderFront(self) + } else { + let addFolderPanel = NSOpenPanel() + addFolderPanel.allowsMultipleSelection = false + addFolderPanel.canChooseDirectories = true + addFolderPanel.canCreateDirectories = false + addFolderPanel.canChooseFiles = false + addFolderPanel.title = "Select a folder containing videos" + + addFolderPanel.begin { (response) in + if response.rawValue == NSFileHandlingPanelOKButton { + self.processPathForVideos(url: addFolderPanel.url!) + } + addFolderPanel.close() } - addFolderPanel.close() } + } + + @IBAction func addFolderCatalinaConfirm(_ sender: Any) { + let strFolder = addFolderTextField.stringValue + if FileManager.default.fileExists(atPath: strFolder as String) { + self.processPathForVideos(url: URL(fileURLWithPath: strFolder, isDirectory: true)) + } + + addFolderCatalinaPanel.close() } func processPathForVideos(url: URL) { @@ -393,6 +431,56 @@ extension CustomVideoController: NSOutlineViewDelegate { let size = track.naturalSize.applying(track.preferredTransform) return CGSize(width: abs(size.width), height: abs(size.height)) } +/* + func outlineView(_ outlineView: NSOutlineView, pasteboardWriterForItem item: Any) -> NSPasteboardWriting? { + let pp = NSPasteboardItem() + + debugLog("Received pp") + debugLog("\(pp)") +/* // working as expected here + if let fi = item as? FileItem { + pp.setString( fi.Path, forType: "public.text" ) + + print( "pb write \(fi.Name)") + + } else { + print( "pb write, not a file item \(item)") + } +*/ + return pp + } +*/ + + // swiftlint:disable:next line_length + func outlineView(_ outlineView: NSOutlineView, validateDrop info: NSDraggingInfo, proposedItem item: Any?, proposedChildIndex index: Int) -> NSDragOperation { + //print("info \(info.draggingPasteboard)") + //print( "validate: \(String(describing: item))") + return NSDragOperation.copy + // + } + + func outlineView(_ outlineView: NSOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool { + + if let items = info.draggingPasteboard.pasteboardItems { + for item in items { + if #available(OSX 10.13, *) { + if let str = item.string(forType: .fileURL) { + let surl = URL(fileURLWithPath: str).standardized + debugLog("received drop \(surl)") + if let isDir = surl.isDirectory { + if isDir { + debugLog("processing dir") + self.processPathForVideos(url: surl) + } + } + } + } else { + // Fallback on earlier versions + } + } + } + return true + } } // MARK: - Extension for poi table view @@ -453,3 +541,14 @@ extension Dictionary { } } } + +extension URL { + var isDirectory: Bool? { + do { + let values = try self.resourceValues( + forKeys: Set([URLResourceKey.isDirectoryKey]) + ) + return values.isDirectory + } catch { return nil } + } +} diff --git a/Aerial/Source/Models/ManifestLoader.swift b/Aerial/Source/Models/ManifestLoader.swift index ed5e3515..72956f9b 100644 --- a/Aerial/Source/Models/ManifestLoader.swift +++ b/Aerial/Source/Models/ManifestLoader.swift @@ -404,12 +404,12 @@ class ManifestLoader { // customvideos.json var cacheFileUrl = URL(fileURLWithPath: cacheDirectory as String) cacheFileUrl.appendPathComponent("customvideos.json") - if FileManager.default.fileExists(atPath: cacheFileUrl.absoluteString) { + if FileManager.default.fileExists(atPath: cacheFileUrl.path) { debugLog("loading custom file : \(cacheFileUrl)") let ndata = try Data(contentsOf: cacheFileUrl) customVideoFolders = try CustomVideoFolders(data: ndata) } else { - debugLog("No customvideos.json at : \(cacheFileUrl)") + debugLog("No customvideos.json at : \(cacheFileUrl.path)") } } } catch { diff --git a/Aerial/Source/Views/AerialView.swift b/Aerial/Source/Views/AerialView.swift index 4d06c427..ab2ef8c0 100644 --- a/Aerial/Source/Views/AerialView.swift +++ b/Aerial/Source/Views/AerialView.swift @@ -200,28 +200,32 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { // Initialize Sparkle updater if !isPreview && preferences.updateWhileSaverMode { - let suup = SUUpdater.init(for: Bundle(for: AerialView.self)) + if #available(OSX 10.15, *) { + debugLog("Ignoring updateWhileSaverMode in Catalina") + } else { + let suup = SUUpdater.init(for: Bundle(for: AerialView.self)) - // Make sure we can create SUUpdater - if let suu = suup { - if preferences.allowBetas { - suu.feedURL = URL(string: "https://raw.githubusercontent.com/JohnCoates/Aerial/master/beta-appcast.xml") - } + // Make sure we can create SUUpdater + if let suu = suup { + if preferences.allowBetas { + suu.feedURL = URL(string: "https://raw.githubusercontent.com/JohnCoates/Aerial/master/beta-appcast.xml") + } - // We manually ensure the correct amount of time passed since last check - var distance = -86400 // 1 day - if preferences.betaCheckFrequency == 0 { - distance = -3600 // 1 hour - } else if preferences.betaCheckFrequency == 1 { - distance = -43200 // 12 hours - } + // We manually ensure the correct amount of time passed since last check + var distance = -86400 // 1 day + if preferences.betaCheckFrequency == 0 { + distance = -3600 // 1 hour + } else if preferences.betaCheckFrequency == 1 { + distance = -43200 // 12 hours + } - // If we never went into System Preferences, we may not have a lastUpdateCheckDate - if suu.lastUpdateCheckDate != nil { - if suu.lastUpdateCheckDate.timeIntervalSinceNow.distance(to: Double(distance)) > 0 { - // Then force check/install udpates - suu.resetUpdateCycle() - suu.installUpdatesIfAvailable() + // If we never went into System Preferences, we may not have a lastUpdateCheckDate + if suu.lastUpdateCheckDate != nil { + if suu.lastUpdateCheckDate.timeIntervalSinceNow.distance(to: Double(distance)) > 0 { + // Then force check/install udpates + suu.resetUpdateCycle() + suu.installUpdatesIfAvailable() + } } } } diff --git a/Resources/CustomVideos.xib b/Resources/CustomVideos.xib index 96adf0e9..064b3f1d 100644 --- a/Resources/CustomVideos.xib +++ b/Resources/CustomVideos.xib @@ -1,14 +1,16 @@ - + - - + + + + @@ -66,7 +68,7 @@ - + @@ -119,9 +121,8 @@ - + - Click the "+ Add Folder" button on top of the window and point to a folder containing your personal videos that you would like to add to Aerial. @@ -155,7 +156,7 @@ - + @@ -170,7 +171,7 @@ - + @@ -217,7 +218,7 @@ - + @@ -253,7 +254,7 @@ - + @@ -507,7 +508,7 @@ - + @@ -556,6 +557,57 @@ DQ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 813c8b5587165b531740a6c5d092c17549310b87 Mon Sep 17 00:00:00 2001 From: Guillaume Louel Date: Tue, 8 Oct 2019 17:08:33 +0200 Subject: [PATCH 2/2] add message about catalina and updates --- Resources/PreferencesWindow.xib | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib index 074627bc..eb5e35d4 100644 --- a/Resources/PreferencesWindow.xib +++ b/Resources/PreferencesWindow.xib @@ -1,9 +1,9 @@ - + - - + + @@ -1773,7 +1773,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) - + @@ -1947,11 +1947,20 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required) + + + + + + + + + - +