From 163dac3e81025c81c8258cc0eab436f6050ed4d9 Mon Sep 17 00:00:00 2001 From: qnblackcat Date: Sun, 12 Jun 2022 13:41:29 +0700 Subject: [PATCH] fix compiling, code format --- Settings.xm | 9 ++++----- uYouPlus.xm | 39 +++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Settings.xm b/Settings.xm index 78faec5..5212078 100644 --- a/Settings.xm +++ b/Settings.xm @@ -1,8 +1,7 @@ #import "Tweaks/YouTubeHeader/YTSettingsViewController.h" #import "Tweaks/YouTubeHeader/YTSettingsSectionItem.h" #import "Tweaks/YouTubeHeader/YTSettingsSectionItemManager.h" - -#define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil] +#import "Header.h" @interface YTSettingsSectionItemManager (YouPiP) - (void)updateuYouPlusSectionWithEntry:(id)entry; @@ -24,8 +23,6 @@ extern BOOL castConfirm(); extern BOOL ytMiniPlayer(); extern BOOL hidePreviousAndNextButton(); -NSBundle *tweakBundle = uYouPlusBundle(); - // Settings %hook YTAppSettingsPresentationData + (NSArray *)settingsCategoryOrder { @@ -39,8 +36,10 @@ NSBundle *tweakBundle = uYouPlusBundle(); %end %hook YTSettingsSectionItemManager -%new - (void)updateuYouPlusSectionWithEntry:(id)entry { +%new +- (void)updateuYouPlusSectionWithEntry:(id)entry { YTSettingsViewController *delegate = [self valueForKey:@"_dataDelegate"]; + NSBundle *tweakBundle = uYouPlusBundle(); YTSettingsSectionItem *hidePreviousAndNextButton = [[%c(YTSettingsSectionItem) alloc] initWithTitle:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON") titleDescription:LOC(@"HIDE_PREVIOUS_AND_NEXT_BUTTON_DESC")]; hidePreviousAndNextButton.hasSwitch = YES; diff --git a/uYouPlus.xm b/uYouPlus.xm index 949c203..569b88d 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -14,11 +14,19 @@ #import "Tweaks/YouTubeHeader/YTCommonColorPalette.h" #import "Tweaks/YouTubeHeader/ASCollectionView.h" -#define LOC(x) [tweakBundle localizedStringForKey:x value:nil table:nil] - -#define YT_BUNDLE_ID @"com.google.ios.youtube" -#define YT_NAME @"YouTube" +// Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f +NSBundle *uYouPlusBundle() { + static NSBundle *bundle = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]; + bundle = [NSBundle bundleWithPath:tweakBundlePath]; + }); + return bundle; +} +NSBundle *tweakBundle = uYouPlusBundle(); +// BOOL hideHUD() { return [[NSUserDefaults standardUserDefaults] boolForKey:@"hideHUD_enabled"]; } @@ -70,17 +78,17 @@ BOOL ytMiniPlayer() { // Hide CC / Autoplay switch / Next & Previous button %hook YTMainAppControlsOverlayView -- (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC?! +- (void)setClosedCaptionsOrSubtitlesButtonAvailable:(BOOL)arg1 { // hide CC button if (hideCC()) { return %orig(NO); } else { return %orig; } } -- (void)setAutoplaySwitchButtonRenderer:(id)arg1 { +- (void)setAutoplaySwitchButtonRenderer:(id)arg1 { // hide Autoplay if (hideAutoplaySwitch()) {} else { return %orig; } } - (void)layoutSubviews { - if (hidePreviousAndNextButton()) { - %orig; + %orig; + if (hidePreviousAndNextButton()) { // hide Next & Previous button MSHookIvar(self, "_nextButton").hidden = YES; MSHookIvar(self, "_previousButton").hidden = YES; } @@ -121,7 +129,6 @@ BOOL ytMiniPlayer() { %hook MDXPlaybackRouteButtonController - (void)didPressButton:(id)arg1 { if (castConfirm()) { - NSBundle *tweakBundle = uYouPlusBundle(); UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:LOC(@"CASTING") message:LOC(@"MSG_ARE_YOU_SURE") preferredStyle:UIAlertControllerStyleAlert]; @@ -151,7 +158,6 @@ BOOL ytMiniPlayer() { } [rootViewController presentViewController:alertController animated:YES completion:nil]; } else { return %orig; } - } %end @@ -615,17 +621,6 @@ static void replaceTab(YTIGuideResponse *response) { %end %end -// Tweak's bundle for Localizations support - @PoomSmart - https://github.com/PoomSmart/YouPiP/commit/aea2473f64c75d73cab713e1e2d5d0a77675024f -NSBundle *uYouPlusBundle() { - static NSBundle *bundle = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSString *tweakBundlePath = [[NSBundle mainBundle] pathForResource:@"uYouPlus" ofType:@"bundle"]; - bundle = [NSBundle bundleWithPath:tweakBundlePath]; - }); - return bundle; -} - # pragma mark - ctor %ctor { %init; @@ -641,4 +636,4 @@ NSBundle *uYouPlusBundle() { if (bigYTMiniPlayer() && (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPad)) { %init(Main); } -} +} \ No newline at end of file