diff --git a/Header.h b/Header.h index 02748b5..09a25af 100644 --- a/Header.h +++ b/Header.h @@ -43,7 +43,8 @@ // DontEatMyContent NSString* deviceName(); -BOOL isDeviceSupported(); +void aspectRatioChanged(CGFloat arg); +BOOL deviceIsSupported(); void activate(); void deactivate(); void center(); diff --git a/uYouPlus.xm b/uYouPlus.xm index 2d1e424..10ce928 100644 --- a/uYouPlus.xm +++ b/uYouPlus.xm @@ -940,7 +940,6 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen } - (void)didPressToggleFullscreen { YTMainAppVideoPlayerOverlayViewController *activeVideoPlayerOverlay = [self activeVideoPlayerOverlay]; - if (![activeVideoPlayerOverlay isFullscreen]) // Entering fullscreen activate(); else // Exiting fullscreen @@ -948,26 +947,34 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen %orig; } -- (void)didSwipeToEnterFullscreen { - %orig; activate(); -} -- (void)didSwipeToExitFullscreen { - %orig; deactivate(); -} -// Get video aspect ratio; doesn't work for some users; see -(void)resetForVideoWithAspectRatio:(double) +- (void)didSwipeToEnterFullscreen { %orig; activate(); } +- (void)didSwipeToExitFullscreen { %orig; deactivate(); } + +// Retrieve video aspect ratio (1) (no longer works but kept for backwards compatibility) - (void)singleVideo:(id)arg1 aspectRatioDidChange:(CGFloat)arg2 { - aspectRatio = arg2; - if (aspectRatio == 0.0) { - // App backgrounded - } else if (aspectRatio < THRESHOLD) { - deactivate(); - } else { - activate(); - } %orig(arg1, arg2); + aspectRatioChanged(arg2); } %end +// Retrieve video aspect ratio (2) (no longer works but kept for backwards compatibility) +%hook YTVideoZoomOverlayController +- (void)resetForVideoWithAspectRatio:(double)arg1 { + %orig(arg1); + aspectRatioChanged(arg1); +} +%end + +// Retrieve video aspect ratio (3) +%hook YTPlayerView +- (void)setAspectRatio:(CGFloat)arg1 { + %orig(arg1); + aspectRatioChanged(arg1); + // %log((CGFloat) aspectRatio); +} +%end + +// Detect pinch gesture (1) (no longer works but kept for backwards compatibility) %hook YTVideoZoomOverlayView - (void)didRecognizePinch:(UIPinchGestureRecognizer *)pinchGestureRecognizer { // %log((CGFloat) [pinchGestureRecognizer scale], (CGFloat) [pinchGestureRecognizer velocity]); @@ -980,27 +987,22 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen } %orig(pinchGestureRecognizer); } -- (void)flashAndHideSnapIndicator {} -// https://github.com/lgariv/UniZoom/blob/master/Tweak.xm -- (void)setSnapIndicatorVisible:(bool)arg1 { - %orig(NO); +%end + +// Detect pinch gesture (2) +%hook YTVideoFreeZoomOverlayView +- (void)didRecognizePinch:(UIPinchGestureRecognizer *)pinchGestureRecognizer { + if ([pinchGestureRecognizer velocity] <= 0.0) { // >>Zoom out<< + zoomedToFill = false; + activate(); + } else if ([pinchGestureRecognizer velocity] > 0.0) { // <> + zoomedToFill = true; + deactivate(); + } + %orig(pinchGestureRecognizer); } %end -%hook YTVideoZoomOverlayController -// Get video aspect ratio; fallback for -(void)singleVideo:(id)aspectRatioDidChange:(CGFloat) -- (void)resetForVideoWithAspectRatio:(double)arg1 { - aspectRatio = arg1; - %log; - if (aspectRatio == 0.0) {} - else if (aspectRatio < THRESHOLD) { - deactivate(); - } else { - activate(); - } - %orig(arg1); -} -%end %end // gDontEatMyContent // DontEatMycontent - detecting device model @@ -1011,7 +1013,7 @@ NSString* deviceName() { return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } -BOOL isDeviceSupported() { +BOOL deviceIsSupported() { NSString *identifier = deviceName(); NSArray *unsupportedDevices = UNSUPPORTED_DEVICES; @@ -1032,6 +1034,17 @@ BOOL isDeviceSupported() { } else return NO; } +void aspectRatioChanged(CGFloat arg) { + aspectRatio = arg; + if (aspectRatio == 0.0) { + // App backgrounded or something went wrong + } else if (aspectRatio < THRESHOLD) { + deactivate(); + } else { + activate(); + } +} + void activate() { if (aspectRatio < THRESHOLD || zoomedToFill) return; // NSLog(@"activate"); @@ -1159,7 +1172,7 @@ static BOOL didFinishLaunching; if (replacePreviousAndNextButton()) { %init(gReplacePreviousAndNextButton); } - if (dontEatMyContent() && isDeviceSupported()) { + if (dontEatMyContent() && deviceIsSupported()) { %init(gDontEatMyContent); } if (@available(iOS 16, *)) {