From 2a0c0807a62ed3f681970f0b3314f00b6a3df1f1 Mon Sep 17 00:00:00 2001 From: Brianna Birman Date: Thu, 21 Nov 2024 11:01:47 -0800 Subject: [PATCH] Ensure window container level is set on underlying window --- .../SalesforceSDKCore/Classes/Views/SFSDKWindowContainer.m | 5 +++++ .../Classes/Views/SFSDKWindowManager+Internal.h | 4 ++++ .../SalesforceSDKCore/Classes/Views/SFSDKWindowManager.m | 4 +--- .../SalesforceSDKCoreTests/SFSDKWindowManagerTests.m | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowContainer.m b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowContainer.m index bf739c76e8..d5c9b9e8f6 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowContainer.m +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowContainer.m @@ -99,6 +99,11 @@ - (BOOL)isEnabled { #endif } +- (void)setWindowLevel:(UIWindowLevel)windowLevel { + _windowLevel = windowLevel; + _window.windowLevel = _windowLevel; +} + - (void)presentWindowAnimated:(BOOL)animated withCompletion:(void (^ _Nullable)(void))completion { if ([self.windowDelegate respondsToSelector:@selector(presentWindow:animated:withCompletion:)]) { [self.windowDelegate presentWindow:self animated:animated withCompletion:completion]; diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager+Internal.h b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager+Internal.h index 6259b763c9..fb922c29f5 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager+Internal.h +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager+Internal.h @@ -27,6 +27,10 @@ #import "SFSDKWindowManager.h" +static const CGFloat SFWindowLevelScreenLockOffset = 100; +static const CGFloat SFWindowLevelAuthOffset = 120; +static const CGFloat SFWindowLevelSnapshotOffset = 1000; + @interface SFSDKWindowManager () - (UIScene *)defaultScene; diff --git a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager.m b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager.m index b938e63f92..603d3a57e7 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager.m +++ b/libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Views/SFSDKWindowManager.m @@ -28,6 +28,7 @@ WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #import "SFSDKWindowManager.h" +#import "SFSDKWindowManager+Internal.h" #import "SFSDKWindowContainer.h" #import "SFApplicationHelper.h" #import "SFSDKMacDetectUtil.h" @@ -70,9 +71,6 @@ - (void)disableWindow; @implementation SFSDKWindowManager -static const CGFloat SFWindowLevelScreenLockOffset = 100; -static const CGFloat SFWindowLevelAuthOffset = 120; -static const CGFloat SFWindowLevelSnapshotOffset = 1000; static NSString *const kSFMainWindowKey = @"main"; static NSString *const kSFLoginWindowKey = @"auth"; static NSString *const kSFSnaphotWindowKey = @"snapshot"; diff --git a/libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKWindowManagerTests.m b/libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKWindowManagerTests.m index 7158694c71..d49356f820 100644 --- a/libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKWindowManagerTests.m +++ b/libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKWindowManagerTests.m @@ -25,6 +25,7 @@ #import #import "SFSDKWindowManager.h" +#import "SFSDKWindowManager+Internal.h" #import "SFApplicationHelper.h" @interface SFSDKWindowManagerTests: XCTestCase{ @@ -110,6 +111,7 @@ - (void)testLoginWindow { SFSDKWindowContainer *authWindowNilScene = [[SFSDKWindowManager sharedManager] authWindow:nil]; XCTAssert(authWindowNilScene.window != nil); XCTAssert(authWindowNilScene.windowType == SFSDKWindowTypeAuth); + XCTAssertEqual(authWindowNilScene.window.windowLevel, SFWindowLevelAuthOffset); UIScene *scene = [SFApplicationHelper sharedApplication].connectedScenes.allObjects.firstObject; SFSDKWindowContainer *authWindowScene = [[SFSDKWindowManager sharedManager] authWindow:scene]; @@ -122,6 +124,7 @@ - (void)testScreenLockWindow { SFSDKWindowContainer *screenLockWindow = [SFSDKWindowManager sharedManager].screenLockWindow; XCTAssert(screenLockWindow.window!=nil); XCTAssert(screenLockWindow.windowType == SFSDKWindowTypeScreenLock); + XCTAssertEqual(screenLockWindow.window.windowLevel, SFWindowLevelScreenLockOffset); } - (void)testSnapshotWindow { @@ -134,6 +137,7 @@ - (void)testSnapshotWindow { XCTAssert(snapshowWindowScene.window != nil); XCTAssert(snapshowWindowScene.windowType == SFSDKWindowTypeSnapshot); XCTAssertEqualObjects(snapshotWindowNilScene, snapshowWindowScene); + XCTAssertEqual(snapshowWindowScene.window.windowLevel, SFWindowLevelSnapshotOffset); } - (void)testEnable {