Update uYouPlusPatches.xm

This commit is contained in:
arichornlover 2024-07-14 08:50:48 -05:00 committed by GitHub
parent 829b0c7d6b
commit 1b3a422a61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,7 +110,7 @@ static inline NSString* extractIdWithFormat(GPBUnknownFieldSet *fields, NSIntege
NSString *id = [[NSString alloc] initWithData:[idField.lengthDelimitedList firstObject] encoding:NSUTF8StringEncoding];
return [NSString stringWithFormat:format, id];
}
static BOOL showNativeShareSheet(NSString *serializedShareEntity) {
static BOOL showNativeShareSheet(NSString *serializedShareEntity, UIView *sourceView) {
GPBMessage *shareEntity = [%c(GPBMessage) deserializeFromString:serializedShareEntity];
GPBUnknownFieldSet *fields = shareEntity.unknownFields;
NSString *shareUrl;
@ -148,14 +148,11 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity) {
if (activityViewController.popoverPresentationController) {
activityViewController.popoverPresentationController.sourceView = topViewController.view;
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
activityViewController.popoverPresentationController.sourceRect = CGRectMake(screenWidth / 2.0, screenHeight, 0, 0);
activityViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
activityViewController.popoverPresentationController.sourceRect = [sourceView convertRect:sourceView.bounds toView:topViewController.view];
}
[topViewController presentViewController:activityViewController animated:YES completion:nil];
return YES;
}
@ -169,7 +166,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity) {
YTIShareEntityEndpoint *shareEntityEndpoint = [self.command getExtension:shareEntityEndpointDescriptor];
if (!shareEntityEndpoint.hasSerializedShareEntity)
return %orig;
if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity))
if (!showNativeShareSheet(shareEntityEndpoint.serializedShareEntity, self.fromView))
return %orig;
}
%end
@ -177,7 +174,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity) {
/* ------------------- iPhone Layout ------------------- */
%hook ELMPBShowActionSheetCommand
- (void)executeWithCommandContext:(id)_context handler:(id)_handler {
- (void)executeWithCommandContext:(ELMCommandContext*)context handler:(id)_handler {
if (!self.hasOnAppear)
return %orig;
GPBExtensionDescriptor *innertubeCommandDescriptor = [%c(YTIInnertubeCommandExtensionRoot) innertubeCommand];
@ -190,7 +187,7 @@ static BOOL showNativeShareSheet(NSString *serializedShareEntity) {
YTIUpdateShareSheetCommand *updateShareSheetCommand = [innertubeCommand getExtension:updateShareSheetCommandDescriptor];
if (!updateShareSheetCommand.hasSerializedShareEntity)
return %orig;
if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity))
if (!showNativeShareSheet(updateShareSheetCommand.serializedShareEntity, context.context.fromView))
return %orig;
}
%end
@ -351,6 +348,4 @@ static void refreshUYouAppearance() {
// Disable uYou's playback speed controls (prevent crash on video playback https://github.com/therealFoxster/uYouPlus/issues/2#issuecomment-1894912963)
// [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"showPlaybackRate"];
// Disable uYou's adblock
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"removeYouTubeAds"];
}