Skip to content

Commit

Permalink
Merge pull request #864 from glouel/master
Browse files Browse the repository at this point in the history
1.6.2
  • Loading branch information
glouel authored Oct 8, 2019
2 parents dcb6857 + 813c8b5 commit afa7de2
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 53 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1185,15 +1185,15 @@
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;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
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 = "";
Expand All @@ -1214,15 +1214,15 @@
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;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
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)";
Expand Down
123 changes: 111 additions & 12 deletions Aerial/Source/Controllers/CustomVideoController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
}
}
4 changes: 2 additions & 2 deletions Aerial/Source/Models/ManifestLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
42 changes: 23 additions & 19 deletions Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
}
Expand Down
Loading

0 comments on commit afa7de2

Please sign in to comment.