Test: disable settings view in portrait mode for iphone (prevents buggy settings view), flag not ready for release

This commit is contained in:
True Zhuanjia
2024-07-13 17:51:19 +08:00
parent 88d5038f94
commit 0a449c25eb
4 changed files with 32 additions and 6 deletions
@@ -24,6 +24,7 @@
-(void)simulateSettingsButtonPress;
-(void)reloadStreamConfig;
-(bool)isIPhonePortrait;
#endif
@end
@@ -880,6 +880,7 @@ static NSMutableSet* hostList;
}
#if !TARGET_OS_TV
// this method is deprecated
- (void)simulateSettingsButtonPressOpen { //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated.
if (currentPosition == FrontViewPositionLeft && _settingsButton.target && [_settingsButton.target respondsToSelector:_settingsButton.action]) {
[_settingsButton.target performSelector:_settingsButton.action withObject:_settingsButton];
@@ -887,6 +888,7 @@ static NSMutableSet* hostList;
}
- (void)simulateSettingsButtonPress { //simulate pressing the setting button, called from setting view controller.
//if([self isIPhonePortrait]) return; // disable settings view expanding in iphone portrait mode since it's buggy.
if (_settingsButton.target && [_settingsButton.target respondsToSelector:_settingsButton.action]) {
[_settingsButton.target performSelector:_settingsButton.action withObject:_settingsButton];
}
@@ -901,6 +903,7 @@ static NSMutableSet* hostList;
dispatch_after(delayTime, dispatch_get_main_queue(), ^{// Code to execute after the delay
[self swapResolutionWidthHeightAccordingly];
[self.settingsButton setEnabled:![self isIPhonePortrait]]; //make sure settings button is disabled in iphone portrait mode.
if([self->_upButton title] == nil) [self reloadScrollHostView]; // title of the _upButton is good flag for judging if we're on the Host selection view
//self->recordedScreenWidth = screenWidthInPoints; // kind of obselete, but i keep this in the code.
});
@@ -931,6 +934,7 @@ static NSMutableSet* hostList;
[settingsViewController.framePacingSelector setEnabled:!self.settingsExpandedInStreamView];
[settingsViewController.btMouseSelector setEnabled:!self.settingsExpandedInStreamView];
[settingsViewController.goBackToStreamViewButton setEnabled:self.settingsExpandedInStreamView];
[settingsViewController.allowPortraitSelector setEnabled:!self.settingsExpandedInStreamView];
if (position == FrontViewPositionLeft) {
[settingsViewController saveSettings];
@@ -1015,6 +1019,14 @@ static NSMutableSet* hostList;
]];
}
- (bool)isIPhonePortrait{
bool isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
bool isPortrait = screenHeightInPoints > screenWidthInPoints;
// return isIPhone && isPortrait;
return isPortrait;
}
- (void)viewDidLoad
{
@@ -1035,7 +1047,11 @@ static NSMutableSet* hostList;
[self disableUpButton];
// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
bool isPortrait = false;
if(![self isIPhonePortrait]) [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer]; // to prevent buggy settings view in iphone portrait mode;
// Get callbacks associated with the viewController
[self.revealViewController setDelegate:self];
@@ -1253,7 +1269,7 @@ static NSMutableSet* hostList;
[[self revealViewController] setPrimaryViewController:self];
self.revealViewController.isStreaming = false; // tell the revealViewController streaming is finished
[self.settingsButton setEnabled:![self isIPhonePortrait]]; //make sure settings button is disabled in iphone portrait mode.
//recordedScreenWidth = CGRectGetWidth([[UIScreen mainScreen] bounds]); // Get the screen's bounds (in points), update recorded screen width
#endif
@@ -1520,7 +1536,7 @@ static NSMutableSet* hostList;
[cell.subviews.firstObject removeFromSuperview]; // Remove a view that was previously added
[cell addSubview:appView];
[self.settingsButton setEnabled:![self isIPhonePortrait]]; // update settings button after host is clicked & appview loaded
// Shadow opacity is controlled inside UIAppView based on whether the app
// is hidden or not during the update cycle.
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:cell.bounds];
@@ -553,6 +553,7 @@ static CGFloat scaledValue( CGFloat v1, CGFloat min2, CGFloat max2, CGFloat min1
const int kDirectionPanThreshold = 5;
UITouch *touch = [touches anyObject];
CGPoint nowPoint = [touch locationInView:self.view];
if (fabs(nowPoint.x - _beginPoint.x) > kDirectionPanThreshold) _dragging = YES;
@@ -729,7 +730,7 @@ const int FrontViewPositionNone = 0xff;
}
// tested on iOS17. this method does not call back on iOS14, so runtime orientation limitation not working for iOS14. Probably depends on iOS16 or higher.
// tested on iOS17. this method does not call back on iOS14, runtime orientation limitation not working for iOS14. Probably depends on iOS16 or higher.
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
// Return the supported interface orientations based on the current state
NSLog(@"supportedInterfaceOrientations called back 666");
@@ -919,6 +920,7 @@ const int FrontViewPositionNone = 0xff;
[_contentView.frontView addGestureRecognizer:_panGestureRecognizer];
}
return _panGestureRecognizer;
return nil;
}
@@ -1265,7 +1267,6 @@ const int FrontViewPositionNone = 0xff;
CGFloat baseLocation = [_contentView frontLocationForPosition:_panInitialFrontPosition];
CGFloat xLocation = baseLocation + translation; // buggy on portrait mode??/
if ( xLocation < 0 )
{
if ( _rightViewController == nil ) xLocation = 0;
@@ -89,7 +89,7 @@
- (void)configExitGesture{
[self.view removeGestureRecognizer:_exitSwipeRecognizer];
_exitSwipeRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(expandSettingsView)];
_exitSwipeRecognizer = [[CustomEdgeSwipeGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
_exitSwipeRecognizer.edges = _settings.swipeExitScreenEdge.intValue;
_exitSwipeRecognizer.normalizedThresholdDistance = _settings.swipeToExitDistance.floatValue;
_exitSwipeRecognizer.delaysTouchesBegan = NO;
@@ -484,6 +484,14 @@
[self.mainFrameViewcontroller simulateSettingsButtonPress];
}
- (void)edgeSwiped{
if([self->_mainFrameViewcontroller isIPhonePortrait]){ // disable backmenu for iphone portrait mode;
[self returnToMainFrame]; //directly quit the session
return;
}
[self expandSettingsView]; // expand settings view in other cases;
}
- (void)sessionDisconnectedBySettingView {
Log(LOG_I, @"Settings view disconnect the session in stream view");
self.mainFrameViewcontroller.settingsExpandedInStreamView = false; // reset this flag to false