prepare for uYou v3.0.2+

This commit is contained in:
qnblackcat 2024-02-15 09:25:57 +07:00
parent b9d1826c99
commit ced5cf81df
2 changed files with 90 additions and 88 deletions

View file

@ -332,9 +332,9 @@ NSBundle *tweakBundle = uYouPlusBundle();
if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) { if (IS_ENABLED(@"hidePreviousAndNextButton_enabled")) {
%init(gHidePreviousAndNextButton); %init(gHidePreviousAndNextButton);
} }
if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) { // if (IS_ENABLED(@"replacePreviousAndNextButton_enabled")) {
%init(gReplacePreviousAndNextButton); // %init(gReplacePreviousAndNextButton);
} // }
if (IS_ENABLED(@"disableHints_enabled")) { if (IS_ENABLED(@"disableHints_enabled")) {
%init(gDisableHints); %init(gDisableHints);
} }

View file

@ -62,36 +62,36 @@
%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
@ -116,61 +116,63 @@
%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; // DownloadsPagerVC *downloadsPagerVC;
NSUInteger selectedTabIndex; // NSUInteger selectedTabIndex;
static void refreshUYouAppearance() { // static void refreshUYouAppearance() {
if (!downloadsPagerVC) return; // if (!downloadsPagerVC) return;
// View pager // // View pager
[downloadsPagerVC updatePageStyles]; // [downloadsPagerVC updatePageStyles];
// Views // // Views
for (UIViewController *vc in [downloadsPagerVC viewControllers]) { // for (UIViewController *vc in [downloadsPagerVC viewControllers]) {
if ([vc isKindOfClass:%c(DownloadingVC)]) { // if ([vc isKindOfClass:%c(DownloadingVC)]) {
// `Downloading` view // // `Downloading` view
[(DownloadingVC *)vc updatePageStyles]; // [(DownloadingVC *)vc updatePageStyles];
for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells) // for (UITableViewCell *cell in [(DownloadingVC *)vc tableView].visibleCells)
if ([cell isKindOfClass:%c(DownloadingCell)]) // if ([cell isKindOfClass:%c(DownloadingCell)])
[(DownloadingCell *)cell updatePageStyles]; // [(DownloadingCell *)cell updatePageStyles];
} // }
else if ([vc isKindOfClass:%c(DownloadedVC)]) { // else if ([vc isKindOfClass:%c(DownloadedVC)]) {
// `All`, `Audios`, `Videos`, `Shorts` views // // `All`, `Audios`, `Videos`, `Shorts` views
[(DownloadedVC *)vc updatePageStyles]; // [(DownloadedVC *)vc updatePageStyles];
for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells) // for (UITableViewCell *cell in [(DownloadedVC *)vc tableView].visibleCells)
if ([cell isKindOfClass:%c(DownloadedCell)]) // if ([cell isKindOfClass:%c(DownloadedCell)])
[(DownloadedCell *)cell updatePageStyles]; // [(DownloadedCell *)cell updatePageStyles];
} // }
} // }
// View pager tabs // // View pager tabs
for (UIView *subview in [downloadsPagerVC view].subviews) { // for (UIView *subview in [downloadsPagerVC view].subviews) {
if ([subview isKindOfClass:[UIScrollView class]]) { // if ([subview isKindOfClass:[UIScrollView class]]) {
UIScrollView *tabs = (UIScrollView *)subview; // UIScrollView *tabs = (UIScrollView *)subview;
NSUInteger i = 0; // NSUInteger i = 0;
for (UIView *item in tabs.subviews) { // for (UIView *item in tabs.subviews) {
if ([item isKindOfClass:[UILabel class]]) { // if ([item isKindOfClass:[UILabel class]]) {
// Tab label // // Tab label
UILabel *tabLabel = (UILabel *)item; // UILabel *tabLabel = (UILabel *)item;
if (i == selectedTabIndex) {} // Selected tab should be excluded // if (i == selectedTabIndex) {} // Selected tab should be excluded
else [tabLabel setTextColor:[UILabel _defaultColor]]; // else [tabLabel setTextColor:[UILabel _defaultColor]];
i++; // i++;
} // }
} // }
} // }
} // }
} // }
%hook DownloadsPagerVC
- (instancetype)init { // %hook DownloadsPagerVC
downloadsPagerVC = %orig; // - (instancetype)init {
return downloadsPagerVC; // downloadsPagerVC = %orig;
} // return downloadsPagerVC;
- (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 { // }
%orig; selectedTabIndex = arg1; // - (void)viewPager:(id)viewPager didChangeTabToIndex:(NSUInteger)arg1 fromTabIndex:(NSUInteger)arg2 {
} // %orig; selectedTabIndex = arg1;
%end // }
%hook UIViewController // %end
- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
%orig; // %hook UIViewController
refreshUYouAppearance(); // - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
} // %orig;
%end // refreshUYouAppearance();
// }
// %end
// Prevent uYou's playback from colliding with YouTube's // Prevent uYou's playback from colliding with YouTube's
%hook PlayerVC %hook PlayerVC
@ -196,9 +198,9 @@ static void refreshUYouAppearance() {
%ctor { %ctor {
%init; %init;
if (@available(iOS 16, *)) { // if (@available(iOS 16, *)) {
%init(iOS16); // %init(iOS16);
} // }
// Disable broken options // Disable broken options