Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

feat: a release newer than the build says so on its own, a few seconds after Spotify comes up

Vojtěch Škopekcf292542ccfc
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 1020b592..46336781 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -189,8 +189,9 @@ App:
ModSettings.x the root page and the rows that open it from Spotify's settings and the side drawer
Pages.m the Appearance card with Redesigned UI, the Player and Lyrics pages, which Navbar page opens
- About/ the update check against the repo's GitHub Releases and the Updates page it fills (the state,
- and the changelog of every release newer than the build, a line per commit), backup, the
+ About/ 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
+ release 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
Onboarding/ the welcome page over Home on the first launch, with Redesigned UI, offered again from the Mod page
@@ -254,7 +255,8 @@ blocking and the telemetry blocking have stopped) and Labs (features Spotify bui
AI Chat (Martini) first). Last, All flags, Spotify's remote-config flags with a search field and an
Auto / Off / On control per flag (a text field for the number and text ones), and Mod: Updates
(the row reads out where the build stands and opens the changelog of everything newer than it, read
-from the releases Release Please cuts, with Check now, the release to get and all the releases), the
+from the releases Release Please cuts, with Check now, the release to get, all the releases and Tell
+me when one is out, the sheet a newer release brings up a few seconds after Spotify opens), the
build and Spotify's version, the site and the repo, the welcome tour again and Reset all
settings. A flag switch on a page forces that one flag and off leaves Spotify's own value, so the All
flags page is where a flag goes back to Auto. Spotify ships its newer design behind several flags at
diff --git a/harness/update/README.md b/harness/update/README.md
index efe1be28..6d5d8ddc 100644
--- a/harness/update/README.md
+++ b/harness/update/README.md
@@ -1,16 +1,19 @@
# Updates harness
-`SGUpdatePage()` on the simulator, running the real check against the repo's GitHub Releases: the
-state rows, the changelog of every release newer than the build, and the page rebuilding itself when
-a check lands. Only `Update.m`, `UpdatePage.m` and the page style are compiled; nothing of Spotify's
-is needed, so the page looks as it does on the phone apart from the fonts, which Mod Settings takes
-off Spotify's own list at runtime.
+`SGUpdatePage()` and the launch notice on the simulator, running the real check against the repo's
+GitHub Releases: the state rows, the changelog of every release newer than the build, the page
+rebuilding itself when a check lands, and the sheet `SGWatchForUpdates()` brings up over a plain
+screen. Only `Update.m`, `UpdatePage.m`, `UpdateNotice.m` and the page style are compiled; nothing of
+Spotify's is needed, so the page looks as it does on the phone apart from the fonts, which Mod
+Settings takes off Spotify's own list at runtime.
./build.sh [version] # what the page believes it is running, 0.18.0 by default
xcrun simctl install booted build/UpdateHarness.app
- xcrun simctl launch --console-pty booted com.vojta.updateharness [wipe] [recheck]
+ xcrun simctl launch --console-pty booted com.vojta.updateharness [wipe] [notice] [recheck]
-`wipe` clears what an earlier run stored, so the page opens as it does on a phone that has never
-checked; `recheck` taps Check now five seconds in. A version behind the newest release (`0.18.0`)
+`wipe` clears what an earlier run stored, so it starts as a phone that has never checked does;
+`notice` puts a plain screen up and watches for updates over it, the way the settings %ctor does
+inside Spotify, and the sheet follows about seven seconds in -- a second run without `wipe` stays
+quiet, 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 went
into this build; an old one (`0.17.0`) shows several releases, newest first.
diff --git a/harness/update/build.sh b/harness/update/build.sh
index 3c7ae4c0..a7aa3542 100755
--- a/harness/update/build.sh
+++ b/harness/update/build.sh
@@ -12,7 +12,7 @@ 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" \
- "$SRC"/App/About/Update.m "$SRC"/App/About/UpdatePage.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 \
"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m "$SRC"/Core/SGUIMode.m \
diff --git a/harness/update/main.m b/harness/update/main.m
index 584fa9bc..79ed373d 100644
--- a/harness/update/main.m
+++ b/harness/update/main.m
@@ -1,29 +1,54 @@
-// The Updates page on the simulator: SGUpdatePage() in a navigation controller, with the real check
-// running against the repo's GitHub Releases. The build it claims to be is SG_VERSION, set by
-// build.sh, so `0.18.0` shows a version behind the newest and `99.0.0` shows one that is current.
-// `wipe` clears what an earlier run stored, so the page opens as it does on a phone that has never
-// checked, and `recheck` taps Check now five seconds in.
+// The Updates page and the launch notice on the simulator, with the real check running against the
+// repo's GitHub Releases. The build it claims to be is SG_VERSION, set by build.sh, so `0.18.0`
+// shows a version behind the newest and `99.0.0` shows one that is current. `wipe` clears what an
+// earlier run stored, so it starts as a phone that has never checked does; `notice` puts a plain
+// screen up and runs SGWatchForUpdates() over it, the way the settings %ctor does inside Spotify;
+// `recheck` taps Check now five seconds in.
#import <UIKit/UIKit.h>
#import "App/About/About.h"
+// Spotify's welcome tour is not built here, and nothing holds the screen against the notice.
+BOOL SGOnboardingShowing(void) {
+ return NO;
+}
+
@interface Delegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
@implementation Delegate
+// What the notice comes up over: a stand-in for whatever Spotify has on screen when it opens.
+static UIViewController *plainScreen(void) {
+ UIViewController *screen = [UIViewController new];
+ screen.view.backgroundColor = UIColor.blackColor;
+ UILabel *label = [UILabel new];
+ label.text = @"Spotify";
+ label.textColor = [UIColor colorWithWhite:1 alpha:0.35];
+ label.font = [UIFont systemFontOfSize:22 weight:UIFontWeightSemibold];
+ label.translatesAutoresizingMaskIntoConstraints = NO;
+ [screen.view addSubview:label];
+ [NSLayoutConstraint activateConstraints:@[
+ [label.centerXAnchor constraintEqualToAnchor:screen.view.centerXAnchor],
+ [label.centerYAnchor constraintEqualToAnchor:screen.view.centerYAnchor],
+ ]];
+ return screen;
+}
+
- (BOOL)application:(UIApplication *)app didFinishLaunchingWithOptions:(NSDictionary *)options {
NSArray<NSString *> *arguments = NSProcessInfo.processInfo.arguments;
if ([arguments containsObject:@"wipe"]) {
- for (NSString *key in @[@"spotifyglass.update.checked", @"spotifyglass.update.releases"])
+ for (NSString *key in @[@"spotifyglass.update.checked", @"spotifyglass.update.releases", @"spotifyglass.update.told"])
[NSUserDefaults.standardUserDefaults removeObjectForKey:key];
}
+ BOOL notice = [arguments containsObject:@"notice"];
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
- UINavigationController *stack = [[UINavigationController alloc] initWithRootViewController:SGUpdatePage()];
+ UINavigationController *stack = [[UINavigationController alloc] initWithRootViewController:notice ? plainScreen() : SGUpdatePage()];
stack.navigationBar.overrideUserInterfaceStyle = UIUserInterfaceStyleDark;
self.window.rootViewController = stack;
self.window.backgroundColor = UIColor.blackColor;
[self.window makeKeyAndVisible];
+ if (notice) SGWatchForUpdates();
if ([arguments containsObject:@"recheck"])
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
SGCheckForUpdate(YES);
diff --git a/tweak/Sources/App/About/About.h b/tweak/Sources/App/About/About.h
index b7214730..92ac9d14 100644
--- a/tweak/Sources/App/About/About.h
+++ b/tweak/Sources/App/About/About.h
@@ -33,6 +33,12 @@ NSString *SGUpdateStatus(void);
void SGCheckForUpdate(BOOL force);
UIViewController *SGUpdatePage(void); // UpdatePage.m: the state and the changelog
+// UpdateNotice.m: the sheet a release newer than this build brings on its own, a few seconds after
+// Spotify comes up, once per release. Watched from the settings %ctor; the switch is on the Updates
+// page and takes effect at once.
+#define SGKeyUpdateNotice @"spotifyglass.update.notice"
+void SGWatchForUpdates(void);
+
// Whether the now playing card on the lock screen can open this build. It depends on the signature,
// not on the mod: iOS launches by the App ID of the application-identifier entitlement, so a build
diff --git a/tweak/Sources/App/About/Update.m b/tweak/Sources/App/About/Update.m
index 54e29dd6..243b2729 100644
--- a/tweak/Sources/App/About/Update.m
+++ b/tweak/Sources/App/About/Update.m
@@ -3,8 +3,9 @@
// 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 when Mod Settings opens, at most once every six hours, and on demand from the
-// page; nothing but the request itself leaves.
+// 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; nothing but the
+// request itself leaves.
#import "Core/SGCore.h"
#import "About.h"
diff --git a/tweak/Sources/App/About/UpdateNotice.m b/tweak/Sources/App/About/UpdateNotice.m
new file mode 100644
index 00000000..dcf23c16
--- /dev/null
+++ b/tweak/Sources/App/About/UpdateNotice.m
@@ -0,0 +1,107 @@
+// The one thing the mod says for itself, unasked: a release newer than this build is out. Nobody
+// opens Mod Settings to look, so the check runs on its own a few seconds after Spotify comes up and
+// a release nobody has been told about brings a sheet -- once per release, and never over the
+// welcome tour, the signing fix or anything else holding the screen, which it waits out. Tell me
+// when one is out on the Updates page switches it off; the page and the row are still there.
+#import "Core/SGCore.h"
+#import "Settings/SGPageStyle.h"
+#import "About.h"
+#import "App/Onboarding/Onboarding.h"
+
+static NSString *const kTold = @"spotifyglass.update.told";
+static const NSTimeInterval kSettle = 6; // after the app comes up, for its own screens to land
+static const NSTimeInterval kRetry = 4;
+static const NSInteger kTries = 15; // a minute of waiting for the screen, then not this run
+
+static BOOL sg_offered; // once a run, whatever else happens
+
+// Everything that has changed since this build, newest release first, which is what the sheet counts
+// and reads the first lines of.
+static NSArray<SGUpdateChange *> *changesSinceThisBuild(void) {
+ NSMutableArray<SGUpdateChange *> *changes = [NSMutableArray array];
+ for (SGUpdateRelease *release in SGUpdateReleases()) {
+ if (!SGUpdateIsNewer(release.version)) break;
+ [changes addObjectsFromArray:release.changes];
+ }
+ return changes;
+}
+
+// Three lines and a count: enough to know whether to care, with the whole changelog a tap away.
+static NSString *noticeBody(NSString *version) {
+ NSArray<SGUpdateChange *> *changes = changesSinceThisBuild();
+ NSMutableString *body = [NSMutableString stringWithFormat:@"This build is %s.", SG_VERSION];
+ 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];
+ return body;
+}
+
+static void offerWhenClear(NSInteger tries) {
+ if (sg_offered) return;
+ NSString *version = SGUpdateVersion();
+ if (!version || !SGEnabled(SGKeyUpdateNotice)) return;
+ if ([[NSUserDefaults.standardUserDefaults stringForKey:kTold] isEqualToString:version]) return;
+ UIViewController *top = SGTopController();
+ // The tour, the signing sheet and Spotify's own alerts own the screen first; a sheet presented
+ // from one of them lands nowhere, so this one waits its turn and gives up rather than nagging.
+ if (!top || SGOnboardingShowing() || [top isKindOfClass:UIAlertController.class]) {
+ if (tries <= 0) {
+ SGLog(@"update notice: the screen stayed busy, %@ waits for Mod Settings", version);
+ return;
+ }
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kRetry * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ offerWhenClear(tries - 1);
+ });
+ return;
+ }
+
+ sg_offered = YES;
+ // Told before it is read, not after: a sheet dismissed by a tap outside it, or by Spotify going
+ // away under it, is still a sheet this release has had.
+ [NSUserDefaults.standardUserDefaults setObject:version forKey:kTold];
+ SGUpdateRelease *release = SGUpdateNewestRelease();
+ UIAlertController *sheet = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"%@ is out", version]
+ message:noticeBody(version)
+ 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.
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ SGShowPage(SGTopController(), SGUpdatePage());
+ });
+ }]];
+ if (release.url.length)
+ [sheet addAction:[UIAlertAction actionWithTitle:@"Get it" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+ SGOpenURL(release.url);
+ }]];
+ [sheet addAction:[UIAlertAction actionWithTitle:@"Not now" style:UIAlertActionStyleCancel handler:nil]];
+ [top presentViewController:sheet animated:YES completion:nil];
+ SGLog(@"update notice: offered %@ over %@", version, NSStringFromClass(top.class));
+}
+
+// The first time Spotify is in front, and once: a check every launch would ask GitHub far more often
+// than the six hours the cache allows anyway, and what a check already landed is enough to go on.
+void SGWatchForUpdates(void) {
+ if (!SGEnabled(SGKeyUpdateNotice)) return;
+ __block id token = [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidBecomeActiveNotification
+ object:nil
+ queue:NSOperationQueue.mainQueue
+ usingBlock:^(NSNotification *note) {
+ [NSNotificationCenter.defaultCenter removeObserver:token];
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kSettle * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+ if (SGUpdateVersion()) { // the last check knows one already
+ offerWhenClear(kTries);
+ return;
+ }
+ __block id landed = [NSNotificationCenter.defaultCenter addObserverForName:SGUpdateCheckedNotification
+ object:nil
+ queue:NSOperationQueue.mainQueue
+ usingBlock:^(NSNotification *n) {
+ [NSNotificationCenter.defaultCenter removeObserver:landed];
+ offerWhenClear(kTries);
+ }];
+ // Inside the six hours this does nothing and no check lands, which is the point: the
+ // sheet is for a release that turned up, not for every launch.
+ SGCheckForUpdate(NO);
+ });
+ }];
+}
diff --git a/tweak/Sources/App/About/UpdatePage.m b/tweak/Sources/App/About/UpdatePage.m
index 2c3aa41a..24e491c3 100644
--- a/tweak/Sources/App/About/UpdatePage.m
+++ b/tweak/Sources/App/About/UpdatePage.m
@@ -14,12 +14,14 @@
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy) NSString *symbol;
+@property (nonatomic, copy) NSString *key; // a switch row, on until it is switched off
@property (nonatomic, copy) NSString *(^value)(void); // read out on the right, again once a second
@property (nonatomic, copy) void (^action)(void);
@end
@interface SGUpdateGroup : NSObject
@property (nonatomic, copy) NSString *title;
+@property (nonatomic, copy) NSString *footer;
@property (nonatomic, copy) NSArray<SGUpdateRow *> *rows;
@end
@@ -138,6 +140,14 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {
@"clock.arrow.circlepath", [SGRepoURL stringByAppendingString:@"/releases"])];
[groups addObject:group(nil, top)];
+ SGUpdateRow *notice = [SGUpdateRow new];
+ notice.title = @"Tell me when one is out";
+ notice.symbol = @"bell";
+ notice.key = SGKeyUpdateNotice;
+ SGUpdateGroup *told = group(nil, @[notice]);
+ told.footer = @"A release newer than this build brings this up once, a few seconds after Spotify opens.";
+ [groups addObject:told];
+
for (SGUpdateRelease *release in releasesToShow()) {
NSMutableArray<NSString *> *kinds = [NSMutableArray array];
NSMutableDictionary<NSString *, NSMutableArray<SGUpdateRow *> *> *byKind = [NSMutableDictionary dictionary];
@@ -176,7 +186,7 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {
- (void)viewDidLoad {
[super viewDidLoad];
_intro = SGNote([self introText]);
- _footer = SGNote(@"Releases are cut from the commits, so every line here is one change and opens it on GitHub. The mod asks for them when Mod Settings opens, at most once every six hours.");
+ _footer = SGNote(@"Releases are cut from the commits, so every line here is one change and opens it on GitHub. The mod asks GitHub for them a few seconds after Spotify opens and whenever Mod Settings does, at most once every six hours.");
self.tableView.tableHeaderView = _intro;
self.tableView.tableFooterView = _footer;
}
@@ -252,11 +262,13 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {
}
- (UIView *)tableView:(UITableView *)table viewForFooterInSection:(NSInteger)section {
- return nil;
+ NSString *footer = _groups[(NSUInteger)section].footer;
+ return footer ? SGSectionFooter(table, footer) : nil;
}
- (CGFloat)tableView:(UITableView *)table heightForFooterInSection:(NSInteger)section {
- return CGFLOAT_MIN;
+ NSString *footer = _groups[(NSUInteger)section].footer;
+ return footer ? SGSectionFooterHeight(table, footer) : CGFLOAT_MIN;
}
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)path {
@@ -270,7 +282,14 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {
cell.contentConfiguration = content;
}
cell.separatorInset = UIEdgeInsetsMake(0, row.symbol ? 58 : 16, 0, 0);
- if (row.value) {
+ if (row.key) {
+ UISwitch *toggle = [UISwitch new];
+ toggle.onTintColor = SGGreen();
+ toggle.on = SGEnabled(row.key);
+ toggle.accessibilityLabel = row.title;
+ [toggle addTarget:self action:@selector(toggled:) forControlEvents:UIControlEventValueChanged];
+ cell.accessoryView = toggle;
+ } else if (row.value) {
UILabel *label = [UILabel new];
label.font = SGTitleFont();
label.textColor = SGGrey();
@@ -283,6 +302,14 @@ static NSArray<SGUpdateRelease *> *releasesToShow(void) {
return cell;
}
+// The switch is read by the cell it sits in, since a rebuilt page moves the rows under it.
+- (void)toggled:(UISwitch *)toggle {
+ UIView *view = toggle;
+ while (view && ![view isKindOfClass:UITableViewCell.class]) view = view.superview;
+ SGUpdateRow *row = [self rowAt:[self.tableView indexPathForCell:(UITableViewCell *)view]];
+ if (row.key) SGSetEnabled(row.key, toggle.on);
+}
+
- (BOOL)tableView:(UITableView *)table shouldHighlightRowAtIndexPath:(NSIndexPath *)path {
return [self rowAt:path].action != nil;
}
diff --git a/tweak/Sources/App/ModSettings.x b/tweak/Sources/App/ModSettings.x
index 8973dba3..e5cdd463 100644
--- a/tweak/Sources/App/ModSettings.x
+++ b/tweak/Sources/App/ModSettings.x
@@ -247,4 +247,5 @@ static BOOL isSettingsRoot(UIViewController *list) {
SGRequireClasses(@[@"_TtC21Settings_PlatformImpl26SettingsListViewController", @"_TtC23SideDrawer_ListPageImpl18ListViewController"]);
SGRegisterPages();
SGCheckSigningOnce();
+ SGWatchForUpdates();
}