WIP: Media Landscape Mode

This commit is contained in:
Michael Kirk 2018-10-25 11:02:30 -06:00
parent 85f85d9c3a
commit 19f2d0db48
13 changed files with 106 additions and 3 deletions

View File

@ -137,6 +137,11 @@ static NSTimeInterval launchStartedAt;
return SSKEnvironment.shared.messageManager;
}
- (OWSWindowManager *)windowManager
{
return Environment.shared.windowManager;
}
#pragma mark -
- (void)applicationDidEnterBackground:(UIApplication *)application {
@ -919,6 +924,23 @@ static NSTimeInterval launchStartedAt;
return NO;
}
#pragma mark - Orientation
- (UIInterfaceOrientationMask)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window
{
if (self.windowManager.rootWindow != window) {
return UIInterfaceOrientationMaskPortrait;
}
if (self.windowManager.hasCall) {
// The call-banner window is only suitable for portrait display
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskAllButUpsideDown;
}
#pragma mark Push Notifications Delegate Methods
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

View File

@ -90,6 +90,14 @@ public class LoadingViewController: UIViewController {
}
}
// MARK: Orientation
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
// MARK:
private func buildLabel() -> UILabel {
let label = UILabel()

View File

@ -205,6 +205,14 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
notImplemented()
}
// MARK: View LifeCycle
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// If the user's device is already rotated, try to respect that by rotating to landscape now
UIViewController.attemptRotationToDeviceOrientation()
}
// HACK: Though we don't have an input accessory view, the VC we are presented above (ConversationVC) does.
// If the app is backgrounded and then foregrounded, when OWSWindowManager calls mainWindow.makeKeyAndVisible
// the ConversationVC's inputAccessoryView will appear *above* us unless we'd previously become first responder.
@ -908,4 +916,10 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
}
return Int(count) - deletedMessages.count
}
// MARK: Orientation
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .allButUpsideDown
}
}

View File

@ -510,7 +510,10 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
return
}
mediaGalleryDataSource.dismissMediaDetailViewController(self, animated: isAnimated, completion: completion)
mediaGalleryDataSource.dismissMediaDetailViewController(self, animated: isAnimated) {
UIDevice.current.ows_setOrientation(.portrait)
completion?()
}
}
// MARK: MediaDetailViewControllerDelegate

View File

@ -90,6 +90,12 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
ensureDelegateIsInformedThatDisappearenceCompleted()
}
// MARK: Orientation
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
// MARK: Present / Dismiss animations
var presentationFocusOffset: CGFloat?

View File

@ -172,6 +172,13 @@ NS_ASSUME_NONNULL_BEGIN
[UIView setAnimationsEnabled:YES];
}
#pragma mark - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -177,6 +177,13 @@ NS_ASSUME_NONNULL_BEGIN
[self.bottomLayoutView.superview layoutIfNeeded];
}
#pragma mark - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -77,4 +77,11 @@ public class ReturnToCallViewController: UIViewController {
super.viewDidLayoutSubviews()
}
// MARK: Orientation
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
}

View File

@ -147,4 +147,11 @@ NSString *NSStringForScreenLockUIState(ScreenLockUIState value)
return YES;
}
#pragma mark - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end

View File

@ -48,7 +48,7 @@ public class OWSNavigationBar: UINavigationBar {
applyTheme()
NotificationCenter.default.addObserver(self, selector: #selector(callDidChange), name: .OWSWindowManagerCallDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatusBarFrame), name: .UIApplicationDidChangeStatusBarFrame, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(didChangeStatusBarFrame), name: .UIApplicationDidChangeStatusBarFrame, object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(themeDidChange),
name: .ThemeDidChange,

View File

@ -53,4 +53,16 @@ public extension UIDevice {
return isNativeIPad || isCompatabilityModeIPad
}
public func ows_setOrientation(_ orientation: UIInterfaceOrientation) {
// XXX - This is not officially supported, but there's no other way to programmatically rotate
// the interface.
let orientationKey = "orientation"
self.setValue(orientation.rawValue, forKey: orientationKey)
// Not strictly necessary for the orientation to appear as changed
// but allegedly helps ensure related rotation delegate methods are called.
// https://stackoverflow.com/questions/20987249/how-do-i-programmatically-set-device-orientation-in-ios7
UINavigationController.attemptRotationToDeviceOrientation()
}
}

View File

@ -26,6 +26,8 @@ extern const UIWindowLevel UIWindowLevel_Background;
- (void)setupWithRootWindow:(UIWindow *)rootWindow screenBlockingWindow:(UIWindow *)screenBlockingWindow;
@property (nonatomic, readonly) UIWindow *rootWindow;
- (void)setIsScreenBlockActive:(BOOL)isScreenBlockActive;
#pragma mark - Message Actions

View File

@ -91,6 +91,13 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
return YES;
}
#pragma mark - Orientation
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
@end
#pragma mark -
@ -259,7 +266,8 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
OWSAssertDebug(!self.callNavigationController);
self.callNavigationController = navigationController;
window.rootViewController = navigationController;
// MJK DO NOT COMMIT.
window.rootViewController = viewController;
return window;
}