Skip to content

Commit

Permalink
3.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Feb 14, 2022
1 parent 7630d7e commit c2a93e3
Show file tree
Hide file tree
Showing 8 changed files with 532 additions and 460 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Expand Up @@ -3190,15 +3190,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.0.5;
CURRENT_PROJECT_VERSION = 3.0.6;
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.12;
MARKETING_VERSION = 3.0.5;
MARKETING_VERSION = 3.0.6;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -3218,15 +3218,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.0.5;
CURRENT_PROJECT_VERSION = 3.0.6;
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.12;
MARKETING_VERSION = 3.0.5;
MARKETING_VERSION = 3.0.6;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
45 changes: 25 additions & 20 deletions Aerial/Source/Models/ErrorLog.swift
Expand Up @@ -111,29 +111,34 @@ func logToDisk(_ message: String) {

let cacheDirectory = path()
// if let cacheDirectory = path() {
var cacheFileUrl = URL(fileURLWithPath: cacheDirectory as String)
var cacheFileUrl = URL(fileURLWithPath: cacheDirectory as String)

if Aerial.underCompanion {
cacheFileUrl.appendPathComponent("AerialUnderCompanionLog.txt")
} else {
cacheFileUrl.appendPathComponent("AerialLog.txt")
}

let data = string.data(using: String.Encoding.utf8, allowLossyConversion: false)!

if FileManager.default.fileExists(atPath: cacheFileUrl.path) {
// Append to log
do {
let fileHandle = try FileHandle(forWritingTo: cacheFileUrl)
fileHandle.seekToEndOfFile()
fileHandle.write(data)
fileHandle.closeFile()
} catch {
NSLog("AerialError: Can't open handle for AerialLog.txt")
}
} else {
// Create new log
do {
try data.write(to: cacheFileUrl, options: .atomic)
} catch {
NSLog("AerialError: Can't write to file AerialLog.txt")
}
let data = string.data(using: String.Encoding.utf8, allowLossyConversion: false)!

if FileManager.default.fileExists(atPath: cacheFileUrl.path) {
// Append to log
do {
let fileHandle = try FileHandle(forWritingTo: cacheFileUrl)
fileHandle.seekToEndOfFile()
fileHandle.write(data)
fileHandle.closeFile()
} catch {
NSLog("AerialError: Can't open handle for AerialLog.txt")
}
} else {
// Create new log
do {
try data.write(to: cacheFileUrl, options: .atomic)
} catch {
NSLog("AerialError: Can't write to file AerialLog.txt")
}
}
// }
}
}
Expand Down
17 changes: 16 additions & 1 deletion Aerial/Source/Views/AerialView.swift
Expand Up @@ -448,16 +448,31 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
name: NSNotification.Name.AVPlayerItemPlaybackStalled,
object: currentItem)


DistributedNotificationCenter.default.addObserver(self,
selector: #selector(AerialView.willStart(_:)),
name: Notification.Name("com.apple.screensaver.willstart"), object: nil)
DistributedNotificationCenter.default.addObserver(self,
selector: #selector(AerialView.willStop(_:)),
name: Notification.Name("com.apple.screensaver.willstop"), object: nil)

Music.instance.setup()
}

@objc func willStart(_ aNotification: Notification) {
if Aerial.underCompanion {
debugLog("############ willStart")
player?.pause()
}
}

@objc func willStop(_ aNotification: Notification) {
debugLog("############ willStop")
self.stopAnimation()
if !Aerial.underCompanion {
self.stopAnimation()
} else {
player?.play()
}
}

// Tentative integration with companion of extra features
Expand Down
2 changes: 2 additions & 0 deletions Aerial/Source/Views/Layers/AnimationTextLayer.swift
Expand Up @@ -72,9 +72,11 @@ class AnimationTextLayer: CATextLayer, AnimatableLayer {
self.string = string
self.isWrapped = true

debugLog("string : " + string)
// This is the rect resized to our string
let newCorner = getCorner()
frame = calculateRect(string: string, font: font as! NSFont, newCorner: newCorner)
//debugLog(frame.debugDescription)
move(toCorner: newCorner, fullRedraw: false)
}

