summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-07-16 13:43:03 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-07-16 13:43:03 +0200
commit2b9f674affac160d615c1f1270d8fa880f562ddb (patch)
tree32cbc5ddb167e63d8134fdc1d8e9e1cd866f1811
parent19d3618e8f88bf6d9a392df3a39a33be889d169e (diff)
parent0711fb17f38e7345c48ac21cb9b5241d1db79156 (diff)
downloadmullvadvpn-2b9f674affac160d615c1f1270d8fa880f562ddb.tar.xz
mullvadvpn-2b9f674affac160d615c1f1270d8fa880f562ddb.zip
Merge branch 'root-accessibility'
-rw-r--r--ios/MullvadVPN/AppDelegate.swift22
-rw-r--r--ios/MullvadVPN/ConnectMainContentView.swift4
-rw-r--r--ios/MullvadVPN/HeaderBarView.swift4
-rw-r--r--ios/MullvadVPN/RootContainerViewController.swift19
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 {