From 56fc18c378620aa13c9ae43ada39e797e6de8d05 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Tue, 9 Jul 2024 22:42:01 +0800 Subject: [PATCH] add exit button by storyboard, config widget disabling in streamview settingview --- Limelight/Base.lproj/iPad.storyboard | 106 ++++++++++-------- Limelight/Base.lproj/iPhone.storyboard | 105 +++++++++-------- .../ViewControllers/MainFrameViewController.h | 1 + .../ViewControllers/MainFrameViewController.m | 15 ++- .../ViewControllers/SettingsViewController.h | 1 + .../ViewControllers/SettingsViewController.m | 38 ++++++- .../StreamFrameViewController.h | 2 +- .../StreamFrameViewController.m | 24 ++-- Limelight/mul.lproj/iPad.xcstrings | 60 ++++++++++ Limelight/mul.lproj/iPhone.xcstrings | 60 ++++++++++ 10 files changed, 308 insertions(+), 104 deletions(-) diff --git a/Limelight/Base.lproj/iPad.storyboard b/Limelight/Base.lproj/iPad.storyboard index d778dfb6..2467b20f 100644 --- a/Limelight/Base.lproj/iPad.storyboard +++ b/Limelight/Base.lproj/iPad.storyboard @@ -63,7 +63,7 @@ - + @@ -86,12 +86,12 @@ - + - + @@ -110,7 +110,7 @@ - + - + @@ -142,7 +142,7 @@ - + - + - + - + @@ -200,7 +200,7 @@ - + @@ -221,14 +221,14 @@ - + @@ -238,14 +238,14 @@ - + @@ -255,14 +255,14 @@ - + @@ -272,14 +272,14 @@ - + @@ -289,12 +289,12 @@ - + - + - + @@ -343,14 +343,14 @@ ICAgICAgICAgICAgICA - + @@ -362,14 +362,14 @@ ICAgICAgICAgICAgICA - + @@ -379,14 +379,14 @@ ICAgICAgICAgICAgICA - + @@ -396,14 +396,14 @@ ICAgICAgICAgICAgICA - + @@ -413,14 +413,14 @@ ICAgICAgICAgICAgICA - + @@ -430,7 +430,7 @@ ICAgICAgICAgICAgICA - + @@ -439,6 +439,20 @@ ICAgICAgICAgICAgICA + @@ -480,7 +494,7 @@ ICAgICAgICAgICAgICA - + diff --git a/Limelight/Base.lproj/iPhone.storyboard b/Limelight/Base.lproj/iPhone.storyboard index 5e8b492d..ba657a55 100644 --- a/Limelight/Base.lproj/iPhone.storyboard +++ b/Limelight/Base.lproj/iPhone.storyboard @@ -87,14 +87,14 @@ - + @@ -109,19 +109,19 @@ - + - + @@ -132,26 +132,26 @@ - + - + @@ -163,7 +163,7 @@ - + - + - + - + - + @@ -239,14 +239,14 @@ ICAgICAgICAgICAgIA - + @@ -256,21 +256,21 @@ ICAgICAgICAgICAgIA - + @@ -280,14 +280,14 @@ ICAgICAgICAgICAgIA - + @@ -297,14 +297,14 @@ ICAgICAgICAgICAgIA - + @@ -314,14 +314,14 @@ ICAgICAgICAgICAgIA - + @@ -331,14 +331,14 @@ ICAgICAgICAgICAgIA - + @@ -350,14 +350,14 @@ ICAgICAgICAgICAgIA - + @@ -367,14 +367,14 @@ ICAgICAgICAgICAgIA - + @@ -384,14 +384,14 @@ ICAgICAgICAgICAgIA - + @@ -401,14 +401,14 @@ ICAgICAgICAgICAgIA - + @@ -418,7 +418,7 @@ ICAgICAgICAgICAgIA - + @@ -437,19 +437,19 @@ ICAgICAgICAgICAgIA - + - + @@ -458,6 +458,19 @@ ICAgICAgICAgICAgIA + @@ -499,7 +512,7 @@ ICAgICAgICAgICAgIA - + diff --git a/Limelight/ViewControllers/MainFrameViewController.h b/Limelight/ViewControllers/MainFrameViewController.h index 9064c7ad..e217452c 100644 --- a/Limelight/ViewControllers/MainFrameViewController.h +++ b/Limelight/ViewControllers/MainFrameViewController.h @@ -20,6 +20,7 @@ @property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsButton; #if !TARGET_OS_TV @property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton; +@property (nonatomic, assign) bool settingsExpandedInStreamView; -(void)simulateSettingsButtonPress; -(void)reloadStreamConfig; diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index cec25406..74680f8f 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -906,6 +906,17 @@ static NSMutableSet* hostList; // If we moved back to the center position, we should save the settings SettingsViewController* settingsViewController = (SettingsViewController*)[revealController rearViewController]; settingsViewController.mainFrameViewController = self; + // enable / disable widgets acoordingly: in streamview, disable, outside of streamview, enable. + [settingsViewController.resolutionSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.framerateSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController widget:settingsViewController.bitrateSlider setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.optimizeSettingsSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.audioOnPCSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.codecSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.framePacingSelector setEnabled:!self.settingsExpandedInStreamView]; + [settingsViewController.btMouseSelector setEnabled:!self.settingsExpandedInStreamView]; + + if (position == FrontViewPositionLeft) { [settingsViewController saveSettings]; _settingsButton.enabled = YES; // make sure these 2 buttons are enabled after closing setting view. @@ -925,7 +936,7 @@ static NSMutableSet* hostList; - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.destinationViewController isKindOfClass:[StreamFrameViewController class]]) { StreamFrameViewController* streamFrame = segue.destinationViewController; - streamFrame.mainframeViewcontroller = self; + streamFrame.mainFrameViewcontroller = self; streamFrame.streamConfig = _streamConfig; } } @@ -995,7 +1006,7 @@ static NSMutableSet* hostList; [self attachWaterMark]; #if !TARGET_OS_TV - + _settingsExpandedInStreamView = false; // init this flag // Set the side bar button action. When it's tapped, it'll show the sidebar. [_settingsButton setTarget:self.revealViewController]; diff --git a/Limelight/ViewControllers/SettingsViewController.h b/Limelight/ViewControllers/SettingsViewController.h index 67366cc7..cbfe44f5 100644 --- a/Limelight/ViewControllers/SettingsViewController.h +++ b/Limelight/ViewControllers/SettingsViewController.h @@ -59,5 +59,6 @@ - (void) saveSettings; + (bool) isLandscapeNow; +- (void) widget:(UISlider*)widget setEnabled:(bool)enabled; @end diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index 3ebac2a8..cb984777 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -201,10 +201,46 @@ BOOL isCustomResolution(CGSize res) { - (void)viewDidDisappear:(BOOL)animated{ [super viewDidDisappear:animated]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"SettingsViewClosed" object:self]; // notify other view that settings view just closed + [[NSNotificationCenter defaultCenter] postNotificationName:@"SettingsViewClosedNotification" object:self]; // notify other view that settings view just closed } +- (void)pushDownExistingWidgets{ + // Calculate the height needed for the exit button + CGFloat exitButtonHeight = 50.0; // Adjust as needed + CGFloat topOffset = exitButtonHeight; // Space needed for the exit button + // Iterate through subviews of self.view and adjust their frames + for (UIView *subview in self.view.subviews) { + CGRect frame = subview.frame; + frame.origin.y += topOffset; + subview.frame = frame; + } +} + + +- (IBAction)exitButtonTapped:(id)sender { + [self->_mainFrameViewController simulateSettingsButtonPress]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"SessionDisconnectedBySettingsViewNotification" object:self]; +} + + +- (void)addExitButtonOnTop{ + UIButton *exitButton = [UIButton buttonWithType:UIButtonTypeSystem]; + [exitButton setTitle:@"Exit" forState:UIControlStateNormal]; + [exitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; // Set font color + exitButton.backgroundColor = [UIColor clearColor]; // Set background color + exitButton.titleLabel.font = [UIFont boldSystemFontOfSize:16.0]; // Set font size and style + exitButton.layer.cornerRadius = 8.0; // Optional: Round corners if desired + exitButton.clipsToBounds = YES; // Ensure rounded corners are applied properly + [exitButton addTarget:self action:@selector(exitButtonTapped) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:exitButton]; + exitButton.frame = CGRectMake(0, 20, 200, 50); // Adjust Y and height as needed +} + + - (void)viewDidLoad { + //[self pushDownExistingWidgets]; + //[self addExitButtonOnTop]; + justEnteredSettingsViewDoNotOpenOscLayoutTool = true; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) // handle orientation change since i made portrait mode available diff --git a/Limelight/ViewControllers/StreamFrameViewController.h b/Limelight/ViewControllers/StreamFrameViewController.h index 12215edf..1e881723 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.h +++ b/Limelight/ViewControllers/StreamFrameViewController.h @@ -23,7 +23,7 @@ #endif @property (nonatomic) StreamConfiguration* streamConfig; -@property (nonatomic, assign) MainFrameViewController *mainframeViewcontroller; +@property (nonatomic, assign) MainFrameViewController *mainFrameViewcontroller; -(void)updatePreferredDisplayMode:(BOOL)streamActive; diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 5bbbeaec..d494b273 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -97,18 +97,20 @@ [self.view addGestureRecognizer:_exitSwipeRecognizer]; } - +// key implementation of reconfiguring streamview after realtime setting menu is closed. - (void)reConfigStreamViewRealtime{ _settings = [[[DataManager alloc] init] getSettings]; //StreamFrameViewController retrieve the settings here. [self configOscLayoutTool]; [self configExitGesture]; [self->_streamView disableOnScreenControls]; //don't know why but this must be called outside the streamview class, just put it here. execute in streamview class cause hang - [self.mainframeViewcontroller reloadStreamConfig]; // reload streamconfig + [self.mainFrameViewcontroller reloadStreamConfig]; // reload streamconfig [_streamView setupStreamView:_controllerSupport interactionDelegate:self config:self.streamConfig]; //reinitiate setupStreamView process. [self->_streamView reloadOnScreenControlsRealtimeWith:(ControllerSupport*)_controllerSupport andConfig:(StreamConfiguration*)_streamConfig]; //reload OSC here. } + + - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; @@ -116,8 +118,13 @@ #if !TARGET_OS_TV [[self revealViewController] setPrimaryViewController:self]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(reConfigStreamViewRealtime) // //force expand settings view to update resolution table, and all setting includes current fullscreen resolution will be updated. - name:@"SettingsViewClosed" + selector:@selector(reConfigStreamViewRealtime) // reconfig streamview when settings view is closed in stream view + name:@"SettingsViewClosedNotification" + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(sessionDisconnectedBySettingView) //quit session when exit button is press in setting view during streaming + name:@"SessionDisconnectedBySettingsViewNotification" object:nil]; #endif } @@ -438,12 +445,13 @@ } - (void)expandSettingsView{ - [self.mainframeViewcontroller simulateSettingsButtonPress]; + self.mainFrameViewcontroller.settingsExpandedInStreamView = true; //notify mainFrameViewContorller that this is a setting expansion in stream view, some settings shall be disabled. + [self.mainFrameViewcontroller simulateSettingsButtonPress]; } -- (void)edgeSwiped { - Log(LOG_I, @"User swiped to end stream"); - +- (void)sessionDisconnectedBySettingView { + Log(LOG_I, @"Settings view disconnect the session in stream view"); + self.mainFrameViewcontroller.settingsExpandedInStreamView = false; // reset this flag to false [self returnToMainFrame]; } diff --git a/Limelight/mul.lproj/iPad.xcstrings b/Limelight/mul.lproj/iPad.xcstrings index e01f2d82..252c59ba 100644 --- a/Limelight/mul.lproj/iPad.xcstrings +++ b/Limelight/mul.lproj/iPad.xcstrings @@ -1927,6 +1927,66 @@ } } }, + "yq8-Hq-UWQ.configuration.title" : { + "comment" : "Class = \"UIButton\"; configuration.title = \"Exit\"; ObjectID = \"yq8-Hq-UWQ\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Exit" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + } + } + }, + "yq8-Hq-UWQ.normalTitle" : { + "comment" : "Class = \"UIButton\"; normalTitle = \"Button\"; ObjectID = \"yq8-Hq-UWQ\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Button" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "退出" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "退出" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "needs_review", + "value" : "退出" + } + } + } + }, "ZWC-Gw-pSq.text" : { "comment" : "Class = \"UILabel\"; text = \"Frame Pacing Preference \"; ObjectID = \"ZWC-Gw-pSq\";", "extractionState" : "extracted_with_value", diff --git a/Limelight/mul.lproj/iPhone.xcstrings b/Limelight/mul.lproj/iPhone.xcstrings index 6c720384..1679be67 100644 --- a/Limelight/mul.lproj/iPhone.xcstrings +++ b/Limelight/mul.lproj/iPhone.xcstrings @@ -661,6 +661,66 @@ } } }, + "CMK-cS-h9b.configuration.title" : { + "comment" : "Class = \"UIButton\"; configuration.title = \"Exit\"; ObjectID = \"CMK-cS-h9b\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Exit" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + } + } + }, + "CMK-cS-h9b.normalTitle" : { + "comment" : "Class = \"UIButton\"; normalTitle = \"Button\"; ObjectID = \"CMK-cS-h9b\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Button" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-Hant" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + }, + "zh-HK" : { + "stringUnit" : { + "state" : "translated", + "value" : "退出" + } + } + } + }, "d2a-Ka-H2c.segmentTitles[0]" : { "comment" : "Class = \"UISegmentedControl\"; d2a-Ka-H2c.segmentTitles[0] = \"Lowest Latency\"; ObjectID = \"d2a-Ka-H2c\";", "extractionState" : "extracted_with_value",