Skip to content

Commit

Permalink
auto updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ejbills committed Jun 23, 2024
1 parent b3c9fa3 commit 3a70701
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
37 changes: 35 additions & 2 deletions DockDoor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
BBE7CC942C225D9700AB8F4D /* App Icon.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBE7CC932C225D9700AB8F4D /* App Icon.swift */; };
BBF6C6222C1A9B4300BF1D40 /* AnimatedGradientOverlay.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF6C6212C1A9B4300BF1D40 /* AnimatedGradientOverlay.swift */; };
BBF6C6242C1B4B4400BF1D40 /* KeybindHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBF6C6232C1B4B4400BF1D40 /* KeybindHelper.swift */; };
BBFAD73A2C287A9C0092F5F1 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = BBFAD7392C287A9C0092F5F1 /* Sparkle */; };
BBFAD73C2C287C770092F5F1 /* UpdateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFAD73B2C287C770092F5F1 /* UpdateView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -50,6 +52,7 @@
BB1CBD5C2C1BCA4F003969BC /* Misc Utils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Misc Utils.swift"; sourceTree = "<group>"; };
BB2567C52C10C5F000C0C93E /* DockUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DockUtils.swift; sourceTree = "<group>"; };
BB6A4F1B2C1CFCFF00CB4C9E /* PermView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PermView.swift; sourceTree = "<group>"; };
BB8247782C2889B20098A440 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
BBA153F52C115DDA00119C02 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BBA153F72C11604400119C02 /* HoverWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HoverWindow.swift; sourceTree = "<group>"; };
BBA153F92C11FFD500119C02 /* consts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = consts.swift; sourceTree = "<group>"; };
Expand All @@ -59,6 +62,7 @@
BBE7CC932C225D9700AB8F4D /* App Icon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "App Icon.swift"; sourceTree = "<group>"; };
BBF6C6212C1A9B4300BF1D40 /* AnimatedGradientOverlay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedGradientOverlay.swift; sourceTree = "<group>"; };
BBF6C6232C1B4B4400BF1D40 /* KeybindHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeybindHelper.swift; sourceTree = "<group>"; };
BBFAD73B2C287C770092F5F1 /* UpdateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -67,6 +71,7 @@
buildActionMask = 2147483647;
files = (
BB33E68C2C24C72F00A21D69 /* LaunchAtLogin in Frameworks */,
BBFAD73A2C287A9C0092F5F1 /* Sparkle in Frameworks */,
BB1CBD5B2C1BA8DC003969BC /* Defaults in Frameworks */,
BBE7CC8F2C22421900AB8F4D /* Settings in Frameworks */,
);
Expand Down Expand Up @@ -111,6 +116,8 @@
BB157B672C0E31CE00997315 /* DockDoor */ = {
isa = PBXGroup;
children = (
BB8247792C288FD30098A440 /* Updates */,
BB8247782C2889B20098A440 /* Info.plist */,
BBA153F92C11FFD500119C02 /* consts.swift */,
BBA153FB2C12356100119C02 /* main.swift */,
BBA153F52C115DDA00119C02 /* AppDelegate.swift */,
Expand Down Expand Up @@ -148,6 +155,13 @@
path = Utilities;
sourceTree = "<group>";
};
BB8247792C288FD30098A440 /* Updates */ = {
isa = PBXGroup;
children = (
);
path = Updates;
sourceTree = "<group>";
};
BBA153FD2C12358600119C02 /* Views */ = {
isa = PBXGroup;
children = (
Expand All @@ -165,6 +179,7 @@
BBE7CC902C22429A00AB8F4D /* settings.swift */,
BB1CBD572C1BA800003969BC /* SettingsView.swift */,
BB6A4F1B2C1CFCFF00CB4C9E /* PermView.swift */,
BBFAD73B2C287C770092F5F1 /* UpdateView.swift */,
);
path = Settings;
sourceTree = "<group>";
Expand All @@ -189,6 +204,7 @@
BB1CBD5A2C1BA8DC003969BC /* Defaults */,
BBE7CC8E2C22421900AB8F4D /* Settings */,
BB33E68B2C24C72F00A21D69 /* LaunchAtLogin */,
BBFAD7392C287A9C0092F5F1 /* Sparkle */,
);
productName = DockDoor;
productReference = BB157B652C0E31CE00997315 /* DockDoor.app */;
Expand Down Expand Up @@ -222,6 +238,7 @@
BB1CBD592C1BA8DC003969BC /* XCRemoteSwiftPackageReference "Defaults" */,
BBE7CC8D2C22421900AB8F4D /* XCRemoteSwiftPackageReference "Settings" */,
BB33E68A2C24C72F00A21D69 /* XCRemoteSwiftPackageReference "LaunchAtLogin-Modern" */,
BBFAD7382C287A9C0092F5F1 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = BB157B662C0E31CE00997315 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -268,6 +285,7 @@
BBCFAE402C266234002E1516 /* FirstTimeView.swift in Sources */,
BB1CBD582C1BA800003969BC /* SettingsView.swift in Sources */,
BB157B792C0E330100997315 /* WindowUtil.swift in Sources */,
BBFAD73C2C287C770092F5F1 /* UpdateView.swift in Sources */,
BB157B7B2C0E343000997315 /* SystemPreferencesHelper.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -402,12 +420,13 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0;
DEVELOPMENT_ASSET_PATHS = "\"DockDoor/Preview Content\"";
DEVELOPMENT_TEAM = 2Q775S63Q3;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = DockDoor/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = DockDoor;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand All @@ -433,12 +452,13 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 1.0;
DEVELOPMENT_ASSET_PATHS = "\"DockDoor/Preview Content\"";
DEVELOPMENT_TEAM = 2Q775S63Q3;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = DockDoor/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = DockDoor;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
Expand Down Expand Up @@ -503,6 +523,14 @@
minimumVersion = 3.1.1;
};
};
BBFAD7382C287A9C0092F5F1 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.6.3;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -521,6 +549,11 @@
package = BBE7CC8D2C22421900AB8F4D /* XCRemoteSwiftPackageReference "Settings" */;
productName = Settings;
};
BBFAD7392C287A9C0092F5F1 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = BBFAD7382C287A9C0092F5F1 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BB157B5D2C0E31CE00997315 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "334ab441e2240d01dcdb3feea27f9e28aa71b2409d7b2457e70869276f1c59f9",
"originHash" : "51cd277ee08a0c8292b10496d5218bc50644a246f89f7bf92bb44cd945819e13",
"pins" : [
{
"identity" : "defaults",
Expand Down Expand Up @@ -27,6 +27,15 @@
"revision" : "879ea83a7bbc6dbebf62bed8c547f090146372a6",
"version" : "3.1.1"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "b456fd404954a9e13f55aa0c88cd5a40b8399638",
"version" : "2.6.3"
}
}
],
"version" : 3
Expand Down
Binary file not shown.
Binary file modified DockDoor/.DS_Store
Binary file not shown.
12 changes: 11 additions & 1 deletion DockDoor/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ import Cocoa
import SwiftUI
import Defaults
import Settings
import Sparkle

