From a43f8ff13e2571ee7ce361d291cad4c17dad5fa4 Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Wed, 10 Apr 2024 23:06:20 -0700 Subject: [PATCH] Allow feature for portrait videos --- Sources/uYouPlus.h | 10 ++++++++++ Sources/uYouPlus.xm | 25 +++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Sources/uYouPlus.h b/Sources/uYouPlus.h index d1b2c6e..c30beeb 100644 --- a/Sources/uYouPlus.h +++ b/Sources/uYouPlus.h @@ -30,6 +30,7 @@ #import #import #import +#import // Hide buttons under the video player by @PoomSmart #import @@ -67,6 +68,15 @@ @property(readonly, nonatomic) YTIIcon *iconImage; @end +// Disable Pull to Full for landscape videos - @bhackel +@interface YTWatchPullToFullController : NSObject +@property(nonatomic, strong) YTWatchViewController *playerViewSource; +@end +@interface YTWatchViewController (uYouEnhanced) +@property(nonatomic, strong) YTWatchPullToFullController *pullToFullController; +- (NSUInteger)allowedFullScreenOrientations; +@end + // uYouPlus @interface YTHeaderLogoController : UIView @property(readonly, nonatomic) long long pageStyle; diff --git a/Sources/uYouPlus.xm b/Sources/uYouPlus.xm index bb55225..214d67c 100644 --- a/Sources/uYouPlus.xm +++ b/Sources/uYouPlus.xm @@ -657,12 +657,29 @@ BOOL isAd(YTIElementRenderer *self) { } %end -// Disable pull to enter vertical fullscreen gesture - @bhackel +// Disable pull to enter vertical/portrait fullscreen gesture - @bhackel // This was introduced in version 19.XX +// This only applies to landscape videos %group gDisablePullToFull -%hook YTColdConfig -- (BOOL)enablePullToFull { return NO; } -- (BOOL)enablePullToFullAlwaysExitFullscreenLandscape { return NO; } +%hook YTWatchPullToFullController +// New variable to store the controller +- (BOOL)shouldRecognizeOverscrollEventsFromWatchOverscrollController:(id)arg1 { + NSLog(@"bhackel - shouldRecognizeOverscrollEventsFromWatchOverscrollController"); + // Get the current player orientation + YTWatchViewController *watchViewController = self.playerViewSource; + NSUInteger allowedFullScreenOrientations = [watchViewController allowedFullScreenOrientations]; + NSLog(@"bhackel - current orientation: %lu", allowedFullScreenOrientations); + // Check if the current player orientation is portrait + if (allowedFullScreenOrientations == UIInterfaceOrientationMaskAllButUpsideDown + || allowedFullScreenOrientations == UIInterfaceOrientationMaskPortrait + || allowedFullScreenOrientations == UIInterfaceOrientationMaskPortraitUpsideDown) { + NSLog(@"bhackel - allow pull to full: YES"); + return %orig; + } else { + NSLog(@"bhackel - allow pull to full: NO"); + return NO; + } +} %end %end