From 2f472694d1774c54fc57df1d1adc652225a946a0 Mon Sep 17 00:00:00 2001 From: Foxster Date: Mon, 19 Feb 2024 13:21:33 -0800 Subject: [PATCH] Refactor --- .gitmodules | 3 ++ Settings.h | 18 +++++++ Settings.x | 5 +- Tweak.h | 132 +++++++--------------------------------------------- Tweak.x | 9 +--- YTHeaders | 1 + 6 files changed, 41 insertions(+), 127 deletions(-) create mode 100644 .gitmodules create mode 100644 Settings.h create mode 160000 YTHeaders diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2c42dc3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "YTHeaders"] + path = YTHeaders + url = https://github.com/therealFoxster/YTHeaders diff --git a/Settings.h b/Settings.h new file mode 100644 index 0000000..357a424 --- /dev/null +++ b/Settings.h @@ -0,0 +1,18 @@ +#import +#import +#import +#import +#import + +#define DEMC @"DontEatMyContent" +#define VERSION @"1.1.3" +#define LOCALIZED_STRING(s) [bundle localizedStringForKey:s value:nil table:nil] + +extern void DEMC_showSnackBar(NSString *text); +extern NSBundle *DEMC_getTweakBundle(); +extern CGFloat constant; + +// Category for additional functions +@interface YTSettingsSectionItemManager (DontEatMyContent) +- (void)updateDEMCSectionWithEntry:(id)entry; +@end \ No newline at end of file diff --git a/Settings.x b/Settings.x index 0234f37..b81d6f8 100644 --- a/Settings.x +++ b/Settings.x @@ -1,4 +1,5 @@ #import "Tweak.h" +#import "Settings.h" // Adapted from // https://github.com/PoomSmart/YouPiP/blob/bd04bf37be3d01540db418061164ae17a8f0298e/Settings.x @@ -7,10 +8,6 @@ #define SECTION_HEADER(s) [sectionItems addObject:[%c(YTSettingsSectionItem) itemWithTitle:@"\t" titleDescription:[s uppercaseString] accessibilityIdentifier:nil detailTextBlock:nil selectBlock:^BOOL (YTSettingsCell *cell, NSUInteger sectionItemIndex) { return NO; }]] #define SWITCH_ITEM(t, d, k) [sectionItems addObject:[%c(YTSettingsSectionItem) switchItemWithTitle:t titleDescription:d accessibilityIdentifier:nil switchOn:IS_ENABLED(k) switchBlock:^BOOL (YTSettingsCell *cell, BOOL enabled) {[[NSUserDefaults standardUserDefaults] setBool:enabled forKey:k];DEMC_showSnackBar(LOCALIZED_STRING(@"CHANGES_SAVED"));return YES;} settingItemId:0]] -extern void DEMC_showSnackBar(NSString *text); -extern NSBundle *DEMC_getTweakBundle(); -extern CGFloat constant; - static const NSInteger sectionId = 517; // DontEatMyContent's section ID (just a random number) %hook YTAppSettingsPresentationData diff --git a/Tweak.h b/Tweak.h index d5f2fe8..e664315 100644 --- a/Tweak.h +++ b/Tweak.h @@ -1,7 +1,16 @@ -#import - -#define DEMC @"DontEatMyContent" -#define VERSION @"1.1.3" +// #import +#import +#import +#import +#import +// #import +#import +#import +#import +#import +#import +#import +#import // Keys #define kTweak @"DEMC_enabled" @@ -11,117 +20,10 @@ #define kLimitZoomToFill @"DEMC_limitZoomToFill" #define kEnableForAllVideos @"DEMC_enableForAllVideos" +#define THRESHOLD 1.97 #define DEFAULT_CONSTANT 21.5 #define IS_ENABLED(k) [[NSUserDefaults standardUserDefaults] boolForKey:k] -#define LOCALIZED_STRING(s) [bundle localizedStringForKey:s value:nil table:nil] - -@interface YTPlayerViewController : UIViewController -- (id)activeVideoPlayerOverlay; -- (id)playerView; -- (BOOL)isCurrentVideoVertical; -@end - -@interface YTPlayerView : UIView -- (id)renderingView; -@end - -@interface YTMainAppVideoPlayerOverlayViewController : UIViewController -- (BOOL)isFullscreen; -@end - -@interface MLHAMSBDLSampleBufferRenderingView : UIView -@end - -@interface HAMSampleBufferDisplayLayerView : UIView -@end - -@interface YTMainAppEngagementPanelViewController : UIViewController -- (BOOL)isLandscapeEngagementPanel; -- (BOOL)isPeekingSupported; -@end - -@interface YTEngagementPanelContainerViewController : UIViewController -- (BOOL)isLandscapeEngagementPanel; -- (BOOL)isPeekingSupported; -@end - -@interface YTLabel : UILabel -@property (nonatomic, copy, readwrite) NSString *text; -@end - -@interface YTSettingsCell : UICollectionViewCell -@end - -@interface YTSettingsSectionItemManager : NSObject -- (id)parentResponder; -@end - -// Category for additional functions -@interface YTSettingsSectionItemManager (DontEatMyContent) -- (void)updateDEMCSectionWithEntry:(id)entry; -@end - -@interface YTSettingsPickerViewController : UIViewController -- (instancetype)initWithNavTitle:(NSString *)navTitle - pickerSectionTitle:(NSString *)pickerSectionTitle - rows:(NSArray *)rows - selectedItemIndex:(NSUInteger)selectedItemIndex - parentResponder:(id)parentResponder; -@end - -@interface YTSettingsSectionItem : NSObject -+ (instancetype)switchItemWithTitle:(NSString *)title - titleDescription:(NSString *)titleDescription - accessibilityIdentifier:(NSString *)accessibilityIdentifier - switchOn:(BOOL)switchOn - switchBlock:(BOOL (^)(YTSettingsCell *, BOOL))switchBlock - settingItemId:(int)settingItemId; -+ (instancetype)itemWithTitle:(NSString *)title - titleDescription:(NSString *)titleDescription - accessibilityIdentifier:(NSString *)accessibilityIdentifier - detailTextBlock:(id)detailTextBlock - selectBlock:(BOOL (^)(YTSettingsCell *, NSUInteger))selectBlock; -+ (instancetype)checkmarkItemWithTitle:(NSString *)title - selectBlock:(BOOL (^)(YTSettingsCell *, NSUInteger))selectBlock; -@end - -@interface YTSettingsViewController : UIViewController -- (void)setSectionItems:(NSMutableArray *)sectionItems - forCategory:(NSInteger)category - title:(NSString *)title - titleDescription:(NSString *)titleDescription - headerHidden:(BOOL)headerHidden; -- (void)setSectionItems:(NSMutableArray *)sectionItems - forCategory:(NSInteger)category - title:(NSString *)title - icon:(id)icon - titleDescription:(NSString *)titleDescription - headerHidden:(BOOL)headerHidden; -- (void)pushViewController:(UIViewController *)viewController; -- (void)reloadData; -- (id)accountID; -- (id)initWithAccountID:(id)accountID parentResponder:(id)parentResponder; -@end - -// Alert -@interface YTAlertView : UIView -@property (nonatomic, copy, readwrite) NSString *title; -@property (nonatomic, copy, readwrite) NSString *subtitle; -+ (instancetype)confirmationDialogWithAction:(void (^)(void))action - actionTitle:(NSString *)actionTitle - cancelTitle:(NSString *)cancelTitle; -- (void)show; -@end - -// Snack bar -@interface YTHUDMessage : NSObject -+ (id)messageWithText:(id)text; -@end -@interface GOOHUDManagerInternal : NSObject -- (void)showMessageMainThread:(id)message; -+ (id)sharedInstance; -@end -@interface YTUIUtils : NSObject -+ (BOOL)openURL:(NSURL *)url; -@end \ No newline at end of file +void DEMC_showSnackBar(NSString *text); +NSBundle *DEMC_getTweakBundle(); +CGFloat constant; // Makes rendering view a bit larger since constraining to safe area leaves a gap between the notch/Dynamic Island and video \ No newline at end of file diff --git a/Tweak.x b/Tweak.x index d83d9d2..891009c 100644 --- a/Tweak.x +++ b/Tweak.x @@ -1,22 +1,15 @@ -#import -#import #import "Tweak.h" -#define THRESHOLD 1.97 - -CGFloat constant; // Makes rendering view a bit larger since constraining to safe area leaves a gap between the notch/Dynamic Island and video static CGFloat videoAspectRatio = 16/9; static BOOL isZoomedToFill = NO; static BOOL isEngagementPanelVisible = NO; static BOOL isEngagementPanelViewControllerRemoved = NO; -static MLHAMSBDLSampleBufferRenderingView *renderingView; +static UIView *renderingView; // MLHAMSBDLSampleBufferRenderingView * static NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *centerYConstraint; static void DEMC_activateConstraints(); static void DEMC_deactivateConstraints(); static void DEMC_centerRenderingView(); -void DEMC_showSnackBar(NSString *text); -NSBundle *DEMC_getTweakBundle(); %hook YTPlayerViewController - (void)viewDidAppear:(BOOL)animated { diff --git a/YTHeaders b/YTHeaders new file mode 160000 index 0000000..256f8c7 --- /dev/null +++ b/YTHeaders @@ -0,0 +1 @@ +Subproject commit 256f8c79288e0006e436423ebd23ec92980391a3