WIP: Media Landscape Mode
This commit is contained in:
parent
85f85d9c3a
commit
19f2d0db48
|
@ -137,6 +137,11 @@ static NSTimeInterval launchStartedAt;
|
||||||
return SSKEnvironment.shared.messageManager;
|
return SSKEnvironment.shared.messageManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (OWSWindowManager *)windowManager
|
||||||
|
{
|
||||||
|
return Environment.shared.windowManager;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||||
|
@ -919,6 +924,23 @@ static NSTimeInterval launchStartedAt;
|
||||||
return NO;
|
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
|
#pragma mark Push Notifications Delegate Methods
|
||||||
|
|
||||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
||||||
|
|
|
@ -90,6 +90,14 @@ public class LoadingViewController: UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Orientation
|
||||||
|
|
||||||
|
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
|
return .portrait
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK:
|
||||||
|
|
||||||
private func buildLabel() -> UILabel {
|
private func buildLabel() -> UILabel {
|
||||||
let label = UILabel()
|
let label = UILabel()
|
||||||
|
|
||||||
|
|
|
@ -205,6 +205,14 @@ class MediaGalleryViewController: OWSNavigationController, MediaGalleryDataSourc
|
||||||
notImplemented()
|
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.
|
// 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
|
// 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.
|
// 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
|
return Int(count) - deletedMessages.count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Orientation
|
||||||
|
|
||||||
|
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
|
return .allButUpsideDown
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -510,7 +510,10 @@ class MediaPageViewController: UIPageViewController, UIPageViewControllerDataSou
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaGalleryDataSource.dismissMediaDetailViewController(self, animated: isAnimated, completion: completion)
|
mediaGalleryDataSource.dismissMediaDetailViewController(self, animated: isAnimated) {
|
||||||
|
UIDevice.current.ows_setOrientation(.portrait)
|
||||||
|
completion?()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: MediaDetailViewControllerDelegate
|
// MARK: MediaDetailViewControllerDelegate
|
||||||
|
|
|
@ -90,6 +90,12 @@ class MenuActionsViewController: UIViewController, MenuActionSheetDelegate {
|
||||||
ensureDelegateIsInformedThatDisappearenceCompleted()
|
ensureDelegateIsInformedThatDisappearenceCompleted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Orientation
|
||||||
|
|
||||||
|
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
|
return .portrait
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: Present / Dismiss animations
|
// MARK: Present / Dismiss animations
|
||||||
|
|
||||||
var presentationFocusOffset: CGFloat?
|
var presentationFocusOffset: CGFloat?
|
||||||
|
|
|
@ -172,6 +172,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
[UIView setAnimationsEnabled:YES];
|
[UIView setAnimationsEnabled:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Orientation
|
||||||
|
|
||||||
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||||
|
{
|
||||||
|
return UIInterfaceOrientationMaskPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -177,6 +177,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
[self.bottomLayoutView.superview layoutIfNeeded];
|
[self.bottomLayoutView.superview layoutIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Orientation
|
||||||
|
|
||||||
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||||
|
{
|
||||||
|
return UIInterfaceOrientationMaskPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -77,4 +77,11 @@ public class ReturnToCallViewController: UIViewController {
|
||||||
|
|
||||||
super.viewDidLayoutSubviews()
|
super.viewDidLayoutSubviews()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Orientation
|
||||||
|
|
||||||
|
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
|
||||||
|
return .portrait
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,4 +147,11 @@ NSString *NSStringForScreenLockUIState(ScreenLockUIState value)
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Orientation
|
||||||
|
|
||||||
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||||
|
{
|
||||||
|
return UIInterfaceOrientationMaskPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class OWSNavigationBar: UINavigationBar {
|
||||||
applyTheme()
|
applyTheme()
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(callDidChange), name: .OWSWindowManagerCallDidChange, object: nil)
|
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,
|
NotificationCenter.default.addObserver(self,
|
||||||
selector: #selector(themeDidChange),
|
selector: #selector(themeDidChange),
|
||||||
name: .ThemeDidChange,
|
name: .ThemeDidChange,
|
||||||
|
|
|
@ -53,4 +53,16 @@ public extension UIDevice {
|
||||||
|
|
||||||
return isNativeIPad || isCompatabilityModeIPad
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ extern const UIWindowLevel UIWindowLevel_Background;
|
||||||
|
|
||||||
- (void)setupWithRootWindow:(UIWindow *)rootWindow screenBlockingWindow:(UIWindow *)screenBlockingWindow;
|
- (void)setupWithRootWindow:(UIWindow *)rootWindow screenBlockingWindow:(UIWindow *)screenBlockingWindow;
|
||||||
|
|
||||||
|
@property (nonatomic, readonly) UIWindow *rootWindow;
|
||||||
|
|
||||||
- (void)setIsScreenBlockActive:(BOOL)isScreenBlockActive;
|
- (void)setIsScreenBlockActive:(BOOL)isScreenBlockActive;
|
||||||
|
|
||||||
#pragma mark - Message Actions
|
#pragma mark - Message Actions
|
||||||
|
|
|
@ -91,6 +91,13 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - Orientation
|
||||||
|
|
||||||
|
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||||
|
{
|
||||||
|
return UIInterfaceOrientationMaskPortrait;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -259,7 +266,8 @@ const UIWindowLevel UIWindowLevel_MessageActions(void)
|
||||||
OWSAssertDebug(!self.callNavigationController);
|
OWSAssertDebug(!self.callNavigationController);
|
||||||
self.callNavigationController = navigationController;
|
self.callNavigationController = navigationController;
|
||||||
|
|
||||||
window.rootViewController = navigationController;
|
// MJK DO NOT COMMIT.
|
||||||
|
window.rootViewController = viewController;
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue