Skip to content

Commit

Permalink
refactor: replace the deprecated SUUpdater with SPUStandardUpdaterCon…
Browse files Browse the repository at this point in the history
…troller
  • Loading branch information
tisfeng committed Dec 11, 2023
1 parent b008728 commit a81fc4b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Easydict/App/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
//

#import <Cocoa/Cocoa.h>
#import <Sparkle/SPUStandardUpdaterController.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (weak) IBOutlet SPUStandardUpdaterController *updaterController;

@end
18 changes: 11 additions & 7 deletions Easydict/App/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,17 @@ DQ
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
</connections>
</application>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
<connections>
<outlet property="updaterController" destination="dTQ-Lg-1D6" id="ulf-mx-z8R"/>
</connections>
</customObject>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="dTQ-Lg-1D6" customClass="SPUStandardUpdaterController">
<connections>
<outlet property="updaterDelegate" destination="Voe-Tx-rLC" id="3Ya-Y2-qiK"/>
</connections>
</customObject>
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
<customObject id="qM9-fT-Fym" customClass="EZMenuItemManager">
<connections>
Expand All @@ -727,11 +736,6 @@ DQ
<outlet property="versionItem" destination="PkP-25-JBw" id="beL-5f-TOn"/>
</connections>
</customObject>
<customObject id="jrA-nT-KAI" customClass="SUUpdater">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="x7m-9L-GYz"/>
</connections>
</customObject>
<menu autoenablesItems="NO" identifier="status.item.menu" id="A3F-ys-zOg" userLabel="Status Item Menu">
<items>
<menuItem title="Easydict" id="PkP-25-JBw">
Expand Down Expand Up @@ -784,7 +788,7 @@ DQ
<menuItem title="检查更新" id="GQ2-WA-9QB">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="checkForUpdates:" target="jrA-nT-KAI" id="9sy-r4-kzD"/>
<action selector="checkForUpdates:" target="dTQ-Lg-1D6" id="ydL-Jy-6z2"/>
</connections>
</menuItem>
<menuItem title="帮助" id="ICB-w8-IqK">
Expand Down
13 changes: 11 additions & 2 deletions Easydict/Feature/Configuration/EZConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#import "EZScriptExecutor.h"
#import "EZLog.h"
#import "EZLanguageManager.h"
#import "AppDelegate.h"

static NSString *const kEasydictHelperBundleId = @"com.izual.EasydictHelper";

Expand Down Expand Up @@ -55,6 +56,12 @@
static NSString *const kClearInputKey = @"EZConfiguration_kClearInputKey";


@interface EZConfiguration ()

@property (nonatomic, strong) AppDelegate *appDelegate;

@end

@implementation EZConfiguration

static EZConfiguration *_instance;
Expand All @@ -78,6 +85,8 @@ + (instancetype)allocWithZone:(struct _NSZone *)zone {
}

- (void)setup {
self.appDelegate = (AppDelegate *)[NSApp delegate];

EZLanguage defaultFirstLanguage = [EZLanguageManager.shared systemPreferredTwoLanguages][0];
self.firstLanguage = [NSUserDefaults mm_readString:kFirstLanguageKey defaultValue:defaultFirstLanguage];
EZLanguage defaultSecondLanguage = [EZLanguageManager.shared systemPreferredTwoLanguages][1];
Expand Down Expand Up @@ -123,7 +132,7 @@ - (BOOL)launchAtStartup {
}

- (BOOL)automaticallyChecksForUpdates {
return [SUUpdater sharedUpdater].automaticallyChecksForUpdates;
return self.appDelegate.updaterController.updater.automaticallyChecksForUpdates;
}

#pragma mark - setter
Expand Down Expand Up @@ -210,7 +219,7 @@ - (void)setLaunchAtStartup:(BOOL)launchAtStartup {
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyChecksForUpdates {
[NSUserDefaults mm_write:@(automaticallyChecksForUpdates) forKey:kAutomaticallyChecksForUpdatesKey];

[[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:automaticallyChecksForUpdates];
self.appDelegate.updaterController.updater.automaticallyChecksForUpdates = automaticallyChecksForUpdates;

[self logSettings:@{@"automatically_checks_for_updates" : @(automaticallyChecksForUpdates)}];
}
Expand Down
10 changes: 10 additions & 0 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
<channel>
<title>Easydict</title>

<item>
<title>2.4.0</title>
<pubDate>Sun, 10 Dec 2023 19:30:00 +0800</pubDate>
<sparkle:version>29</sparkle:version>
<sparkle:shortVersionString>2.4.0</sparkle:shortVersionString>
<sparkle:minimumSystemVersion>11.0</sparkle:minimumSystemVersion>
<sparkle:releaseNotesLink>https://github.com/tisfeng/easydict/releases/tag/2.3.0</sparkle:releaseNotesLink>
<enclosure url="https://github.com/tisfeng/Easydict/releases/download/2.3.0/Easydict.zip" type="application/octet-stream" sparkle:edSignature="yjrKEXjTfKqC1YdJvPIIGK7G27jd4aK2CJ4j/ZqbaZBUC2hQyyKvgC1CPuuWOrk274Oz/N53L2G/aXHXt7H1CQ==" length="11153425" />
</item>

<item>
<title>2.3.0</title>
<pubDate>Sun, 10 Dec 2023 19:30:00 +0800</pubDate>
Expand Down

0 comments on commit a81fc4b

Please sign in to comment.