diff options
| -rw-r--r-- | ios/MullvadVPN/AppDelegate.swift | 22 | ||||
| -rw-r--r-- | ios/MullvadVPN/ConnectMainContentView.swift | 4 | ||||
| -rw-r--r-- | ios/MullvadVPN/HeaderBarView.swift | 4 | ||||
| -rw-r--r-- | ios/MullvadVPN/RootContainerViewController.swift | 19 |
4 files changed, 44 insertions, 5 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index 0591fa0d79..9bc80732fa 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -382,6 +382,18 @@ extension AppDelegate: RootContainerViewControllerDelegate { return controller.supportedInterfaceOrientations } } + + func rootContainerViewAccessibilityPerformMagicTap(_ controller: RootContainerViewController) -> Bool { + guard Account.shared.isLoggedIn else { return false } + + switch TunnelManager.shared.tunnelState { + case .connected, .connecting, .reconnecting: + reconnectTunnel() + case .disconnecting, .disconnected: + connectTunnel() + } + return true + } } // MARK: - LoginViewControllerDelegate @@ -517,9 +529,7 @@ extension AppDelegate: ConnectViewControllerDelegate { } func connectViewControllerShouldReconnectTunnel(_ controller: ConnectViewController) { - TunnelManager.shared.reconnectTunnel { - self.logger?.debug("Re-connected VPN tunnel") - } + reconnectTunnel() } @objc private func handleDismissSelectLocationController(_ sender: Any) { @@ -554,6 +564,12 @@ extension AppDelegate: ConnectViewControllerDelegate { } } + private func reconnectTunnel() { + TunnelManager.shared.reconnectTunnel { + self.logger?.debug("Re-connected VPN tunnel") + } + } + private func presentTunnelError(_ error: TunnelManager.Error, alertTitle: String) { let alertController = UIAlertController( title: alertTitle, diff --git a/ios/MullvadVPN/ConnectMainContentView.swift b/ios/MullvadVPN/ConnectMainContentView.swift index 1ddab593b2..851ddfbad3 100644 --- a/ios/MullvadVPN/ConnectMainContentView.swift +++ b/ios/MullvadVPN/ConnectMainContentView.swift @@ -84,6 +84,10 @@ class ConnectMainContentView: UIView { backgroundColor = .primaryColor layoutMargins = UIMetrics.contentLayoutMargins + if #available(iOS 13.0, *) { + accessibilityContainerType = .semanticGroup + } + addSubviews() } diff --git a/ios/MullvadVPN/HeaderBarView.swift b/ios/MullvadVPN/HeaderBarView.swift index 056bfcbb73..0912e5c107 100644 --- a/ios/MullvadVPN/HeaderBarView.swift +++ b/ios/MullvadVPN/HeaderBarView.swift @@ -63,6 +63,10 @@ class HeaderBarView: UIView { right: UIMetrics.contentLayoutMargins.right ) + if #available(iOS 13.0, *) { + accessibilityContainerType = .semanticGroup + } + let constraints = [ logoImageView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor), logoImageView.centerYAnchor.constraint(equalTo: titleLabel.centerYAnchor), diff --git a/ios/MullvadVPN/RootContainerViewController.swift b/ios/MullvadVPN/RootContainerViewController.swift index 5ba68f75cf..0364b411c8 100644 --- a/ios/MullvadVPN/RootContainerViewController.swift +++ b/ios/MullvadVPN/RootContainerViewController.swift @@ -49,6 +49,8 @@ protocol RootContainerViewControllerDelegate: AnyObject { func rootContainerViewControllerShouldShowSettings(_ controller: RootContainerViewController, navigateTo route: SettingsNavigationRoute?, animated: Bool) func rootContainerViewSupportedInterfaceOrientations(_ controller: RootContainerViewController) -> UIInterfaceOrientationMask + + func rootContainerViewAccessibilityPerformMagicTap(_ controller: RootContainerViewController) -> Bool } /// A root container view controller @@ -105,8 +107,6 @@ class RootContainerViewController: UIViewController { addTransitionView() addHeaderBarView() updateHeaderBarBackground() - - accessibilityElements = [headerBarView, transitionContainer] } override func viewDidLayoutSubviews() { @@ -271,6 +271,12 @@ class RootContainerViewController: UIViewController { } } + // MARK: - Accessibility + + override func accessibilityPerformMagicTap() -> Bool { + return delegate?.rootContainerViewAccessibilityPerformMagicTap(self) ?? super.accessibilityPerformMagicTap() + } + // MARK: - Private private func addTransitionView() { @@ -353,6 +359,7 @@ class RootContainerViewController: UIViewController { } self.updateInterfaceOrientation(attemptRotateToDeviceOrientation: true) + self.updateAccessibilityElementsAndNotifyScreenChange() completion?() } @@ -544,6 +551,14 @@ class RootContainerViewController: UIViewController { } } + private func updateAccessibilityElementsAndNotifyScreenChange() { + // Update accessibility elements to define the correct navigation order: header bar, content view. + view.accessibilityElements = [headerBarView, topViewController?.view].compactMap { $0 } + + // Tell accessibility that the significant part of screen was changed. + UIAccessibility.post(notification: .screenChanged, argument: nil) + } + } class RootContainerPushSegue: UIStoryboardSegue { |
