Skip to content

Commit

Permalink
Merge pull request #928 from glouel/master
Browse files Browse the repository at this point in the history
1.8.0
  • Loading branch information
glouel authored Feb 18, 2020
2 parents 3614a06 + 23a5e62 commit 0419a90
Show file tree
Hide file tree
Showing 27 changed files with 1,379 additions and 389 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Extern/Sparkle"]
path = Extern/Sparkle
url = https://github.com/sparkle-project/Sparkle.git
5 changes: 4 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ disabled_rules:
- operator_whitespace
- redundant_string_enum_value

excluded:
- Extern

opt_in_rules:
# Prefer checking `isEmpty` over `count > 0`
- empty_count
Expand All @@ -28,4 +31,4 @@ trailing_comma:
mandatory_comma: true
identifier_name:
min_length:
warning: 2
warning: 2
415 changes: 263 additions & 152 deletions Aerial.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Aerial/App/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
9 changes: 5 additions & 4 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Info.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ extension PreferencesWindowController {
PrefsInfo.layers.append(.battery)
}

if !PrefsInfo.layers.contains(.updates) {
PrefsInfo.layers.append(.updates)
}

if !PrefsInfo.layers.contains(.countdown) {
PrefsInfo.layers.append(.countdown)
}

// Annnd for backward compatibility with 1.7.2 betas, remove the updates that was once here ;)
if PrefsInfo.layers.contains(.updates) {
PrefsInfo.layers.remove(at: PrefsInfo.layers.firstIndex(of: .updates)!)
}

infoSource = InfoTableSource()
infoSource?.setController(self)
infoTableView.dataSource = infoSource
Expand Down
67 changes: 61 additions & 6 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Updates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension PreferencesWindowController {
lastCheckedSparkle.stringValue = "Never checked for update"
}

if sparkleUpdater!.automaticallyChecksForUpdates {
if PrefsUpdates.checkForUpdates {
automaticallyCheckForUpdatesCheckbox.state = .on
}
if preferences.updateWhileSaverMode {
Expand All @@ -37,6 +37,13 @@ extension PreferencesWindowController {
allowBetasCheckbox.state = .on
betaCheckFrequencyPopup.isEnabled = true
}

sparkleScreenSaverMode.selectItem(at: PrefsUpdates.sparkleUpdateMode.rawValue)

// We disable silent installs in Catalina
if #available(OSX 10.15, *) {
silentInstallMenuItem.isEnabled = false
}
}

// MARK: - Update panel
Expand All @@ -57,7 +64,8 @@ extension PreferencesWindowController {
// Sparkle updates
@IBAction func automaticallyCheckForUpdatesChange(_ button: NSButton) {
let onState = button.state == .on
sparkleUpdater!.automaticallyChecksForUpdates = onState
PrefsUpdates.checkForUpdates = onState
//sparkleUpdater!.automaticallyChecksForUpdates = onState
debugLog("UI automaticallyCheckForUpdatesChange: \(onState)")
}

Expand All @@ -67,6 +75,10 @@ extension PreferencesWindowController {
debugLog("UI allowScreenSaverModeUpdatesChange: \(onState)")
}

@IBAction func sparkleScreenSaverModeChange(_ sender: NSPopUpButton) {
PrefsUpdates.sparkleUpdateMode = UpdateMode(rawValue: sender.indexOfSelectedItem) ?? .notify
}

@IBAction func allowBetasChange(_ button: NSButton) {
let onState = button.state == .on
preferences.allowBetas = onState
Expand All @@ -82,11 +94,54 @@ extension PreferencesWindowController {
}
}

@IBAction func checkForUpdatesButton(_ sender: Any) {
debugLog("check for updates")
sparkleUpdater!.checkForUpdates(self)
@IBAction func checkForUpdatesButton(_ sender: NSButton) {
if #available(OSX 10.15, *) {
debugLog("check for updates (using Catalina probe)")

let autoUpdates = AutoUpdates.sharedInstance

if !autoUpdates.didProbeForUpdate {
// Let's probe
autoUpdates.doProbingCheck()

_ = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false, block: { (_) in
self.checkForProbeResults(silent: false)
})
} else {
// If we already probed, show the results !
checkForProbeResults(silent: false)
}

lastCheckedSparkle.stringValue = "Last checked today"
} else {
debugLog("check for updates (using Sparkle's auto)")
sparkleUpdater!.checkForUpdates(self)

lastCheckedSparkle.stringValue = "Last checked today"
}
}

func checkForProbeResults(silent: Bool) {
let autoUpdates = AutoUpdates.sharedInstance

if !autoUpdates.didProbeForUpdate {
// Try again in 2s
if #available(OSX 10.12, *) {
_ = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false, block: { (_) in
self.checkForProbeResults(silent: silent)
})
} else {
// We should only come here in Catalina anyway
errorLog("checkForProbeResults called in macOS < 10.12")
}
} else {
if autoUpdates.isAnUpdateAvailable() {
updateReleaseController.show(sender: self.versionButton, controller: self)
} else {
if !silent {
updateReleaseController.showNoUpdate()
}
}
}
}

