Skip to content

Commit

Permalink
Merge pull request #820 from glouel/master
Browse files Browse the repository at this point in the history
Beta 6
  • Loading branch information
glouel committed Jun 24, 2019
2 parents 8953d21 + fae84ae commit 48a048d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Expand Up @@ -1169,15 +1169,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta5;
CURRENT_PROJECT_VERSION = 1.5.1beta6;
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.5.1beta5;
MARKETING_VERSION = 1.5.1beta6;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1198,15 +1198,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta5;
CURRENT_PROJECT_VERSION = 1.5.1beta6;
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.5.1beta5;
MARKETING_VERSION = 1.5.1beta6;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
11 changes: 2 additions & 9 deletions Aerial/App/AppDelegate.swift
Expand Up @@ -28,7 +28,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ notification: Notification) {

let objects = objectsFromNib(loadNibNamed: "PreferencesWindow")
preferencesWindowController.appMode = true
// We need to find the correct window in our nib
Expand All @@ -54,17 +53,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

private func objectsFromNib(loadNibNamed nibName: String) -> [AnyObject] {
let bundle = Bundle.main
var topLevelObjects: NSArray? = NSArray()
print("bundle \(bundle)")

//let res = Bundle.main.loadNibNamed(nibName, owner: preferencesWindowController, topLevelObjects: &topLevelObjects)

let res = bundle.loadNibNamed(nibName,
owner: preferencesWindowController,
topLevelObjects: &topLevelObjects)
_ = Bundle.main.loadNibNamed(nibName, owner: preferencesWindowController,
topLevelObjects: &topLevelObjects)

print("res")
return topLevelObjects! as [AnyObject]
}
}
26 changes: 21 additions & 5 deletions Aerial/Source/Models/AerialVideo.swift
Expand Up @@ -228,6 +228,7 @@ final class AerialVideo: CustomStringConvertible, Equatable {
updateDuration() // We need to have the video duration
}

