From 18b794f5ee45cbf6f14cccba88b86f10f709ad66 Mon Sep 17 00:00:00 2001 From: Guillaume Louel <37544189+glouel@users.noreply.github.com> Date: Sat, 9 Nov 2024 17:22:21 +0100 Subject: [PATCH] 3.5.2beta2 --- Aerial.xcodeproj/project.pbxproj | 16 +-- Aerial/Source/Models/API/Forecast.swift | 4 +- Aerial/Source/Models/API/GeoCoding.swift | 2 +- Aerial/Source/Models/API/OneCall.swift | 4 +- Aerial/Source/Models/API/OpenWeather.swift | 4 +- Aerial/Source/Models/AerialVideo.swift | 3 + .../Models/Cache/PoiStringProvider.swift | 2 +- Aerial/Source/Models/Cache/VideoCache.swift | 53 ++++++++- .../Models/Downloads/DownloadManager.swift | 2 + Aerial/Source/Models/Sources/SourceList.swift | 104 +++++++++++------- Aerial/Source/Views/AerialView+Player.swift | 6 +- Aerial/Source/Views/AerialView.swift | 8 +- .../Layers/Weather/ConditionSymbolLayer.swift | 4 +- .../Views/MainUI/AspectFillNSImageView.swift | 6 +- Resources/MainUI/PanelWindowController.xib | 5 +- .../BrightnessViewController.xib | 9 +- .../OverlaysViewController.xib | 5 +- 17 files changed, 158 insertions(+), 79 deletions(-) diff --git a/Aerial.xcodeproj/project.pbxproj b/Aerial.xcodeproj/project.pbxproj index 897d6a9e..10be1666 100644 --- a/Aerial.xcodeproj/project.pbxproj +++ b/Aerial.xcodeproj/project.pbxproj @@ -3058,7 +3058,7 @@ ENABLE_TESTABILITY = YES; INFOPLIST_FILE = Aerial/App/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; + MACOSX_DEPLOYMENT_TARGET = 10.14; MARKETING_VERSION = 2.1.4beta1.appmode; PRODUCT_BUNDLE_IDENTIFIER = "com.johncoates.Aerial-Test"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3081,7 +3081,7 @@ ENABLE_TESTABILITY = YES; INFOPLIST_FILE = Aerial/App/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; + MACOSX_DEPLOYMENT_TARGET = 10.14; MARKETING_VERSION = 2.1.4beta1.appmode; PRODUCT_BUNDLE_IDENTIFIER = "com.johncoates.Aerial-Test"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3249,15 +3249,15 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3.3.7; + CURRENT_PROJECT_VERSION = 3.5.2beta1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist"; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.3.7; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 3.5.2beta1; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3278,15 +3278,15 @@ CODE_SIGN_IDENTITY = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 3.3.7; + CURRENT_PROJECT_VERSION = 3.5.2beta1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = 3L54M5L5KK; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist"; INSTALL_PATH = "$(HOME)/Library/Screen Savers"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MARKETING_VERSION = 3.3.7; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MARKETING_VERSION = 3.5.2beta1; OTHER_CODE_SIGN_FLAGS = "--timestamp"; PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Aerial/Source/Models/API/Forecast.swift b/Aerial/Source/Models/API/Forecast.swift index 8b37302b..176a57c6 100644 --- a/Aerial/Source/Models/API/Forecast.swift +++ b/Aerial/Source/Models/API/Forecast.swift @@ -140,7 +140,7 @@ struct Forecast { } static func makeUrl(lat: String, lon: String) -> String { - return "http://api.openweathermap.org/data/2.5/forecast" + return "https://api.openweathermap.org/data/2.5/forecast" + "?lat=\(lat)&lon=\(lon)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" @@ -150,7 +150,7 @@ struct Forecast { static func makeUrl(location: String) -> String { let nloc = location.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! - return "http://api.openweathermap.org/data/2.5/forecast" + return "https://api.openweathermap.org/data/2.5/forecast" + "?q=\(nloc)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" diff --git a/Aerial/Source/Models/API/GeoCoding.swift b/Aerial/Source/Models/API/GeoCoding.swift index 7cc0ee04..a861c34c 100644 --- a/Aerial/Source/Models/API/GeoCoding.swift +++ b/Aerial/Source/Models/API/GeoCoding.swift @@ -75,7 +75,7 @@ struct GeoCoding { static func makeUrl() -> String { let nloc = PrefsInfo.weather.locationString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! - return "http://api.openweathermap.org/geo/1.0/direct" + return "https://api.openweathermap.org/geo/1.0/direct" + "?q=\(nloc)" + "&appid=\(APISecrets.openWeatherAppId)" } diff --git a/Aerial/Source/Models/API/OneCall.swift b/Aerial/Source/Models/API/OneCall.swift index 34c6eb71..378b65ad 100644 --- a/Aerial/Source/Models/API/OneCall.swift +++ b/Aerial/Source/Models/API/OneCall.swift @@ -170,7 +170,7 @@ struct OneCall { } static func makeUrl(lat: String, lon: String) -> String { - return "http://api.openweathermap.org/data/2.5/onecall" + return "https://api.openweathermap.org/data/2.5/onecall" + "?lat=\(lat)&lon=\(lon)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" @@ -182,7 +182,7 @@ struct OneCall { let nloc = location.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! - return "http://api.openweathermap.org/data/2.5/onecall" + return "https://api.openweathermap.org/data/2.5/onecall" + "?q=\(nloc)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" diff --git a/Aerial/Source/Models/API/OpenWeather.swift b/Aerial/Source/Models/API/OpenWeather.swift index 54624b1d..cf8ecaea 100644 --- a/Aerial/Source/Models/API/OpenWeather.swift +++ b/Aerial/Source/Models/API/OpenWeather.swift @@ -135,7 +135,7 @@ struct OpenWeather { } static func makeUrl(lat: String, lon: String) -> String { - return "http://api.openweathermap.org/data/2.5/weather" + return "https://api.openweathermap.org/data/2.5/weather" + "?lat=\(lat)&lon=\(lon)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" @@ -145,7 +145,7 @@ struct OpenWeather { static func makeUrl(location: String) -> String { let nloc = location.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! - return "http://api.openweathermap.org/data/2.5/weather" + return "https://api.openweathermap.org/data/2.5/weather" + "?q=\(nloc)" + "&units=\(getUnits())" + "&lang=\(getShortcodeLanguage())" diff --git a/Aerial/Source/Models/AerialVideo.swift b/Aerial/Source/Models/AerialVideo.swift index 39a4878f..ba913270 100644 --- a/Aerial/Source/Models/AerialVideo.swift +++ b/Aerial/Source/Models/AerialVideo.swift @@ -155,6 +155,9 @@ final class AerialVideo: CustomStringConvertible, Equatable { updateDuration() // We need to have the video duration } + + + func updateDuration() { // We need to retrieve video duration from the cached files. // This is a workaround as currently, the VideoCache infrastructure diff --git a/Aerial/Source/Models/Cache/PoiStringProvider.swift b/Aerial/Source/Models/Cache/PoiStringProvider.swift index 9d06b77c..1d48f904 100644 --- a/Aerial/Source/Models/Cache/PoiStringProvider.swift +++ b/Aerial/Source/Models/Cache/PoiStringProvider.swift @@ -47,7 +47,7 @@ final class PoiStringProvider { private func loadBundle() { // Idle string bundle - var bundlePath = Cache.supportPath.appending("/macOS 14") + var bundlePath = Cache.supportPath.appending("/macOS 15") if PrefsAdvanced.ciOverrideLanguage == "" { debugLog("Preferred languages : \(Locale.preferredLanguages)") diff --git a/Aerial/Source/Models/Cache/VideoCache.swift b/Aerial/Source/Models/Cache/VideoCache.swift index 199fa519..840a7e57 100644 --- a/Aerial/Source/Models/Cache/VideoCache.swift +++ b/Aerial/Source/Models/Cache/VideoCache.swift @@ -145,7 +145,23 @@ final class VideoCache { let fileManager = FileManager.default if video.url.absoluteString.starts(with: "file") { - return fileManager.fileExists(atPath: video.url.path) + if fileManager.fileExists(atPath: video.url.path) { + do { + let resourceValues = try video.url.resourceValues(forKeys: [.fileSizeKey]) + let fileSize = resourceValues.fileSize! + + // Make sure the file is big enough to be a video and not some network failure + if fileSize > 500000 { + return true + } + } catch { + errorLog("File check throw") + } + + return false + } else { + return false + } } else { if video.source.isCachable { guard let videoCachePath = cachePath(forVideo: video) else { @@ -153,10 +169,41 @@ final class VideoCache { return false } - return fileManager.fileExists(atPath: videoCachePath) + if fileManager.fileExists(atPath: videoCachePath) { + do { + let fileUrl = Foundation.URL(fileURLWithPath: videoCachePath) + + + let resourceValues = try fileUrl.resourceValues(forKeys: [.fileSizeKey]) + let fileSize = resourceValues.fileSize! + + // Make sure the file is big enough to be a video and not some network failure + if fileSize > 500000 { + return true + } + + } catch { + errorLog("File check throw") + } + } + + return false } else { let path = sourcePathFor(video) - return fileManager.fileExists(atPath: path) + do { + let fileUrl = Foundation.URL(fileURLWithPath: path) + let resourceValues = try fileUrl.resourceValues(forKeys: [.fileSizeKey]) + let fileSize = resourceValues.fileSize! + + // Make sure the file is big enough to be a video and not some network failure + if fileSize > 500000 { + return true + } + + } catch { + errorLog("File check throw") + } + return false } } } diff --git a/Aerial/Source/Models/Downloads/DownloadManager.swift b/Aerial/Source/Models/Downloads/DownloadManager.swift index c9bcbecf..a0b84043 100644 --- a/Aerial/Source/Models/Downloads/DownloadManager.swift +++ b/Aerial/Source/Models/Downloads/DownloadManager.swift @@ -179,6 +179,8 @@ extension DownloadOperation: URLSessionTaskDelegate { FileHelpers.unTar(file: destinationDirectory.appending("/resources.tar"), atPath: destinationDirectory) } else if folder == "macOS 14" { FileHelpers.unTar(file: destinationDirectory.appending("/resources-14-0-10.tar"), atPath: destinationDirectory) + } else if folder == "macOS 15" { + FileHelpers.unTar(file: destinationDirectory.appending("/resources-15-0-2.tar"), atPath: destinationDirectory) } debugLog("Finished downloading \(task.originalRequest!.url!.absoluteString)") diff --git a/Aerial/Source/Models/Sources/SourceList.swift b/Aerial/Source/Models/Sources/SourceList.swift index 722205a1..91dd9986 100644 --- a/Aerial/Source/Models/Sources/SourceList.swift +++ b/Aerial/Source/Models/Sources/SourceList.swift @@ -16,14 +16,24 @@ struct SourceHeader { // swiftlint:disable:next type_body_length struct SourceList { // This is the current one until next fall - static let macOS14 = Source(name: "macOS 14", + static let macOS15 = Source(name: "macOS 15", + description: "High framerate videos from macOS 15 Sequoia", + manifestUrl: "https://sylvan.apple.com/itunes-assets/Aerials126/v4/82/2e/34/822e344c-f5d2-878c-3d56-508d5b09ed61/resources-15-0-2.tar", + type: .macOS, + scenes: [.nature, .city, .space, .sea], + isCachable: true, + license: "", + more: "") + + // This is the current one until next fall + /*static let macOS14 = Source(name: "macOS 14", description: "High framerate videos from macOS 14 Sonoma", manifestUrl: "https://sylvan.apple.com/itunes-assets/Aerials126/v4/82/2e/34/822e344c-f5d2-878c-3d56-508d5b09ed61/resources-14-0-10.tar", type: .macOS, scenes: [.nature, .city, .space, .sea], isCachable: true, license: "", - more: "") + more: "")*/ // This is the current one until next fall static let tvOS16 = Source(name: "tvOS 16", @@ -72,7 +82,7 @@ struct SourceList { license: "", more: "")*/ - static var list: [Source] = [macOS14, tvOS16, tvOS13] + foundSources + static var list: [Source] = [macOS15, tvOS16, tvOS13] + foundSources // static var list: [Source] = foundSources // This is where the magic happens @@ -251,30 +261,36 @@ struct SourceList { for lurl in urls { if lurl.path.lowercased().hasSuffix(".mp4") || lurl.path.lowercased().hasSuffix(".mov") { + + let resourceValues = try lurl.resourceValues(forKeys: [.fileSizeKey]) + let fileSize = resourceValues.fileSize! + + if fileSize > 500000 { + // Check if the asset was there previously + let foundAssets = originalAssets.filter { $0.url4KSDR == lurl.path } + + if let foundAsset = foundAssets.first { + // Just add the asset to the new array + updatedAssets.append(foundAsset) + } else { + // Create a new entry + updatedAssets.append(VideoAsset(accessibilityLabel: folderName, + id: NSUUID().uuidString, + title: lurl.lastPathComponent, + timeOfDay: "day", + scene: "", + pointsOfInterest: [:], + url4KHDR: "", + url4KSDR: lurl.path, + url1080H264: "", + url1080HDR: "", + url4KSDR120FPS: "", + url4KSDR240FPS: "", + url1080SDR: "", + url: "", + type: "nature")) + } - // Check if the asset was there previously - let foundAssets = originalAssets.filter { $0.url4KSDR == lurl.path } - - if let foundAsset = foundAssets.first { - // Just add the asset to the new array - updatedAssets.append(foundAsset) - } else { - // Create a new entry - updatedAssets.append(VideoAsset(accessibilityLabel: folderName, - id: NSUUID().uuidString, - title: lurl.lastPathComponent, - timeOfDay: "day", - scene: "", - pointsOfInterest: [:], - url4KHDR: "", - url4KSDR: lurl.path, - url1080H264: "", - url1080HDR: "", - url4KSDR120FPS: "", - url4KSDR240FPS: "", - url1080SDR: "", - url: "", - type: "nature")) } } } @@ -307,21 +323,27 @@ struct SourceList { for lurl in urls { if lurl.path.lowercased().hasSuffix(".mp4") || lurl.path.lowercased().hasSuffix(".mov") { - assets.append(VideoAsset(accessibilityLabel: folderName, - id: NSUUID().uuidString, - title: lurl.lastPathComponent, - timeOfDay: "day", - scene: "", - pointsOfInterest: [:], - url4KHDR: "", - url4KSDR: lurl.path, - url1080H264: "", - url1080HDR: "", - url4KSDR120FPS: "", - url4KSDR240FPS: "", - url1080SDR: "", - url: "", - type: "nature")) + + let resourceValues = try lurl.resourceValues(forKeys: [.fileSizeKey]) + let fileSize = resourceValues.fileSize! + + if fileSize > 500000 { + assets.append(VideoAsset(accessibilityLabel: folderName, + id: NSUUID().uuidString, + title: lurl.lastPathComponent, + timeOfDay: "day", + scene: "", + pointsOfInterest: [:], + url4KHDR: "", + url4KSDR: lurl.path, + url1080H264: "", + url1080HDR: "", + url4KSDR120FPS: "", + url4KSDR240FPS: "", + url1080SDR: "", + url: "", + type: "nature")) + } } } diff --git a/Aerial/Source/Views/AerialView+Player.swift b/Aerial/Source/Views/AerialView+Player.swift index c4897bf7..e7e13235 100644 --- a/Aerial/Source/Views/AerialView+Player.swift +++ b/Aerial/Source/Views/AerialView+Player.swift @@ -144,7 +144,11 @@ extension AerialView { 1-(AerialView.fadeDuration/(video.duration/playbackSpeed)), 1 ] as [NSNumber] fadeAnimation.duration = video.duration/playbackSpeed - fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic + if #available(macOS 10.14, *) { + fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic + } else { + // Fallback on earlier versions + } view.playerLayer.add(fadeAnimation, forKey: "mainfade") } else { view.playerLayer.opacity = 1.0 diff --git a/Aerial/Source/Views/AerialView.swift b/Aerial/Source/Views/AerialView.swift index 36698e35..782784cb 100644 --- a/Aerial/Source/Views/AerialView.swift +++ b/Aerial/Source/Views/AerialView.swift @@ -464,12 +464,12 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate { } if !isDisabled { - if let layer = layer { - layer.contentsScale = (self.window?.backingScaleFactor) ?? 1.0 - self.playerLayer.contentsScale = (self.window?.backingScaleFactor) ?? 1.0 + if let layer = layer, let window = self.window { + layer.contentsScale = (window.backingScaleFactor) ?? 1.0 + self.playerLayer.contentsScale = (window.backingScaleFactor) ?? 1.0 // And our additional layers - layerManager.setContentScale(scale: (self.window?.backingScaleFactor) ?? 1.0) + layerManager.setContentScale(scale: (window.backingScaleFactor) ?? 1.0) } } } diff --git a/Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.swift b/Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.swift index 66afb93a..062eb9f4 100644 --- a/Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.swift +++ b/Aerial/Source/Views/Layers/Weather/ConditionSymbolLayer.swift @@ -96,7 +96,7 @@ class ConditionSymbolLayer: CALayer { img = makeColorSymbol(name: getColorSymbol(condition: weather.id, isNight: isNight), size: size) case .oweather: - downloadImage(from: URL(string: "http://openweathermap.org/img/wn/\(weather.icon)@4x.png")!, size: size) + downloadImage(from: URL(string: "https://openweathermap.org/img/wn/\(weather.icon)@4x.png")!, size: size) img = nil } @@ -135,7 +135,7 @@ class ConditionSymbolLayer: CALayer { img = makeColorSymbol(name: getColorSymbol(condition: weather.id, isNight: isNight), size: size) case .oweather: - downloadImage(from: URL(string: "http://openweathermap.org/img/wn/\(weather.icon)@4x.png")!, size: size) + downloadImage(from: URL(string: "https://openweathermap.org/img/wn/\(weather.icon)@4x.png")!, size: size) img = nil } diff --git a/Aerial/Source/Views/MainUI/AspectFillNSImageView.swift b/Aerial/Source/Views/MainUI/AspectFillNSImageView.swift index c935cb34..8c64786e 100644 --- a/Aerial/Source/Views/MainUI/AspectFillNSImageView.swift +++ b/Aerial/Source/Views/MainUI/AspectFillNSImageView.swift @@ -17,7 +17,11 @@ open class AspectFillNSImageView: NSImageView { set { self.layer = CALayer() - self.layer?.contentsGravity = CALayerContentsGravity.resizeAspectFill + if #available(macOS 10.14, *) { + self.layer?.contentsGravity = CALayerContentsGravity.resizeAspectFill + } else { + // Fallback on earlier versions + } self.layer?.contents = newValue self.wantsLayer = true diff --git a/Resources/MainUI/PanelWindowController.xib b/Resources/MainUI/PanelWindowController.xib index e5016854..49ce9b32 100644 --- a/Resources/MainUI/PanelWindowController.xib +++ b/Resources/MainUI/PanelWindowController.xib @@ -1,8 +1,7 @@ - + - - + diff --git a/Resources/MainUI/Settings panels/BrightnessViewController.xib b/Resources/MainUI/Settings panels/BrightnessViewController.xib index aa9db833..5b9983c0 100644 --- a/Resources/MainUI/Settings panels/BrightnessViewController.xib +++ b/Resources/MainUI/Settings panels/BrightnessViewController.xib @@ -1,8 +1,7 @@ - + - - + @@ -56,8 +55,8 @@ - - + + diff --git a/Resources/MainUI/Settings panels/OverlaysViewController.xib b/Resources/MainUI/Settings panels/OverlaysViewController.xib index 50e5cdc1..aff32707 100644 --- a/Resources/MainUI/Settings panels/OverlaysViewController.xib +++ b/Resources/MainUI/Settings panels/OverlaysViewController.xib @@ -1,8 +1,7 @@ - + - - +