Expand Down
19 changes: 15 additions & 4 deletions Aerial/Source/Views/Layers/MessageLayer.swift
Expand Up @@ -53,11 +53,20 @@ class MessageLayer: AnimationTextLayer {
case .text:
update(string: config.message)
case .shell:
update(string: "")
DispatchQueue.global().async {
debugLog("setting up initial")
let result = self.runShell()
self.update(string: result ?? "")

if let result = result {
// Do it on the main queue...
DispatchQueue.main.async {
debugLog("updating initial " + result)
self.update(string: result)
}
}
}
setupRefresh()
//setupRefresh()
case .textfile:
// TODO
update(string: config.message)
Expand All @@ -69,6 +78,7 @@ class MessageLayer: AnimationTextLayer {
}

func setupRefresh() {
debugLog("setting up refresh")
guard let config = config else {
return
}
Expand Down Expand Up @@ -97,8 +107,8 @@ class MessageLayer: AnimationTextLayer {
messageTimer = Timer.scheduledTimer(withTimeInterval: interval, repeats: true, block: { [self] (_) in

DispatchQueue.global().async {
let result = runShell()
update(string: result ?? "")
let result = self.runShell()
self.update(string: result ?? "")
}
})
}
Expand All @@ -113,6 +123,7 @@ class MessageLayer: AnimationTextLayer {
if FileManager.default.fileExists(atPath: PrefsInfo.message.shellScript) {
let (result, _) = Aerial.shell(launchPath: PrefsInfo.message.shellScript)

debugLog("result " + (result ?? ""))
if let res = result {
return res
}
Expand Down
22 changes: 11 additions & 11 deletions Aerial/Source/Views/PrefPanel/InfoCommonView.swift
Expand Up @@ -32,7 +32,7 @@ class InfoCommonView: NSView {
// We need the controller for callbacks, when we update the isEnabled state,
// we need to update the list view on the left too
self.controller = controller

// Store type
self.forType = forType

Expand All @@ -44,34 +44,34 @@ class InfoCommonView: NSView {

switch forType {
case .location:
controller.infoBox.title = "Video location information"
//controller.infoBox.title = "Video location information"
posRandom.isHidden = false
case .message:
controller.infoBox.title = "Custom message"
//controller.infoBox.title = "Custom message"
posRandom.isHidden = true
case .clock:
controller.infoBox.title = "Current time"
//controller.infoBox.title = "Current time"
posRandom.isHidden = true
case .date:
controller.infoBox.title = "Current date"
//controller.infoBox.title = "Current date"
posRandom.isHidden = true
case .battery:
controller.infoBox.title = "Battery status"
//controller.infoBox.title = "Battery status"
posRandom.isHidden = true
case .updates:
controller.infoBox.title = "Updates notifications"
//controller.infoBox.title = "Updates notifications"
posRandom.isHidden = true
case .weather:
controller.infoBox.title = "Weather provided by OpenWeather"
//controller.infoBox.title = "Weather provided by OpenWeather"
posRandom.isHidden = true
case .countdown:
controller.infoBox.title = "Countdown to a time/date"
//controller.infoBox.title = "Countdown to a time/date"
posRandom.isHidden = true
case .timer:
controller.infoBox.title = "Timer"
//controller.infoBox.title = "Timer"
posRandom.isHidden = true
case .music:
controller.infoBox.title = "Music"
//controller.infoBox.title = "Music"
posRandom.isHidden = true
}
}
Expand Down
62 changes: 44 additions & 18 deletions Resources/MainUI/Settings panels/OverlaysViewController.swift
Expand Up @@ -12,9 +12,13 @@ class OverlaysViewController: NSViewController {
@IBOutlet var popoverWeather: NSPopover!
@IBOutlet var infoTableView: NSTableView!
@IBOutlet var infoSettingsTableView: NSTableView!
@IBOutlet var infoBox: NSBox!
@IBOutlet var infoContainerView: InfoContainerView!
//@IBOutlet var infoBox: NSBox!
//@IBOutlet var infoContainerView: InfoContainerView!


@IBOutlet var infoScrollView: NSScrollView!
@IBOutlet var infoScrollableView: InfoContainerView!

// Then all the individual views
@IBOutlet var infoSettingsView: InfoSettingsView!
@IBOutlet var infoCommonView: InfoCommonView!
Expand Down Expand Up @@ -70,8 +74,10 @@ class OverlaysViewController: NSViewController {
resetInfoPanel()

// Add the common block of features (enabled, font, position, screen)
infoContainerView.addSubview(infoSettingsView)
infoBox.title = "Advanced text settings"
infoScrollableView.addSubview(infoSettingsView)

//infoContainerView.addSubview(infoSettingsView)
//infoBox.title = "Advanced text settings"
infoSettingsView.setStates()
}

Expand All @@ -80,65 +86,85 @@ class OverlaysViewController: NSViewController {
resetInfoPanel()

// Add the common block of features (enabled, font, position, screen)
infoContainerView.addSubview(infoCommonView)
infoScrollableView.addSubview(infoCommonView)
//infoContainerView.addSubview(infoCommonView)
infoCommonView.setType(forType, controller: self)
infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: 800))

infoCommonView.frame.origin.y = 0

//infoScrollView.documentView?.scroll(.zero)


// Then the per-type blocks if any
switch forType {
case .location:
infoContainerView.addSubview(infoLocationView)
infoScrollableView.addSubview(infoLocationView)
infoLocationView.frame.origin.y = infoCommonView.frame.height
infoLocationView.setStates()

//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoLocationView.frame.height))
case .message:
infoContainerView.addSubview(infoMessageView)
infoScrollableView.addSubview(infoMessageView)
infoMessageView.frame.origin.y = infoCommonView.frame.height
addSubMessagePanel()
infoMessageView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoLocationView.frame.height))
case .clock:
infoContainerView.addSubview(infoClockView)
infoScrollableView.addSubview(infoClockView)
infoClockView.frame.origin.y = infoCommonView.frame.height
infoClockView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoClockView.frame.height))
case .date:
infoContainerView.addSubview(infoDateView)
infoScrollableView.addSubview(infoDateView)
infoDateView.frame.origin.y = infoCommonView.frame.height
infoDateView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoDateView.frame.height))
case .battery:
infoContainerView.addSubview(infoBatteryView)
infoScrollableView.addSubview(infoBatteryView)
infoBatteryView.frame.origin.y = infoCommonView.frame.height
infoBatteryView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoBatteryView.frame.height))
case .updates:
break
case .weather:
infoContainerView.addSubview(infoWeatherView)
infoScrollableView.addSubview(infoWeatherView)
infoWeatherView.frame.origin.y = infoCommonView.frame.height
infoWeatherView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoWeatherView.frame.height))
case .countdown:
infoContainerView.addSubview(infoCountdownView)
infoScrollableView.addSubview(infoCountdownView)
infoCountdownView.frame.origin.y = infoCommonView.frame.height
infoCountdownView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoCountdownView.frame.height))
case .timer:
infoContainerView.addSubview(infoTimerView)
infoScrollableView.addSubview(infoTimerView)
infoTimerView.frame.origin.y = infoCommonView.frame.height
infoTimerView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoTimerView.frame.height))
case .music:
infoContainerView.addSubview(infoMusicView)
infoScrollableView.addSubview(infoMusicView)
infoMusicView.frame.origin.y = infoCommonView.frame.height
infoMusicView.setStates()
//infoScrollableView.setFrameSize(NSSize(width: infoScrollableView.frame.width, height: infoCommonView.frame.height + infoMusicView.frame.height))
}

