Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Updates offers Vitrine releases and lets release builds include betas
My-Name-Is-Jeffb9b1f5fe3cca
diff --git a/docs/parity.md b/docs/parity.mdindex 4240b11f..732a9e4a 100644--- a/docs/parity.md+++ b/docs/parity.md@@ -66,6 +66,7 @@ fixed in the commits that follow `956e65c`.| 90, 105 | Live Activity: the cover, its colour, progress, centred and translated lyrics, and a small layout on Apple Watch and CarPlay from iOS 18 || 89 | Listening stats, with Spotify's export imported || 79, 98 | Apple Music red accent, one font for the whole app |+| 17 | Beta builds update to the next beta, then the release. Mod > Include betas lets a release build opt in |### Round 2: player, pages, lyrics, settings@@ -159,7 +160,6 @@ Rebuilt from behaviour-only descriptions; each commit credits the PR's author.| # | Item | Why ||---|---|---|-| 17 | Beta builds update to beta pre-releases | Update check is off until the fork has releases || 19, 35, 86 | Certificate offer, Arctic Sign card, usage ping | Third-party signing upsell and upstream telemetry || 91, 99, 100, 102, 131 | Plus categories, locks and offer | No paid tier || 95 (Account page) | chroma.pw account | No account. The system Settings style is below |diff --git a/docs/tweaks.md b/docs/tweaks.mdindex d459e04a..e8a0b3bc 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -399,15 +399,17 @@ App:ModSettings.x the root page and the rows that open it from Spotify's settings and the side drawerPages.m Redesigned UI's switch, the Appearance, Vibrations, Player and Lyrics pages, which Tab bar page opensAbout/ the update check against the repo's GitHub Releases, the Updates page it fills (the state, and- the changelog of every release newer than the build, a line per commit) and the sheet a newer+ the changelog of every release newer than the build, a line per commit), betas counted only+ while Mod > Include betas is on (unset, on for a beta build), and the sheet a newerrelease brings up on its own a few seconds after Spotify opens, once per release; backup, the- signing warning and the Mod page with the reset+ signing warning, the date the provisioning profile runs out (on the Mod page, and at the top of+ Mod Settings for a free Apple ID's week) and the Mod page with the resetOnboarding/ the welcome page over Home on the first launch, opening on the logo in glass, with Redesigned UI;on the first launch of a new version instead, What's new (WhatsNew.m), this version's section ofCHANGELOG.md, which scripts/whats-new.sh writes into a gitignored header at each make (a sectionthat came over from upstream is left out, so a build without its own has no sheet). The Modpage offers both again. Environment.m says once per install state, a few seconds in, when- EeveeSpotify is injected too (a dyld image named so) or Spotify is not the version the mod is+ EeveeSpotify is injected too (a dyld image named so, or its settings page's Swift class) or Spotify is not the version the mod ismade for (SGSpotifyMadeFor), and when a redesign below iOS 26 did not start; the first two stayas red rows at the top of Mod Settings. Laid out on the simulator by harness/onboarding/diff --git a/harness/update/README.md b/harness/update/README.mdindex 6d5d8ddc..726a4ed9 100644--- a/harness/update/README.md+++ b/harness/update/README.md@@ -17,3 +17,13 @@ inside Spotify, and the sheet follows about seven seconds in -- a second run witquiet, because a release is told about once; `recheck` taps Check now five seconds in. A version behind the newest release (`0.18.0`)shows the update and everything since; the newest one (`0.19.0`) shows "up to date" and what wentinto this build; an old one (`0.17.0`) shows several releases, newest first.++`releases` checks, without the network, what a reply and a stored list leave for the build: run it+built as `1.0.0` and as `1.0.0-beta.1`. A release build keeps no beta, neither from GitHub's reply+nor from a list a beta stored, and a reply of betas only reads "up to date"; a beta keeps them. With+Include betas switched the other way, each keeps what the other would. A table of stored lists then+names the version offered with the switch on and off: beta to beta to release, a beta after a+release only with the switch on, never a version below the build's.++`versions` checks the ordering itself, including the chain 1.0.0-beta.1, 1.0.0-beta.2, 1.0.0,+1.0.1-beta.1, 1.0.1 and that no step back counts as newer.diff --git a/harness/update/build.sh b/harness/update/build.shindex a7aa3542..916417a1 100755--- a/harness/update/build.sh+++ b/harness/update/build.sh@@ -11,7 +11,7 @@ rm -rf "$OUT"; mkdir -p "$OUT/UpdateHarness.app"SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g -O0 \-I"$SRC" -isysroot "$SDK" -Wno-deprecated-declarations -DSG_VERSION="\"$VERSION\"" \- "$(dirname "$0")/main.m" \+ "$(dirname "$0")/main.m" "$(dirname "$0")/../scene.m" \"$SRC"/App/About/Update.m "$SRC"/App/About/UpdatePage.m "$SRC"/App/About/UpdateNotice.m \"$SRC"/Settings/SGPage.m "$SRC"/Settings/SGPageStyle.m \"$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGViewTree.m "$SRC"/Core/SGGlass.m \@@ -32,6 +32,12 @@ cat > "$OUT/UpdateHarness.app/Info.plist" <<'PLIST'<key>UILaunchScreen</key><dict/><key>UIApplicationSceneManifest</key><dict><key>UIApplicationSupportsMultipleScenes</key><false/>+ <key>UISceneConfigurations</key><dict>+ <key>UIWindowSceneSessionRoleApplication</key><array><dict>+ <key>UISceneConfigurationName</key><string>Default</string>+ <key>UISceneDelegateClassName</key><string>SGRHarnessScene</string>+ </dict></array>+ </dict></dict></dict></plist>PLISTdiff --git a/harness/update/main.m b/harness/update/main.mindex 79ed373d..d5ec6419 100644--- a/harness/update/main.m+++ b/harness/update/main.m@@ -37,6 +37,119 @@ static UIViewController *plainScreen(void) {- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)options {NSArray<NSString *> *arguments = NSProcessInfo.processInfo.arguments;+ // `versions`: the comparison the check sorts and decides by, then quits.+ if ([arguments containsObject:@"versions"]) {+ NSArray<NSArray<NSString *> *> *newer = @[+ @[@"0.21.2", @"0.21.1"], @[@"1.0.0", @"0.50.0"], @[@"1.0.0-beta.2", @"1.0.0-beta.1"],+ @[@"1.0.0-beta.10", @"1.0.0-beta.9"], @[@"1.0.0", @"1.0.0-beta.9"], @[@"1.0.0-rc.1", @"1.0.0-beta.9"],+ @[@"1.0.1-beta.1", @"1.0.0"], @[@"1.0.0-beta.1.1", @"1.0.0-beta.1"], @[@"1.1", @"1.0.9"],+ // Beta to beta to release, and on past it: each step is newer than the one before, so the+ // reverse, a downgrade, never is.+ @[@"1.0.0-beta.2", @"1.0.0-beta.1"], @[@"1.0.0", @"1.0.0-beta.2"], @[@"1.0.1-beta.1", @"1.0.0"],+ @[@"1.0.1", @"1.0.1-beta.1"], @[@"1.1.0-beta.1", @"1.0.1"], @[@"1.0.0-beta.1", @"0.50.0"],+ ];+ NSUInteger wrong = 0;+ for (NSArray<NSString *> *pair in newer) {+ if (!SGVersionIsNewer(pair[0], pair[1]) || SGVersionIsNewer(pair[1], pair[0])) {+ wrong++;+ NSLog(@"[harness] versions: WRONG %@ should be newer than %@", pair[0], pair[1]);+ }+ }+ for (NSString *same in @[@"1.0.0", @"1.0.0-beta.1", @"0.21.1"]) {+ if (SGVersionIsNewer(same, same)) { wrong++; NSLog(@"[harness] versions: WRONG %@ newer than itself", same); }+ }+ if (SGVersionIsNewer(@"1.0", @"1.0.0") || SGVersionIsNewer(@"1.0.0", @"1.0")) { wrong++; NSLog(@"[harness] versions: WRONG 1.0 and 1.0.0 differ"); }+ NSLog(@"[harness] versions: %lu wrong -- %@", (unsigned long)wrong, wrong ? @"FAIL" : @"PASS");+ exit(wrong ? 1 : 0);+ }+ // `releases`: what a reply and a stored list leave for the build it is, then quits. Build it as+ // 1.0.0 and as 1.0.0-beta.1; the checks name which they expect of each.+ if ([arguments containsObject:@"releases"]) {+ BOOL beta = strchr(SG_VERSION, '-') != NULL;+ NSUInteger wrong = 0;+ // As a phone that has never checked nor touched Include betas, whatever a crashed run left.+ for (NSString *key in @[@"spotifyglass.update.checked", @"spotifyglass.update.releases", SGKeyUpdateBetas, @"spotifyglass.stock"])+ [NSUserDefaults.standardUserDefaults removeObjectForKey:key];+ // Twenty-five betas, newest first, with a stable 1.1.0 in 22nd place.+ NSMutableArray *reply = [NSMutableArray array];+ for (int i = 25; i >= 1; i--) {+ [reply addObject:@{@"tag_name": [NSString stringWithFormat:@"v2.0.0-beta.%d", i], @"prerelease": @YES, @"draft": @NO}];+ if (i == 5) [reply addObject:@{@"tag_name": @"v1.1.0", @"prerelease": @NO, @"draft": @NO}];+ }+ NSArray<NSDictionary *> *kept = SGUpdateReleasesFrom([NSJSONSerialization dataWithJSONObject:reply options:0 error:NULL]);+ NSString *expected = beta ? @"2.0.0-beta.25" : @"1.1.0";+ if (kept.count != (beta ? 20 : 1) || ![kept.firstObject[@"version"] isEqualToString:expected]) {+ wrong++; NSLog(@"[harness] releases: WRONG kept %lu, newest %@, expected %@", (unsigned long)kept.count, kept.firstObject[@"version"], expected);+ }+ // Only betas: a release build has nothing newer, which is an empty list and not a failure.+ NSArray *onlyBetas = [reply filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"prerelease == YES"]];+ kept = SGUpdateReleasesFrom([NSJSONSerialization dataWithJSONObject:onlyBetas options:0 error:NULL]);+ if (!kept || kept.count != (beta ? 20 : 0)) { wrong++; NSLog(@"[harness] releases: WRONG only betas left %@", kept); }+ if (SGUpdateReleasesFrom([@"{\"message\":\"Not Found\"}" dataUsingEncoding:NSUTF8StringEncoding])) {+ wrong++; NSLog(@"[harness] releases: WRONG an error object read as releases");+ }+ // A list a beta stored, one entry before the prerelease mark existed: a release build sees neither.+ NSUserDefaults *store = NSUserDefaults.standardUserDefaults;+ [store setObject:@[@{@"version": @"1.1.0-beta.2", @"prerelease": @YES}, @{@"version": @"1.1.0-beta.1"}, @{@"version": @"1.0.0", @"prerelease": @NO}]+ forKey:@"spotifyglass.update.releases"];+ [store setDouble:NSDate.date.timeIntervalSince1970 forKey:@"spotifyglass.update.checked"];+ NSString *newer = SGUpdateVersion(), *status = SGUpdateStatus();+ if (beta ? ![newer isEqualToString:@"1.1.0-beta.2"] : (newer != nil || ![status isEqualToString:@"up to date"])) {+ wrong++; NSLog(@"[harness] releases: WRONG the stored list reads %@ (%@)", newer, status);+ }+ [store setObject:@[] forKey:@"spotifyglass.update.releases"];+ if (![SGUpdateStatus() isEqualToString:@"up to date"]) { wrong++; NSLog(@"[harness] releases: WRONG an empty check reads %@", SGUpdateStatus()); }+ if (SGUpdateIncludesBetas() != beta) { wrong++; NSLog(@"[harness] releases: WRONG Include betas starts %d", SGUpdateIncludesBetas()); }++ // Include betas switched the other way from the build's default: the reply keeps what the other+ // kind of build would.+ [store setBool:!beta forKey:SGKeyUpdateBetas];+ kept = SGUpdateReleasesFrom([NSJSONSerialization dataWithJSONObject:reply options:0 error:NULL]);+ expected = beta ? @"1.1.0" : @"2.0.0-beta.25";+ if (kept.count != (beta ? 1 : 20) || ![kept.firstObject[@"version"] isEqualToString:expected]) {+ wrong++; NSLog(@"[harness] releases: WRONG switched, kept %lu, newest %@, expected %@", (unsigned long)kept.count, kept.firstObject[@"version"], expected);+ }+ // A beta tag GitHub has not marked is still a beta.+ kept = SGUpdateReleasesFrom([@"[{\"tag_name\":\"v3.0.0-beta.1\",\"prerelease\":false}]" dataUsingEncoding:NSUTF8StringEncoding]);+ if (kept.count != (beta ? 0 : 1)) { wrong++; NSLog(@"[harness] releases: WRONG an unmarked beta tag, switched, left %@", kept); }++ // What is offered out of a stored list, with the switch on and off. The columns after the list+ // are a beta build (1.0.0-beta.1) on, off, then a release build (1.0.0) on, off; "-" is nothing.+ NSDictionary *pre = @{@"prerelease": @YES}, *final = @{@"prerelease": @NO};+ NSArray *offers = @[+ @[@[@[@"1.0.0-beta.2", pre]], @"1.0.0-beta.2", @"-", @"-", @"-"],+ @[@[@[@"1.0.0", final], @[@"1.0.0-beta.2", pre]], @"1.0.0", @"1.0.0", @"-", @"-"],+ @[@[@[@"1.0.1-beta.1", pre], @[@"1.0.0", final]], @"1.0.1-beta.1", @"1.0.0", @"1.0.1-beta.1", @"-"],+ @[@[@[@"1.0.0-beta.9", @{}]], @"1.0.0-beta.9", @"-", @"-", @"-"], // stored before the mark+ @[@[@[@"1.1.0", final], @[@"1.0.1-beta.1", pre]], @"1.1.0", @"1.1.0", @"1.1.0", @"1.1.0"],+ @[@[@[@"0.9.0", final]], @"-", @"-", @"-", @"-"],+ @[@[], @"-", @"-", @"-", @"-"],+ ];+ for (NSArray *offer in offers) {+ NSMutableArray *stored = [NSMutableArray array], *versions = [NSMutableArray array];+ for (NSArray *entry in offer[0]) {+ NSMutableDictionary *release = [entry[1] mutableCopy];+ release[@"version"] = entry[0];+ [stored addObject:release];+ [versions addObject:entry[0]];+ }+ [store setObject:stored forKey:@"spotifyglass.update.releases"];+ NSString *list = [versions componentsJoinedByString:@", "];+ for (int on = 1; on >= 0; on--) {+ [store setBool:on forKey:SGKeyUpdateBetas];+ NSString *want = offer[(beta ? 1 : 3) + (on ? 0 : 1)];+ NSString *got = SGUpdateVersion() ?: @"-";+ BOOL saysBeta = SGUpdateNewestRelease().prerelease;+ BOOL right = [got isEqualToString:want] && (!SGUpdateVersion() || saysBeta == [got containsString:@"-"]);+ if (!right) wrong++;+ NSLog(@"[harness] releases: %@betas %s, stored [%@]: offered %@%@, expected %@", right ? @"" : @"WRONG ",+ on ? "on" : "off", list, got, saysBeta && SGUpdateVersion() ? @" as a beta" : @"", want);+ }+ }+ for (NSString *key in @[@"spotifyglass.update.checked", @"spotifyglass.update.releases", SGKeyUpdateBetas]) [store removeObjectForKey:key];+ NSLog(@"[harness] releases as %s: %lu wrong -- %@", SG_VERSION, (unsigned long)wrong, wrong ? @"FAIL" : @"PASS");+ exit(wrong ? 1 : 0);+ }if ([arguments containsObject:@"wipe"]) {for (NSString *key in @[@"spotifyglass.update.checked", @"spotifyglass.update.releases", @"spotifyglass.update.told"])[NSUserDefaults.standardUserDefaults removeObjectForKey:key];diff --git a/tweak/Sources/App/About/About.h b/tweak/Sources/App/About/About.hindex 93340b9a..03b01a6f 100644--- a/tweak/Sources/App/About/About.h+++ b/tweak/Sources/App/About/About.h@@ -23,14 +23,26 @@ extern NSString *const SGUpdateCheckedNotification; // on the main thread, aft@property (nonatomic, copy) NSString *date; // ISO 8601, as GitHub publishes it@property (nonatomic, copy) NSString *url; // the release page, where the .deb is@property (nonatomic, copy) NSArray<SGUpdateChange *> *changes;+@property (nonatomic) BOOL prerelease; // a beta, by GitHub's mark or the "-" in its version@end-NSArray<SGUpdateRelease *> *SGUpdateReleases(void); // newest first, empty until a check lands+// Mod > Include betas: whether the check counts pre-releases. Unset, it is on for a beta build (a "-"+// in SG_VERSION) and off for a release; the row rechecks when it is flipped.+#define SGKeyUpdateBetas @"spotifyglass.update.betas"+BOOL SGBuildIsBeta(void);+BOOL SGUpdateIncludesBetas(void);++NSArray<SGUpdateRelease *> *SGUpdateReleases(void); // newest first that count for this build, empty until a check lands+// GitHub's reply as the check stores it: the newest twenty that count for this build, newest first,+// empty when none does, nil when the reply is not a list of releases.+NSArray<NSDictionary *> *SGUpdateReleasesFrom(NSData *data);+BOOL SGUpdateChecked(void); // a check has landed at least once// The lines of a release body as Release Please writes it, also what the What's new sheet reads.NSArray<SGUpdateChange *> *SGUpdateChangesIn(NSString *body);SGUpdateRelease *SGUpdateNewestRelease(void);NSString *SGUpdateVersion(void); // nil unless GitHub has a release newer than this buildBOOL SGUpdateIsNewer(NSString *version); // whether that release is newer than the build running+BOOL SGVersionIsNewer(NSString *candidate, NSString *current); // semantic versions, pre-releases includedNSString *SGUpdateStatus(void);void SGCheckForUpdate(BOOL force);UIViewController *SGUpdatePage(void); // UpdatePage.m: the state and the changelogdiff --git a/tweak/Sources/App/About/AboutSettings.m b/tweak/Sources/App/About/AboutSettings.mindex 9e8747da..d8d25d88 100644--- a/tweak/Sources/App/About/AboutSettings.m+++ b/tweak/Sources/App/About/AboutSettings.m@@ -42,6 +42,11 @@ UIViewController *SGAboutPage(void) {// The row reads out where the build stands and opens the changelog of everything newer than it.SGModRow *updates = SGPageRow(@"Updates", ^UIViewController *{ return SGUpdatePage(); });updates.value = ^NSString *{ return SGUpdateStatus(); };+ // A release build can opt into betas; a beta build starts opted in. Either way a check follows at+ // once, since the stored list only holds what counted at the last one.+ SGModRow *betas = SGSwitchRow(@"Include betas", @"Offer test builds ahead of each release", SGKeyUpdateBetas);+ betas.defaultOn = SGBuildIsBeta();+ betas.changed = ^(BOOL on) { SGCheckForUpdate(YES); };NSMutableArray<SGModRow *> *links = [NSMutableArray array];if (SGRepoURL) [links addObject:withSymbol(SGLinkRow(@"GitHub", nil, SGRepoURL), @"chevron.left.forwardslash.chevron.right")];[links addObjectsFromArray:@[@@ -49,7 +54,7 @@ UIViewController *SGAboutPage(void) {withSymbol(SGActionRow(@"Welcome tour", nil, ^{ SGShowOnboarding(); }), @"map"),]];if (SGWhatsNewChanges().count) [links insertObject:withSymbol(SGActionRow(@"What's New", nil, ^{ SGShowWhatsNew(); }), @"sparkles") atIndex:links.count - 1];- NSMutableArray<SGModRow *> *build = [NSMutableArray arrayWithObjects:updates,+ NSMutableArray<SGModRow *> *build = [NSMutableArray arrayWithObjects:updates, betas,SGStatRow(@"Version", ^NSString *{ return @(SG_VERSION); }),SGStatRow(@"Spotify", ^NSString *{ return spotify; }), nil];SGModRow *signedUntil = SGSigningExpiryRow();diff --git a/tweak/Sources/App/About/Signing.m b/tweak/Sources/App/About/Signing.mindex 1419afb4..87a208e9 100644--- a/tweak/Sources/App/About/Signing.m+++ b/tweak/Sources/App/About/Signing.m@@ -70,7 +70,7 @@ static void showFix(void) {UIPasteboard.generalPasteboard.string = appID;}]];if (SGRepoURL) [sheet addAction:[UIAlertAction actionWithTitle:@"Read more" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {- SGOpenURL([SGRepoURL stringByAppendingString:@"#signing-it-yourself"]);+ SGOpenURL([SGRepoURL stringByAppendingString:@"#signing"]);}]];[sheet addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];[top presentViewController:sheet animated:YES completion:nil];diff --git a/tweak/Sources/App/About/Update.m b/tweak/Sources/App/About/Update.mindex 7b3e7603..604d26bb 100644--- a/tweak/Sources/App/About/Update.m+++ b/tweak/Sources/App/About/Update.m@@ -1,21 +1,22 @@// The repo's GitHub Releases, so a build that is already on someone's phone can tell them a newer one// exists and show what changed in it. Release Please cuts every release from the commits, so the// release body is the changelog itself: a "### Features" or "### Fixes" heading over a line per-// commit, each ending in a link to it. One request brings the last twenty releases rather than only-// the newest, which is what lets the Updates page show every version between this build and the-// newest one. Asked a few seconds after Spotify comes up (UpdateNotice.m) and when Mod Settings-// opens, at most once every six hours either way, and on demand from the page. Off while+// commit, each ending in a link to it. One request brings the last hundred releases and the newest+// twenty that count are kept, which is what lets the Updates page show every version between this+// build and the newest one even after a run of betas a release build skips. Betas count only while+// Include betas is on: on by default for a beta build, off for a release. Asked a few seconds after+// Spotify comes up (UpdateNotice.m) and when Mod Settings opens, at most once every six hours either way, and on demand from the page. Off while// SGUpdateURL is nil.#import "Core/SGCore.h"#import "About.h"-// The fork's GitHub releases, e.g. https://api.github.com/repos/<owner>/<repo>/releases?per_page=20-NSString *const SGUpdateURL = nil;+NSString *const SGUpdateURL = @"https://api.github.com/repos/My-Name-Is-Jeff/vitrine/releases?per_page=100";NSString *const SGUpdateCheckedNotification = @"spotifyglass.update.checked.notification";static NSString *const kChecked = @"spotifyglass.update.checked";static NSString *const kReleases = @"spotifyglass.update.releases";static const NSTimeInterval kInterval = 6 * 60 * 60;+static const NSUInteger kKept = 20;static NSString *sg_failure;static BOOL sg_running;@@ -26,22 +27,59 @@ static BOOL sg_running;@implementation SGUpdateRelease@end-// "0.14.1" against "0.15": the numbers position by position, a missing one counting zero.-static BOOL isNewer(NSString *candidate, NSString *current) {- NSArray<NSString *> *left = [candidate componentsSeparatedByString:@"."];- NSArray<NSString *> *right = [current componentsSeparatedByString:@"."];+// Semantic versions: the numbers position by position, a missing one counting zero, then a release+// above its own pre-releases ("1.0.0" over "1.0.0-beta.9"), then the pre-release's parts in turn, a+// number by its value and a word by its letters ("beta.10" over "beta.9", "rc.1" over "beta.9").+BOOL SGVersionIsNewer(NSString *candidate, NSString *current) {+ NSRange dashA = [candidate rangeOfString:@"-"], dashB = [current rangeOfString:@"-"];+ NSString *coreA = dashA.location == NSNotFound ? candidate : [candidate substringToIndex:dashA.location];+ NSString *coreB = dashB.location == NSNotFound ? current : [current substringToIndex:dashB.location];+ NSArray<NSString *> *left = [coreA componentsSeparatedByString:@"."], *right = [coreB componentsSeparatedByString:@"."];for (NSUInteger i = 0; i < MAX(left.count, right.count); i++) {NSInteger a = i < left.count ? left[i].integerValue : 0;NSInteger b = i < right.count ? right[i].integerValue : 0;if (a != b) return a > b;}- return NO;+ BOOL preA = dashA.location != NSNotFound, preB = dashB.location != NSNotFound;+ if (preA != preB) return !preA;+ if (!preA) return NO;+ NSArray<NSString *> *partsA = [[candidate substringFromIndex:dashA.location + 1] componentsSeparatedByString:@"."];+ NSArray<NSString *> *partsB = [[current substringFromIndex:dashB.location + 1] componentsSeparatedByString:@"."];+ NSCharacterSet *digits = NSCharacterSet.decimalDigitCharacterSet.invertedSet;+ for (NSUInteger i = 0; i < MIN(partsA.count, partsB.count); i++) {+ NSString *a = partsA[i], *b = partsB[i];+ BOOL numberA = a.length && [a rangeOfCharacterFromSet:digits].location == NSNotFound;+ BOOL numberB = b.length && [b rangeOfCharacterFromSet:digits].location == NSNotFound;+ if (numberA && numberB) {+ if (a.integerValue != b.integerValue) return a.integerValue > b.integerValue;+ } else if (numberA != numberB) {+ return numberB; // a word ranks above a number+ } else if (![a isEqualToString:b]) {+ return [a compare:b] == NSOrderedDescending;+ }+ }+ return partsA.count > partsB.count;+}++static BOOL isNewer(NSString *candidate, NSString *current) {+ return SGVersionIsNewer(candidate, current);}static NSString *stringOr(id value, NSString *fallback) {return [value isKindOfClass:NSString.class] ? value : fallback;}+BOOL SGBuildIsBeta(void) {+ return strchr(SG_VERSION, '-') != NULL;+}++// A build told of betas is offered the newest newer release, beta or not (1.0.0-beta.1, then+// 1.0.0-beta.2, then 1.0.0); one that is not, only releases. Never a lower version than its own.+// The stock marker of a reset turns it off on a beta build too, as it does every switch.+BOOL SGUpdateIncludesBetas(void) {+ return SGFlag(SGKeyUpdateBetas, SGBuildIsBeta());+}+#pragma mark - the changelog out of the release's markdown// "[the text](https://…)" is left as its text, and what release-please writes around a scope --@@ -110,15 +148,23 @@ NSArray<SGUpdateChange *> *SGUpdateChangesIn(NSString *body) {#pragma mark - what the last check left+// The defaults outlive an IPA installed over the same bundle id, so a release build can find what a+// beta stored before it, and Include betas can go off after a check. Pre-releases are dropped here as+// well as at the check, by GitHub's mark or, for a list stored before the mark was, by the "-" in the+// version.NSArray<SGUpdateRelease *> *SGUpdateReleases(void) {NSArray *stored = [NSUserDefaults.standardUserDefaults arrayForKey:kReleases];NSMutableArray<SGUpdateRelease *> *releases = [NSMutableArray array];+ BOOL betas = SGUpdateIncludesBetas();for (id entry in stored) {if (![entry isKindOfClass:NSDictionary.class]) continue;NSString *version = stringOr(entry[@"version"], nil);if (!version.length) continue;+ BOOL prerelease = [entry[@"prerelease"] boolValue] || [version containsString:@"-"];+ if (prerelease && !betas) continue;SGUpdateRelease *release = [SGUpdateRelease new];release.version = version;+ release.prerelease = prerelease;release.date = stringOr(entry[@"date"], @"");release.url = stringOr(entry[@"url"], nil);release.changes = SGUpdateChangesIn(stringOr(entry[@"notes"], @""));@@ -135,6 +181,10 @@ BOOL SGUpdateIsNewer(NSString *version) {return version.length && isNewer(version, @(SG_VERSION));}+BOOL SGUpdateChecked(void) {+ return [NSUserDefaults.standardUserDefaults doubleForKey:kChecked] > 0;+}+NSString *SGUpdateVersion(void) {NSString *newest = SGUpdateNewestRelease().version;return SGUpdateIsNewer(newest) ? newest : nil;@@ -148,36 +198,41 @@ NSString *SGUpdateStatus(void) {if (sg_failure) return sg_failure;NSString *latest = SGUpdateVersion();if (latest) return [latest stringByAppendingString:@" is out"];- if ([NSUserDefaults.standardUserDefaults doubleForKey:kChecked] > 0) return @"up to date";+ if (SGUpdateChecked()) return @"up to date";return @"not checked";}#pragma mark - the check-// Drafts and pre-releases are not builds anyone is meant to be sent to, so they count for neither the-// newest version nor the changelog. GitHub answers newest first; the sort keeps that true whatever-// order a hand-made release lands in.-static NSArray<NSDictionary *> *releasesFrom(NSData *data) {+// Drafts never count, and pre-releases only while Include betas is on. GitHub answers newest first;+// the sort keeps that true whatever order a hand-made release lands in. A reply with nothing that counts+// -- betas left out while every release is a beta -- is an empty list, which reads as up to date; only a+// reply that is not a list of releases is nil.+NSArray<NSDictionary *> *SGUpdateReleasesFrom(NSData *data) {id json = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL] : nil;if (![json isKindOfClass:NSArray.class]) return nil;NSMutableArray<NSDictionary *> *entries = [NSMutableArray array];+ BOOL betas = SGUpdateIncludesBetas();for (id item in (NSArray *)json) {if (![item isKindOfClass:NSDictionary.class]) continue;NSDictionary *release = item;- if ([release[@"draft"] boolValue] || [release[@"prerelease"] boolValue]) continue;NSString *tag = stringOr(release[@"tag_name"], nil);- if (!tag.length) continue;+ if (!tag.length || [release[@"draft"] boolValue]) continue;+ // A beta tag published without GitHub's mark is still a beta.+ BOOL prerelease = [release[@"prerelease"] boolValue] || [tag containsString:@"-"];+ if (prerelease && !betas) continue;[entries addObject:@{@"version": [tag hasPrefix:@"v"] ? [tag substringFromIndex:1] : tag,@"notes": stringOr(release[@"body"], @""),@"date": stringOr(release[@"published_at"], @""),@"url": stringOr(release[@"html_url"], @""),+ @"prerelease": @(prerelease),}];}[entries sortUsingComparator:^NSComparisonResult(NSDictionary *a, NSDictionary *b) {return isNewer(a[@"version"], b[@"version"]) ? NSOrderedAscending : NSOrderedDescending;}];- return entries.count ? entries : nil;+ return entries.count > kKept ? [entries subarrayWithRange:NSMakeRange(0, kKept)] : entries;}static void ask(NSString *url, NSData *body, void (^done)(NSArray<NSDictionary *> *releases, NSInteger status, NSError *error)) {@@ -196,7 +251,7 @@ static void ask(NSString *url, NSData *body, void (^done)(NSArray<NSDictionary *dataTaskWithRequest:requestcompletionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {NSInteger status = [response isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)response).statusCode : 0;- done(status == 200 ? releasesFrom(data) : nil, status, error);+ done(status == 200 ? SGUpdateReleasesFrom(data) : nil, status, error);}];[task resume];}@@ -221,7 +276,7 @@ void SGCheckForUpdate(BOOL force) {} else {[store setObject:releases forKey:kReleases];[store setDouble:NSDate.date.timeIntervalSince1970 forKey:kChecked];- SGLog(@"update check: the newest is %@, this build is %s", releases.firstObject[@"version"], SG_VERSION);+ SGLog(@"update check: the newest is %@, this build is %s", releases.firstObject[@"version"] ?: @"none for this build", SG_VERSION);}[NSNotificationCenter.defaultCenter postNotificationName:SGUpdateCheckedNotification object:nil];});diff --git a/tweak/Sources/App/About/UpdateNotice.m b/tweak/Sources/App/About/UpdateNotice.mindex 8d37a8e2..25d06d64 100644--- a/tweak/Sources/App/About/UpdateNotice.m+++ b/tweak/Sources/App/About/UpdateNotice.m@@ -27,9 +27,10 @@ static NSArray<SGUpdateChange *> *changesSinceThisBuild(void) {}// Three lines and a count: enough to know whether to care, with the whole changelog a tap away.-static NSString *noticeBody(NSString *version) {+static NSString *noticeBody(NSString *version, BOOL beta) {NSArray<SGUpdateChange *> *changes = changesSinceThisBuild();NSMutableString *body = [NSMutableString stringWithFormat:@"This build is %s.", SG_VERSION];+ if (beta) [body appendString:@" This one is a beta, a test build ahead of the next release."];NSUInteger shown = MIN(changes.count, (NSUInteger)3);for (NSUInteger i = 0; i < shown; i++) [body appendFormat:@"\n\n• %@", changes[i].text];if (changes.count > shown) [body appendFormat:@"\n\nand %lu more in %@.", (unsigned long)(changes.count - shown), version];@@ -61,7 +62,7 @@ static void offerWhenClear(NSInteger tries) {[NSUserDefaults.standardUserDefaults setObject:version forKey:kTold];SGUpdateRelease *release = SGUpdateNewestRelease();UIAlertController *sheet = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"%@ is out", version]- message:noticeBody(version)+ message:noticeBody(version, release.prerelease)preferredStyle:UIAlertControllerStyleAlert];[sheet addAction:[UIAlertAction actionWithTitle:@"What's new" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {// The sheet is still going as this runs, so the page waits for the screen it is pushed onto.diff --git a/tweak/Sources/App/About/UpdatePage.m b/tweak/Sources/App/About/UpdatePage.mindex 17a380e5..d4bd6e50 100644--- a/tweak/Sources/App/About/UpdatePage.m+++ b/tweak/Sources/App/About/UpdatePage.m@@ -112,7 +112,9 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {- (NSString *)introText {SGUpdateRelease *newest = SGUpdateNewestRelease();- if (!newest) return [NSString stringWithFormat:@"This build is %s. Nothing has been asked of GitHub yet.", SG_VERSION];+ if (!newest) return SGUpdateChecked()+ ? [NSString stringWithFormat:@"This build is %s. GitHub has no newer release.", SG_VERSION]+ : [NSString stringWithFormat:@"This build is %s. Nothing has been asked of GitHub yet.", SG_VERSION];NSString *date = longDate(newest.date);NSString *when = date.length ? [@" came out on " stringByAppendingString:date] : @" is out";if (SGUpdateVersion())@@ -134,7 +136,8 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {SGUpdateRelease *newest = SGUpdateNewestRelease();if (SGUpdateVersion() && newest.url.length)[top addObject:linkRow([@"Get " stringByAppendingString:newest.version],- @"The release on GitHub, where its .deb is", @"arrow.down.circle", newest.url)];+ newest.prerelease ? @"A beta, on GitHub with its .deb" : @"The release on GitHub, where its .deb is",+ @"arrow.down.circle", newest.url)];if (SGRepoURL) [top addObject:linkRow(@"All releases", @"Every version, this one and the ones before it",@"clock.arrow.circlepath", [SGRepoURL stringByAppendingString:@"/releases"])];[groups addObject:group(nil, top)];diff --git a/tweak/Sources/Settings/SGPageStyle.m b/tweak/Sources/Settings/SGPageStyle.mindex a9d087e2..8e7bf49f 100644--- a/tweak/Sources/Settings/SGPageStyle.m+++ b/tweak/Sources/Settings/SGPageStyle.m@@ -225,7 +225,7 @@ UIViewController *SGTopController(void) {}// The fork's repo. Its links stay hidden while this is nil.-NSString *const SGRepoURL = nil;+NSString *const SGRepoURL = @"https://github.com/My-Name-Is-Jeff/vitrine";void SGOpenURL(NSString *url) {NSURL *target = url ? [NSURL URLWithString:url] : nil;