// Json updates
Expand Down
58 changes: 41 additions & 17 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Sparkle
final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSource, NSOutlineViewDelegate {

lazy var customVideosController: CustomVideoController = CustomVideoController()
lazy var updateReleaseController: UpdateReleaseController = UpdateReleaseController()

// Main UI
@IBOutlet weak var prefTabView: NSTabView!
Expand Down Expand Up @@ -98,13 +99,6 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

@IBOutlet var infoCountdownView: InfoCountdownView!

// Todo remap those

@IBOutlet var secondaryMarginHorizontalTextfield: NSTextField!
@IBOutlet var secondaryMarginVerticalTextfield: NSTextField!
@IBOutlet var editMarginsPanel: NSPanel!
@IBOutlet var editExtraMessagePanel: NSPanel!

// Time Tab
@IBOutlet var iconTime1: NSImageCell!
@IBOutlet var iconTime2: NSImageCell!
Expand Down Expand Up @@ -168,10 +162,12 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo

@IBOutlet var automaticallyCheckForUpdatesCheckbox: NSButton!
@IBOutlet var allowScreenSaverModeUpdateCheckbox: NSButton!
@IBOutlet var sparkleScreenSaverMode: NSPopUpButton!
@IBOutlet var allowBetasCheckbox: NSButton!
@IBOutlet var betaCheckFrequencyPopup: NSPopUpButton!
@IBOutlet var lastCheckedSparkle: NSTextField!

@IBOutlet var silentInstallMenuItem: NSMenuItem!
// Advanced Tab
@IBOutlet weak var debugModeCheckbox: NSButton!
@IBOutlet weak var showLogBottomClick: NSButton!
Expand Down Expand Up @@ -279,11 +275,36 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
name: Notification.Name.SUUpdaterWillRestart,
object: nil)

// Starting the Sparkle update system
sparkleUpdater = SUUpdater.init(for: Bundle(for: PreferencesWindowController.self))
// We override the feeds for betas
if preferences.allowBetas {
sparkleUpdater?.feedURL = URL(string: "https://raw.githubusercontent.com/JohnCoates/Aerial/master/beta-appcast.xml")
if PrefsUpdates.checkForUpdates {
// Starting the Sparkle update system
sparkleUpdater = SUUpdater.init(for: Bundle(for: PreferencesWindowController.self))

// We override the feeds for betas
if preferences.allowBetas {
sparkleUpdater?.feedURL = URL(string: "https://raw.githubusercontent.com/JohnCoates/Aerial/master/beta-appcast.xml")
}

// On macOS 10.15, we simply disable the auto update check
if #available(OSX 10.15, *) {
sparkleUpdater!.automaticallyChecksForUpdates = false

// And we start our own probe thing
let autoUpdates = AutoUpdates.sharedInstance

// We make sure the required delay has elapsed
if autoUpdates.shouldCheckForUpdates(sparkleUpdater!) {
autoUpdates.doProbingCheck()

_ = Timer.scheduledTimer(withTimeInterval: 5.0, repeats: false, block: { (_) in
self.checkForProbeResults(silent: true)
})
}

} else {
sparkleUpdater!.automaticallyChecksForUpdates = true
}
} else {
sparkleUpdater!.automaticallyChecksForUpdates = false
}

// Setup the updates for the Logs
Expand Down Expand Up @@ -328,13 +349,8 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
// To workaround our High Sierra issues with textfields, we have separate panels
// that replicate the features and are editable. They are hidden unless needed.
if #available(OSX 10.14, *) {
//editMarginButton.isHidden = true
//editExtraMessageButton.isHidden = true
enterCoordinatesButton.isHidden = true
} else {
//marginHorizontalTextfield.isEnabled = false
//marginVerticalTextfield.isEnabled = false
// extraMessageTextField.isEnabled = false
latitudeTextField.isEnabled = false
longitudeTextField.isEnabled = false
}
Expand All @@ -347,6 +363,14 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
topLevelObjects: &topLevelObjects) {
errorLog("Could not load nib for CustomVideos, please report")
}

// And our new, hopefully temporary, updater
topLevelObjects = NSArray()
if !bundle.loadNibNamed(NSNib.Name("UpdateReleaseWindow"),
owner: updateReleaseController,
topLevelObjects: &topLevelObjects) {
errorLog("Could not load nib for UpdateReleaseWindow, please report")
}
}

