Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Appearance lets you choose the app icon from a menu
My-Name-Is-Jeff72dddccb64d3
diff --git a/icons/README.md b/icons/README.mdnew file mode 100644index 00000000..fde104e4--- /dev/null+++ b/icons/README.md@@ -0,0 +1,7 @@+# Alternate icons++Each `NAME.png` here becomes an app icon that Appearance > App icon offers. `scripts/pipeline.sh`+scales it for iPhone and iPad and adds it to Spotify's `Info.plist`.++- Square, 1024 × 1024, no transparency.+- `NAME` is letters, digits, `_` and `-`. An `_` shows as a space in the list.diff --git a/scripts/pipeline.sh b/scripts/pipeline.shindex d31af954..e5c27a3e 100755--- a/scripts/pipeline.sh+++ b/scripts/pipeline.sh@@ -3,6 +3,8 @@## scripts/pipeline.sh <decrypted.ipa> [-o out.ipa] [--no-flex] [--install] [--name N] [--icon P.png] (or: make build / make install)#+# Every icons/NAME.png becomes an alternate icon (icons/README.md).+## --install hands the result to install.sh (sign with your certificate, push to the plugged-in iPhone).## The IPA is yours to supply: drop a decrypted Spotify .ipa in ipa/ and the Makefile finds it.@@ -127,6 +129,33 @@ elseecho " no WidgetExtension.appex in this IPA"fi+shopt -s nullglob+ICONS=("$ROOT"/icons/*.png)+shopt -u nullglob+if [ ${#ICONS[@]} -gt 0 ]; then+ echo "==> adding ${#ICONS[@]} alternate icons from icons/"+ PATCH="$(mktemp -d)"+ unzip -q "$OUT" "${APP_DIR}Info.plist" -d "$PATCH"+ PLIST="$PATCH/${APP_DIR}Info.plist"+ for png in "${ICONS[@]}"; do+ name="$(basename "$png" .png)"+ [[ "$name" =~ ^[A-Za-z0-9_-]+$ ]] || { echo "icon names are letters, digits, _ and - only: $png" >&2; exit 1; }+ sips -s format png -z 120 120 "$png" --out "$PATCH/[email protected]" >/dev/null+ sips -s format png -z 180 180 "$png" --out "$PATCH/[email protected]" >/dev/null+ sips -s format png -z 152 152 "$png" --out "$PATCH/$APP_DIR$name@2x~ipad.png" >/dev/null+ for key in CFBundleIcons 'CFBundleIcons~ipad'; do+ /usr/libexec/PlistBuddy -c "Print :$key" "$PLIST" >/dev/null 2>&1 || continue+ /usr/libexec/PlistBuddy -c "Add :$key:CFBundleAlternateIcons dict" "$PLIST" 2>/dev/null || true+ /usr/libexec/PlistBuddy -c "Delete :$key:CFBundleAlternateIcons:$name" "$PLIST" 2>/dev/null || true+ /usr/libexec/PlistBuddy -c "Add :$key:CFBundleAlternateIcons:$name:CFBundleIconFiles array" \+ -c "Add :$key:CFBundleAlternateIcons:$name:CFBundleIconFiles:0 string $name" "$PLIST"+ done+ done+ OUT_ABS="$(cd "$(dirname "$OUT")" && pwd)/$(basename "$OUT")"+ (cd "$PATCH" && zip -q -r "$OUT_ABS" "$APP_DIR")+ rm -rf "$PATCH"+fi+if [ -n "${EXT_DIR:-}" ]; thenecho "==> adding the Live Activity intents to Spotify's App Intents metadata""$ROOT/scripts/merge-appintents.py" "$OUT" "$APP_DIR" "$EXT_DIR/app/Metadata.appintents"diff --git a/tweak/Sources/App/Pages.m b/tweak/Sources/App/Pages.mindex 415177a1..0c289fe6 100644--- a/tweak/Sources/App/Pages.m+++ b/tweak/Sources/App/Pages.m@@ -1,4 +1,5 @@#import "Core/SGCore.h"+#import "Shared/AppIcon/AppIcon.h"#import "Shared/Fonts/Fonts.h"#import "Shared/LyricsTranslation/LyricsTranslation.h"#import "Redesigned/Player/Player.h"@@ -60,6 +61,7 @@ SGModSection *SGAppearanceSection(void) {NSMutableArray<SGModRow *> *rows = [NSMutableArray arrayWithObject:unavailableRow()];[rows addObjectsFromArray:SGNativeAppearanceRows()];[rows addObject:font];+ if (SGAppIconRow()) [rows addObject:SGAppIconRow()];return SGNotedSection(@"Appearance", rows, @"Changes apply after you restart Spotify.");}SGModRow *redesign = SGOptionRow(@"Redesigned UI", nil, SGKeyRedesign);@@ -72,6 +74,7 @@ SGModSection *SGAppearanceSection(void) {NSMutableArray<SGModRow *> *rows = [NSMutableArray arrayWithObject:SGWithSymbol(redesign, @"sparkles")];[rows addObjectsFromArray:SGRedesignedUIStored() ? SGRAppearanceRows() : SGNativeAppearanceRows()];[rows addObject:font];+ if (SGAppIconRow()) [rows addObject:SGAppIconRow()];return SGNotedSection(@"Appearance", rows, @"Changes apply after you restart Spotify.");}diff --git a/tweak/Sources/Shared/AppIcon/AppIcon.h b/tweak/Sources/Shared/AppIcon/AppIcon.hnew file mode 100644index 00000000..e7ed1829--- /dev/null+++ b/tweak/Sources/Shared/AppIcon/AppIcon.h@@ -0,0 +1,9 @@+// The home screen icon, picked from the alternate icons the IPA carries: Vitrine's, which+// scripts/pipeline.sh adds from icons/, and any other mod's. iOS keeps the choice, so the row+// reads it back from iOS rather than from the settings.+#import <UIKit/UIKit.h>++@class SGModRow;++// The Appearance card's row, or nil when the IPA carries no alternate icon.+SGModRow *SGAppIconRow(void);diff --git a/tweak/Sources/Shared/AppIcon/AppIcon.m b/tweak/Sources/Shared/AppIcon/AppIcon.mnew file mode 100644index 00000000..bf022765--- /dev/null+++ b/tweak/Sources/Shared/AppIcon/AppIcon.m@@ -0,0 +1,42 @@+#import "Core/SGCore.h"+#import "Settings/SGModPage.h"+#import "Settings/SGPageStyle.h"+#import "AppIcon.h"++// The names Info.plist declares, sorted, so the list reads the same each time.+static NSArray<NSString *> *iconNames(void) {+ NSDictionary *icons = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleIcons"];+ NSDictionary *alternates = [icons isKindOfClass:NSDictionary.class] ? icons[@"CFBundleAlternateIcons"] : nil;+ if (![alternates isKindOfClass:NSDictionary.class]) return @[];+ return [alternates.allKeys sortedArrayUsingSelector:@selector(localizedStandardCompare:)];+}++static NSString *label(NSString *name) {+ return name ? [name stringByReplacingOccurrencesOfString:@"_" withString:@" "] : @"Default";+}++static void setIcon(NSString *icon) {+ [UIApplication.sharedApplication setAlternateIconName:icon completionHandler:^(NSError *error) {+ if (!error) return; // iOS says so itself when it worked+ SGLog(@"app icon: %@ not set: %@", label(icon), error.localizedDescription);+ // A re-signed install, or a call while the app is not frontmost, can be refused; without+ // a word the row looks broken. The handler can run off the main thread.+ dispatch_async(dispatch_get_main_queue(), ^{+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"The icon did not change"+ message:error.localizedDescription+ preferredStyle:UIAlertControllerStyleAlert];+ [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];+ [SGTopController() presentViewController:alert animated:YES completion:nil];+ });+ }];+}++// A menu of Default and the icons, as the page's other choices are.+SGModRow *SGAppIconRow(void) {+ NSArray<NSString *> *names = iconNames();+ if (!names.count || !UIApplication.sharedApplication.supportsAlternateIcons) return nil;+ NSMutableArray<NSString *> *choices = [NSMutableArray arrayWithObject:label(nil)];+ for (NSString *name in names) [choices addObject:label(name)];+ return SGWithSymbol(SGMenuRow(@"App icon", choices, ^NSString *{ return label(UIApplication.sharedApplication.alternateIconName); },+ ^(NSInteger index) { setIcon(index > 0 ? names[(NSUInteger)index - 1] : nil); }), @"app.badge");+}