Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
refactor: split tweak into per-area sources
Vojtěch Škopekd6b7d16b6270
diff --git a/.gitignore b/.gitignoreindex 25b6d614..002eb409 100644--- a/.gitignore+++ b/.gitignore@@ -1,10 +1,10 @@+!trees/screens.txt*.ipa+.DS_Store+.signing.env+__pycache__/out/+trees/*.txttweak/.theos/tweak/obj/tweak/packages/-.DS_Store-.signing.env-trees/*.txt-!trees/screens.txt-__pycache__/diff --git a/Makefile b/Makefilenew file mode 100644index 00000000..76499e01--- /dev/null+++ b/Makefile@@ -0,0 +1,14 @@+# Entry points; the real work is in scripts/. IPA defaults to the first file in ipa/.+IPA ?= $(firstword $(wildcard ipa/*.ipa))++.PHONY: build release install trees log+build: ## FLEX + glass IPA into out/+ ./scripts/pipeline.sh $(IPA)+release: ## glass only, no FLEX+ ./scripts/pipeline.sh $(IPA) --no-flex+install: ## build, sign with your certificate, push to the phone on USB+ ./scripts/pipeline.sh $(IPA) --install+trees: ## record per-screen view trees into trees/+ ./scripts/record-trees.py+log: ## stream the tweak's log lines from the phone+ ./scripts/dump-log.shdiff --git a/README.md b/README.mdindex 6f258742..1d4e8859 100644--- a/README.md+++ b/README.md@@ -1,30 +1,36 @@# custom_spotify-Liquid Glass for the Spotify iOS app, applied to a decrypted IPA without a jailbreak.-- ./pipeline.sh src/com.spotify.client-9.1.78-Decrypted.ipa # FLEX + glass- ./pipeline.sh src/com.spotify.client-9.1.78-Decrypted.ipa --no-flex--The result lands in `out/` fakesigned. Add `--install` (or run `./install.sh out/<file>.ipa`) to sign it-with your own certificate and push it to the iPhone over USB; put `SIGN_P12`, `SIGN_PROFILE` and-`SIGN_P12_PASSWORD` into `.signing.env` first. Needs `brew install zsign ideviceinstaller`.--- `tweak/` — Theos tweak. Flips Spotify's own Liquid Glass flags (`Reprise_LiquidGlassKit`),- turns the now playing bar into a glass card with round artwork, and turns the tab bar into a- glass capsule plus a separate glass search circle. Spotify's own controls stay in place.-- `plist/liquid-glass.plist` — merged into Info.plist, turns `UIDesignRequiresCompatibility` off.-- `deb/` — [AutoFLEX](https://github.com/pwnless/AutoFLEX) release, injected unless `--no-flex`.--Runtime log lines are prefixed `[spotifyglass]`. With the phone on USB, `./dump-log.sh > out/spotifyglass.log`-then relaunch Spotify captures them on the Mac; on the phone they are in FLEX → System Log (long-press-a row to copy it). The first layout of each bar dumps its full view hierarchy in numbered parts, and in a FLEX build every-time the app goes to the background it dumps the whole visible screen: classes, frames, colours, radii,-label text and the view controller tree. Open a screen, swipe to the home screen, and the tree is in the log.--## Recording view trees--`./record-trees.py` captures one tree per screen over USB into `trees/<name>.txt`. It lists the-screens from `trees/screens.txt` with their recorded/missing status, lets you pick some, all, only-the missing ones, or add a new named screen, then walks you through them: open the screen, swipe-to the iOS home screen, press Enter. Nothing is overwritten unless you selected it.-`./record-trees.py --import out/spotifyglass.log name` files an existing capture the same way.+Liquid Glass UI for the Spotify iOS app, applied to a decrypted IPA without a jailbreak.+A Theos tweak, one dylib built from one source file per UI area, is injected into the IPA+together with [FLEX](https://github.com/FLEXTool/FLEX) for in-app inspection. The result is+signed and installed from the Mac.++## Layout++ tweak/src/ui/*.x the tweaks: NowPlayingBar, TabBar, NowPlayingView, SearchField, LiquidGlassFlags, Repaint+ tweak/src/SG* shared helpers (glass panes, view walking, logging, screen dumps)+ scripts/ pipeline.sh (build + inject), install.sh (sign + install), record-trees.py, dump-log.sh+ trees/ recorded view trees, one per screen; the input for every new tweak+ plist/ Info.plist overrides merged into the app (turns UIDesignRequiresCompatibility off)+ vendor/ AutoFLEX deb+ ipa/, out/ decrypted Spotify IPA in, built IPAs out (both gitignored)++## Use++ make build # out/Spotify-<version>-glass.ipa with FLEX+ make release # same without FLEX+ make install # build, sign with your certificate, install over USB+ make trees # record view trees screen by screen+ make log # stream [spotifyglass] log lines from the phone++Needs Theos in `~/theos` with an iPhoneOS SDK, Homebrew `make ldid dpkg zsign ideviceinstaller+libimobiledevice`, and cyan (`uv tool install "cyan @ git+https://github.com/asdfzxcvbn/pyzule-rw"`).+Signing reads `SIGN_P12`, `SIGN_PROFILE` and `SIGN_P12_PASSWORD` from `.signing.env`.++## Adding a tweak++1. `make trees`, record the screen, read `trees/<screen>.txt` for the classes and frames.+2. Add `tweak/src/ui/<Area>.x`: hook the classes, use `SGGlassFor`/`SGGlassAt` + `SGShapeGlass` for+ glass, `SGStripBackgrounds` to clear Spotify's paint, and end with `%ctor { %init; SGRequireClasses(...); }`.+3. `make install`. Log lines are prefixed `[spotifyglass]`; a FLEX build also dumps the visible+ screen whenever the app goes to the background.diff --git a/dump-log.sh b/scripts/dump-log.shsimilarity index 59%rename from dump-log.shrename to scripts/dump-log.shindex 9f97d4d2..0b7930e3 100755--- a/dump-log.sh+++ b/scripts/dump-log.sh@@ -1,8 +1,8 @@#!/usr/bin/env bash# Streams the tweak's log lines from the iPhone plugged into this Mac. Ctrl-C stops it.#-# ./dump-log.sh > out/spotifyglass.log # then kill and relaunch Spotify on the phone-# ./dump-log.sh -n # over Wi-Fi+# scripts/dump-log.sh > out/spotifyglass.log # then kill and relaunch Spotify on the phone+# scripts/dump-log.sh -n # over Wi-Fi## The hierarchy dumps arrive as numbered parts ("now playing hierarchy 3/9").exec idevicesyslog -p Spotify -m spotifyglass "$@"diff --git a/install.sh b/scripts/install.shsimilarity index 90%rename from install.shrename to scripts/install.shindex 3c7df846..390e735c 100755--- a/install.sh+++ b/scripts/install.sh@@ -1,7 +1,7 @@#!/usr/bin/env bash# Signs an IPA with your own certificate and installs it on the iPhone plugged into this Mac.#-# ./install.sh out/Spotify-9.1.78-glass.ipa+# scripts/install.sh out/Spotify-9.1.78-glass.ipa## Put the certificate details in .signing.env (gitignored):# SIGN_P12=/path/to/cert.p12@@ -10,7 +10,7 @@# WIFI=1 installs over Wi-Fi instead of USB (the phone must be paired for wireless sync).set -euo pipefail-ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"[ -f "$ROOT/.signing.env" ] && . "$ROOT/.signing.env": "${SIGN_P12:?set SIGN_P12 in .signing.env}" "${SIGN_PROFILE:?set SIGN_PROFILE in .signing.env}" "${SIGN_P12_PASSWORD:?set SIGN_P12_PASSWORD in .signing.env}"diff --git a/pipeline.sh b/scripts/pipeline.shsimilarity index 88%rename from pipeline.shrename to scripts/pipeline.shindex 260330a9..f80116da 100755--- a/pipeline.sh+++ b/scripts/pipeline.sh@@ -1,7 +1,7 @@#!/usr/bin/env bash# Builds the spotifyglass tweak and injects it (plus FLEX) into a decrypted Spotify IPA.#-# ./pipeline.sh <decrypted.ipa> [-o out.ipa] [--no-flex] [--install]+# scripts/pipeline.sh <decrypted.ipa> [-o out.ipa] [--no-flex] [--install] (or: make build / make install)## --install hands the result to install.sh (sign with your certificate, push to the plugged-in iPhone).#@@ -9,9 +9,9 @@# gmake, ldid, dpkg-deb (brew) and cyan (uv tool install "cyan @ git+https://github.com/asdfzxcvbn/pyzule-rw").set -euo pipefail-ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"THEOS="${THEOS:-$HOME/theos}"-FLEX_DEB="$ROOT/deb/com.hopeless.autoflex_0.0.1_iphoneos-arm.deb"+FLEX_DEB="$ROOT/vendor/com.hopeless.autoflex_0.0.1_iphoneos-arm.deb"IN="" OUT="" WITH_FLEX=1 INSTALL=0while [ $# -gt 0 ]; do@@ -54,5 +54,5 @@ echo "==> injecting"cyan -i "$IN" -o "$OUT" -f "${FILES[@]}" -l "$ROOT/plist/liquid-glass.plist" -s --overwriteecho "==> done: $OUT"-[ "$INSTALL" = 1 ] && exec "$ROOT/install.sh" "$OUT"+[ "$INSTALL" = 1 ] && exec "$ROOT/scripts/install.sh" "$OUT"exit 0diff --git a/record-trees.py b/scripts/record-trees.pysimilarity index 97%rename from record-trees.pyrename to scripts/record-trees.pyindex 4bbf1e9a..77372f0c 100755--- a/record-trees.py+++ b/scripts/record-trees.py@@ -1,8 +1,8 @@#!/usr/bin/env python3"""Record Spotify view trees from the iPhone over USB, one file per screen, into trees/.- ./record-trees.py # interactive: pick screens, record each, save trees/<name>.txt- ./record-trees.py --import LOG NAME # parse an existing capture into trees/NAME.txt+ scripts/record-trees.py # interactive: pick screens, record each, save trees/<name>.txt+ scripts/record-trees.py --import LOG NAME # parse an existing capture into trees/NAME.txtThe FLEX build of the tweak dumps the visible screen when Spotify goes to the background (and thefull player once it appears). Screens live in trees/screens.txt as "name | hint"; new ones are added@@ -15,7 +15,7 @@ import subprocessimport sysimport threading-ROOT = os.path.dirname(os.path.abspath(__file__))+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))TREES = os.path.join(ROOT, "trees")SCREENS = os.path.join(TREES, "screens.txt")diff --git a/trees/screens.txt b/trees/screens.txtindex 45e9d7ad..44fba3ac 100644--- a/trees/screens.txt+++ b/trees/screens.txt@@ -4,6 +4,7 @@ search | Search tablibrary | Library tabcreate | the + tabnow-playing | tap the now playing bar to open the full player, wait 2 s+playlist list | open the playlist listplaylist | open any playlistalbum | open any albumartist | open any artist pagediff --git a/tweak/Makefile b/tweak/Makefileindex 80e9c988..f7bab456 100644--- a/tweak/Makefile+++ b/tweak/Makefile@@ -6,8 +6,8 @@ include $(THEOS)/makefiles/common.mkTWEAK_NAME := spotifyglass-spotifyglass_FILES := Tweak.x-spotifyglass_CFLAGS := -fobjc-arc+spotifyglass_FILES := $(wildcard src/*.m) $(wildcard src/*.x) $(wildcard src/ui/*.x)+spotifyglass_CFLAGS := -fobjc-arc -Isrcspotifyglass_FRAMEWORKS := UIKit QuartzCore# Runtime swizzling instead of Substrate so the dylib has no extra dependency inside the IPA.spotifyglass_LOGOS_DEFAULT_GENERATOR := internaldiff --git a/tweak/Tweak.x b/tweak/Tweak.xdeleted file mode 100644index 37b0821b..00000000--- a/tweak/Tweak.x+++ /dev/null@@ -1,569 +0,0 @@-#import <UIKit/UIKit.h>-#import <objc/runtime.h>-#import <os/log.h>--// iOS 26 API, absent from the SDK Theos builds against. Resolved at runtime.-@interface UIGlassEffect : UIVisualEffect-@property (nonatomic, copy) UIColor *tintColor;-@property (nonatomic, getter=isInteractive) BOOL interactive;-@end--@interface NSObject (SpotifyGlassIOS26)-+ (id)capsuleConfiguration;-+ (id)configurationWithUniformRadius:(id)radius;-+ (id)fixedRadius:(CGFloat)radius;-- (void)setCornerConfiguration:(id)configuration;-@end--@interface UIView (SpotifyGlassPrivate)-- (NSString *)recursiveDescription;-@end--@interface UIViewController (SpotifyGlassPrivate)-- (NSString *)_printHierarchy;-@end--// %{public}s so idevicesyslog on the Mac sees the text instead of <private>.-#define SGLog(fmt, ...) os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, "[spotifyglass] %{public}s", [NSString stringWithFormat:(fmt), ##__VA_ARGS__].UTF8String)--// The unified log cuts a message at about 1 KB, so long dumps go out as numbered parts.-static void SGLogLong(NSString *tag, NSString *text) {- NSMutableArray<NSString *> *parts = [NSMutableArray array];- NSMutableString *current = [NSMutableString string];- for (NSString *line in [text componentsSeparatedByString:@"\n"]) {- if (current.length && [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + [line lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 900) {- [parts addObject:[current copy]];- [current setString:@""];- }- [current appendFormat:@"%@\n", line];- }- if (current.length) [parts addObject:current];- [parts enumerateObjectsUsingBlock:^(NSString *part, NSUInteger i, BOOL *stop) {- SGLog(@"%@ %lu/%lu\n%@", tag, (unsigned long)i + 1, (unsigned long)parts.count, part);- }];-}--static const CGFloat kCardRadius = 24;-static const CGFloat kTabPillHeight = 56;-static const CGFloat kTabSearchSize = 52;--// Views whose subtree must stay transparent so the glass behind them shows.-static __weak UIView *sg_nowPlayingRoot;-static __weak UIView *sg_tabBarRoot;-// The view Spotify paints with the album colour, refreshed from the layer hook on every repaint.-static __weak UIView *sg_nowPlayingCard;--static char kNowPlayingGlassKey, kTabPillKey, kTabSearchKey;--#pragma mark - helpers--static void forEachView(UIView *view, void (^fn)(UIView *)) {- fn(view);- for (UIView *sub in view.subviews) forEachView(sub, fn);-}--static CGRect frameIn(UIView *view, UIView *target) {- return [view.superview convertRect:view.frame toView:target];-}--static BOOL isInside(UIView *view, UIView *root) {- if (!root) return NO;- for (UIView *v = view; v; v = v.superview) {- if ([v isKindOfClass:UIVisualEffectView.class]) return NO;- if (v == root) return YES;- }- return NO;-}--// Artwork, glyphs, text and thin lines (progress bar) keep their colour, everything else goes clear.-static BOOL keepsColor(UIView *view) {- return [view isKindOfClass:UIImageView.class] || [view isKindOfClass:UILabel.class] || view.bounds.size.height <= 4;-}--static void stripBackgrounds(UIView *view) {- if ([view isKindOfClass:UIVisualEffectView.class]) return;- if (!keepsColor(view)) view.layer.backgroundColor = NULL;- if ([view.layer isKindOfClass:CAGradientLayer.class] || [NSStringFromClass(view.class) containsString:@"GradientView"]) view.hidden = YES;- for (CALayer *layer in view.layer.sublayers) {- if ([layer isKindOfClass:CAGradientLayer.class]) layer.hidden = YES;- }- for (UIView *sub in view.subviews) stripBackgrounds(sub);-}--static BOOL isVisibleColor(CGColorRef color) {- if (!color || CGColorGetAlpha(color) < 0.05) return NO;- const CGFloat *c = CGColorGetComponents(color);- size_t n = CGColorGetNumberOfComponents(color);- CGFloat brightest = 0;- for (size_t i = 0; i + 1 < n; i++) brightest = MAX(brightest, c[i]);- return brightest > 0.08;-}--#pragma mark - glass--static UIVisualEffect *glassEffect(void) {- Class glass = NSClassFromString(@"UIGlassEffect");- if (glass) return [[glass alloc] init];- return [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterialDark];-}--static UIVisualEffectView *glassFor(UIView *host, const void *key) {- UIVisualEffectView *glass = objc_getAssociatedObject(host, key);- if (!glass) {- glass = [[UIVisualEffectView alloc] initWithEffect:glassEffect()];- glass.userInteractionEnabled = NO;- objc_setAssociatedObject(host, key, glass, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- if (glass.superview != host) [host insertSubview:glass atIndex:0];- return glass;-}--// Several glass panes on one host, addressed by index, all kept behind the host's own content.-static UIVisualEffectView *glassAt(UIView *host, NSUInteger index) {- static char kPanesKey;- NSMutableArray<UIVisualEffectView *> *panes = objc_getAssociatedObject(host, &kPanesKey);- if (!panes) {- panes = [NSMutableArray array];- objc_setAssociatedObject(host, &kPanesKey, panes, OBJC_ASSOCIATION_RETAIN_NONATOMIC);- }- while (panes.count <= index) {- UIVisualEffectView *glass = [[UIVisualEffectView alloc] initWithEffect:glassEffect()];- glass.userInteractionEnabled = NO;- [panes addObject:glass];- }- UIVisualEffectView *glass = panes[index];- if (glass.superview != host) [host insertSubview:glass atIndex:0];- return glass;-}--static void shapeGlass(UIView *glass, CGFloat radius, BOOL capsule) {- Class config = NSClassFromString(@"UICornerConfiguration");- Class cornerRadius = NSClassFromString(@"UICornerRadius");- id shape = nil;- if (config && [glass respondsToSelector:@selector(setCornerConfiguration:)]) {- if (capsule && [config respondsToSelector:@selector(capsuleConfiguration)]) {- shape = [config capsuleConfiguration];- } else if ([config respondsToSelector:@selector(configurationWithUniformRadius:)] && [cornerRadius respondsToSelector:@selector(fixedRadius:)]) {- shape = [config configurationWithUniformRadius:[cornerRadius fixedRadius:radius]];- }- }- if (shape) {- [glass setCornerConfiguration:shape];- glass.clipsToBounds = NO;- } else {- glass.layer.cornerRadius = capsule ? glass.bounds.size.height / 2 : radius;- glass.layer.cornerCurve = kCACornerCurveContinuous;- glass.clipsToBounds = YES;- }-}--#pragma mark - now playing bar--static BOOL looksLikeCard(UIView *view, CGColorRef color) {- CGSize size = view.bounds.size;- return size.height >= 40 && size.height <= 140 && size.width >= 200 && isVisibleColor(color);-}--static UIView *detectColoredCard(UIView *bar) {- __block UIView *best = nil;- __block CGFloat bestArea = 0;- forEachView(bar, ^(UIView *v) {- if ([v isKindOfClass:UIVisualEffectView.class] || keepsColor(v) || !looksLikeCard(v, v.layer.backgroundColor)) return;- CGFloat area = v.bounds.size.width * v.bounds.size.height;- if (area > bestArea) { bestArea = area; best = v; }- });- return best;-}--// Fallback when nothing is painted: the box around artwork, text and the small buttons.-static CGRect contentBounds(UIView *bar, UIView *target) {- __block CGRect box = CGRectNull;- forEachView(bar, ^(UIView *v) {- if (v.hidden || v.alpha == 0) return;- CGFloat width = v.bounds.size.width;- BOOL content = ([v isKindOfClass:UIImageView.class] && width >= 20 && width <= 120)- || [v isKindOfClass:UILabel.class]- || ([v isKindOfClass:UIControl.class] && width <= 100);- if (content) box = CGRectUnion(box, frameIn(v, target));- });- return CGRectIsNull(box) ? box : CGRectInset(box, -10, -8);-}--// Round artwork (a 40pt square with a small radius, no image view inside) and move the progress-// line from the card's bottom edge to right under the text, like the reference.-static void restyleCardContent(UIView *card) {- forEachView(card, ^(UIView *v) {- CGSize size = v.bounds.size;- BOOL square = size.width >= 36 && size.width <= 48 && fabs(size.width - size.height) < 1;- if (!square || v.layer.cornerRadius <= 0 || v.layer.cornerRadius >= size.width / 2) return;- for (UIView *u = v; u && u != card && CGSizeEqualToSize(u.bounds.size, size); u = u.superview) {- u.layer.cornerRadius = size.width / 2;- u.clipsToBounds = YES;- }- });- forEachView(card, ^(UIView *v) {- CGRect f = v.frame;- if (f.size.height > 3 || f.size.width < 200 || v.superview.bounds.size.height < 40) return;- CGRect target = CGRectMake(52, card.bounds.size.height - 6, 226, 2);- if (CGRectEqualToRect(f, target)) return;- v.frame = target;- [v setNeedsLayout];- [v layoutIfNeeded];- });-}--static void styleNowPlayingBar(UIViewController *container) {- UIViewController *barVC = container.childViewControllers.firstObject;- UIView *bar = barVC.viewIfLoaded ?: container.view;- sg_nowPlayingRoot = bar;-- UIView *card = sg_nowPlayingCard;- if (!card || !isInside(card, bar)) card = sg_nowPlayingCard = detectColoredCard(bar);-- container.view.layer.backgroundColor = NULL;- stripBackgrounds(bar);-- CGRect frame = card ? frameIn(card, container.view) : contentBounds(bar, container.view);- if (CGRectIsNull(frame)) return;- frame.size.height = MIN(frame.size.height, 80);- if (frame.size.height < 30 || frame.size.width < 100) return;-- CGFloat radius = MIN(kCardRadius, frame.size.height / 2);- if (card) {- card.layer.cornerRadius = radius;- card.layer.cornerCurve = kCACornerCurveContinuous;- restyleCardContent(card);- }-- UIVisualEffectView *glass = glassFor(container.view, &kNowPlayingGlassKey);- glass.frame = frame;- shapeGlass(glass, radius, NO);-- static dispatch_once_t once;- dispatch_once(&once, ^{- SGLog(@"now playing card %@ at %@ (bar %@, container %@)", card.class, NSStringFromCGRect(frame),- NSStringFromCGRect(bar.frame), NSStringFromCGRect(container.view.bounds));- });-}--%hook _TtC18NowPlaying_BarImpl36NowPlayingBarContainerViewController-- (void)viewDidLayoutSubviews {- %orig;- styleNowPlayingBar((UIViewController *)self);-}-%end--%hook _TtC18NowPlaying_BarImpl27NowPlayingBarViewController-- (void)viewDidLayoutSubviews {- %orig;- UIViewController *parent = ((UIViewController *)self).parentViewController;- if ([NSStringFromClass(parent.class) containsString:@"NowPlayingBarContainer"]) styleNowPlayingBar(parent);-}-%end--#pragma mark - tab bar (NavigationUI_TabBarImpl.TabBarView: gradient + stack of 4 item elements)-// Spotify maps taps by position, so the items stay in their order: Home, Search, Library in the-// capsule and Create in its own circle.--static NSArray<UIView *> *tabItems(UIView *tabBar) {- NSMutableArray<UIView *> *items = [NSMutableArray array];- forEachView(tabBar, ^(UIView *v) {- if (v != tabBar && v.bounds.size.width >= 20 && [NSStringFromClass(v.class) containsString:@"TabBarItemElement"]) [items addObject:v];- });- // Element wrappers nest; keep the outermost per item.- return [items filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UIView *v, id _) {- for (UIView *u = v.superview; u && u != tabBar; u = u.superview) if ([items containsObject:u]) return NO;- return YES;- }]];-}--static void styleTabBar(UIView *tabBar) {- sg_tabBarRoot = tabBar;- stripBackgrounds(tabBar);- tabBar.superview.layer.backgroundColor = NULL;-- NSArray<UIView *> *items = tabItems(tabBar);- static dispatch_once_t once;- dispatch_once(&once, ^{ SGLog(@"tab bar %@ with %lu items", tabBar.class, (unsigned long)items.count); });- if (items.count < 2) return;-- NSArray<UIView *> *sorted = [items sortedArrayUsingComparator:^NSComparisonResult(UIView *a, UIView *b) {- return [@(frameIn(a, tabBar).origin.x) compare:@(frameIn(b, tabBar).origin.x)];- }];- CGRect first = frameIn(sorted.firstObject, tabBar);- CGRect lastMain = frameIn(sorted[sorted.count - 2], tabBar);- CGRect last = frameIn(sorted.lastObject, tabBar);- CGFloat midY = CGRectGetMidY(first);-- UIVisualEffectView *pill = glassFor(tabBar, &kTabPillKey);- CGFloat left = MAX(12, first.origin.x + 12);- pill.frame = CGRectMake(left, midY - kTabPillHeight / 2, CGRectGetMaxX(lastMain) + 4 - left, kTabPillHeight);- shapeGlass(pill, kTabPillHeight / 2, YES);-- UIVisualEffectView *circle = glassFor(tabBar, &kTabSearchKey);- circle.frame = CGRectMake(CGRectGetMidX(last) - kTabSearchSize / 2, midY - kTabSearchSize / 2, kTabSearchSize, kTabSearchSize);- shapeGlass(circle, kTabSearchSize / 2, YES);-}--// Items lay out their own icon and label; hide the label and centre the icon after each pass.-static void styleTabItem(UIView *item) {- CGFloat midY = CGRectGetMidY(item.bounds);- forEachView(item, ^(UIView *v) {- if ([v isKindOfClass:UILabel.class]) {- v.alpha = 0;- } else if ([NSStringFromClass(v.class) containsString:@"IconView"]) {- CGPoint target = [item convertPoint:CGPointMake(0, midY) toView:v.superview];- v.center = CGPointMake(v.center.x, target.y);- }- });-}--// Items lay out after the bar, so the bar's own pass sees no item frames; restyle from the items too.-static void styleTabItemAndBar(UIView *item) {- styleTabItem(item);- Class barClass = NSClassFromString(@"_TtC23NavigationUI_TabBarImpl10TabBarView");- for (UIView *v = item.superview; v; v = v.superview) {- if ([v isKindOfClass:barClass]) { styleTabBar(v); return; }- }-}--%hook _TtC23NavigationUI_TabBarImpl10TabBarView-- (void)layoutSubviews {- %orig;- for (UIView *sub in ((UIView *)self).subviews) [sub layoutIfNeeded];- styleTabBar((UIView *)self);-}-%end--%hook _TtC23NavigationUI_TabBarImpl21TabBarItemElementView-- (void)layoutSubviews {- %orig;- styleTabItemAndBar((UIView *)self);-}-%end--%hook _TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView-- (void)layoutSubviews {- %orig;- styleTabItemAndBar((UIView *)self);-}-%end--#pragma mark - full screen player (NowPlaying_ModesImpl units: header, playback controls, footer)--// A glass pane per direct child of the unit's row: circles for square children, capsules for wide-// ones. `fixedSize` forces every pane to one size; children matching `skip` get none.-static void glassBehindRowChildren(UIViewController *unit, CGFloat minSize, CGFloat fixedSize, NSString *skip) {- UIView *host = unit.viewIfLoaded;- __block UIStackView *row = nil;- forEachView(host, ^(UIView *v) {- if (!row && [v isKindOfClass:UIStackView.class] && v.bounds.size.width > 200 && ((UIStackView *)v).arrangedSubviews.count >= 2) row = (UIStackView *)v;- });- if (!row) return;- [row layoutIfNeeded];- NSUInteger index = 0;- for (UIView *child in row.arrangedSubviews) {- CGRect f = frameIn(child, host);- if (child.hidden || f.size.width < 20 || f.size.height < 20) continue;- __block BOOL skipped = NO;- if (skip) forEachView(child, ^(UIView *v) { if ([NSStringFromClass(v.class) containsString:skip]) skipped = YES; });- if (skipped) continue;- CGFloat height = fixedSize ?: MAX(minSize, MIN(f.size.height, 48));- CGFloat width = fixedSize ?: MAX(f.size.width, height);- CGRect frame = CGRectMake(CGRectGetMidX(f) - width / 2, CGRectGetMidY(f) - height / 2, width, height);- UIVisualEffectView *glass = glassAt(host, index++);- glass.frame = frame;- shapeGlass(glass, height / 2, YES);- }-}--%hook _TtC20NowPlaying_ModesImpl18HeaderElementsUnit-- (void)viewDidLayoutSubviews {- %orig;- glassBehindRowChildren((UIViewController *)self, 36, 0, nil);-}-%end--// Shuffle, previous, next and repeat each get a circle; the white play button stays as it is.-%hook _TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit-- (void)viewDidLayoutSubviews {- %orig;- glassBehindRowChildren((UIViewController *)self, 0, 52, @"PlayButton");-}-%end--%hook _TtC20NowPlaying_ModesImpl18FooterElementsUnit-- (void)viewDidLayoutSubviews {- %orig;- glassBehindRowChildren((UIViewController *)self, 36, 0, nil);-}-%end--#pragma mark - search field (a wide, white Encore tertiary button on the Search page)--static char kSearchFieldKey;--static BOOL isLightColor(CGColorRef color) {- if (!color || CGColorGetAlpha(color) < 0.5) return NO;- const CGFloat *c = CGColorGetComponents(color);- size_t n = CGColorGetNumberOfComponents(color);- for (size_t i = 0; i + 1 < n; i++) if (c[i] < 0.85) return NO;- return YES;-}--static void styleSearchField(UIView *button) {- CGSize size = button.bounds.size;- if (size.width < 200 || size.height < 40 || size.height > 60) return;- BOOL styled = [objc_getAssociatedObject(button, &kSearchFieldKey) boolValue];- if (!styled && !isLightColor(button.layer.backgroundColor)) return;- objc_setAssociatedObject(button, &kSearchFieldKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);-- button.layer.backgroundColor = NULL;- button.layer.cornerRadius = size.height / 2;- button.layer.cornerCurve = kCACornerCurveContinuous;-- UIVisualEffectView *glass = glassAt(button, 0);- glass.frame = button.bounds;- shapeGlass(glass, size.height / 2, YES);-- forEachView(button, ^(UIView *v) {- if ([v isKindOfClass:UILabel.class]) ((UILabel *)v).textColor = UIColor.whiteColor;- else if ([NSStringFromClass(v.class) containsString:@"IconView"]) v.tintColor = UIColor.whiteColor;- });-}--%hook _TtCCE16Encore_ButtonKitO16EncoreFoundation6Encore6Button8Tertiary-- (void)layoutSubviews {- %orig;- styleSearchField((UIView *)self);-}-%end--#pragma mark - keep the stripped areas transparent when Spotify repaints them--%hook CALayer-- (void)setBackgroundColor:(CGColorRef)color {- if (color && (sg_nowPlayingRoot || sg_tabBarRoot)) {- UIView *view = (UIView *)self.delegate;- if ([view isKindOfClass:UIView.class] && view.layer == self && !keepsColor(view)) {- if (isInside(view, sg_nowPlayingRoot)) {- if (looksLikeCard(view, color) && sg_nowPlayingCard != view) {- sg_nowPlayingCard = view;- UIView *bar = sg_nowPlayingRoot;- dispatch_async(dispatch_get_main_queue(), ^{ [bar.superview setNeedsLayout]; });- }- color = NULL;- } else if (isInside(view, sg_tabBarRoot)) {- color = NULL;- }- }- }- %orig(color);-}-%end--#pragma mark - Spotify's own Liquid Glass (Reprise_LiquidGlassKit)--%hook _TtC33Reprise_LiquidGlassPropertiesImpl25LiquidGlassPropertiesImpl-- (BOOL)isContextMenuInNavigationBarEnabled { return YES; }-%end--%hook SPTHubViewController-- (BOOL)prefersLiquidGlassNavigationBar { return YES; }-%end--#pragma mark - screen dumps (debug builds only, when FLEX is injected)--static NSString *hexColor(CGColorRef color) {- CGFloat r = 0, g = 0, b = 0, a = 0;- [[UIColor colorWithCGColor:color] getRed:&r green:&g blue:&b alpha:&a];- return [NSString stringWithFormat:@"#%02X%02X%02X@%.2f", (int)(r * 255), (int)(g * 255), (int)(b * 255), a];-}--static void appendTree(UIView *view, NSUInteger depth, NSMutableString *out) {- NSMutableString *line = [NSMutableString stringWithFormat:@"%*s%@ %@", (int)depth * 2, "", NSStringFromClass(view.class), NSStringFromCGRect(view.frame)];- CGColorRef bg = view.layer.backgroundColor;- if (bg && CGColorGetAlpha(bg) > 0) [line appendFormat:@" bg=%@", hexColor(bg)];- if (view.layer.cornerRadius > 0) [line appendFormat:@" r=%.1f", view.layer.cornerRadius];- if (view.alpha < 1) [line appendFormat:@" a=%.2f", view.alpha];- if (view.hidden) [line appendString:@" hidden"];- if (view.layer.mask) [line appendString:@" masked"];- if (view.clipsToBounds) [line appendString:@" clips"];- if ([view isKindOfClass:UILabel.class]) {- UILabel *label = (UILabel *)view;- [line appendFormat:@" \"%@\" %.0fpt %@", label.text, label.font.pointSize, hexColor(label.textColor.CGColor)];- }- if ([view isKindOfClass:UIImageView.class] && ((UIImageView *)view).image) {- CGSize size = ((UIImageView *)view).image.size;- [line appendFormat:@" img=%.0fx%.0f", size.width, size.height];- }- [out appendString:line];- [out appendString:@"\n"];- for (UIView *sub in view.subviews) appendTree(sub, depth + 1, out);-}--static void dumpScreen(NSString *reason) {- NSMutableString *out = [NSMutableString string];- UIViewController *root = nil;- for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {- if (![scene isKindOfClass:UIWindowScene.class]) continue;- for (UIWindow *window in ((UIWindowScene *)scene).windows) {- if (window.hidden || [NSStringFromClass(window.class) containsString:@"FLEX"]) continue;- if (!root || window.isKeyWindow) root = window.rootViewController;- [out appendFormat:@"== window %@ level %.0f\n", window.class, window.windowLevel];- appendTree(window, 0, out);- }- }- if ([root respondsToSelector:@selector(_printHierarchy)]) {- [out appendFormat:@"== view controllers\n%@\n", [root _printHierarchy]];- }- SGLogLong([@"screen dump " stringByAppendingString:reason], out);-}--static BOOL isDebugBuild(void) {- return NSClassFromString(@"FLEXManager") != nil;-}--// Full screen player: dump its tree once it has appeared, so no background trick is needed.-%hook _TtC21NowPlaying_ScrollImpl23NPVScrollViewController-- (void)viewDidAppear:(BOOL)animated {- %orig;- if (!isDebugBuild()) return;- static dispatch_once_t once;- dispatch_once(&once, ^{- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{- dumpScreen(@"now playing view");- });- });-}-%end--#pragma mark - diagnostics--%ctor {- %init;- NSArray *targets = @[- @"_TtC33Reprise_LiquidGlassPropertiesImpl25LiquidGlassPropertiesImpl",- @"SPTHubViewController",- @"_TtC23NavigationUI_TabBarImpl10TabBarView",- @"_TtC23NavigationUI_TabBarImpl21TabBarItemElementView",- @"_TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView",- @"_TtC18NowPlaying_BarImpl36NowPlayingBarContainerViewController",- @"_TtC18NowPlaying_BarImpl27NowPlayingBarViewController",- @"_TtC21NowPlaying_ScrollImpl23NPVScrollViewController",- @"_TtC20NowPlaying_ModesImpl18HeaderElementsUnit",- @"_TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit",- @"_TtC20NowPlaying_ModesImpl18FooterElementsUnit",- @"_TtCCE16Encore_ButtonKitO16EncoreFoundation6Encore6Button8Tertiary",- ];- for (NSString *name in targets) {- if (!NSClassFromString(name)) SGLog(@"class %@ not found, its hooks are inactive", name);- }- SGLog(@"loaded, UIGlassEffect %@", NSClassFromString(@"UIGlassEffect") ? @"available" : @"missing");- if (isDebugBuild()) {- [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {- dumpScreen(@"on background");- }];- SGLog(@"debug build: backgrounding the app dumps the visible screen's view tree");- }-}diff --git a/tweak/src/SGCommon.h b/tweak/src/SGCommon.hnew file mode 100644index 00000000..ef06c418--- /dev/null+++ b/tweak/src/SGCommon.h@@ -0,0 +1,54 @@+// Shared declarations for every spotifyglass source file.+#import <UIKit/UIKit.h>+#import <objc/runtime.h>+#import <os/log.h>++// iOS 26 API, absent from the SDK Theos builds against. Resolved at runtime.+@interface UIGlassEffect : UIVisualEffect+@property (nonatomic, copy) UIColor *tintColor;+@property (nonatomic, getter=isInteractive) BOOL interactive;+@end++@interface NSObject (SGiOS26)++ (id)capsuleConfiguration;++ (id)configurationWithUniformRadius:(id)radius;++ (id)fixedRadius:(CGFloat)radius;+- (void)setCornerConfiguration:(id)configuration;+@end++@interface UIView (SGPrivate)+- (NSString *)recursiveDescription;+@end++@interface UIViewController (SGPrivate)+- (NSString *)_printHierarchy;+@end++// %{public}s so idevicesyslog on the Mac sees the text instead of <private>.+#define SGLog(fmt, ...) os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEFAULT, "[spotifyglass] %{public}s", [NSString stringWithFormat:(fmt), ##__VA_ARGS__].UTF8String)+void SGLogLong(NSString *tag, NSString *text);+void SGRequireClasses(NSArray<NSString *> *names);++// View tree+void SGForEachView(UIView *view, void (^fn)(UIView *));+CGRect SGFrameIn(UIView *view, UIView *target);+BOOL SGIsInside(UIView *view, UIView *root);+BOOL SGKeepsColor(UIView *view);+void SGStripBackgrounds(UIView *view);+BOOL SGIsVisibleColor(CGColorRef color);+BOOL SGIsLightColor(CGColorRef color);++// Glass panes+UIVisualEffectView *SGGlassFor(UIView *host, const void *key);+UIVisualEffectView *SGGlassAt(UIView *host, NSUInteger index);+void SGShapeGlass(UIView *glass, CGFloat radius, BOOL capsule);++// Areas kept transparent by ui/Repaint.x, set by the tweaks that own them.+extern __weak UIView *sg_nowPlayingRoot;+extern __weak UIView *sg_tabBarRoot;+extern __weak UIView *sg_nowPlayingCard;+BOOL SGLooksLikeCard(UIView *view, CGColorRef color);++// Diagnostics (SGDiagnostics.x)+BOOL SGIsDebugBuild(void);+void SGDumpScreen(NSString *reason);diff --git a/tweak/src/SGCommon.m b/tweak/src/SGCommon.mnew file mode 100644index 00000000..a0c5aaa1--- /dev/null+++ b/tweak/src/SGCommon.m@@ -0,0 +1,148 @@+#import "SGCommon.h"++__weak UIView *sg_nowPlayingRoot = nil;+__weak UIView *sg_tabBarRoot = nil;+__weak UIView *sg_nowPlayingCard = nil;++#pragma mark - logging++// The unified log cuts a message at about 1 KB, so long dumps go out as numbered parts.+void SGLogLong(NSString *tag, NSString *text) {+ NSMutableArray<NSString *> *parts = [NSMutableArray array];+ NSMutableString *current = [NSMutableString string];+ for (NSString *line in [text componentsSeparatedByString:@"\n"]) {+ if (current.length && [current lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + [line lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 900) {+ [parts addObject:[current copy]];+ [current setString:@""];+ }+ [current appendFormat:@"%@\n", line];+ }+ if (current.length) [parts addObject:current];+ [parts enumerateObjectsUsingBlock:^(NSString *part, NSUInteger i, BOOL *stop) {+ SGLog(@"%@ %lu/%lu\n%@", tag, (unsigned long)i + 1, (unsigned long)parts.count, part);+ }];+}++void SGRequireClasses(NSArray<NSString *> *names) {+ for (NSString *name in names) {+ if (!NSClassFromString(name)) SGLog(@"class %@ not found, its hooks are inactive", name);+ }+}++#pragma mark - view tree++void SGForEachView(UIView *view, void (^fn)(UIView *)) {+ fn(view);+ for (UIView *sub in view.subviews) SGForEachView(sub, fn);+}++CGRect SGFrameIn(UIView *view, UIView *target) {+ return [view.superview convertRect:view.frame toView:target];+}++BOOL SGIsInside(UIView *view, UIView *root) {+ if (!root) return NO;+ for (UIView *v = view; v; v = v.superview) {+ if ([v isKindOfClass:UIVisualEffectView.class]) return NO;+ if (v == root) return YES;+ }+ return NO;+}++// Artwork, glyphs, text and thin lines (progress bar) keep their colour, everything else goes clear.+BOOL SGKeepsColor(UIView *view) {+ return [view isKindOfClass:UIImageView.class] || [view isKindOfClass:UILabel.class] || view.bounds.size.height <= 4;+}++void SGStripBackgrounds(UIView *view) {+ if ([view isKindOfClass:UIVisualEffectView.class]) return;+ if (!SGKeepsColor(view)) view.layer.backgroundColor = NULL;+ if ([view.layer isKindOfClass:CAGradientLayer.class] || [NSStringFromClass(view.class) containsString:@"GradientView"]) view.hidden = YES;+ for (CALayer *layer in view.layer.sublayers) {+ if ([layer isKindOfClass:CAGradientLayer.class]) layer.hidden = YES;+ }+ for (UIView *sub in view.subviews) SGStripBackgrounds(sub);+}++BOOL SGIsVisibleColor(CGColorRef color) {+ if (!color || CGColorGetAlpha(color) < 0.05) return NO;+ const CGFloat *c = CGColorGetComponents(color);+ size_t n = CGColorGetNumberOfComponents(color);+ CGFloat brightest = 0;+ for (size_t i = 0; i + 1 < n; i++) brightest = MAX(brightest, c[i]);+ return brightest > 0.08;+}++BOOL SGIsLightColor(CGColorRef color) {+ if (!color || CGColorGetAlpha(color) < 0.5) return NO;+ const CGFloat *c = CGColorGetComponents(color);+ size_t n = CGColorGetNumberOfComponents(color);+ for (size_t i = 0; i + 1 < n; i++) if (c[i] < 0.85) return NO;+ return YES;+}++BOOL SGLooksLikeCard(UIView *view, CGColorRef color) {+ CGSize size = view.bounds.size;+ return size.height >= 40 && size.height <= 140 && size.width >= 200 && SGIsVisibleColor(color);+}++#pragma mark - glass++static UIVisualEffect *glassEffect(void) {+ Class glass = NSClassFromString(@"UIGlassEffect");+ if (glass) return [[glass alloc] init];+ return [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemChromeMaterialDark];+}++static UIVisualEffectView *newPane(void) {+ UIVisualEffectView *glass = [[UIVisualEffectView alloc] initWithEffect:glassEffect()];+ glass.userInteractionEnabled = NO;+ return glass;+}++// One pane per host and key, kept behind the host's own content.+UIVisualEffectView *SGGlassFor(UIView *host, const void *key) {+ UIVisualEffectView *glass = objc_getAssociatedObject(host, key);+ if (!glass) {+ glass = newPane();+ objc_setAssociatedObject(host, key, glass, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ if (glass.superview != host) [host insertSubview:glass atIndex:0];+ return glass;+}++// Several panes on one host, addressed by index.+UIVisualEffectView *SGGlassAt(UIView *host, NSUInteger index) {+ static char kPanesKey;+ NSMutableArray<UIVisualEffectView *> *panes = objc_getAssociatedObject(host, &kPanesKey);+ if (!panes) {+ panes = [NSMutableArray array];+ objc_setAssociatedObject(host, &kPanesKey, panes, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ while (panes.count <= index) [panes addObject:newPane()];+ UIVisualEffectView *glass = panes[index];+ if (glass.superview != host) [host insertSubview:glass atIndex:0];+ return glass;+}++// Glass takes its shape from cornerConfiguration on iOS 26; layer.cornerRadius is the fallback.+void SGShapeGlass(UIView *glass, CGFloat radius, BOOL capsule) {+ Class config = NSClassFromString(@"UICornerConfiguration");+ Class cornerRadius = NSClassFromString(@"UICornerRadius");+ id shape = nil;+ if (config && [glass respondsToSelector:@selector(setCornerConfiguration:)]) {+ if (capsule && [config respondsToSelector:@selector(capsuleConfiguration)]) {+ shape = [config capsuleConfiguration];+ } else if ([config respondsToSelector:@selector(configurationWithUniformRadius:)] && [cornerRadius respondsToSelector:@selector(fixedRadius:)]) {+ shape = [config configurationWithUniformRadius:[cornerRadius fixedRadius:radius]];+ }+ }+ if (shape) {+ [glass setCornerConfiguration:shape];+ glass.clipsToBounds = NO;+ } else {+ glass.layer.cornerRadius = capsule ? glass.bounds.size.height / 2 : radius;+ glass.layer.cornerCurve = kCACornerCurveContinuous;+ glass.clipsToBounds = YES;+ }+}diff --git a/tweak/src/SGDiagnostics.x b/tweak/src/SGDiagnostics.xnew file mode 100644index 00000000..d4aa9bcc--- /dev/null+++ b/tweak/src/SGDiagnostics.x@@ -0,0 +1,77 @@+// Screen dumps for FLEX builds: the visible tree on background, the full player once it appears.+#import "SGCommon.h"++static NSString *hexColor(CGColorRef color) {+ CGFloat r = 0, g = 0, b = 0, a = 0;+ [[UIColor colorWithCGColor:color] getRed:&r green:&g blue:&b alpha:&a];+ return [NSString stringWithFormat:@"#%02X%02X%02X@%.2f", (int)(r * 255), (int)(g * 255), (int)(b * 255), a];+}++static void appendTree(UIView *view, NSUInteger depth, NSMutableString *out) {+ NSMutableString *line = [NSMutableString stringWithFormat:@"%*s%@ %@", (int)depth * 2, "", NSStringFromClass(view.class), NSStringFromCGRect(view.frame)];+ CGColorRef bg = view.layer.backgroundColor;+ if (bg && CGColorGetAlpha(bg) > 0) [line appendFormat:@" bg=%@", hexColor(bg)];+ if (view.layer.cornerRadius > 0) [line appendFormat:@" r=%.1f", view.layer.cornerRadius];+ if (view.alpha < 1) [line appendFormat:@" a=%.2f", view.alpha];+ if (view.hidden) [line appendString:@" hidden"];+ if (view.layer.mask) [line appendString:@" masked"];+ if (view.clipsToBounds) [line appendString:@" clips"];+ if ([view isKindOfClass:UILabel.class]) {+ UILabel *label = (UILabel *)view;+ [line appendFormat:@" \"%@\" %.0fpt %@", label.text, label.font.pointSize, hexColor(label.textColor.CGColor)];+ }+ if ([view isKindOfClass:UIImageView.class] && ((UIImageView *)view).image) {+ CGSize size = ((UIImageView *)view).image.size;+ [line appendFormat:@" img=%.0fx%.0f", size.width, size.height];+ }+ [out appendString:line];+ [out appendString:@"\n"];+ for (UIView *sub in view.subviews) appendTree(sub, depth + 1, out);+}++BOOL SGIsDebugBuild(void) {+ return NSClassFromString(@"FLEXManager") != nil;+}++void SGDumpScreen(NSString *reason) {+ NSMutableString *out = [NSMutableString string];+ UIViewController *root = nil;+ for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {+ if (![scene isKindOfClass:UIWindowScene.class]) continue;+ for (UIWindow *window in ((UIWindowScene *)scene).windows) {+ if (window.hidden || [NSStringFromClass(window.class) containsString:@"FLEX"]) continue;+ if (!root || window.isKeyWindow) root = window.rootViewController;+ [out appendFormat:@"== window %@ level %.0f\n", window.class, window.windowLevel];+ appendTree(window, 0, out);+ }+ }+ if ([root respondsToSelector:@selector(_printHierarchy)]) {+ [out appendFormat:@"== view controllers\n%@\n", [root _printHierarchy]];+ }+ SGLogLong([@"screen dump " stringByAppendingString:reason], out);+}++%hook _TtC21NowPlaying_ScrollImpl23NPVScrollViewController+- (void)viewDidAppear:(BOOL)animated {+ %orig;+ if (!SGIsDebugBuild()) return;+ static dispatch_once_t once;+ dispatch_once(&once, ^{+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ SGDumpScreen(@"now playing view");+ });+ });+}+%end++%ctor {+ %init;+ SGRequireClasses(@[@"_TtC21NowPlaying_ScrollImpl23NPVScrollViewController"]);+ SGLog(@"loaded, UIGlassEffect %@", NSClassFromString(@"UIGlassEffect") ? @"available" : @"missing");+ if (SGIsDebugBuild()) {+ [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification *note) {+ SGDumpScreen(@"on background");+ }];+ SGLog(@"debug build: backgrounding the app dumps the visible screen's view tree");+ }+}diff --git a/tweak/src/ui/LiquidGlassFlags.x b/tweak/src/ui/LiquidGlassFlags.xnew file mode 100644index 00000000..24ef5de7--- /dev/null+++ b/tweak/src/ui/LiquidGlassFlags.x@@ -0,0 +1,19 @@+// Spotify's own Liquid Glass work (Reprise_LiquidGlassKit) is remote-config gated; force it on.+// The rest of the switch is UIDesignRequiresCompatibility=false, merged into Info.plist by cyan.+#import "SGCommon.h"++%hook _TtC33Reprise_LiquidGlassPropertiesImpl25LiquidGlassPropertiesImpl+- (BOOL)isContextMenuInNavigationBarEnabled { return YES; }+%end++%hook SPTHubViewController+- (BOOL)prefersLiquidGlassNavigationBar { return YES; }+%end++%ctor {+ %init;+ SGRequireClasses(@[+ @"_TtC33Reprise_LiquidGlassPropertiesImpl25LiquidGlassPropertiesImpl",+ @"SPTHubViewController",+ ]);+}diff --git a/tweak/src/ui/NowPlayingBar.x b/tweak/src/ui/NowPlayingBar.xnew file mode 100644index 00000000..68b3f8e5--- /dev/null+++ b/tweak/src/ui/NowPlayingBar.x@@ -0,0 +1,112 @@+// Now playing bar: the album-coloured card becomes a glass card with round artwork and the+// progress line under the text. Spotify's own labels, buttons and gestures stay in place.+//+// Tree (trees/home.txt): NowPlayingBarContainerViewController.view > NowPlayingBarViewController.view+// > UIView 386x56 (the painted card) > artwork 40x40 r=4, title stack, progress line 370x2 at the bottom.+#import "SGCommon.h"++static const CGFloat kCardRadius = 24;+static char kGlassKey;++static UIView *detectColoredCard(UIView *bar) {+ __block UIView *best = nil;+ __block CGFloat bestArea = 0;+ SGForEachView(bar, ^(UIView *v) {+ if ([v isKindOfClass:UIVisualEffectView.class] || SGKeepsColor(v) || !SGLooksLikeCard(v, v.layer.backgroundColor)) return;+ CGFloat area = v.bounds.size.width * v.bounds.size.height;+ if (area > bestArea) { bestArea = area; best = v; }+ });+ return best;+}++// Fallback when nothing is painted: the box around artwork, text and the small buttons.+static CGRect contentBounds(UIView *bar, UIView *target) {+ __block CGRect box = CGRectNull;+ SGForEachView(bar, ^(UIView *v) {+ if (v.hidden || v.alpha == 0) return;+ CGFloat width = v.bounds.size.width;+ BOOL content = ([v isKindOfClass:UIImageView.class] && width >= 20 && width <= 120)+ || [v isKindOfClass:UILabel.class]+ || ([v isKindOfClass:UIControl.class] && width <= 100);+ if (content) box = CGRectUnion(box, SGFrameIn(v, target));+ });+ return CGRectIsNull(box) ? box : CGRectInset(box, -10, -8);+}++static void restyleCardContent(UIView *card) {+ SGForEachView(card, ^(UIView *v) {+ CGSize size = v.bounds.size;+ BOOL square = size.width >= 36 && size.width <= 48 && fabs(size.width - size.height) < 1;+ if (!square || v.layer.cornerRadius <= 0 || v.layer.cornerRadius >= size.width / 2) return;+ for (UIView *u = v; u && u != card && CGSizeEqualToSize(u.bounds.size, size); u = u.superview) {+ u.layer.cornerRadius = size.width / 2;+ u.clipsToBounds = YES;+ }+ });+ SGForEachView(card, ^(UIView *v) {+ CGRect f = v.frame;+ if (f.size.height > 3 || f.size.width < 200 || v.superview.bounds.size.height < 40) return;+ CGRect target = CGRectMake(52, card.bounds.size.height - 6, 226, 2);+ if (CGRectEqualToRect(f, target)) return;+ v.frame = target;+ [v setNeedsLayout];+ [v layoutIfNeeded];+ });+}++static void styleNowPlayingBar(UIViewController *container) {+ UIViewController *barVC = container.childViewControllers.firstObject;+ UIView *bar = barVC.viewIfLoaded ?: container.view;+ sg_nowPlayingRoot = bar;++ UIView *card = sg_nowPlayingCard;+ if (!card || !SGIsInside(card, bar)) card = sg_nowPlayingCard = detectColoredCard(bar);++ container.view.layer.backgroundColor = NULL;+ SGStripBackgrounds(bar);++ CGRect frame = card ? SGFrameIn(card, container.view) : contentBounds(bar, container.view);+ if (CGRectIsNull(frame)) return;+ frame.size.height = MIN(frame.size.height, 80);+ if (frame.size.height < 30 || frame.size.width < 100) return;++ CGFloat radius = MIN(kCardRadius, frame.size.height / 2);+ if (card) {+ card.layer.cornerRadius = radius;+ card.layer.cornerCurve = kCACornerCurveContinuous;+ restyleCardContent(card);+ }++ UIVisualEffectView *glass = SGGlassFor(container.view, &kGlassKey);+ glass.frame = frame;+ SGShapeGlass(glass, radius, NO);++ static dispatch_once_t once;+ dispatch_once(&once, ^{+ SGLog(@"now playing card %@ at %@ (bar %@, container %@)", card.class, NSStringFromCGRect(frame),+ NSStringFromCGRect(bar.frame), NSStringFromCGRect(container.view.bounds));+ });+}++%hook _TtC18NowPlaying_BarImpl36NowPlayingBarContainerViewController+- (void)viewDidLayoutSubviews {+ %orig;+ styleNowPlayingBar((UIViewController *)self);+}+%end++%hook _TtC18NowPlaying_BarImpl27NowPlayingBarViewController+- (void)viewDidLayoutSubviews {+ %orig;+ UIViewController *parent = ((UIViewController *)self).parentViewController;+ if ([NSStringFromClass(parent.class) containsString:@"NowPlayingBarContainer"]) styleNowPlayingBar(parent);+}+%end++%ctor {+ %init;+ SGRequireClasses(@[+ @"_TtC18NowPlaying_BarImpl36NowPlayingBarContainerViewController",+ @"_TtC18NowPlaying_BarImpl27NowPlayingBarViewController",+ ]);+}diff --git a/tweak/src/ui/NowPlayingView.x b/tweak/src/ui/NowPlayingView.xnew file mode 100644index 00000000..eb9d7c93--- /dev/null+++ b/tweak/src/ui/NowPlayingView.x@@ -0,0 +1,62 @@+// Full screen player: glass behind the header buttons, each transport control except play, and+// the footer buttons. Spotify's blurred artwork background stays underneath.+//+// Tree (trees/now-playing.txt): NowPlaying_ModesImpl units, each a child controller whose view holds+// one UIStackView row: header (chevron, title, more), playback controls (shuffle, previous, play,+// next, repeat), footer (connect, share, queue).+#import "SGCommon.h"++// A pane per direct child of the unit's row: circles for square children, capsules for wide ones.+// `fixedSize` forces every pane to one size; children containing a `skip` class get none.+static void glassBehindRowChildren(UIViewController *unit, CGFloat minSize, CGFloat fixedSize, NSString *skip) {+ UIView *host = unit.viewIfLoaded;+ __block UIStackView *row = nil;+ SGForEachView(host, ^(UIView *v) {+ if (!row && [v isKindOfClass:UIStackView.class] && v.bounds.size.width > 200 && ((UIStackView *)v).arrangedSubviews.count >= 2) row = (UIStackView *)v;+ });+ if (!row) return;+ [row layoutIfNeeded];+ NSUInteger index = 0;+ for (UIView *child in row.arrangedSubviews) {+ CGRect f = SGFrameIn(child, host);+ if (child.hidden || f.size.width < 20 || f.size.height < 20) continue;+ __block BOOL skipped = NO;+ if (skip) SGForEachView(child, ^(UIView *v) { if ([NSStringFromClass(v.class) containsString:skip]) skipped = YES; });+ if (skipped) continue;+ CGFloat height = fixedSize ?: MAX(minSize, MIN(f.size.height, 48));+ CGFloat width = fixedSize ?: MAX(f.size.width, height);+ UIVisualEffectView *glass = SGGlassAt(host, index++);+ glass.frame = CGRectMake(CGRectGetMidX(f) - width / 2, CGRectGetMidY(f) - height / 2, width, height);+ SGShapeGlass(glass, height / 2, YES);+ }+}++%hook _TtC20NowPlaying_ModesImpl18HeaderElementsUnit+- (void)viewDidLayoutSubviews {+ %orig;+ glassBehindRowChildren((UIViewController *)self, 36, 0, nil);+}+%end++%hook _TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit+- (void)viewDidLayoutSubviews {+ %orig;+ glassBehindRowChildren((UIViewController *)self, 0, 52, @"PlayButton");+}+%end++%hook _TtC20NowPlaying_ModesImpl18FooterElementsUnit+- (void)viewDidLayoutSubviews {+ %orig;+ glassBehindRowChildren((UIViewController *)self, 36, 0, nil);+}+%end++%ctor {+ %init;+ SGRequireClasses(@[+ @"_TtC20NowPlaying_ModesImpl18HeaderElementsUnit",+ @"_TtC20NowPlaying_ModesImpl28PlaybackControlsElementsUnit",+ @"_TtC20NowPlaying_ModesImpl18FooterElementsUnit",+ ]);+}diff --git a/tweak/src/ui/Repaint.x b/tweak/src/ui/Repaint.xnew file mode 100644index 00000000..2ff5d6c2--- /dev/null+++ b/tweak/src/ui/Repaint.x@@ -0,0 +1,28 @@+// Keeps the areas other tweaks stripped transparent when Spotify repaints them, and learns which+// view is the now playing card from the album-colour paint.+#import "SGCommon.h"++%hook CALayer+- (void)setBackgroundColor:(CGColorRef)color {+ if (color && (sg_nowPlayingRoot || sg_tabBarRoot)) {+ UIView *view = (UIView *)self.delegate;+ if ([view isKindOfClass:UIView.class] && view.layer == self && !SGKeepsColor(view)) {+ if (SGIsInside(view, sg_nowPlayingRoot)) {+ if (SGLooksLikeCard(view, color) && sg_nowPlayingCard != view) {+ sg_nowPlayingCard = view;+ UIView *bar = sg_nowPlayingRoot;+ dispatch_async(dispatch_get_main_queue(), ^{ [bar.superview setNeedsLayout]; });+ }+ color = NULL;+ } else if (SGIsInside(view, sg_tabBarRoot)) {+ color = NULL;+ }+ }+ }+ %orig(color);+}+%end++%ctor {+ %init;+}diff --git a/tweak/src/ui/SearchField.x b/tweak/src/ui/SearchField.xnew file mode 100644index 00000000..8e507e2f--- /dev/null+++ b/tweak/src/ui/SearchField.x@@ -0,0 +1,41 @@+// Search page: the white search field becomes a glass capsule with white text.+//+// Tree (trees/search.txt): a 370x48 Encore tertiary button, bg white, r=6, holding an+// SPTEncoreIconView and the placeholder label. The class is shared app-wide, so only a wide, light+// instance is touched.+#import "SGCommon.h"++static char kStyledKey;++static void styleSearchField(UIView *button) {+ CGSize size = button.bounds.size;+ if (size.width < 200 || size.height < 40 || size.height > 60) return;+ BOOL styled = [objc_getAssociatedObject(button, &kStyledKey) boolValue];+ if (!styled && !SGIsLightColor(button.layer.backgroundColor)) return;+ objc_setAssociatedObject(button, &kStyledKey, @YES, OBJC_ASSOCIATION_RETAIN_NONATOMIC);++ button.layer.backgroundColor = NULL;+ button.layer.cornerRadius = size.height / 2;+ button.layer.cornerCurve = kCACornerCurveContinuous;++ UIVisualEffectView *glass = SGGlassAt(button, 0);+ glass.frame = button.bounds;+ SGShapeGlass(glass, size.height / 2, YES);++ SGForEachView(button, ^(UIView *v) {+ if ([v isKindOfClass:UILabel.class]) ((UILabel *)v).textColor = UIColor.whiteColor;+ else if ([NSStringFromClass(v.class) containsString:@"IconView"]) v.tintColor = UIColor.whiteColor;+ });+}++%hook _TtCCE16Encore_ButtonKitO16EncoreFoundation6Encore6Button8Tertiary+- (void)layoutSubviews {+ %orig;+ styleSearchField((UIView *)self);+}+%end++%ctor {+ %init;+ SGRequireClasses(@[@"_TtCCE16Encore_ButtonKitO16EncoreFoundation6Encore6Button8Tertiary"]);+}diff --git a/tweak/src/ui/TabBar.x b/tweak/src/ui/TabBar.xnew file mode 100644index 00000000..eb4762de--- /dev/null+++ b/tweak/src/ui/TabBar.x@@ -0,0 +1,100 @@+// Tab bar: gradient and labels go, icons centre, a glass capsule sits behind Home, Search and+// Library and a glass circle behind Create. Spotify maps taps by position, so the item order stays.+//+// Tree (trees/home.txt): NavigationUI_TabBarImpl.TabBarView > TabBarCompactView > TabBarGradientView+// + UIStackView 402x49 of four ElementContentView<TabBarItemElement> 100x49, each with an+// SPTEncoreIconView 24x24 and an SPTEncoreLabel.+#import "SGCommon.h"++static const CGFloat kPillHeight = 56;+static const CGFloat kCircleSize = 52;+static char kPillKey, kCircleKey;++static NSArray<UIView *> *tabItems(UIView *tabBar) {+ NSMutableArray<UIView *> *items = [NSMutableArray array];+ SGForEachView(tabBar, ^(UIView *v) {+ if (v != tabBar && v.bounds.size.width >= 20 && [NSStringFromClass(v.class) containsString:@"TabBarItemElement"]) [items addObject:v];+ });+ // Element wrappers nest; keep the outermost per item.+ return [items filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UIView *v, id _) {+ for (UIView *u = v.superview; u && u != tabBar; u = u.superview) if ([items containsObject:u]) return NO;+ return YES;+ }]];+}++static void styleTabBar(UIView *tabBar) {+ sg_tabBarRoot = tabBar;+ SGStripBackgrounds(tabBar);+ tabBar.superview.layer.backgroundColor = NULL;++ NSArray<UIView *> *items = tabItems(tabBar);+ static dispatch_once_t once;+ dispatch_once(&once, ^{ SGLog(@"tab bar %@ with %lu items", tabBar.class, (unsigned long)items.count); });+ if (items.count < 2) return;++ NSArray<UIView *> *sorted = [items sortedArrayUsingComparator:^NSComparisonResult(UIView *a, UIView *b) {+ return [@(SGFrameIn(a, tabBar).origin.x) compare:@(SGFrameIn(b, tabBar).origin.x)];+ }];+ CGRect first = SGFrameIn(sorted.firstObject, tabBar);+ CGRect lastMain = SGFrameIn(sorted[sorted.count - 2], tabBar);+ CGRect last = SGFrameIn(sorted.lastObject, tabBar);+ CGFloat midY = CGRectGetMidY(first);++ UIVisualEffectView *pill = SGGlassFor(tabBar, &kPillKey);+ CGFloat left = MAX(12, first.origin.x + 12);+ pill.frame = CGRectMake(left, midY - kPillHeight / 2, CGRectGetMaxX(lastMain) + 4 - left, kPillHeight);+ SGShapeGlass(pill, kPillHeight / 2, YES);++ UIVisualEffectView *circle = SGGlassFor(tabBar, &kCircleKey);+ circle.frame = CGRectMake(CGRectGetMidX(last) - kCircleSize / 2, midY - kCircleSize / 2, kCircleSize, kCircleSize);+ SGShapeGlass(circle, kCircleSize / 2, YES);+}++// Items lay out their own icon and label, after the bar; hide the label, centre the icon, then+// restyle the bar, whose own pass ran before the items had frames.+static void styleTabItem(UIView *item) {+ CGFloat midY = CGRectGetMidY(item.bounds);+ SGForEachView(item, ^(UIView *v) {+ if ([v isKindOfClass:UILabel.class]) {+ v.alpha = 0;+ } else if ([NSStringFromClass(v.class) containsString:@"IconView"]) {+ CGPoint target = [item convertPoint:CGPointMake(0, midY) toView:v.superview];+ v.center = CGPointMake(v.center.x, target.y);+ }+ });+ Class barClass = NSClassFromString(@"_TtC23NavigationUI_TabBarImpl10TabBarView");+ for (UIView *v = item.superview; v; v = v.superview) {+ if ([v isKindOfClass:barClass]) { styleTabBar(v); return; }+ }+}++%hook _TtC23NavigationUI_TabBarImpl10TabBarView+- (void)layoutSubviews {+ %orig;+ for (UIView *sub in ((UIView *)self).subviews) [sub layoutIfNeeded];+ styleTabBar((UIView *)self);+}+%end++%hook _TtC23NavigationUI_TabBarImpl21TabBarItemElementView+- (void)layoutSubviews {+ %orig;+ styleTabItem((UIView *)self);+}+%end++%hook _TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView+- (void)layoutSubviews {+ %orig;+ styleTabItem((UIView *)self);+}+%end++%ctor {+ %init;+ SGRequireClasses(@[+ @"_TtC23NavigationUI_TabBarImpl10TabBarView",+ @"_TtC23NavigationUI_TabBarImpl21TabBarItemElementView",+ @"_TtC25CreateMenu_TabBarItemImpl24CreateMenuTabBarItemView",+ ]);+}diff --git a/deb/com.hopeless.autoflex_0.0.1_iphoneos-arm.deb b/vendor/com.hopeless.autoflex_0.0.1_iphoneos-arm.debsimilarity index 100%rename from deb/com.hopeless.autoflex_0.0.1_iphoneos-arm.debrename to vendor/com.hopeless.autoflex_0.0.1_iphoneos-arm.deb