Skip to content

Commit

Permalink
Replace secured/unsecure terminology by connected/disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Dec 6, 2024
1 parent 4baba02 commit 96ec07a
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 125 deletions.
128 changes: 32 additions & 96 deletions ios/MullvadVPN/TunnelManager/TunnelState+UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit

extension TunnelState {
var textColorForSecureLabel: UIColor {
var textColorForConnectionStatusLabel: UIColor {
switch self {
case .connecting, .reconnecting, .waitingForConnectivity(.noConnection), .negotiatingEphemeralPeer:
.white
Expand All @@ -32,55 +32,20 @@ extension TunnelState {

var localizedTitleForSecureLabel: String {
switch self {
case let .connecting(_, isPostQuantum, _), let .reconnecting(_, isPostQuantum, _):
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTING",
tableName: "Main",
value: "Creating quantum secure connection",
comment: ""
)
} else {
NSLocalizedString(
"TUNNEL_STATE_CONNECTING",
tableName: "Main",
value: "Creating secure connection",
comment: ""
)
}

case let .negotiatingEphemeralPeer(_, _, isPostQuantum, _):
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_NEGOTIATING_KEY",
tableName: "Main",
value: "Creating quantum secure connection",
comment: ""
)
} else {
NSLocalizedString(
"TUNNEL_STATE_CONNECTING",
tableName: "Main",
value: "Creating secure connection",
comment: ""
)
}
case let .connected(_, isPostQuantum, _):
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTED",
tableName: "Main",
value: "Quantum secure connection",
comment: ""
)
} else {
NSLocalizedString(
"TUNNEL_STATE_CONNECTED",
tableName: "Main",
value: "Secure connection",
comment: ""
)
}
case .connecting, .reconnecting, .negotiatingEphemeralPeer:
NSLocalizedString(
"TUNNEL_STATE_CONNECTING",
tableName: "Main",
value: "Connecting...",
comment: ""
)
case .connected:
NSLocalizedString(
"TUNNEL_STATE_CONNECTED",
tableName: "Main",
value: "Connected",
comment: ""
)

case .disconnecting(.nothing):
NSLocalizedString(
Expand All @@ -101,7 +66,7 @@ extension TunnelState {
NSLocalizedString(
"TUNNEL_STATE_DISCONNECTED",
tableName: "Main",
value: "Unsecured connection",
value: "Disconnected",
comment: ""
)

Expand Down Expand Up @@ -159,62 +124,33 @@ extension TunnelState {
}
}

func secureConnectionLabel(isPostQuantum: Bool) -> String {
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating quantum secure connection",
comment: ""
)
} else {
var localizedAccessibilityLabel: String {
switch self {
case .connecting, .negotiatingEphemeralPeer:
NSLocalizedString(
"TUNNEL_STATE_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating secure connection",
value: "Connecting",
comment: ""
)
}
}

var localizedAccessibilityLabel: String {
switch self {
case let .connecting(_, isPostQuantum, _):
secureConnectionLabel(isPostQuantum: isPostQuantum)

case let .negotiatingEphemeralPeer(_, _, isPostQuantum, _):
secureConnectionLabel(isPostQuantum: isPostQuantum)

case let .connected(tunnelInfo, isPostQuantum, _):
if isPostQuantum {
String(
format: NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Quantum secure connection. Connected to %@, %@",
comment: ""
),
tunnelInfo.exit.location.city,
tunnelInfo.exit.location.country
)
} else {
String(
format: NSLocalizedString(
"TUNNEL_STATE_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Secure connection. Connected to %@, %@",
comment: ""
),
tunnelInfo.exit.location.city,
tunnelInfo.exit.location.country
)
}
case let .connected(tunnelInfo, _, _):
String(
format: NSLocalizedString(
"TUNNEL_STATE_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Connected to %@, %@",
comment: ""
),
tunnelInfo.exit.location.city,
tunnelInfo.exit.location.country
)

case .disconnected:
NSLocalizedString(
"TUNNEL_STATE_DISCONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Unsecured connection",
value: "Disconnected",
comment: ""
)

Expand Down
24 changes: 12 additions & 12 deletions ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private enum TunnelControlActionButton {
}

final class TunnelControlView: UIView {
private let secureLabel = makeBoldTextLabel(ofSize: 20, numberOfLines: 0)
private let connectionStatusLabel = makeBoldTextLabel(ofSize: 20, numberOfLines: 0)
private let cityLabel = makeBoldTextLabel(ofSize: 34)
private let countryLabel = makeBoldTextLabel(ofSize: 34)

Expand Down Expand Up @@ -135,16 +135,16 @@ final class TunnelControlView: UIView {
func update(with model: TunnelControlViewModel) {
viewModel = model
let tunnelState = model.tunnelStatus.state
secureLabel.text = model.secureLabelText
secureLabel.textColor = tunnelState.textColorForSecureLabel
connectionStatusLabel.text = model.connectionStatusLabelText
connectionStatusLabel.textColor = tunnelState.textColorForConnectionStatusLabel
selectLocationButtonBlurView.isEnabled = model.enableButtons
connectButtonBlurView.isEnabled = model.enableButtons
cityLabel.attributedText = attributedStringForLocation(string: model.city)
countryLabel.attributedText = attributedStringForLocation(string: model.country)
connectionPanel.connectedRelayName = model.connectedRelaysName
connectionPanel.dataSource = model.connectionPanel

updateSecureLabel(tunnelState: tunnelState)
updateConnectionStatusLabel(tunnelState: tunnelState)
updateActionButtons(tunnelState: tunnelState)
updateTunnelRelays(tunnelStatus: model.tunnelStatus)
}
Expand All @@ -166,17 +166,17 @@ final class TunnelControlView: UIView {
setArrangedButtons(views)
}

private func updateSecureLabel(tunnelState: TunnelState) {
secureLabel.text = tunnelState.localizedTitleForSecureLabel.uppercased()
secureLabel.textColor = tunnelState.textColorForSecureLabel
private func updateConnectionStatusLabel(tunnelState: TunnelState) {
connectionStatusLabel.text = tunnelState.localizedTitleForSecureLabel.uppercased()
connectionStatusLabel.textColor = tunnelState.textColorForConnectionStatusLabel

switch tunnelState {
case .connected:
secureLabel.accessibilityIdentifier = .connectionStatusConnectedLabel
connectionStatusLabel.accessibilityIdentifier = .connectionStatusConnectedLabel
case .connecting:
secureLabel.accessibilityIdentifier = .connectionStatusConnectingLabel
connectionStatusLabel.accessibilityIdentifier = .connectionStatusConnectingLabel
default:
secureLabel.accessibilityIdentifier = .connectionStatusNotConnectedLabel
connectionStatusLabel.accessibilityIdentifier = .connectionStatusNotConnectedLabel
}
}

Expand All @@ -185,7 +185,7 @@ final class TunnelControlView: UIView {
NSLocalizedString(
"CONNECT_BUTTON_TITLE",
tableName: "Main",
value: "Secure connection",
value: "Connect",
comment: ""
), for: .normal
)
Expand Down Expand Up @@ -274,7 +274,7 @@ final class TunnelControlView: UIView {
// MARK: - Private

private func addSubviews() {
for subview in [secureLabel, countryLabel, cityLabel, connectionPanel] {
for subview in [connectionStatusLabel, countryLabel, cityLabel, connectionPanel] {
locationContainerView.addArrangedSubview(subview)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

struct TunnelControlViewModel {
let tunnelStatus: TunnelStatus
let secureLabelText: String
let connectionStatusLabelText: String
let enableButtons: Bool
let city: String
let country: String
Expand All @@ -37,7 +37,7 @@ struct TunnelControlViewModel {
static var empty: Self {
TunnelControlViewModel(
tunnelStatus: TunnelStatus(),
secureLabelText: "",
connectionStatusLabelText: "",
enableButtons: true,
city: "",
country: "",
Expand All @@ -49,7 +49,7 @@ struct TunnelControlViewModel {
func update(status: TunnelStatus) -> TunnelControlViewModel {
TunnelControlViewModel(
tunnelStatus: status,
secureLabelText: secureLabelText,
connectionStatusLabelText: connectionStatusLabelText,
enableButtons: enableButtons,
city: city,
country: country,
Expand All @@ -61,7 +61,7 @@ struct TunnelControlViewModel {
func update(outgoingConnectionInfo: OutgoingConnectionInfo) -> TunnelControlViewModel {
TunnelControlViewModel(
tunnelStatus: tunnelStatus,
secureLabelText: secureLabelText,
connectionStatusLabelText: connectionStatusLabelText,
enableButtons: enableButtons,
city: city,
country: country,
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/ConnectivityTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class ConnectivityTests: LoggedOutUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

HeaderBar(app)
.tapAccountButton()
Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class TunnelControlPage: Page {
return self
}

@discardableResult func waitForSecureConnectionLabel() -> Self {
@discardableResult func waitForConnectedLabel() -> Self {
let labelFound = app.staticTexts[.connectionStatusConnectedLabel]
.waitForExistence(timeout: BaseUITestCase.extremelyLongTimeout)
XCTAssertTrue(labelFound, "Secure connection label presented")
XCTAssertTrue(labelFound, "Connected label presented")

return self
}
Expand Down
18 changes: 9 additions & 9 deletions ios/MullvadVPNUITests/RelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked() // Allow adding VPN configurations iOS permission

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

try Networking.verifyCannotReachAdServingDomain()

Expand All @@ -95,7 +95,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

try Networking.verifyCanAccessInternet()
try Networking.verifyConnectedThroughMullvad()
Expand Down Expand Up @@ -163,7 +163,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

try Networking.verifyCanAccessInternet()

Expand Down Expand Up @@ -204,7 +204,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

try Networking.verifyCanAccessInternet()

Expand Down Expand Up @@ -253,7 +253,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
// Should be two UDP connection attempts but sometimes only one is shown in the UI
TunnelControlPage(app)
.verifyConnectingOverTCPAfterUDPAttempts()
.waitForSecureConnectionLabel()
.waitForConnectedLabel()
.tapDisconnectButton()
}

Expand Down Expand Up @@ -282,7 +282,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
TunnelControlPage(app)
.tapRelayStatusExpandCollapseButton()
.verifyConnectingToPort("4001")
.waitForSecureConnectionLabel()
.waitForConnectedLabel()
.tapDisconnectButton()
}

Expand Down Expand Up @@ -363,7 +363,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()
.verifyConnectingOverMultihop()
.tapDisconnectButton()
}
Expand All @@ -386,7 +386,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

let relayIPAddress = TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()
.tapRelayStatusExpandCollapseButton()
.getInIPAddressFromConnectionStatus()

Expand All @@ -408,7 +408,7 @@ class RelayTests: LoggedInWithTimeUITestCase {
allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

try Networking.verifyCanAccessInternet()

Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/Screenshots/ScreenshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ScreenshotTests: LoggedInWithTimeUITestCase {
.tapLocationCell(withName: "Sweden")

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.waitForConnectedLabel()

snapshot("QuantumConnectionSecured")
}
Expand Down

0 comments on commit 96ec07a

Please sign in to comment.