From 1b3a422a6161323916eb4322f112b7a3a55bb66d Mon Sep 17 00:00:00 2001 From: arichornlover <78001398+arichornlover@users.noreply.github.com> Date: Sun, 14 Jul 2024 08:50:48 -0500 Subject: [PATCH] Update uYouPlusPatches.xm --- Sources/uYouPlusPatches.xm | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Sources/uYouPlusPatches.xm b/Sources/uYouPlusPatches.xm index 24bae43..7540250 100644 --- a/Sources/uYouPlusPatches.xm +++ b/Sources/uYouPlusPatches.xm @@ -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"]; }