override func windowDidLoad() {
Expand Down
70 changes: 70 additions & 0 deletions Aerial/Source/Controllers/UpdateReleaseController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// UpdateReleaseController.swift
// Aerial
//
// Created by Guillaume Louel on 17/02/2020.
// Copyright © 2020 Guillaume Louel. All rights reserved.
//

import Foundation
import AppKit
import WebKit

class UpdateReleaseController: NSWindowController {
var controller: PreferencesWindowController?

@IBOutlet var updateWindow: NSWindow!

@IBOutlet var noUpdateWindow: NSWindow!

@IBOutlet var versionTextField: NSTextField!
@IBOutlet var releaseNotesWKWebView: WKWebView!

@IBOutlet var helpPopover: NSPopover!

// MARK: - Update available
func show(sender: NSButton, controller: PreferencesWindowController) {
self.controller = controller

if !updateWindow.isVisible {
let autoUpdates = AutoUpdates.sharedInstance

updateWindow.makeKeyAndOrderFront(nil)
versionTextField.stringValue = autoUpdates.getVersion()

releaseNotesWKWebView.configuration.preferences.javaScriptEnabled = false
let html = "<html><head><style>body { font-family: -apple-system }</style></head><body>\(autoUpdates.getReleaseNotes())</body></html>"
releaseNotesWKWebView.loadHTMLString(html, baseURL: nil)
}
}

@IBAction func visitReleasePageClick(_ sender: NSButton) {
let workspace = NSWorkspace.shared
let autoUpdates = AutoUpdates.sharedInstance

// We construct the URL this way... This is not great !
let url = URL(string: "https://github.com/JohnCoates/Aerial/releases/tag/v\(autoUpdates.getVersion())")!
workspace.open(url)

updateWindow.close()
}

@IBAction func helpButtonClick(_ sender: NSButton) {
helpPopover.show(relativeTo: sender.preparedContentRect, of: sender, preferredEdge: .maxY)
}

@IBAction func closeClick(_ sender: NSButton) {
updateWindow.close()
}

// MARK: - No update available
func showNoUpdate() {
if !noUpdateWindow.isVisible {
noUpdateWindow.makeKeyAndOrderFront(nil)
}
}

@IBAction func noUpdateCloseClick(_ sender: Any) {
noUpdateWindow.close()
}
}
17 changes: 9 additions & 8 deletions Aerial/Source/Models/AerialVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,28 @@ private let spaceVideos = [
]

private let seaVideos = [
"83C65C90-270C-4490-9C69-F51FE03D7F06", // Seals
"BA4ECA11-592F-4727-9221-D2A32A16EB28", // Palau Jellies
"83C65C90-270C-4490-9C69-F51FE03D7F06", // Seals (outdated)
"BA4ECA11-592F-4727-9221-D2A32A16EB28", // Palau Jellies *
"F07CC61B-30FC-4614-BDAD-3240B61F6793", // Palau Coral
"6143116D-03BB-485E-864E-A8CF58ACF6F1", // Kelp
"2B30E324-E4FF-4CC1-BA45-A958C2D2B2EC", // Barracuda
"E580E5A5-0888-4BE8-A4CA-F74A18A643C3", // Palau Jellies
"EC3DC957-D4C2-4732-AACE-7D0C0F390EC8", // Palau Jellies
"E580E5A5-0888-4BE8-A4CA-F74A18A643C3", // Palau Jellies *
"EC3DC957-D4C2-4732-AACE-7D0C0F390EC8", // Palau Jellies *
"581A4F1A-2B6D-468C-A1BE-6F473F06D10B", // Sea Stars
"687D03A2-18A5-4181-8E85-38F3A13409B9", // Bumpheads
"537A4DAB-83B0-4B66-BCD1-05E5DBB4A268", // Jacks
"C7AD3D0A-7EDF-412C-A237-B3C9D27381A1", // Alaskan Jellies
"C6DC4E54-1130-44F8-AF6F-A551D8E8A181", // Alaskan Jellies
"C7AD3D0A-7EDF-412C-A237-B3C9D27381A1", // Alaskan Jellies *
"C6DC4E54-1130-44F8-AF6F-A551D8E8A181", // Alaskan Jellies *
"27A37B0F-738D-4644-A7A4-E33E7A6C1175", // California Dolphins
"EB3F48E7-D30F-4079-858F-1A61331D5026", // California Kelp Forest
"CE9B5D5B-B6E7-47C5-8C04-59BF182E98FB", // Costa Rica Dolphins
"58C75C62-3290-47B8-849C-56A583173570", // Cownose Rays
"3716DD4B-01C0-4F5B-8DD6-DB771EC472FB", // Gray Reef Sharks
"DD47D8E1-CB66-4C12-BFEA-2ADB0D8D1E2E", // Humpback Whale
"82175C1F-153C-4EC8-AE37-2860EA828004", // Red Sea Coral
"149E7795-DBDA-4F5D-B39A-14712F841118", // Tahiti Waves
"8C31B06F-91A4-4F7C-93ED-56146D7F48B9", // Tahiti Waves,
"149E7795-DBDA-4F5D-B39A-14712F841118", // Tahiti Waves *
"8C31B06F-91A4-4F7C-93ED-56146D7F48B9", // Tahiti Waves *
"391BDF6E-3279-4CE1-9CA5-0F82811452D7", // Seals (new version)
]

private let timeInformation = [
Expand Down
Loading

0 comments on commit 0419a90

Please sign in to comment.