summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SmartDeviceLink/SDLLockScreenPresenter.m22
-rw-r--r--SmartDeviceLink/SDLViewControllerPresentable.h2
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m8
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m28
4 files changed, 31 insertions, 29 deletions
diff --git a/SmartDeviceLink/SDLLockScreenPresenter.m b/SmartDeviceLink/SDLLockScreenPresenter.m
index 1b40cbda4..fa82a9a94 100644
--- a/SmartDeviceLink/SDLLockScreenPresenter.m
+++ b/SmartDeviceLink/SDLLockScreenPresenter.m
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SDLLockScreenPresenter ()
@property (strong, nonatomic, nullable) UIWindow *lockWindow;
-@property (assign, nonatomic) BOOL presented;
+@property (assign, nonatomic) BOOL showLockScreen;
@end
@@ -31,13 +31,13 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init];
if (!self) { return nil; }
- _presented = NO;
+ _showLockScreen = NO;
return self;
}
- (void)stop {
- self.presented = NO;
+ self.showLockScreen = NO;
if (!self.lockWindow) {
return;
@@ -50,18 +50,18 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)updateLockScreenToShow:(BOOL)show {
- self.presented = show;
+ self.showLockScreen = show;
if (show) {
[self sdl_presentWithCompletionHandler:^{
- if (self.presented) { return; }
+ if (self.showLockScreen) { return; }
SDLLogV(@"The lockscreen has been presented but needs to be dismissed");
[self sdl_dismissWithCompletionHandler:nil];
}];
} else {
[self sdl_dismissWithCompletionHandler:^{
- if (!self.presented) { return; }
+ if (!self.showLockScreen) { return; }
SDLLogV(@"The lockscreen has been dismissed but needs to be presented");
[self sdl_presentLockscreenWithCompletionHandler:nil];
@@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLLogD(@"Presenting the lockscreen window");
[self.lockWindow makeKeyAndVisible];
- if ([self sdl_isPresented]) {
+ if ([self sdl_isPresentedOrPresenting]) {
// Call this right before attempting to present the view controller to make sure we are not already animating, otherwise the app may crash.
SDLLogV(@"The lockscreen is already being presented");
if (completionHandler == nil) { return; }
@@ -138,7 +138,7 @@ NS_ASSUME_NONNULL_BEGIN
return completionHandler();
}
- if ([self sdl_isBeingDismissed]) {
+ if ([self sdl_isDismissing]) {
// Make sure we are not already animating, otherwise the app may crash
SDLLogV(@"The lockscreen is already being dismissed");
if (completionHandler == nil) { return; }
@@ -164,11 +164,13 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Custom Presented / Dismissed Getters
-- (BOOL)sdl_isPresented {
+/// Returns whether or not the lockViewController is presented or currently animating
+- (BOOL)sdl_isPresentedOrPresenting {
return (self.lockViewController.isViewLoaded && (self.lockViewController.view.window || self.lockViewController.isBeingPresented) && self.lockWindow.isKeyWindow);
}
-- (BOOL)sdl_isBeingDismissed {
+/// Returns whether or not the lockViewController is currently animating
+- (BOOL)sdl_isDismissing {
return (self.lockViewController.isBeingDismissed || self.lockViewController.isMovingFromParentViewController);
}
diff --git a/SmartDeviceLink/SDLViewControllerPresentable.h b/SmartDeviceLink/SDLViewControllerPresentable.h
index a1b53425d..04cf09426 100644
--- a/SmartDeviceLink/SDLViewControllerPresentable.h
+++ b/SmartDeviceLink/SDLViewControllerPresentable.h
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong, nonatomic, nullable) UIViewController *lockViewController;
/// Whether or not the lockscreen should be presented
-@property (assign, nonatomic, readonly) BOOL presented;
+@property (assign, nonatomic, readonly) BOOL showLockScreen;
/// Dismisses and destroys the lock screen window
- (void)stop;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
index 0944eec97..4842d0520 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLFakeViewControllerPresenter.m
@@ -11,7 +11,7 @@
@interface SDLFakeViewControllerPresenter ()
-@property (assign, nonatomic) BOOL presented;
+@property (assign, nonatomic) BOOL showLockScreen;
@end
@@ -22,7 +22,7 @@
self = [super init];
if (!self) { return nil; }
- _presented = NO;
+ _showLockScreen = NO;
return self;
}
@@ -30,11 +30,11 @@
- (void)stop {
if (!self.lockViewController) { return; }
- _presented = NO;
+ _showLockScreen = NO;
}
- (void)updateLockScreenToShow:(BOOL)show {
- _presented = show;
+ _showLockScreen = show;
}
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
index c56f424c4..7fc07abd4 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLLockScreenManagerSpec.m
@@ -48,7 +48,7 @@ describe(@"a lock screen manager", ^{
it(@"should set properties correctly", ^{
// Note: We can't check the "lockScreenPresented" flag on the Lock Screen Manager because it's a computer property checking the window
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).to(beNil());
});
@@ -58,7 +58,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should not have a lock screen controller", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).to(beNil());
});
@@ -80,7 +80,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should not have presented the lock screen", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
});
});
});
@@ -92,7 +92,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set properties correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).to(beNil());
});
@@ -102,7 +102,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set up the view controller correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).toNot(beNil());
expect(testManager.lockScreenViewController).to(beAnInstanceOf([SDLLockScreenViewController class]));
});
@@ -126,7 +126,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should have presented the lock screen", ^{
- expect(fakePresenter.presented).toEventually(beTrue());
+ expect(fakePresenter.showLockScreen).toEventually(beTrue());
});
it(@"should not have a vehicle icon", ^{
@@ -205,7 +205,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should have dismissed the lock screen", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
});
});
@@ -227,7 +227,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should have dismissed the lock screen", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
});
});
});
@@ -270,7 +270,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set properties correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).to(beNil());
});
@@ -280,7 +280,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set up the view controller correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).toNot(beNil());
expect(testManager.lockScreenViewController).to(beAnInstanceOf([SDLLockScreenViewController class]));
expect(((SDLLockScreenViewController *)testManager.lockScreenViewController).backgroundColor).to(equal(testColor));
@@ -298,7 +298,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set properties correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).to(beNil());
});
@@ -308,7 +308,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should set up the view controller correctly", ^{
- expect(fakePresenter.presented).toEventually(beFalse());
+ expect(fakePresenter.showLockScreen).toEventually(beFalse());
expect(testManager.lockScreenViewController).toNot(beNil());
expect(testManager.lockScreenViewController).toNot(beAnInstanceOf([SDLLockScreenViewController class]));
expect(testManager.lockScreenViewController).to(equal(testViewController));
@@ -383,7 +383,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should present the lock screen if not already presented", ^{
- expect(fakePresenter.presented).toEventually(beTrue());
+ expect(fakePresenter.showLockScreen).toEventually(beTrue());
});
});
@@ -396,7 +396,7 @@ describe(@"a lock screen manager", ^{
});
it(@"should present the lock screen if not already presented", ^{
- expect(fakePresenter.presented).toEventually(beTrue());
+ expect(fakePresenter.showLockScreen).toEventually(beTrue());
});
});
});