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: Vitrine offers to delete what Chroma left in Spotify's storage

My-Name-Is-Jeffc9e0d2113d0f
diff --git a/docs/tweaks.md b/docs/tweaks.md
index 1dbe64d3..1340ef30 100644
--- a/docs/tweaks.md
+++ b/docs/tweaks.md
@@ -530,7 +530,9 @@ App:
page 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 its settings page's Swift class) or Spotify is not the version the mod is
made for (SGSpotifyMadeFor), and when a redesign below iOS 26 did not start; the first two stay
- as red rows at the top of Mod Settings. Laid out on the simulator by harness/onboarding/
+ as red rows at the top of Mod Settings. What Chroma left in Spotify's storage when Vitrine
+ replaced it (its Karaoke model and saved lock screen videos, never its listening history or audio
+ effects) is offered for deleting once, and stays a row there until it goes. Laid out on the simulator by harness/onboarding/
Every key a feature stores starts with `spotifyglass.`, whatever it holds: Reset all settings on
the Mod page removes by that prefix and has no list to keep up to date. It leaves `SGKeyStock` behind,
diff --git a/tweak/Sources/App/Onboarding/Environment.m b/tweak/Sources/App/Onboarding/Environment.m
index 615a65cc..bd23d6b4 100644
--- a/tweak/Sources/App/Onboarding/Environment.m
+++ b/tweak/Sources/App/Onboarding/Environment.m
@@ -1,6 +1,7 @@
// What about the install itself can work against the mod, said once and kept at the top of Mod Settings
// while it lasts: EeveeSpotify injected beside it, a Spotify other than the one it is made for, and a
-// redesign below iOS 26 that did not start (Core/SGUIMode.h), which turned itself off.
+// redesign below iOS 26 that did not start (Core/SGUIMode.h), which turned itself off. Also what Chroma, installed
+// over the same Spotify before, left behind, offered once for deleting.
#import "Shared/Lyrics/Lyrics.h"
#import "Core/SGCore.h"
#import "Settings/SGModPage.h"
@@ -8,6 +9,7 @@
#import "Onboarding.h"
static NSString *const kTold = @"spotifyglass.environment.told";
+static NSString *const kCleanupOffered = @"spotifyglass.environment.chromaCleanupOffered";
static const NSTimeInterval kSettle = 4; // after the first activation, behind the signing sheet's 3 s
static const NSTimeInterval kRetry = 4;
static const NSInteger kTries = 45; // three minutes of waiting for the screen, then the rows say it
@@ -57,6 +59,50 @@ static void tell(NSArray<SGProblem> *list) {
[SGTopController() presentViewController:alert animated:YES completion:nil];
}
+// What Chroma, installed over the same Spotify before Vitrine, left in the app's storage that Vitrine never
+// reads: its Karaoke voice model (about 470 MB) and its saved lock screen videos. Its listening history and
+// audio effects are the person's own and stay (AudioEffectsFiles.m moves the effects over).
+static NSArray<NSURL *> *chromaLeftovers(void) {
+ NSFileManager *files = NSFileManager.defaultManager;
+ NSURL *support = [files URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask].firstObject;
+ NSURL *caches = [files URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask].firstObject;
+ NSMutableArray<NSURL *> *found = [NSMutableArray array];
+ for (NSURL *url in @[[support URLByAppendingPathComponent:@"spoti.pw/Sing" isDirectory:YES],
+ [caches URLByAppendingPathComponent:@"spoti.pw/LockArtwork" isDirectory:YES]]) {
+ if ([files fileExistsAtPath:url.path]) [found addObject:url];
+ }
+ return found;
+}
+
+static NSString *sizeOf(NSArray<NSURL *> *urls) {
+ long long total = 0;
+ for (NSURL *url in urls) {
+ for (NSURL *file in [NSFileManager.defaultManager enumeratorAtURL:url includingPropertiesForKeys:@[NSURLTotalFileAllocatedSizeKey] options:0 errorHandler:nil]) {
+ NSNumber *size = nil;
+ [file getResourceValue:&size forKey:NSURLTotalFileAllocatedSizeKey error:nil];
+ total += size.longLongValue;
+ }
+ }
+ return [NSByteCountFormatter stringFromByteCount:total countStyle:NSByteCountFormatterCountStyleFile];
+}
+
+static void offerCleanup(void) {
+ NSArray<NSURL *> *leftovers = chromaLeftovers();
+ if (!leftovers.count) return;
+ NSString *size = sizeOf(leftovers);
+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Chroma left %@ on this iPhone", size]
+ message:@"Its Karaoke voice model and its saved lock screen videos are still in Spotify's storage, and Vitrine uses neither. Your listening history and audio effects stay."
+ preferredStyle:UIAlertControllerStyleAlert];
+ [alert addAction:[UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{
+ for (NSURL *url in leftovers) [NSFileManager.defaultManager removeItemAtURL:url error:nil];
+ SGLog(@"environment: deleted %@ Chroma left", size);
+ });
+ }]];
+ [alert addAction:[UIAlertAction actionWithTitle:@"Keep" style:UIAlertActionStyleCancel handler:nil]];
+ [SGTopController() presentViewController:alert animated:YES completion:nil];
+}
+
// What about the install is worth saying.
static NSArray<SGProblem> *installProblems(void) {
NSMutableArray<SGProblem> *list = [NSMutableArray array];
@@ -74,6 +120,8 @@ NSArray<SGModRow *> *SGEnvironmentWarningRows(void) {
[rows addObject:SGWarningRow([NSString stringWithFormat:@"Made for Spotify %@", SGSpotifyMadeFor],
[NSString stringWithFormat:@"This is %@. Tap for what that does", SGSpotifyVersion()],
^{ tell(@[version()]); })];
+ if (chromaLeftovers().count)
+ [rows addObject:SGWarningRow(@"Chroma left files behind", [NSString stringWithFormat:@"%@ Vitrine never uses. Tap to delete", sizeOf(chromaLeftovers())], ^{ offerCleanup(); })];
return rows;
}
@@ -83,7 +131,7 @@ static NSString *state(void) {
return [NSString stringWithFormat:@"eevee %d, spotify %@", SGEeveeSpotifyInjected(), SGSpotifyVersion()];
}
-static void tellWhenClear(NSInteger tries) {
+static void whenClear(NSInteger tries, void (^then)(void)) {
UIViewController *top = SGTopController();
// The tour, What's new and the signing sheet own the screen first; an alert presented from one of
// them lands nowhere, so this one waits its turn. It also waits for the app to be in front, so it is
@@ -92,10 +140,14 @@ static void tellWhenClear(NSInteger tries) {
if (!front || !top || SGOnboardingShowing() || [top isKindOfClass:UIAlertController.class]) {
if (tries <= 0) return;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kRetry * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- tellWhenClear(tries - 1);
+ whenClear(tries - 1, then);
});
return;
}
+ then();
+}
+
+static void tellProblems(void) {
// The fall back is news every time; the install's state only when it changed.
NSUserDefaults *store = NSUserDefaults.standardUserDefaults;
NSMutableArray<SGProblem> *list = [NSMutableArray array];
@@ -105,6 +157,13 @@ static void tellWhenClear(NSInteger tries) {
[list addObjectsFromArray:installProblems()];
}
if (list.count) tell(list);
+ // Chroma's leftovers are offered once, after any problem; the row in Mod Settings stays while they do.
+ if (chromaLeftovers().count && ![store boolForKey:kCleanupOffered]) {
+ whenClear(kTries, ^{
+ [store setBool:YES forKey:kCleanupOffered];
+ offerCleanup();
+ });
+ }
}
void SGCheckEnvironmentOnce(void) {
@@ -116,7 +175,7 @@ void SGCheckEnvironmentOnce(void) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kSettle * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (SGEeveeSpotifyInjected()) SGLog(@"environment: EeveeSpotify is injected too");
if (otherVersion()) SGLog(@"environment: Spotify %@, made for %@", SGSpotifyVersion(), SGSpotifyMadeFor);
- tellWhenClear(kTries);
+ whenClear(kTries, ^{ tellProblems(); });
});
}];
}