// swiftlint:disable:next cyclomatic_complexity
func updateDuration() {
// We need to retrieve video duration from the cached files.
// This is a workaround as currently, the VideoCache infrastructure
Expand All @@ -247,25 +248,40 @@ final class AerialVideo: CustomStringConvertible, Equatable {
self.duration = 0
}
} else {
let cacheDirectoryPath = VideoCache.cacheDirectory! as NSString
// let cacheDirectoryPath = VideoCache.cacheDirectory! as NSString

var videoCache1080pH264Path = "", videoCache1080pHEVCPath = "",
videoCache4KHEVCPath = "", videoCache1080pHDRPath = "",
videoCache4KHDRPath = ""

var videoCache1080pH264Path = "", videoCache1080pHEVCPath = "", videoCache4KHEVCPath = ""
if self.url1080pH264 != "" {
videoCache1080pH264Path = cacheDirectoryPath.appendingPathComponent((URL(string: url1080pH264)?.lastPathComponent)!)
videoCache1080pH264Path = VideoCache.cachePath(forFilename: (URL(string: url1080pH264)?.lastPathComponent)!)!
}
if self.url1080pHEVC != "" {
videoCache1080pHEVCPath = cacheDirectoryPath.appendingPathComponent((URL(string: url1080pHEVC)?.lastPathComponent)!)
videoCache1080pHEVCPath = VideoCache.cachePath(forFilename: (URL(string: url1080pHEVC)?.lastPathComponent)!)!
}
if self.url4KHEVC != "" {
videoCache4KHEVCPath = cacheDirectoryPath.appendingPathComponent((URL(string: url4KHEVC)?.lastPathComponent)!)
videoCache4KHEVCPath = VideoCache.cachePath(forFilename: (URL(string: url4KHEVC)?.lastPathComponent)!)!
}
if self.url1080pHDR != "" {
videoCache1080pHDRPath = VideoCache.cachePath(forFilename: (URL(string: url1080pHDR)?.lastPathComponent)!)!
}
if self.url4KHDR != "" {
videoCache4KHDRPath = VideoCache.cachePath(forFilename: (URL(string: url4KHDR)?.lastPathComponent)!)!
}

if fileManager.fileExists(atPath: videoCache4KHEVCPath) {
let asset = AVAsset(url: URL(fileURLWithPath: videoCache4KHEVCPath))
self.duration = CMTimeGetSeconds(asset.duration)
} else if fileManager.fileExists(atPath: videoCache4KHDRPath) {
let asset = AVAsset(url: URL(fileURLWithPath: videoCache4KHDRPath))
self.duration = CMTimeGetSeconds(asset.duration)
} else if fileManager.fileExists(atPath: videoCache1080pHEVCPath) {
let asset = AVAsset(url: URL(fileURLWithPath: videoCache1080pHEVCPath))
self.duration = CMTimeGetSeconds(asset.duration)
} else if fileManager.fileExists(atPath: videoCache1080pHDRPath) {
let asset = AVAsset(url: URL(fileURLWithPath: videoCache1080pHDRPath))
self.duration = CMTimeGetSeconds(asset.duration)
} else if fileManager.fileExists(atPath: videoCache1080pH264Path) {
let asset = AVAsset(url: URL(fileURLWithPath: videoCache1080pH264Path))
self.duration = CMTimeGetSeconds(asset.duration)
Expand Down
30 changes: 26 additions & 4 deletions Aerial/Source/Models/Cache/VideoCache.swift
Expand Up @@ -21,6 +21,7 @@ final class VideoCache {
static var computedCacheDirectory: String?
static var computedAppSupportDirectory: String?

// MARK: - Application Support directory
static var appSupportDirectory: String? {
// We only process this once if successful
if computedAppSupportDirectory != nil {
Expand Down Expand Up @@ -67,13 +68,13 @@ final class VideoCache {
return computedAppSupportDirectory
}

// MARK: - User Video cache directory
static var cacheDirectory: String? {

// We only process this once if successful
if computedCacheDirectory != nil {
return computedCacheDirectory
}
debugLog("appSupport : \(appSupportDirectory)")

var cacheDirectory: String?
let preferences = Preferences.sharedInstance
Expand Down Expand Up @@ -140,6 +141,7 @@ final class VideoCache {
return cacheDirectory
}

// MARK: - Helpers
static func aerialFolderExists(at: NSString) -> Bool {
let aerialFolder = at.appendingPathComponent("Aerial")
if FileManager.default.fileExists(atPath: aerialFolder as String) {
Expand All @@ -149,6 +151,7 @@ final class VideoCache {
}
}

// Is a video cached (in either appSupport or cache)
static func isAvailableOffline(video: AerialVideo) -> Bool {
let fileManager = FileManager.default

Expand Down Expand Up @@ -190,13 +193,32 @@ final class VideoCache {
}

static func cachePath(forFilename filename: String) -> String? {
guard let cacheDirectory = VideoCache.cacheDirectory else {
guard let cacheDirectory = VideoCache.cacheDirectory, let appSupportDirectory = VideoCache.appSupportDirectory else {
return nil
}

// Let's compute both
let appSupportPath = appSupportDirectory as NSString
let appSupportVideoPath = appSupportPath.appendingPathComponent(filename)

let cacheDirectoryPath = cacheDirectory as NSString
let videoCachePath = cacheDirectoryPath.appendingPathComponent(filename)
return videoCachePath
let cacheVideoPath = cacheDirectoryPath.appendingPathComponent(filename)

// If the file exists in either dir, returns that
if FileManager.default.fileExists(atPath: appSupportVideoPath as String) {
return appSupportVideoPath
} else if FileManager.default.fileExists(atPath: cacheVideoPath as String) {
return cacheVideoPath
} else {
// File doesn't have to exist, this is also used to compute the save location
// So now with Catalina, considering containerization we need to use appSupport
// Pre catalina we return cache folder instead (no change for users)
if #available(OSX 10.15, *) {
return appSupportVideoPath
} else {
return cacheVideoPath
}
}
}

init(URL: Foundation.URL) {
Expand Down
3 changes: 2 additions & 1 deletion Aerial/Source/Models/Time/TimeManagement.swift
Expand Up @@ -252,7 +252,8 @@ final class TimeManagement: NSObject {
}
}

// swiftlint:disable:next cyclomatic_complexity large_tuple
// siftlint:disable:next cyclomatic_complexity large_tuple
// swiftlint:disable:next large_tuple
func getNightShiftInformation() -> (Bool, sunrise: Date?, sunset: Date?, error: String?) {
// Catalina workaround, /usr/bin/corebrightnessdiag no longer exists
return (false, nil, nil, "Nightshift disabled because of Catalina")
Expand Down
2 changes: 1 addition & 1 deletion Resources/PreferencesWindow.xib
Expand Up @@ -2230,7 +2230,7 @@ Gw
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" ambiguous="YES" id="rFk-xj-xKP">
<rect key="frame" x="1" y="1" width="659" height="337"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" ambiguous="YES" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" viewBased="YES" id="btT-0Y-wSk">
<rect key="frame" x="0.0" y="0.0" width="659" height="337"/>
Expand Down

0 comments on commit 48a048d

Please sign in to comment.