clean up
This commit is contained in:
+51
-54
@@ -881,9 +881,7 @@ static void replaceTab(YTIGuideResponse *response) {
|
|||||||
%end
|
%end
|
||||||
%end
|
%end
|
||||||
|
|
||||||
#define UNSUPPORTED_DEVICES @[@"iPhone14,3", @"iPhone14,6", @"iPhone14,8"]
|
// DontEatMyContent - @therealFoxster: https://github.com/therealFoxster/DontEatMyContent
|
||||||
#define THRESHOLD 1.99
|
|
||||||
|
|
||||||
double aspectRatio = 16/9;
|
double aspectRatio = 16/9;
|
||||||
bool zoomedToFill = false;
|
bool zoomedToFill = false;
|
||||||
|
|
||||||
@@ -892,7 +890,6 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen
|
|||||||
|
|
||||||
%group gDontEatMyContent
|
%group gDontEatMyContent
|
||||||
%hook YTPlayerViewController
|
%hook YTPlayerViewController
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
YTPlayerView *playerView = [self playerView];
|
YTPlayerView *playerView = [self playerView];
|
||||||
UIView *renderingViewContainer = MSHookIvar<UIView *>(playerView, "_renderingViewContainer");
|
UIView *renderingViewContainer = MSHookIvar<UIView *>(playerView, "_renderingViewContainer");
|
||||||
@@ -904,7 +901,7 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen
|
|||||||
heightConstraint = [renderingView.heightAnchor constraintEqualToAnchor:renderingViewContainer.safeAreaLayoutGuide.heightAnchor constant:constant];
|
heightConstraint = [renderingView.heightAnchor constraintEqualToAnchor:renderingViewContainer.safeAreaLayoutGuide.heightAnchor constant:constant];
|
||||||
centerXConstraint = [renderingView.centerXAnchor constraintEqualToAnchor:renderingViewContainer.centerXAnchor];
|
centerXConstraint = [renderingView.centerXAnchor constraintEqualToAnchor:renderingViewContainer.centerXAnchor];
|
||||||
centerYConstraint = [renderingView.centerYAnchor constraintEqualToAnchor:renderingViewContainer.centerYAnchor];
|
centerYConstraint = [renderingView.centerYAnchor constraintEqualToAnchor:renderingViewContainer.centerYAnchor];
|
||||||
|
|
||||||
// playerView.backgroundColor = [UIColor greenColor];
|
// playerView.backgroundColor = [UIColor greenColor];
|
||||||
// renderingViewContainer.backgroundColor = [UIColor redColor];
|
// renderingViewContainer.backgroundColor = [UIColor redColor];
|
||||||
// renderingView.backgroundColor = [UIColor blueColor];
|
// renderingView.backgroundColor = [UIColor blueColor];
|
||||||
@@ -917,16 +914,17 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen
|
|||||||
} else {
|
} else {
|
||||||
center();
|
center();
|
||||||
}
|
}
|
||||||
|
|
||||||
%orig(animated);
|
%orig(animated);
|
||||||
}
|
}
|
||||||
- (void)didPressToggleFullscreen {
|
- (void)didPressToggleFullscreen {
|
||||||
YTMainAppVideoPlayerOverlayViewController *activeVideoPlayerOverlay = [self activeVideoPlayerOverlay];
|
YTMainAppVideoPlayerOverlayViewController *activeVideoPlayerOverlay = [self activeVideoPlayerOverlay];
|
||||||
|
|
||||||
if (![activeVideoPlayerOverlay isFullscreen]) // Entering fullscreen
|
if (![activeVideoPlayerOverlay isFullscreen]) // Entering fullscreen
|
||||||
activate();
|
activate();
|
||||||
else // Exiting fullscreen
|
else // Exiting fullscreen
|
||||||
deactivate();
|
deactivate();
|
||||||
|
|
||||||
%orig;
|
%orig;
|
||||||
}
|
}
|
||||||
- (void)didSwipeToEnterFullscreen {
|
- (void)didSwipeToEnterFullscreen {
|
||||||
@@ -958,67 +956,66 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen
|
|||||||
zoomedToFill = true;
|
zoomedToFill = true;
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
%orig(pinchGestureRecognizer);
|
%orig(pinchGestureRecognizer);
|
||||||
}
|
}
|
||||||
- (void)flashAndHideSnapIndicator {}
|
- (void)flashAndHideSnapIndicator {}
|
||||||
|
|
||||||
// https://github.com/lgariv/UniZoom/blob/master/Tweak.xm
|
// https://github.com/lgariv/UniZoom/blob/master/Tweak.xm
|
||||||
- (void)setSnapIndicatorVisible:(bool)arg1 {
|
- (void)setSnapIndicatorVisible:(bool)arg1 {
|
||||||
%orig(NO);
|
%orig(NO);
|
||||||
}
|
}
|
||||||
%end
|
%end
|
||||||
%end
|
%end // gDontEatMyContent
|
||||||
|
|
||||||
|
// DontEatMycontent - detecting device model
|
||||||
// https://stackoverflow.com/a/11197770/19227228
|
// https://stackoverflow.com/a/11197770/19227228
|
||||||
NSString* deviceName() {
|
NSString* deviceName() {
|
||||||
struct utsname systemInfo;
|
struct utsname systemInfo;
|
||||||
uname(&systemInfo);
|
uname(&systemInfo);
|
||||||
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
|
return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL isDeviceSupported() {
|
BOOL isDeviceSupported() {
|
||||||
NSString *identifier = deviceName();
|
NSString *identifier = deviceName();
|
||||||
NSArray *unsupportedDevices = UNSUPPORTED_DEVICES;
|
NSArray *unsupportedDevices = UNSUPPORTED_DEVICES;
|
||||||
|
|
||||||
|
for (NSString *device in unsupportedDevices) {
|
||||||
|
if ([device isEqualToString:identifier]) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (NSString *device in unsupportedDevices) {
|
if ([identifier containsString:@"iPhone"]) {
|
||||||
if ([device isEqualToString:identifier]) {
|
NSString *model = [identifier stringByReplacingOccurrencesOfString:@"iPhone" withString:@""];
|
||||||
return NO;
|
model = [model stringByReplacingOccurrencesOfString:@"," withString:@"."];
|
||||||
}
|
if ([identifier isEqualToString:@"iPhone13,1"]) { // iPhone 12 mini
|
||||||
}
|
return YES;
|
||||||
|
} else if ([model floatValue] >= 14.0) { // iPhone 13 series and newer
|
||||||
|
return YES;
|
||||||
|
} else return NO;
|
||||||
|
} else return NO;
|
||||||
|
}
|
||||||
|
|
||||||
if ([identifier containsString:@"iPhone"]) {
|
void activate() {
|
||||||
NSString *model = [identifier stringByReplacingOccurrencesOfString:@"iPhone" withString:@""];
|
if (aspectRatio < THRESHOLD || zoomedToFill) return;
|
||||||
model = [model stringByReplacingOccurrencesOfString:@"," withString:@"."];
|
// NSLog(@"activate");
|
||||||
if ([identifier isEqualToString:@"iPhone13,1"]) { // iPhone 12 mini
|
center();
|
||||||
return YES;
|
renderingView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
} else if ([model floatValue] >= 14.0) { // iPhone 13 series and newer
|
widthConstraint.active = YES;
|
||||||
return YES;
|
heightConstraint.active = YES;
|
||||||
} else return NO;
|
}
|
||||||
} else return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
void activate() {
|
void deactivate() {
|
||||||
if (aspectRatio < THRESHOLD || zoomedToFill) return;
|
// NSLog(@"deactivate");
|
||||||
// NSLog(@"activate");
|
center();
|
||||||
center();
|
renderingView.translatesAutoresizingMaskIntoConstraints = YES;
|
||||||
renderingView.translatesAutoresizingMaskIntoConstraints = NO;
|
widthConstraint.active = NO;
|
||||||
widthConstraint.active = YES;
|
heightConstraint.active = NO;
|
||||||
heightConstraint.active = YES;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void deactivate() {
|
void center() {
|
||||||
// NSLog(@"deactivate");
|
centerXConstraint.active = YES;
|
||||||
center();
|
centerYConstraint.active = YES;
|
||||||
renderingView.translatesAutoresizingMaskIntoConstraints = YES;
|
}
|
||||||
widthConstraint.active = NO;
|
|
||||||
heightConstraint.active = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
void center() {
|
|
||||||
centerXConstraint.active = YES;
|
|
||||||
centerYConstraint.active = YES;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -1063,7 +1060,7 @@ NSLayoutConstraint *widthConstraint, *heightConstraint, *centerXConstraint, *cen
|
|||||||
if (replacePreviousAndNextButton()) {
|
if (replacePreviousAndNextButton()) {
|
||||||
%init(gReplacePreviousAndNextButton);
|
%init(gReplacePreviousAndNextButton);
|
||||||
}
|
}
|
||||||
if (dontEatMyContent() && isDeviceSupported()) {
|
if (dontEatMyContent() && isDeviceSupported()) {
|
||||||
%init(gDontEatMyContent);
|
%init(gDontEatMyContent);
|
||||||
}
|
}
|
||||||
if (@available(iOS 16, *)) {
|
if (@available(iOS 16, *)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user