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: Labs shows only the flags this Spotify has, and adds the agent button

My-Name-Is-Jefffdc194cbff4d
diff --git a/tweak/Sources/Shared/Flags/FlagPages.m b/tweak/Sources/Shared/Flags/FlagPages.m
index beb0cf69..5ed3b9c1 100644
--- a/tweak/Sources/Shared/Flags/FlagPages.m
+++ b/tweak/Sources/Shared/Flags/FlagPages.m
@@ -2,8 +2,27 @@
#import "Settings/SGModPage.h"
#import "Flags.h"
+static int compareKey(const void *key, const void *def) {
+ return strcmp(key, ((const SGFlagDef *)def)->key);
+}
+
+// Only the rows for flags this Spotify has: the table comes from the IPA the build is for, and a flag
+// it lacks would force nothing. A section left empty goes too.
+static NSArray<SGModSection *> *known(NSArray<SGModSection *> *sections) {
+ NSMutableArray<SGModSection *> *kept = [NSMutableArray array];
+ for (SGModSection *section in sections) {
+ NSIndexSet *rows = [section.rows indexesOfObjectsPassingTest:^BOOL(SGModRow *row, NSUInteger i, BOOL *stop) {
+ return !row.flag || bsearch(row.key.UTF8String, SGFlagTable, SGFlagCount, sizeof *SGFlagTable, compareKey);
+ }];
+ if (!rows.count) continue;
+ section.rows = [section.rows objectsAtIndexes:rows];
+ [kept addObject:section];
+ }
+ return kept;
+}
+
static UIViewController *martiniPage(void) {
- return [[SGModPage alloc] initWithTitle:@"AI Chat (Martini)" intro:SGRestartNote sections:@[
+ return [[SGModPage alloc] initWithTitle:@"AI Chat (Martini)" intro:SGRestartNote sections:known(@[
SGSection(@"On Home", @[
SGFlagRow(@"Chat entry point", @"ios-home-evopage-impl.interactive_entrypoint_enabled"),
SGFlagRow(@"Martini behind it", @"ios-home-evopage-impl.interactive_entrypoint_martini_enabled"),
@@ -18,12 +37,13 @@ static UIViewController *martiniPage(void) {
]),
SGSection(@"In the player", @[
SGFlagRow(@"Chat entry point", @"ios-martini-npvcardprovider-impl.floating_chat_entry_point_enabled"),
+ SGFlagRow(@"Agent button", @"ios-martini-npvcardprovider-impl.npv_agent_button_enabled"),
]),
- ] footer:nil];
+ ]) footer:nil];
}
UIViewController *SGLabsPage(void) {
- return [[SGModPage alloc] initWithTitle:@"Labs" intro:@"Unreleased features; some do nothing on your version. Changes apply after you restart Spotify." sections:@[
+ return [[SGModPage alloc] initWithTitle:@"Labs" intro:@"Unreleased features; some do nothing on your version. Changes apply after you restart Spotify." sections:known(@[
SGSection(nil, @[
SGWithSymbol(SGPageRow(@"AI Chat (Martini)", ^UIViewController *{ return martiniPage(); }), @"bubble.left.and.bubble.right"),
]),
@@ -50,5 +70,5 @@ UIViewController *SGLabsPage(void) {
SGFlagRow(@"Pinned comments", @"ios-feature-comments.enable_pinned_comments"),
SGFlagRow(@"Several reactions", @"ios-feature-comments.enable_multi_reactions"),
]),
- ] footer:nil];
+ ]) footer:nil];
}