summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2019-11-08 13:45:31 -0500
committerJoel Fischer <joeljfischer@gmail.com>2019-11-08 13:45:31 -0500
commit72282a8fc94450c1dbae6a1378a01f73f9ccfb25 (patch)
tree4ee1d7ef09fce8e1eeb6fdab5edab01e2f96d47e
parenta9bea6f6554cc5e3d8a73d28870f8ae783d02700 (diff)
downloadsdl_ios-72282a8fc94450c1dbae6a1378a01f73f9ccfb25.tar.gz
Changes to fix rotation issues
* Fix lock screen not appearing on iOS 13
-rw-r--r--SmartDeviceLink/SDLLockScreenPresenter.m21
-rw-r--r--SmartDeviceLink/SDLLockScreenViewController.m24
-rwxr-xr-xSmartDeviceLink/SDLScreenshotViewController.m2
3 files changed, 33 insertions, 14 deletions
diff --git a/SmartDeviceLink/SDLLockScreenPresenter.m b/SmartDeviceLink/SDLLockScreenPresenter.m
index 0415e1c2a..20b9b3897 100644
--- a/SmartDeviceLink/SDLLockScreenPresenter.m
+++ b/SmartDeviceLink/SDLLockScreenPresenter.m
@@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Present Lock Window
- (void)present {
+ SDLLogD(@"Trying to present lock screen");
dispatch_async(dispatch_get_main_queue(), ^{
if (@available(iOS 13.0, *)) {
[self sdl_presentIOS13];
@@ -76,7 +77,6 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)sdl_presentIOS13 {
- SDLLogD(@"Seeking to present lock screen on iOS 13");
if (@available(iOS 13.0, *)) {
UIWindowScene *appWindowScene = nil;
for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) {
@@ -118,10 +118,19 @@ NS_ASSUME_NONNULL_BEGIN
self.lockWindow.backgroundColor = [UIColor clearColor];
self.lockWindow.rootViewController = self.screenshotViewController;
}
+
+ [self sdl_presentWithAppWindow:appWindow];
}
}
-- (void)sdl_presentWithAppWindow:(UIWindow *)appWindow {
+- (void)sdl_presentWithAppWindow:(nullable UIWindow *)appWindow {
+ if (appWindow == nil) {
+ SDLLogW(@"Attempted to present lock window but app window is nil");
+ return;
+ }
+
+ SDLLogD(@"Presenting lock screen window from app window: %@", appWindow);
+
// We let ourselves know that the lockscreen will present, because we have to pause streaming video for that 0.3 seconds or else it will be very janky.
[[NSNotificationCenter defaultCenter] postNotificationName:SDLLockScreenManagerWillPresentLockScreenViewController object:nil];
@@ -145,6 +154,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Dismiss Lock Window
- (void)dismiss {
+ SDLLogD(@"Trying to dismiss lock screen");
dispatch_async(dispatch_get_main_queue(), ^{
if (@available(iOS 13.0, *)) {
[self sdl_dismissIOS13];
@@ -158,6 +168,7 @@ NS_ASSUME_NONNULL_BEGIN
NSArray* windows = [[UIApplication sharedApplication] windows];
UIWindow *appWindow = nil;
for (UIWindow *window in windows) {
+ SDLLogV(@"Checking window: %@", window);
if (window != self.lockWindow) {
appWindow = window;
break;
@@ -192,8 +203,8 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<UIWindow *> *windows = appWindowScene.windows;
UIWindow *appWindow = nil;
for (UIWindow *window in windows) {
+ SDLLogV(@"Checking window: %@", window);
if (window != self.lockWindow) {
- SDLLogV(@"Found app window");
appWindow = window;
break;
}
@@ -203,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN
}
}
-- (void)sdl_dismissWithAppWindow:(UIWindow *)appWindow {
+- (void)sdl_dismissWithAppWindow:(nullable UIWindow *)appWindow {
if (appWindow == nil) {
SDLLogE(@"Unable to find the app's window");
return;
@@ -219,7 +230,7 @@ NS_ASSUME_NONNULL_BEGIN
[[NSNotificationCenter defaultCenter] postNotificationName:SDLLockScreenManagerWillDismissLockScreenViewController object:nil];
// Dismiss the lockscreen
- SDLLogD(@"Dismiss lock screen window");
+ SDLLogD(@"Dismiss lock screen window from app window: %@", appWindow);
[self.lockViewController dismissViewControllerAnimated:YES completion:^{
CGRect lockFrame = self.lockWindow.frame;
lockFrame.origin.x = CGRectGetWidth(lockFrame);
diff --git a/SmartDeviceLink/SDLLockScreenViewController.m b/SmartDeviceLink/SDLLockScreenViewController.m
index 9c5a14c99..215ef061c 100644
--- a/SmartDeviceLink/SDLLockScreenViewController.m
+++ b/SmartDeviceLink/SDLLockScreenViewController.m
@@ -38,11 +38,19 @@ NS_ASSUME_NONNULL_BEGIN
}
- (BOOL)shouldAutorotate {
- return NO;
+ if (self.presentingViewController != nil) {
+ return self.presentingViewController.shouldAutorotate;
+ } else {
+ return YES;
+ }
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return UIInterfaceOrientationMaskPortrait;
+ if (self.presentingViewController != nil) {
+ return self.presentingViewController.supportedInterfaceOrientations;
+ } else {
+ return UIInterfaceOrientationMaskAll;
+ }
}
- (UIStatusBarStyle)preferredStatusBarStyle {
@@ -73,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setLockedLabelText:(NSString *_Nullable)lockedLabelText {
_lockedLabelText = lockedLabelText;
-
+
[self sdl_layoutViews];
}
@@ -114,13 +122,13 @@ NS_ASSUME_NONNULL_BEGIN
self.lockedLabel.textColor = iconColor;
self.lockedLabel.numberOfLines = 0;
-
+
if (self.lockedLabelText != nil) {
self.lockedLabel.text = self.lockedLabelText;
} else {
self.lockedLabel.text = NSLocalizedString(@"Locked for your safety", nil);
}
-
+
self.view.backgroundColor = self.backgroundColor;
if (self.vehicleIcon != nil && self.appIcon != nil) {
@@ -150,7 +158,7 @@ NS_ASSUME_NONNULL_BEGIN
self.backupImageView.image = nil;
self.backupImageView.tintColor = nil;
-
+
self.arrowUpImageView.alpha = 1.0;
self.arrowDownImageView.alpha = 1.0;
@@ -163,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
self.backupImageView.image = self.appIcon;
self.backupImageView.tintColor = nil;
-
+
self.arrowUpImageView.alpha = 0.0;
self.arrowDownImageView.alpha = 0.0;
@@ -176,7 +184,7 @@ NS_ASSUME_NONNULL_BEGIN
self.backupImageView.image = self.vehicleIcon;
self.backupImageView.tintColor = nil;
-
+
self.arrowUpImageView.alpha = 0.0;
self.arrowDownImageView.alpha = 0.0;
diff --git a/SmartDeviceLink/SDLScreenshotViewController.m b/SmartDeviceLink/SDLScreenshotViewController.m
index 4fbd661d5..da3060aab 100755
--- a/SmartDeviceLink/SDLScreenshotViewController.m
+++ b/SmartDeviceLink/SDLScreenshotViewController.m
@@ -50,7 +50,7 @@
// HAX: https://github.com/smartdevicelink/sdl_ios/issues/1250
- (BOOL)shouldAutorotate {
- if (self.currentAppWindow == nil) { return UIInterfaceOrientationMaskAll; }
+ if (self.currentAppWindow == nil) { return YES; }
UIViewController *viewController = [self sdl_topMostControllerForWindow:self.currentAppWindow];