Skip to content

Commit c4a3df8

Browse files
authored
Merge pull request #2 from LZhenHong/feat/updates
Add Sparkle.
2 parents c8421cb + 1e854e0 commit c4a3df8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2035
-1704
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ DerivedData/
2222
*.perspectivev3
2323
!default.perspectivev3
2424
*.xcarchive
25+
Archive/
26+
Releases/
2527

2628
## Obj-C/Swift specific
2729
*.hmap

Americano.xcodeproj/project.pbxproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
F225ADD42BF119970024283A /* Storage in Frameworks */ = {isa = PBXBuildFile; productRef = F225ADD32BF119970024283A /* Storage */; };
1111
F2811B322B678C0300C85719 /* Storage in Frameworks */ = {isa = PBXBuildFile; productRef = F2811B312B678C0300C85719 /* Storage */; };
12+
F290F3652D79A86000BC2F65 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = F290F3642D79A86000BC2F65 /* Sparkle */; };
1213
/* End PBXBuildFile section */
1314

1415
/* Begin PBXFileReference section */
@@ -35,6 +36,7 @@
3536
isa = PBXFrameworksBuildPhase;
3637
buildActionMask = 2147483647;
3738
files = (
39+
F290F3652D79A86000BC2F65 /* Sparkle in Frameworks */,
3840
F225ADD42BF119970024283A /* Storage in Frameworks */,
3941
F2811B322B678C0300C85719 /* Storage in Frameworks */,
4042
);
@@ -81,6 +83,7 @@
8183
packageProductDependencies = (
8284
F2811B312B678C0300C85719 /* Storage */,
8385
F225ADD32BF119970024283A /* Storage */,
86+
F290F3642D79A86000BC2F65 /* Sparkle */,
8487
);
8588
productName = Americano;
8689
productReference = F2CACC482ABACDA600CB2BE4 /* Americano.app */;
@@ -114,6 +117,7 @@
114117
mainGroup = F2CACC3F2ABACDA600CB2BE4;
115118
packageReferences = (
116119
F225ADD22BF119970024283A /* XCRemoteSwiftPackageReference "StorageMacro" */,
120+
F290F3632D79A86000BC2F65 /* XCRemoteSwiftPackageReference "Sparkle" */,
117121
);
118122
productRefGroup = F2CACC492ABACDA600CB2BE4 /* Products */;
119123
projectDirPath = "";
@@ -369,6 +373,14 @@
369373
minimumVersion = 0.0.1;
370374
};
371375
};
376+
F290F3632D79A86000BC2F65 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
377+
isa = XCRemoteSwiftPackageReference;
378+
repositoryURL = "https://github.com/sparkle-project/Sparkle";
379+
requirement = {
380+
kind = upToNextMajorVersion;
381+
minimumVersion = 2.7.0;
382+
};
383+
};
372384
/* End XCRemoteSwiftPackageReference section */
373385

374386
/* Begin XCSwiftPackageProductDependency section */
@@ -381,6 +393,11 @@
381393
isa = XCSwiftPackageProductDependency;
382394
productName = Storage;
383395
};
396+
F290F3642D79A86000BC2F65 /* Sparkle */ = {
397+
isa = XCSwiftPackageProductDependency;
398+
package = F290F3632D79A86000BC2F65 /* XCRemoteSwiftPackageReference "Sparkle" */;
399+
productName = Sparkle;
400+
};
384401
/* End XCSwiftPackageProductDependency section */
385402
};
386403
rootObject = F2CACC402ABACDA600CB2BE4 /* Project object */;

Americano.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Americano/AppDelegate.swift

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,56 @@
66
//
77

88
import Cocoa
9+
#if USE_SPARKLE
10+
import Sparkle
11+
#endif
912

