Skip to content

Commit

Permalink
Added AOD animations
Browse files Browse the repository at this point in the history
  • Loading branch information
NSSpiral committed Jan 9, 2024
1 parent 3a260f9 commit 19bab87
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export ARCHS = arm64 arm64e
export SYSROOT = $(THEOS)/sdks/iPhoneOS14.4.sdk

export SYSROOT = $(THEOS)/sdks/iPhoneOS14.5.sdk
export THEOS_PACKAGE_SCHEME = rootless
ifneq ($(THEOS_PACKAGE_SCHEME), rootless)
export TARGET = iphone:clang:14.4:14.0
export TARGET = iphone:clang:14.5:14.0
export PREFIX = $(THEOS)/toolchain/Xcode.xctoolchain/usr/bin/
else
export TARGET = iphone:clang:14.4:15.0
export TARGET = iphone:clang:14.5:15.0
endif

INSTALL_TARGET_PROCESSES = SpringBoard
Expand Down
65 changes: 48 additions & 17 deletions Tweak/Eneko.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,37 @@ static void SBIconController_adjustFrame(SBIconController* self, SEL _cmd) {

#pragma mark - Manangement class hooks

void fadePlayer(AVPlayerLayer *playerLayer, float opacity, NSTimeInterval duration);
void fadePlayer(AVPlayerLayer *playerLayer, float opacity, NSTimeInterval duration) {
if(playerLayer.opacity != opacity) {
if (playerLayer.animationKeys.count > 0) {
playerLayer.opacity = [playerLayer.presentationLayer opacity];
}
[CATransaction begin];
[CATransaction setAnimationDuration:duration];
playerLayer.opacity = opacity;
[CATransaction commit];
}
}

void playVideo(AVPlayerLayer *playerLayer);
void playVideo(AVPlayerLayer *playerLayer) {
if(!playerLayer) return;

fadePlayer(playerLayer, 1.0, 0.2);
AVPlayer *player = playerLayer.player;
[player play];
}

void pauseVideo(AVPlayerLayer *playerLayer);
void pauseVideo(AVPlayerLayer *playerLayer) {
if(!playerLayer) return;

fadePlayer(playerLayer, 0.0, 0.2);
AVPlayer *player = playerLayer.player;
[player pause];
}

static void (* orig_CSCoverSheetViewController_viewWillAppear)(CSCoverSheetViewController* self, SEL _cmd, BOOL animated);
static void override_CSCoverSheetViewController_viewWillAppear(CSCoverSheetViewController* self, SEL _cmd, BOOL animated) {
orig_CSCoverSheetViewController_viewWillAppear(self, _cmd, animated);
Expand All @@ -104,7 +135,7 @@ static void override_CSCoverSheetViewController_viewWillAppear(CSCoverSheetViewC

if (lockScreenPlayer) {
[self adjustFrame];
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer && isHomeScreenVisible) {
Expand All @@ -123,7 +154,7 @@ static void override_CSCoverSheetViewController_viewWillDisappear(CSCoverSheetVi
}

if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer && isHomeScreenVisible) {
Expand All @@ -147,7 +178,7 @@ static void override_SBIconController_viewWillAppear(SBIconController* self, SEL
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}
}

Expand All @@ -166,7 +197,7 @@ static void override_SBIconController_viewWillDisappear(SBIconController* self,
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}
}

Expand All @@ -179,7 +210,7 @@ static void override_CCUIModularControlCenterOverlayViewController_viewWillAppea
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer && isHomeScreenVisible) {
Expand All @@ -196,7 +227,7 @@ static void override_CCUIModularControlCenterOverlayViewController_viewWillDisap
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer && isHomeScreenVisible) {
Expand All @@ -220,7 +251,7 @@ static void override_SBBacklightController_turnOnScreenFullyWithBacklightSource(
}

if (lockScreenPlayer) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand All @@ -235,7 +266,7 @@ static void override_SBLockScreenManager_lockUIFromSource_withOptions(SBLockScre
isScreenOn = NO;

if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand Down Expand Up @@ -293,7 +324,7 @@ static int override_TUCall_status(TUCall* self, SEL _cmd) {
isInCall = YES;

if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand All @@ -304,7 +335,7 @@ static int override_TUCall_status(TUCall* self, SEL _cmd) {

if (isLockScreenVisible && !isHomeScreenVisible) {
if (lockScreenPlayer) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand All @@ -316,7 +347,7 @@ static int override_TUCall_status(TUCall* self, SEL _cmd) {
}

if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}
}
}
Expand Down Expand Up @@ -348,7 +379,7 @@ static void override_SBDashBoardCameraPageViewController_viewWillAppear(SBDashBo
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

isLockScreenVisible = NO;
Expand All @@ -365,7 +396,7 @@ static void override_SBDashBoardCameraPageViewController_viewWillDisappear(SBDas
}

if (lockScreenPlayer && isLockScreenVisible) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}
}

Expand All @@ -375,7 +406,7 @@ static void override_CSModalButton_didMoveToWindow(CSModalButton* self, SEL _cmd

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand All @@ -390,7 +421,7 @@ static void override_CSModalButton_removeFromSuperview(CSModalButton* self, SEL

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
if (lockScreenPlayer) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}

if (homeScreenPlayer) {
Expand All @@ -406,7 +437,7 @@ static void override_SBLockScreenEmergencyCallViewController_viewWillAppear(SBLo
isLockScreenVisible = NO;

if (lockScreenPlayer) {
[lockScreenPlayer pause];
pauseVideo(lockScreenPlayerLayer);
}
}

Expand All @@ -421,7 +452,7 @@ static void override_SBLockScreenEmergencyCallViewController_viewWillDisappear(S
}

if (lockScreenPlayer) {
[lockScreenPlayer play];
playVideo(lockScreenPlayerLayer);
}
}

Expand Down

0 comments on commit 19bab87

Please sign in to comment.