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: the landscape lyrics stay up for a song without lines, with its cover at the screen's height

My-Name-Is-Jeff8797991c8a03
diff --git a/scripts/phone.py b/scripts/phone.py
index fac84d2b..fcada6bf 100755
--- a/scripts/phone.py
+++ b/scripts/phone.py
@@ -16,6 +16,7 @@
scripts/phone.py seek 42 | seek --by -15 # to a position, or by an amount as Spotify's relative seeks do
scripts/phone.py speed 1.5 # playback speed, 1 when normal
scripts/phone.py sing 1 # Karaoke on (0 off)
+ scripts/phone.py landscape 1 # the redesign's landscape lyrics up (0 down), no turn needed
scripts/phone.py lossless anchor --path P | lossless check | lossless stop # a local FLAC in place of Spotify's sound
scripts/phone.py tab 0 | tab Search
scripts/phone.py settings.open
diff --git a/tweak/Sources/Diagnostics/Diagnostics.h b/tweak/Sources/Diagnostics/Diagnostics.h
index b98d135b..45ef7fb6 100644
--- a/tweak/Sources/Diagnostics/Diagnostics.h
+++ b/tweak/Sources/Diagnostics/Diagnostics.h
@@ -23,6 +23,8 @@ double SGPlayerSpeed(void);
void SGSetPlayerSpeed(double speed);
// Defined in Shared/Sing/Sing.x.
void SGSetSingOn(BOOL on);
+// Defined in Redesigned/Player/PlayerLandscape.x: the landscape lyrics, for a Simulator that cannot turn.
+void SGRPlayerShowLandscape(BOOL show);
// Defined in Shared/Lossless/LosslessProbe.m: lossless anchor --path P, check, stop. Nil with *error on failure.
NSDictionary *SGLosslessProbe(NSString *verb, NSDictionary *p, NSString **error);
// Defined in Shared/AutoMix/AutoMix.x: Spotify's Automix and Crossfade settings, read or written.
diff --git a/tweak/Sources/Diagnostics/Driver.m b/tweak/Sources/Diagnostics/Driver.m
index 713339ae..8c0a86a3 100644
--- a/tweak/Sources/Diagnostics/Driver.m
+++ b/tweak/Sources/Diagnostics/Driver.m
@@ -847,6 +847,13 @@ static NSDictionary<NSString *, SGCommand> *commands(void) {
return @{@"sing" : @(on)};
});
},
+ @"landscape" : ^NSDictionary *(NSDictionary *p) {
+ BOOL on = [(p[@"value"] ?: p[@"arg"]) boolValue];
+ return onMain(^id {
+ SGRPlayerShowLandscape(on);
+ return @{@"landscape" : @(on)};
+ });
+ },
@"play" : ^NSDictionary *(NSDictionary *p) {
return onMain(^id {
[requirePlayer() resume:nil];
diff --git a/tweak/Sources/Redesigned/Player/Player.h b/tweak/Sources/Redesigned/Player/Player.h
index 65b3c3ff..0e736d07 100644
--- a/tweak/Sources/Redesigned/Player/Player.h
+++ b/tweak/Sources/Redesigned/Player/Player.h
@@ -78,6 +78,8 @@ void SGRPlayerSetCoverHidden(BOOL hidden);
// Whether the playing track has lyrics the player can show.
BOOL SGRPlayerLyricsAvailable(void);
+// Whether the playing track has none: its grace is over and nothing is looking for them any more.
+BOOL SGRPlayerLyricsNone(void);
// Whether the player is showing them.
BOOL SGRPlayerLyricsOpen(void);
// Shows them, or puts the cover back; does nothing when there are none to show.
@@ -110,6 +112,8 @@ void SGRPlayerPaintCover(UIView *stack);
// until switched off. Shown or put away by hand for the harness.
#define SGRKeyLyricsLandscape @"spotifyglass.redesign.lyrics.landscape"
void SGRPlayerShowLandscape(BOOL show);
+// The playing track's lines came in, or turned out to be none: the landscape screen lays out for it.
+void SGRPlayerLandscapeLinesChanged(void);
// The animated artwork follows the lyrics: blurred behind them (PlayerMotion.x).
void SGRPlayerMotionLyricsChanged(void);
diff --git a/tweak/Sources/Redesigned/Player/PlayerLandscape.x b/tweak/Sources/Redesigned/Player/PlayerLandscape.x
index e2982676..d5eb3b22 100644
--- a/tweak/Sources/Redesigned/Player/PlayerLandscape.x
+++ b/tweak/Sources/Redesigned/Player/PlayerLandscape.x
@@ -1,5 +1,7 @@
// Player redesign: the lyrics turn sideways with the phone onto a landscape screen of their own. The cover
// is on the left with the title, the artist and the controls under it, and the lines are on the right.
+// A track without lines keeps the screen: the cover grows to the screen's height with the title and the
+// controls beside it, until a track with lines comes on.
// The controls fade after a few seconds without a touch and come back at a tap, as in the player: the
// tap that brings them back lands on a clear shield over the screen, so it never seeks. The button beside
// the title turns the screen back to portrait, as VoiceOver's escape does, for a phone held flat or on its
@@ -18,6 +20,8 @@
#import "Player.h"
static const CGFloat kSide = 32, kCoverGap = 16, kControlSide = 44, kColumnShare = 0.38;
+// The title and the controls beside the cover of a track without lines.
+static const CGFloat kBareInfoWidth = 300, kBareControlsWidth = 200;
static const NSTimeInterval kLandscapeRest = 4;
static UIWindow *sg_window;
@@ -40,6 +44,7 @@ static BOOL sg_shut;
NSTimer *_rest;
UITapGestureRecognizer *_hide; // only while the controls are up
UIView *_shield; // only while they are not: the touch that brings them back
+ BOOL _bare; // the track playing has no lines: the cover takes the screen
}
// Portrait once the screen is on its way out, or the scene could not turn back while it fades.
@@ -138,6 +143,7 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,
_shield.accessibilityElementsHidden = YES;
[_shield addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(wake)]];
[_shield addGestureRecognizer:[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(wake)]];
+ [self updateBare:YES];
SGAddPlayerStateObserver(self);
[self playerStateDidChange:SGPlayerState()];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(artworkChanged)
@@ -171,6 +177,20 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,
CGFloat linesLeft = left + side + kSide;
_stage.frame = CGRectMake(linesLeft, CGRectGetMinY(safe), CGRectGetMaxX(safe) - linesLeft, safe.size.height);
_lyrics.frame = _stage.bounds;
+ if (!_bare) return;
+
+ // The cover at the screen's height and the title and controls beside it, the two centered as one. The
+ // lines keep their place above, so they come back from where they will stand.
+ side = safe.size.height - 2 * kSide;
+ CGFloat info = MIN(kBareInfoWidth, safe.size.width - 3 * kSide - side);
+ CGFloat x = CGRectGetMidX(safe) - (side + kSide + info) / 2;
+ _cover.frame = CGRectMake(x, CGRectGetMidY(safe) - side / 2, side, side);
+ CGFloat infoLeft = x + side + kSide;
+ textTop = CGRectGetMidY(safe) - (textHeight + kCoverGap + controlsHeight) / 2;
+ _close.frame = CGRectMake(infoLeft + info - kControlSide + 12, textTop + (textHeight - kControlSide) / 2, kControlSide, kControlSide);
+ _title.frame = CGRectMake(infoLeft, textTop + (textHeight - titleHeight - artistHeight) / 2, info - kControlSide, titleHeight);
+ _artist.frame = CGRectMake(infoLeft, CGRectGetMaxY(_title.frame), info - kControlSide, artistHeight);
+ _controls.frame = CGRectMake(infoLeft, textTop + textHeight + kCoverGap, MIN(kBareControlsWidth, info), controlsHeight);
}
- (void)viewDidAppear:(BOOL)animated {
@@ -199,8 +219,40 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,
[_field setArtwork:art identity:identity animated:YES];
}
+// Lines in: the lines' layout at once. None (the player's own verdict, after its grace): the cover's.
+// Otherwise the layout stays, so a track change does not flash between the two. A track change alone never
+// takes the lines away: the player may not have heard of it yet, and would still count the last one's grace.
+- (void)updateBare:(BOOL)mayGoBare {
+ BOOL bare = _bare;
+ if (SGRPlayerLyricsAvailable()) bare = NO;
+ else if (mayGoBare && SGRPlayerLyricsNone()) bare = YES;
+ if (bare == _bare) return;
+ _bare = bare;
+ SGLog(@"redesign player: landscape %@", bare ? @"without lines, the cover takes the screen" : @"with lines");
+ // The lines leave the window while they are away, so their display link stops with them.
+ if (!bare) [self.view insertSubview:_stage aboveSubview:_controls];
+ UIView *stage = _stage;
+ void (^change)(void) = ^{
+ [self.view setNeedsLayout];
+ [self.view layoutIfNeeded];
+ stage.alpha = bare ? 0 : 1;
+ };
+ void (^done)(BOOL) = ^(BOOL finished) {
+ if (self->_bare) [stage removeFromSuperview];
+ };
+ if (self.view.window) SGRAnimateLayout(self.view, change, done);
+ else {
+ change();
+ done(YES);
+ }
+ // Without lines there is nothing to read past the controls, so they stay.
+ if (bare) [self wake];
+ else [self restartRest];
+}
+
- (void)playerStateDidChange:(SPTPlayerState *)state {
if (!state) return;
+ [self updateBare:NO];
_title.text = state.track.trackTitle;
_artist.text = state.track.artistName;
[_play setImage:[UIImage systemImageNamed:state.isPaused ? @"play.fill" : @"pause.fill" withConfiguration:
@@ -250,7 +302,7 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,
// The lines on their own, unless VoiceOver needs the controls to be there.
- (void)rest {
- if (!UIAccessibilityIsVoiceOverRunning()) [self setControlsShown:NO];
+ if (!_bare && !UIAccessibilityIsVoiceOverRunning()) [self setControlsShown:NO];
}
- (void)wake {
@@ -278,7 +330,7 @@ static UIButton *controlButton(NSString *symbol, CGFloat size, NSString *label,
- (void)restartRest {
[_rest invalidate];
_rest = nil;
- if (!SGEnabled(SGRKeyLyricsAutoHide) || SGPlayerState().isPaused || UIAccessibilityIsVoiceOverRunning()) return;
+ if (_bare || !SGEnabled(SGRKeyLyricsAutoHide) || SGPlayerState().isPaused || UIAccessibilityIsVoiceOverRunning()) return;
__weak SGRLandscapeLyricsController *weakSelf = self;
_rest = [NSTimer scheduledTimerWithTimeInterval:kLandscapeRest repeats:NO block:^(NSTimer *timer) {
// A sheet over the lines (a line's meanings) keeps them up, and the clock runs again behind it.
@@ -329,6 +381,11 @@ static void requestOrientations(UIWindowScene *scene, UIInterfaceOrientationMask
}
}
+void SGRPlayerLandscapeLinesChanged(void) {
+ id screen = sg_window.rootViewController;
+ if ([screen isKindOfClass:SGRLandscapeLyricsController.class]) [screen updateBare:YES];
+}
+
void SGRPlayerShowLandscape(BOOL show) {
UIWindowScene *scene = (UIWindowScene *)UIApplication.sharedApplication.connectedScenes.anyObject;
if (![scene isKindOfClass:UIWindowScene.class]) return;
diff --git a/tweak/Sources/Redesigned/Player/PlayerLyrics.x b/tweak/Sources/Redesigned/Player/PlayerLyrics.x
index 5f832610..9ca14a7e 100644
--- a/tweak/Sources/Redesigned/Player/PlayerLyrics.x
+++ b/tweak/Sources/Redesigned/Player/PlayerLyrics.x
@@ -655,8 +655,6 @@ static void setOpen(BOOL open, BOOL animated) {
else {
[sg_rest invalidate];
sg_rest = nil;
- // The landscape screen shows these lines, so it goes with them (a track without lyrics came on).
- SGRPlayerShowLandscape(NO);
}
SGLog(@"redesign player: lyrics %@, thumbnail %.0fx%.0f at %.0f,%.0f, title row up %.0f and right %.0f, lines %.0fx%.0f",
open ? @"up" : @"away", l.thumb.size.width, l.thumb.size.height, l.thumb.origin.x, l.thumb.origin.y,
@@ -714,6 +712,8 @@ static void replace(void) {
// The bar morphs back out of a full size cover as the player closes, so the thumbnail is put away first.
- (void)viewWillDisappear:(BOOL)animated {
if (sg_open) setOpen(NO, NO);
+ // The landscape screen outlives the lines for a track without lyrics, but not the player.
+ SGRPlayerShowLandscape(NO);
%orig;
}
%end
@@ -799,6 +799,11 @@ static void replace(void) {
if (![note.object isEqual:SGKaraokePlayingTrack()]) return;
if (SGRPlayerLyricsAvailable()) SGRPlayerLyricsChanged();
else [self closeIfNone];
+ SGRPlayerLandscapeLinesChanged();
+}
+
+- (BOOL)none {
+ return _graceOver && !SGRPlayerLyricsAvailable() && !SGKaraokeLooking(SGKaraokePlayingTrack());
}
// The lines go once the grace is over and nothing is looking for the track's own any more.
@@ -827,6 +832,7 @@ static void replace(void) {
if (![self->_track isEqualToString:track]) return;
self->_graceOver = YES;
[self closeIfNone];
+ SGRPlayerLandscapeLinesChanged();
});
}
@@ -834,6 +840,10 @@ static void replace(void) {
static SGRPlayerLyricsWatcher *sg_watcher;
+BOOL SGRPlayerLyricsNone(void) {
+ return [sg_watcher none];
+}
+
%ctor {
if (!SGRedesignedUI()) return;
%init;