From fbdb1ad6906745155652edff943a49ec00d85893 Mon Sep 17 00:00:00 2001 From: Arshak Aghakaryan Date: Mon, 10 Jul 2023 07:17:24 +0400 Subject: [PATCH 1/2] feat: Enable upside down orientation for iPad The "upside down" orientation for iPad devices was disabled in 05814add86d765b83c91baa3120ba65569803906b55b159fbd091a95876e40a70d. However, as an iPad user, not having all orientations is quite uncomfortable and sometimes annoying. Most apps support all orientations on iPad nowadays. This commit brings back the upside down orientation in all places where it was disabled. --- .../Media Viewing & Editing/DocumentTitleViewController.swift | 4 ++++ .../MediaGalleryNavigationController.swift | 4 ++++ Session/Media Viewing & Editing/MediaTileViewController.swift | 4 ++++ Session/Meta/AppDelegate.swift | 2 +- Session/Meta/Session-Info.plist | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Session/Media Viewing & Editing/DocumentTitleViewController.swift b/Session/Media Viewing & Editing/DocumentTitleViewController.swift index bff7c7597..ade2b9338 100644 --- a/Session/Media Viewing & Editing/DocumentTitleViewController.swift +++ b/Session/Media Viewing & Editing/DocumentTitleViewController.swift @@ -45,6 +45,10 @@ public class DocumentTileViewController: UIViewController, UITableViewDelegate, // MARK: - UI override public var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if UIDevice.current.isIPad { + return .all + } + return .allButUpsideDown } diff --git a/Session/Media Viewing & Editing/MediaGalleryNavigationController.swift b/Session/Media Viewing & Editing/MediaGalleryNavigationController.swift index cd9062186..55283edec 100644 --- a/Session/Media Viewing & Editing/MediaGalleryNavigationController.swift +++ b/Session/Media Viewing & Editing/MediaGalleryNavigationController.swift @@ -44,6 +44,10 @@ class MediaGalleryNavigationController: UINavigationController { // MARK: - Orientation public override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if UIDevice.current.isIPad { + return .all + } + return .allButUpsideDown } diff --git a/Session/Media Viewing & Editing/MediaTileViewController.swift b/Session/Media Viewing & Editing/MediaTileViewController.swift index db7915b95..4b9bf6c4b 100644 --- a/Session/Media Viewing & Editing/MediaTileViewController.swift +++ b/Session/Media Viewing & Editing/MediaTileViewController.swift @@ -53,6 +53,10 @@ public class MediaTileViewController: UIViewController, UICollectionViewDataSour // MARK: - UI override public var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if UIDevice.current.isIPad { + return .all + } + return .allButUpsideDown } diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 13046ce60..b5749419b 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -192,7 +192,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { if UIDevice.current.isIPad { - return .allButUpsideDown + return .all } return .portrait diff --git a/Session/Meta/Session-Info.plist b/Session/Meta/Session-Info.plist index be0439a2f..835938843 100644 --- a/Session/Meta/Session-Info.plist +++ b/Session/Meta/Session-Info.plist @@ -147,6 +147,7 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown UIViewControllerBasedStatusBarAppearance From 57dbad7e2e235ccc9757f43c8049e6948ee47b88 Mon Sep 17 00:00:00 2001 From: Arshak Aghakaryan Date: Mon, 10 Jul 2023 07:42:28 +0400 Subject: [PATCH 2/2] fix: Initial glitch when picking a photo in upside-down orientation This was caused by OWSViewController.IsLandscapeOrientationEnabled being hard-coded to return `NO`. Now, whether or not landscape orientation is enabled will be based on whether the current device is an iPad. --- .../Shared View Controllers/OWSViewController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SignalUtilitiesKit/Shared View Controllers/OWSViewController.m b/SignalUtilitiesKit/Shared View Controllers/OWSViewController.m index 6d2ea863b..611174095 100644 --- a/SignalUtilitiesKit/Shared View Controllers/OWSViewController.m +++ b/SignalUtilitiesKit/Shared View Controllers/OWSViewController.m @@ -11,12 +11,12 @@ NS_ASSUME_NONNULL_BEGIN BOOL IsLandscapeOrientationEnabled(void) { - return NO; + return UIDevice.currentDevice.isIPad; } UIInterfaceOrientationMask DefaultUIInterfaceOrientationMask(void) { - return (IsLandscapeOrientationEnabled() ? UIInterfaceOrientationMaskAllButUpsideDown + return (IsLandscapeOrientationEnabled() ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskPortrait); }