From 033265d58e0a0f9408eff28498a7dd805f6ca330 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Sat, 20 Jul 2024 19:40:49 +0800 Subject: [PATCH] disallow orientation change in mainframe host view (need iOS16+) --- Limelight/ViewControllers/MainFrameViewController.m | 7 +++++++ Limelight/ViewControllers/SWRevealViewController.h | 1 + Limelight/ViewControllers/SWRevealViewController.m | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 1808dec6..315a751b 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -126,12 +126,16 @@ static NSMutableSet* hostList; - (void)disableUpButton { #if !TARGET_OS_TV [self->_upButton setTitle:nil]; + self.revealViewController.mainFrameIsInHostView = true; // to allow orientation change only in app view, tell top view controller the mainframe is not in host view + [self setNeedsUpdateAllowedOrientation]; #endif } - (void)enableUpButton { #if !TARGET_OS_TV [self->_upButton setTitle: [LocalizationHelper localizedStringForKey: @"Select New Host"]]; + self.revealViewController.mainFrameIsInHostView = false; // to allow orientation change only in app view, tell top view controller the mainframe is not in host view + [self setNeedsUpdateAllowedOrientation]; #endif } @@ -344,6 +348,8 @@ static NSMutableSet* hostList; Log(LOG_D, @"Clicked host: %@", host.name); _selectedHost = host; [self updateTitle]; + //_appManager = [[AppAssetManager alloc] initWithCallback:self]; + [self.collectionView setCollectionViewLayout:self.collectionViewLayout]; [self.collectionView reloadData]; //for new scroll host view reloading mechanism [self.view addSubview:self.collectionView]; //for new scroll host view reloading mechanism [self attachWaterMark]; @@ -1043,6 +1049,7 @@ static NSMutableSet* hostList; #if !TARGET_OS_TV self.settingsExpandedInStreamView = false; // init this flag self.revealViewController.isStreaming = false; //init this flag for rvlVC + self.revealViewController.mainFrameIsInHostView = true; // Set the side bar button action. When it's tapped, it'll show the sidebar. [_settingsButton setTarget:self.revealViewController]; diff --git a/Limelight/ViewControllers/SWRevealViewController.h b/Limelight/ViewControllers/SWRevealViewController.h index 998c21db..905441d6 100755 --- a/Limelight/ViewControllers/SWRevealViewController.h +++ b/Limelight/ViewControllers/SWRevealViewController.h @@ -312,6 +312,7 @@ typedef NS_ENUM(NSInteger, SWRevealToggleAnimationType) @property (nonatomic,weak) id delegate; @property (nonatomic,assign) bool isStreaming; +@property (nonatomic,assign) bool mainFrameIsInHostView; @end diff --git a/Limelight/ViewControllers/SWRevealViewController.m b/Limelight/ViewControllers/SWRevealViewController.m index 0a65fb17..0b35f977 100755 --- a/Limelight/ViewControllers/SWRevealViewController.m +++ b/Limelight/ViewControllers/SWRevealViewController.m @@ -739,7 +739,7 @@ const int FrontViewPositionNone = 0xff; Settings *currentSettings = [dataMan retrieveSettings]; //Handle allow portrait on & off if(currentSettings.allowPortrait){ - if (self.isStreaming) return [self getCurrentOrientation]; + if (self.isStreaming || self.mainFrameIsInHostView) return [self getCurrentOrientation]; //orientation change is not allowed in streaming or mainframe host view else return UIInterfaceOrientationMaskAll; } else return UIInterfaceOrientationMaskLandscape;