summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-03-02 10:43:14 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-03-02 10:43:14 -0500
commit41b56f5f6aa3782c86af79ac8142a942ae795c0e (patch)
tree12dec1e614f133600d34f7a3f7403b28cbaa1476
parent254eddf6f5300e184fe8d645d53fc76191434745 (diff)
parent708f085f5e3e976f0019e768e0cf5631b4575432 (diff)
downloadsdl_ios-41b56f5f6aa3782c86af79ac8142a942ae795c0e.tar.gz
Merge branch 'master' into develop
# Conflicts: # SmartDeviceLink/SDLLockScreenManager.m
-rw-r--r--SmartDeviceLink/SDLLockScreenManager.m50
1 files changed, 31 insertions, 19 deletions
diff --git a/SmartDeviceLink/SDLLockScreenManager.m b/SmartDeviceLink/SDLLockScreenManager.m
index f38c2df10..74bb9010a 100644
--- a/SmartDeviceLink/SDLLockScreenManager.m
+++ b/SmartDeviceLink/SDLLockScreenManager.m
@@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL canPresent;
@property (strong, nonatomic, readwrite) SDLLockScreenConfiguration *config;
@property (strong, nonatomic) id<SDLViewControllerPresentable> presenter;
+@property (strong, nonatomic, nullable) SDLOnLockScreenStatus *lastLockNotification;
@end
@@ -44,6 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenStatusDidChange:) name:SDLDidChangeLockScreenStatusNotification object:dispatcher];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_lockScreenIconReceived:) name:SDLDidReceiveLockScreenIcon object:dispatcher];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
return self;
}
@@ -96,44 +98,54 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
- if (self.lockScreenViewController == nil) {
+ self.lastLockNotification = notification.notification;
+ [self sdl_checkLockScreen];
+}
+
+- (void)sdl_lockScreenIconReceived:(NSNotification *)notification {
+ NSAssert([notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:[UIImage class]], @"A notification was sent with an unanticipated object");
+ if (![notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:[UIImage class]]) {
return;
}
- SDLOnLockScreenStatus *onLockScreenNotification = notification.notification;
+ UIImage *icon = notification.userInfo[SDLNotificationUserInfoObject];
+
+ // If the VC is our special type, then add the vehicle icon. If they passed in a custom VC, there's no current way to show the vehicle icon. If they're managing it themselves, they can grab the notification themselves.
+ if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
+ ((SDLLockScreenViewController *)self.lockScreenViewController).vehicleIcon = icon;
+ }
+}
+
+- (void)sdl_appDidBecomeActive:(NSNotification *)notification {
+ [self sdl_checkLockScreen];
+}
+
+
+#pragma mark - Private Helpers
+
+- (void)sdl_checkLockScreen {
+ if (self.lockScreenViewController == nil || self.lastLockNotification == nil) {
+ return;
+ }
// Present the VC depending on the lock screen status
- if ([onLockScreenNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusRequired]) {
+ if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusRequired]) {
if (!self.presenter.presented && self.canPresent) {
[self.presenter present];
}
- } else if ([onLockScreenNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOptional]) {
+ } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOptional]) {
if (self.config.showInOptionalState && !self.presenter.presented && self.canPresent) {
[self.presenter present];
} else if (self.presenter.presented) {
[self.presenter dismiss];
}
- } else if ([onLockScreenNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOff]) {
+ } else if ([self.lastLockNotification.lockScreenStatus isEqualToString:SDLLockScreenStatusOff]) {
if (self.presenter.presented) {
[self.presenter dismiss];
}
}
}
-- (void)sdl_lockScreenIconReceived:(NSNotification *)notification {
- NSAssert([notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:[UIImage class]], @"A notification was sent with an unanticipated object");
- if (![notification.userInfo[SDLNotificationUserInfoObject] isKindOfClass:[UIImage class]]) {
- return;
- }
-
- UIImage *icon = notification.userInfo[SDLNotificationUserInfoObject];
-
- // If the VC is our special type, then add the vehicle icon. If they passed in a custom VC, there's no current way to show the vehicle icon. If they're managing it themselves, they can grab the notification themselves.
- if ([self.lockScreenViewController isKindOfClass:[SDLLockScreenViewController class]]) {
- ((SDLLockScreenViewController *)self.lockScreenViewController).vehicleIcon = icon;
- }
-}
-
@end
NS_ASSUME_NONNULL_END