diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m index 7e707980a..b704db862 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m @@ -111,19 +111,18 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; -} - - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [self.qrScanningController startCapture]; + [UIDevice.currentDevice ows_setOrientation:UIInterfaceOrientationPortrait]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.qrScanningController startCapture]; + }); } -// pragma mark - OWSQRScannerDelegate +#pragma mark - OWSQRScannerDelegate - (void)controller:(OWSQRCodeScanningViewController *)controller didDetectQRCodeWithString:(NSString *)string { @@ -137,14 +136,13 @@ NS_ASSUME_NONNULL_BEGIN UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:body preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = - [UIAlertAction actionWithTitle:CommonStrings.cancelButton - style:UIAlertActionStyleCancel - handler:^(UIAlertAction *action) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.navigationController popViewControllerAnimated:YES]; - }); - }]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self popToLinkedDeviceList]; + }); + }]; [alertController addAction:cancelAction]; UIAlertAction *proceedAction = @@ -166,14 +164,13 @@ NS_ASSUME_NONNULL_BEGIN message:linkingDescription preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *cancelAction = - [UIAlertAction actionWithTitle:CommonStrings.cancelButton - style:UIAlertActionStyleCancel - handler:^(UIAlertAction *action) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.navigationController popViewControllerAnimated:YES]; - }); - }]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self popToLinkedDeviceList]; + }); + }]; [alertController addAction:cancelAction]; UIAlertAction *proceedAction = @@ -214,7 +211,7 @@ NS_ASSUME_NONNULL_BEGIN OWSLogInfo(@"Successfully provisioned device."); dispatch_async(dispatch_get_main_queue(), ^{ [self.linkedDevicesTableViewController expectMoreDevices]; - [self.navigationController popToViewController:self.linkedDevicesTableViewController animated:YES]; + [self popToLinkedDeviceList]; // The service implementation of the socket connection caches the linked device state, // so all sync message sends will fail on the socket until it is cycled. @@ -264,6 +261,14 @@ NS_ASSUME_NONNULL_BEGIN return alertController; } +- (void)popToLinkedDeviceList +{ + [self.navigationController popViewControllerWithAnimated:YES + completion:^{ + [UIViewController attemptRotationToDeviceOrientation]; + }]; +} + #pragma mark - Orientation - (UIInterfaceOrientationMask)supportedInterfaceOrientations diff --git a/Signal/src/call/PeerConnectionClient.swift b/Signal/src/call/PeerConnectionClient.swift index 15d85c73f..19eada7a5 100644 --- a/Signal/src/call/PeerConnectionClient.swift +++ b/Signal/src/call/PeerConnectionClient.swift @@ -171,6 +171,10 @@ class PeerConnectionProxy: NSObject, RTCPeerConnectionDelegate, RTCDataChannelDe self.get()?.peerConnection(peerConnection, didOpen: dataChannel) } + public func peerConnection(_ peerConnection: RTCPeerConnection, didChange connectionState: RTCPeerConnectionState) { + self.get()?.peerConnection(peerConnection, didChange: connectionState) + } + // MARK: - RTCDataChannelDelegate public func dataChannelDidChangeState(_ dataChannel: RTCDataChannel) { @@ -1046,6 +1050,10 @@ class PeerConnectionClient: NSObject, RTCPeerConnectionDelegate, RTCDataChannelD } } + internal func peerConnection(_ peerConnectionParam: RTCPeerConnection, didChange connectionState: RTCPeerConnectionState) { + Logger.info("didChange PeerConnectionState:\(connectionState.debugDescription)") + } + // MARK: Helpers /** @@ -1349,3 +1357,22 @@ fileprivate extension RTCIceConnectionState { } } } + +fileprivate extension RTCPeerConnectionState { + var debugDescription: String { + switch self { + case .new: + return "new" + case .connecting: + return "connecting" + case .connected: + return "connected" + case .disconnected: + return "disconnected" + case .failed: + return "failed" + case .closed: + return "closed" + } + } +} diff --git a/SignalMessaging/categories/UIDevice+featureSupport.swift b/SignalMessaging/categories/UIDevice+featureSupport.swift index c5c450eb9..26f1ba3a9 100644 --- a/SignalMessaging/categories/UIDevice+featureSupport.swift +++ b/SignalMessaging/categories/UIDevice+featureSupport.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // import Foundation @@ -54,6 +54,7 @@ public extension UIDevice { return isNativeIPad || isCompatabilityModeIPad } + @objc public func ows_setOrientation(_ orientation: UIInterfaceOrientation) { // XXX - This is not officially supported, but there's no other way to programmatically rotate // the interface. diff --git a/SignalMessaging/categories/UIView+OWS.swift b/SignalMessaging/categories/UIView+OWS.swift index 089346665..1ea3c908c 100644 --- a/SignalMessaging/categories/UIView+OWS.swift +++ b/SignalMessaging/categories/UIView+OWS.swift @@ -12,3 +12,35 @@ public extension UIEdgeInsets { right: CurrentAppContext().isRTL ? leading : trailing) } } + +@objc +public extension UINavigationController { + @objc + public func pushViewController(viewController: UIViewController, + animated: Bool, + completion: (() -> Void)?) { + CATransaction.begin() + CATransaction.setCompletionBlock(completion) + pushViewController(viewController, animated: animated) + CATransaction.commit() + } + + @objc + public func popViewController(animated: Bool, + completion: (() -> Void)?) { + CATransaction.begin() + CATransaction.setCompletionBlock(completion) + popViewController(animated: animated) + CATransaction.commit() + } + + @objc + public func popToViewController(viewController: UIViewController, + animated: Bool, + completion: (() -> Void)?) { + CATransaction.begin() + CATransaction.setCompletionBlock(completion) + self.popToViewController(viewController, animated: animated) + CATransaction.commit() + } +} diff --git a/SignalMessaging/categories/UIViewController+OWS.m b/SignalMessaging/categories/UIViewController+OWS.m index 86a231323..04c1ba1d8 100644 --- a/SignalMessaging/categories/UIViewController+OWS.m +++ b/SignalMessaging/categories/UIViewController+OWS.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "Theme.h" @@ -15,20 +15,33 @@ NS_ASSUME_NONNULL_BEGIN - (UIViewController *)findFrontmostViewController:(BOOL)ignoringAlerts { + NSMutableArray *visitedViewControllers = [NSMutableArray new]; + UIViewController *viewController = self; while (YES) { + [visitedViewControllers addObject:viewController]; + UIViewController *_Nullable nextViewController = viewController.presentedViewController; if (nextViewController) { - if (ignoringAlerts) { - if ([nextViewController isKindOfClass:[UIAlertController class]]) { - break; + if (!ignoringAlerts || ![nextViewController isKindOfClass:[UIAlertController class]]) { + if ([visitedViewControllers containsObject:nextViewController]) { + // Cycle detected. + return viewController; } + viewController = nextViewController; + continue; } - viewController = nextViewController; - } else if ([viewController isKindOfClass:[UINavigationController class]]) { + } + + if ([viewController isKindOfClass:[UINavigationController class]]) { UINavigationController *navigationController = (UINavigationController *)viewController; - if (navigationController.topViewController) { - viewController = navigationController.topViewController; + nextViewController = navigationController.topViewController; + if (nextViewController) { + if ([visitedViewControllers containsObject:nextViewController]) { + // Cycle detected. + return viewController; + } + viewController = nextViewController; } else { break; } diff --git a/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift b/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift index 7c0cfd9a0..26df0bedb 100644 --- a/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift +++ b/SignalServiceKit/src/Messages/Interactions/OWSLinkPreview.swift @@ -337,7 +337,8 @@ public class OWSLinkPreview: MTLModel { "imgur.com", // Instagram - "cdninstagram.com" + "cdninstagram.com", + "fbcdn.net" ] private static let protocolWhitelist = [ diff --git a/ThirdParty/WebRTC b/ThirdParty/WebRTC index aa8bee9bd..55de5593c 160000 --- a/ThirdParty/WebRTC +++ b/ThirdParty/WebRTC @@ -1 +1 @@ -Subproject commit aa8bee9bd6f69e388a9ca7506b8702ef8ab7f195 +Subproject commit 55de5593cc261fa9368c5ccde98884ed1e278ba0