infoScrollView.documentView?.scroll(.zero)

}

func addSubMessagePanel() {
switch PrefsInfo.message.messageType {
case .text:
infoContainerView.addSubview(infoMessageTextView)
infoScrollableView.addSubview(infoMessageTextView)
infoMessageTextView.frame.origin.y = infoCommonView.frame.height + infoMessageView.frame.height
currentSubMessage = infoMessageTextView
case .shell:
infoContainerView.addSubview(infoMessageShellView)
infoScrollableView.addSubview(infoMessageShellView)
infoMessageShellView.frame.origin.y = infoCommonView.frame.height + infoMessageView.frame.height
currentSubMessage = infoMessageShellView
case .textfile:
infoContainerView.addSubview(infoMessageTextFileView)
infoScrollableView.addSubview(infoMessageTextFileView)
infoMessageTextFileView.frame.origin.y = infoCommonView.frame.height + infoMessageView.frame.height
currentSubMessage = infoMessageTextFileView
}
Expand All @@ -157,7 +183,7 @@ class OverlaysViewController: NSViewController {

// Clear the panel
func resetInfoPanel() {
infoContainerView.subviews.forEach({ $0.removeFromSuperview() })
infoScrollableView.subviews.forEach({ $0.removeFromSuperview() })
}

// MARK: Weather panel
Expand Down

0 comments on commit c2a93e3

Please sign in to comment.