1013
final class AppDelegate: NSObject, NSApplicationDelegate {
11-
static var bundleIdentifier: String {
12-
Bundle.main.bundleIdentifier ?? "io.lzhlovesjyq.Americano"
13-
}
14-
15-
func applicationWillFinishLaunching(_ notification: Notification) {
16-
populateMainMenu()
17-
}
18-
19-
func applicationDidFinishLaunching(_ aNotification: Notification) {
20-
URLSchemeUtils.register()
21-
22-
CaffeinateController.shared.setUp()
23-
MenuBarItemController.shared.setUp()
24-
}
25-
26-
func applicationWillTerminate(_ aNotification: Notification) {
27-
CaffeinateController.shared.stop()
28-
}
29-
30-
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
31-
return true
32-
}
14+
static var bundleIdentifier: String {
15+
Bundle.main.bundleIdentifier ?? "io.lzhlovesjyq.Americano"
16+
}
17+
18+
#if USE_SPARKLE
19+
static let updaterController = SPUStandardUpdaterController(
20+
startingUpdater: true,
21+
updaterDelegate: nil,
22+
userDriverDelegate: nil
23+
)
24+
#endif
25+
26+
func applicationWillFinishLaunching(_: Notification) {
27+
populateMainMenu()
28+
}
29+
30+
func applicationDidFinishLaunching(_: Notification) {
31+
URLSchemeUtils.register()
32+
33+
CaffeinateController.shared.setUp()
34+
MenuBarItemController.shared.setUp()
35+
}
36+
37+
func applicationWillTerminate(_: Notification) {
38+
CaffeinateController.shared.stop()
39+
}
40+
41+
func applicationSupportsSecureRestorableState(_: NSApplication) -> Bool {
42+
return true
43+
}
3344
}
3445

3546
extension AppDelegate {
36-
func populateMainMenu() {
37-
let mainMenu = NSMenu(title: "Main Menu")
38-
let fileMenuItem = mainMenu.addItem(withTitle: "File", action: nil, keyEquivalent: "")
39-
let submenu = NSMenu(title: String(localized: "File"))
47+
func populateMainMenu() {
48+
let mainMenu = NSMenu(title: "Main Menu")
49+
let fileMenuItem = mainMenu.addItem(withTitle: "File", action: nil, keyEquivalent: "")
50+
let submenu = NSMenu(title: String(localized: "File"))
4051

41-
let closeWindowItem = NSMenuItem(title: String(localized: "Close Window"),
42-
action: #selector(NSWindow.performClose(_:)),
43-
keyEquivalent: "w")
44-
submenu.addItem(closeWindowItem)
52+
let closeWindowItem = NSMenuItem(title: String(localized: "Close Window"),
53+
action: #selector(NSWindow.performClose(_:)),
54+
keyEquivalent: "w")
55+
submenu.addItem(closeWindowItem)
4556

46-
mainMenu.setSubmenu(submenu, for: fileMenuItem)
57+
mainMenu.setSubmenu(submenu, for: fileMenuItem)
4758

48-
NSApp.mainMenu = mainMenu
49-
}
59+
NSApp.mainMenu = mainMenu
60+
}
5061
}

Americano/Data/AppState.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,43 @@ import SwiftUI
1010

1111
@storage
1212
final class AppState: ObservableObject {
13-
@nonstorage
14-
@Published var preventSleep = false
15-
@nonstorage
16-
@Published var launchAtLogin = LaunchAtLogin.isEnabled
13+
@nonstorage
14+
@Published var preventSleep = false
15+
@nonstorage
16+
@Published var launchAtLogin = LaunchAtLogin.isEnabled
1717

18-
// MARK: - General
18+
// MARK: - General
1919

20-
var activateOnLaunch = false
21-
var activateScreenSaver = false
22-
var allowDisplaySleep = false
20+
var activateOnLaunch = false
21+
var activateScreenSaver = false
22+
var allowDisplaySleep = false
2323

24-
// MARK: - Durations
24+
// MARK: - Durations
2525

26-
var awakeDurations = AwakeDurations()
26+
var awakeDurations = AwakeDurations()
2727

28-
// MARK: - Battery
28+
// MARK: - Battery
2929

30-
var batteryMonitorEnable = false
31-
var batteryLowThreshold = 50
32-
var lowPowerMonitorEnable = false
33-
var activatePlug = false
34-
var deactivateUnplug = false
30+
var batteryMonitorEnable = false
31+
var batteryLowThreshold = 50
32+
var lowPowerMonitorEnable = false
33+
var activatePlug = false
34+
var deactivateUnplug = false
3535

36-
// MARK: - Nofitication
36+
// MARK: - Nofitication
3737

38-
var notifyWhenActivate = false
39-
var notifyWhenDeactivate = false
38+
var notifyWhenActivate = false
39+
var notifyWhenDeactivate = false
4040

41-
static let shared = AppState()
41+
static let shared = AppState()
4242

43-
fileprivate init() {}
43+
fileprivate init() {}
4444
}
4545

4646
#if DEBUG
47-
extension AppState {
47+
extension AppState {
4848
static var sample: AppState {
49-
.shared
49+
.shared
5050
}
51-
}
51+
}
5252
#endif

0 commit comments

Comments
 (0)