class AppDelegate: NSObject, NSApplicationDelegate {
private var dockObserver: DockObserver?
private var keybindHelper: KeybindHelper?
private var statusBarItem: NSStatusItem?

private var updaterController: SPUStandardUpdaterController

// settings
private var settingsWindow: NSWindow?
private lazy var settingsWindowController = SettingsWindowController(
panes: [
GeneralSettingsViewController(),
PermissionsSettingsViewController()
PermissionsSettingsViewController(),
UpdatesSettingsViewController(updater: updaterController.updater)
]
)

override init() {
self.updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
self.updaterController.startUpdater()
super.init()
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
if !Defaults[.launched] {
Expand Down
10 changes: 8 additions & 2 deletions DockDoor/DockDoor.entitlements
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
<dict>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spks</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spki</string>
</array>
</dict>
</plist>
14 changes: 14 additions & 0 deletions DockDoor/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SUEnableDownloaderService</key>
<true/>
<key>SUEnableInstallerLauncherService</key>
<true/>
<key>SUFeedURL</key>
<string>https://dockdoor.kepler.cafe/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>ANSWtGdda5j5Jgr53GvK7uE4KLaVs2cNFD8nKWXWrlI=</string>
</dict>
</plist>
60 changes: 60 additions & 0 deletions DockDoor/Views/Settings/UpdateView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// UpdateView.swift
// DockDoor
//
// Created by Ethan Bills on 6/23/24.
//

import SwiftUI
import Sparkle

// This view model class publishes when new updates can be checked by the user
final class CheckForUpdatesViewModel: ObservableObject {
@Published var canCheckForUpdates = false

init(updater: SPUUpdater) {
updater.publisher(for: \.canCheckForUpdates)
.assign(to: &$canCheckForUpdates)
}
}

// This is the view for the Check for Updates menu item
// Note this intermediate view is necessary for the disabled state on the menu item to work properly before Monterey.
// See https://stackoverflow.com/questions/68553092/menu-not-updating-swiftui-bug for more info
struct CheckForUpdatesView: View {
@ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel
private let updater: SPUUpdater

init(updater: SPUUpdater) {
self.updater = updater

// Create our view model for our CheckForUpdatesView
self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater)
}

var body: some View {
VStack(alignment: .leading, spacing: 20) {
HStack {
Image(systemName: checkForUpdatesViewModel.canCheckForUpdates ? "checkmark.circle.fill" : "xmark.circle.fill")
.foregroundColor(checkForUpdatesViewModel.canCheckForUpdates ? .green : .red)
.scaleEffect(checkForUpdatesViewModel.canCheckForUpdates ? 1.2 : 1.0)
.padding(10)

Text("Can check for updates")
.font(.headline)
}

Button(action: updater.checkForUpdates) {
HStack {
Image(systemName: "arrow.triangle.2.circlepath")
Text("Check for Updates…")
}
}
.buttonStyle(.bordered)
.disabled(!checkForUpdatesViewModel.canCheckForUpdates)

Spacer()
}
.padding(20)
}
}
14 changes: 14 additions & 0 deletions DockDoor/Views/Settings/settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@

import Cocoa
import Settings
import Sparkle

extension Settings.PaneIdentifier {
static let general = Self("general")
static let permissions = Self("permissions")
static let updates = Self("updates")
}

let GeneralSettingsViewController: () -> SettingsPane = {
Expand All @@ -36,3 +38,15 @@ let PermissionsSettingsViewController: () -> SettingsPane = {

return Settings.PaneHostingController(pane: paneView)
}

func UpdatesSettingsViewController(updater: SPUUpdater) -> SettingsPane {
let paneView = Settings.Pane(
identifier: .updates,
title: "Updates",
toolbarIcon: NSImage(systemSymbolName: "arrow.triangle.2.circlepath", accessibilityDescription: "Update settings")!
) {
CheckForUpdatesView(updater: updater)
}

return Settings.PaneHostingController(pane: paneView)
}

0 comments on commit 3a70701

Please sign in to comment.