Update uYouPlusPatches.xm (from uYouPlus)

Added the same changes from uYouPlus.
This commit is contained in:
arichornlover 2024-02-19 22:18:10 -06:00 committed by GitHub
parent 1b8ddd322b
commit 5db8890b05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -92,36 +92,36 @@ static void repositionCreateTab(YTIGuideResponse *response) {
%end %end
// iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224 // iOS 16 uYou crash fix - @level3tjg: https://github.com/qnblackcat/uYouPlus/pull/224
%group iOS16 // %group iOS16
%hook OBPrivacyLinkButton // %hook OBPrivacyLinkButton
%new // %new
- (instancetype)initWithCaption:(NSString *)caption // - (instancetype)initWithCaption:(NSString *)caption
buttonText:(NSString *)buttonText // buttonText:(NSString *)buttonText
image:(UIImage *)image // image:(UIImage *)image
imageSize:(CGSize)imageSize // imageSize:(CGSize)imageSize
useLargeIcon:(BOOL)useLargeIcon { // useLargeIcon:(BOOL)useLargeIcon {
return [self initWithCaption:caption // return [self initWithCaption:caption
buttonText:buttonText // buttonText:buttonText
image:image // image:image
imageSize:imageSize // imageSize:imageSize
useLargeIcon:useLargeIcon // useLargeIcon:useLargeIcon
displayLanguage:[NSLocale currentLocale].languageCode]; // displayLanguage:[NSLocale currentLocale].languageCode];
} // }
%end // %end
%end // %end
// Fix uYou playback speed crashes YT v18.49.3+, see https://github.com/iCrazeiOS/uYouCrashFix // Fix uYou playback speed crashes YT v18.49.3+, see https://github.com/iCrazeiOS/uYouCrashFix
%hook YTPlayerViewController // %hook YTPlayerViewController
%new // %new
-(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 { // -(float)currentPlaybackRateForVarispeedSwitchController:(id)arg1 {
return [[self activeVideo] playbackRate]; // return [[self activeVideo] playbackRate];
} // }
%new // %new
-(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 { // -(void)varispeedSwitchController:(id)arg1 didSelectRate:(float)arg2 {
[[self activeVideo] setPlaybackRate:arg2]; // [[self activeVideo] setPlaybackRate:arg2];
} // }
%end // %end
// Fix streched artwork in uYou's player view - https://github.com/MiRO92/uYou-for-YouTube/issues/287 // Fix streched artwork in uYou's player view - https://github.com/MiRO92/uYou-for-YouTube/issues/287
%hook ArtworkImageView %hook ArtworkImageView
@ -146,8 +146,17 @@ static void repositionCreateTab(YTIGuideResponse *response) {
%end %end
// Fix uYou's appearance not updating if the app is backgrounded // Fix uYou's appearance not updating if the app is backgrounded
DownloadsPagerVC *downloadsPagerVC; static DownloadsPagerVC *downloadsPagerVC;
NSUInteger selectedTabIndex; static NSUInteger selectedTabIndex;
%hook DownloadsPagerVC
- (id)init {
downloadsPagerVC = %orig;
return downloadsPagerVC;
}
- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 {
%orig; selectedTabIndex = arg1;
}
%end
static void refreshUYouAppearance() { static void refreshUYouAppearance() {
if (!downloadsPagerVC) return; if (!downloadsPagerVC) return;
// View pager // View pager
@ -186,31 +195,27 @@ static void refreshUYouAppearance() {
} }
} }
} }
%hook DownloadsPagerVC
- (instancetype)init {
downloadsPagerVC = %orig;
return downloadsPagerVC;
}
- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 {
%orig; selectedTabIndex = arg1;
}
%end
%hook UIViewController %hook UIViewController
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
%orig; %orig;
refreshUYouAppearance(); dispatch_async(dispatch_get_main_queue(), ^{
refreshUYouAppearance();
});
} }
%end %end
// Prevent uYou's playback from colliding with YouTube's // Prevent uYou's playback from colliding with YouTube's
BOOL isYTPlaybackActive = NO; %hook PlayerVC
%hook HAMPlayerInternal - (void)close {
- (void)play { %orig; isYTPlaybackActive = YES; } %orig;
- (void)terminate { %orig; isYTPlaybackActive = NO; } [[%c(PlayerManager) sharedInstance] setSource:nil];
}
%end %end
%hook PlayerManager %hook HAMPlayerInternal
- (void)play { - (void)play {
if (isYTPlaybackActive) return; dispatch_async(dispatch_get_main_queue(), ^{
[[%c(PlayerManager) sharedInstance] pause];
});
%orig; %orig;
} }
%end %end
@ -223,9 +228,9 @@ BOOL isYTPlaybackActive = NO;
%ctor { %ctor {
%init; %init;
if (@available(iOS 16, *)) { // if (@available(iOS 16, *)) {
%init(iOS16); // %init(iOS16);
} // }
// Disable broken options // Disable broken options