@@ -4435,19 +4435,6 @@ static NSHashTable *processedParentViews = nil;
44354435}
44364436%end
44374437
4438- static BOOL DYYYIsLandscapeVideoBounds (CGSize size) {
4439- if (size.width <= 0 .0f || size.height <= 0 .0f ) {
4440- return NO ;
4441- }
4442- if (size.width <= size.height ) {
4443- return NO ;
4444- }
4445- const CGFloat referenceAspect = 414 .0f / 232 .875f ;
4446- const CGFloat tolerance = 0 .5f ;
4447- CGFloat aspectRatio = size.width / size.height ;
4448- return aspectRatio >= (referenceAspect - tolerance);
4449- }
4450-
44514438%hook MTKView
44524439
44534440- (void )layoutSubviews {
@@ -4465,73 +4452,6 @@ static BOOL DYYYIsLandscapeVideoBounds(CGSize size) {
44654452 }
44664453}
44674454
4468- - (void )setFrame:(CGRect)frame {
4469- UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView: self ];
4470- Class playVCClass = NSClassFromString (@" AWEPlayVideoViewController" );
4471- BOOL isPlayVC = (vc && playVCClass && [vc isKindOfClass: playVCClass]);
4472-
4473- objc_setAssociatedObject (self, _cmd, nil , OBJC_ASSOCIATION_RETAIN_NONATOMIC );
4474- %orig (frame);
4475-
4476- if (!isPlayVC) {
4477- return ;
4478- }
4479-
4480- NSNumber *storedValue = objc_getAssociatedObject (self, _cmd);
4481- if (!self.superview ) {
4482- if (storedValue) {
4483- objc_setAssociatedObject (self, _cmd, nil , OBJC_ASSOCIATION_RETAIN_NONATOMIC );
4484- }
4485- return ;
4486- }
4487-
4488- if (!DYYYGetBool (@" DYYYEnableFullScreen" )) {
4489- return ;
4490- }
4491- BOOL shouldAdjust = DYYYIsLandscapeVideoBounds (self.bounds .size );
4492- if (!shouldAdjust) {
4493- return ;
4494- }
4495-
4496- CGFloat viewWidth = CGRectGetWidth (self.bounds );
4497- CGRect screenBounds = [UIScreen mainScreen ].bounds ;
4498- CGFloat screenWidth = CGRectGetWidth (screenBounds);
4499- BOOL isScreenLandscape = screenWidth > CGRectGetHeight (screenBounds);
4500-
4501- if (viewWidth < screenWidth) {
4502- return ;
4503- }
4504-
4505- CGFloat tabHeight = gCurrentTabBarHeight ;
4506- if (tabHeight <= 0 .0f ) {
4507- return ;
4508- }
4509-
4510- CGFloat desiredOffset = isScreenLandscape ? 0 .0f : (tabHeight * 0 .6f );
4511- CGFloat appliedOffset = storedValue ? storedValue.doubleValue : 0 .0f ;
4512- CGFloat delta = desiredOffset - appliedOffset;
4513- if (fabs (delta) < 0 .1f ) {
4514- if (desiredOffset <= 0 .0f && storedValue) {
4515- objc_setAssociatedObject (self, _cmd, nil , OBJC_ASSOCIATION_RETAIN_NONATOMIC );
4516- }
4517- return ;
4518- }
4519-
4520- CGPoint position = self.layer .position ;
4521- position.y -= delta;
4522-
4523- [CATransaction begin ];
4524- [CATransaction setDisableActions: YES ];
4525- self.layer .position = position;
4526- [CATransaction commit ];
4527-
4528- if (desiredOffset > 0 .0f ) {
4529- objc_setAssociatedObject (self, _cmd, @(desiredOffset), OBJC_ASSOCIATION_RETAIN_NONATOMIC );
4530- } else {
4531- objc_setAssociatedObject (self, _cmd, nil , OBJC_ASSOCIATION_RETAIN_NONATOMIC );
4532- }
4533- }
4534-
45354455%end
45364456
45374457// 拦截开屏广告
@@ -6979,6 +6899,80 @@ static Class TagViewClass = nil;
69796899}
69806900%end
69816901
6902+ %hook TTPlayerView
6903+
6904+ - (void )layoutSubviews {
6905+ %orig ;
6906+ UIView *parent = self.superview ;
6907+ if (parent) {
6908+ parent.backgroundColor = self.backgroundColor ;
6909+ }
6910+ }
6911+
6912+ %end
6913+
6914+ %hook TTMetalView
6915+ - (void )setCenter:(CGPoint)center {
6916+ BOOL shouldAdjust = NO ;
6917+ UIView *view = (UIView *)self;
6918+ if (DYYYGetBool (@" DYYYEnableFullScreen" )) {
6919+ CGFloat viewWidth = CGRectGetWidth (view.bounds );
6920+ CGFloat screenWidth = [UIScreen mainScreen ].bounds .size .width ;
6921+ if (viewWidth + 0 .5f >= screenWidth) {
6922+ UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView: view];
6923+ Class playClass = %c (AWEPlayVideoViewController);
6924+ if (playClass && [vc isKindOfClass: playClass]) {
6925+ AWEPlayVideoViewController *playVC = (AWEPlayVideoViewController *)vc;
6926+ AWEAwemeModel *model = playVC.model ;
6927+ if ([model respondsToSelector: @selector (isShowLandscapeEntryView )] && model.isShowLandscapeEntryView ) {
6928+ shouldAdjust = YES ;
6929+ }
6930+ }
6931+ }
6932+ }
6933+
6934+ if (shouldAdjust) {
6935+ CGFloat offset = gCurrentTabBarHeight > 0 ? gCurrentTabBarHeight : originalTabBarHeight;
6936+ if (offset > 0 ) {
6937+ center.y -= offset * 0.5 ;
6938+ }
6939+ }
6940+
6941+ %orig (center);
6942+ }
6943+ %end
6944+
6945+ %hook TTMetalViewNew
6946+ - (void )setCenter:(CGPoint)center {
6947+ BOOL shouldAdjust = NO ;
6948+ UIView *view = (UIView *)self;
6949+ if (DYYYGetBool (@" DYYYEnableFullScreen" )) {
6950+ CGFloat viewWidth = CGRectGetWidth (view.bounds );
6951+ CGFloat screenWidth = [UIScreen mainScreen ].bounds .size .width ;
6952+ if (viewWidth + 0 .5f >= screenWidth) {
6953+ UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView: view];
6954+ Class playClass = %c (AWEPlayVideoViewController);
6955+ if (playClass && [vc isKindOfClass: playClass]) {
6956+ AWEPlayVideoViewController *playVC = (AWEPlayVideoViewController *)vc;
6957+ AWEAwemeModel *model = playVC.model ;
6958+ if ([model respondsToSelector: @selector (isShowLandscapeEntryView )] && model.isShowLandscapeEntryView ) {
6959+ shouldAdjust = YES ;
6960+ }
6961+ }
6962+ }
6963+ }
6964+
6965+ if (shouldAdjust) {
6966+ CGFloat offset = gCurrentTabBarHeight > 0 ? gCurrentTabBarHeight : originalTabBarHeight;
6967+ if (offset > 0 ) {
6968+ center.y -= offset * 0.5 ;
6969+ }
6970+ }
6971+
6972+ %orig (center);
6973+ }
6974+ %end
6975+
69826976// 隐藏图片滑条
69836977%hook AWEStoryProgressContainerView
69846978- (void )setCenter:(CGPoint)center {
@@ -7001,47 +6995,8 @@ static Class TagViewClass = nil;
70016995}
70026996%end
70036997
7004- %hook TTPlayerView
7005-
7006- - (void )setFrame:(CGRect)frame {
7007-
7008- CGFloat viewWidth = CGRectGetWidth (self.bounds );
7009- CGRect screenBounds = [UIScreen mainScreen ].bounds ;
7010- CGFloat screenWidth = CGRectGetWidth (screenBounds);
7011- BOOL isScreenLandscape = screenWidth > CGRectGetHeight (screenBounds);
7012-
7013- if (viewWidth < screenWidth) {
7014- %orig (frame);
7015- } else if (DYYYGetBool (@" DYYYEnableFullScreen" ) && gCurrentTabBarHeight > 0 .0f ) {
7016- if (!isScreenLandscape) {
7017- frame.size .height += 25 .0f ;
7018- }
7019- }
7020- %orig (frame);
7021- }
7022-
7023- %end
7024-
70256998%hook AWELandscapeFeedEntryView
70266999
7027- - (void )setCenter:(CGPoint)center {
7028- if (DYYYGetBool (@" DYYYEnableFullScreen" )) {
7029- UIViewController *vc = [DYYYUtils firstAvailableViewControllerFromView: self ];
7030- Class pureModeVC = NSClassFromString (@" AWEFeedPlayControlImpl.PureModePageCellViewController" );
7031- BOOL inPureMode = (vc && pureModeVC && [vc isKindOfClass: pureModeVC]);
7032- if (inPureMode) {
7033- center.y += gCurrentTabBarHeight * 0.5 ;
7034- } else {
7035- CGFloat screenHeight = [UIScreen mainScreen ].bounds .size .height ;
7036- if (center.y > screenHeight * 0.6 ) {
7037- center.y += gCurrentTabBarHeight * 0.5 ;
7038- }
7039- }
7040- }
7041-
7042- %orig (center);
7043- }
7044-
70457000- (void )setAlpha:(CGFloat)alpha {
70467001 CGFloat finalAlpha = alpha;
70477002 if (alpha > 0 && self.tag != DYYY_IGNORE_GLOBAL_ALPHA_TAG && gGlobalTransparency != kInvalidAlpha ) {
0 commit comments