Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using securedunsecure verbs in main view ios 893 #7277

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,6 @@
44B3C4392BFE2C800079782C /* PacketTunnelActorReducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PacketTunnelActorReducer.swift; sourceTree = "<group>"; };
44B3C43C2C00CBBC0079782C /* PacketTunnelActorReducerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PacketTunnelActorReducerTests.swift; sourceTree = "<group>"; };
44BB5F962BE527F4002520EB /* TunnelState+UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelState+UI.swift"; sourceTree = "<group>"; };
44BB5F992BE529FE002520EB /* TunnelStateTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TunnelStateTests.swift; sourceTree = "<group>"; };
44DD7D232B6CFFD70005F67F /* StartTunnelOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StartTunnelOperationTests.swift; sourceTree = "<group>"; };
44DD7D262B6D18FB0005F67F /* MockTunnelInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTunnelInteractor.swift; sourceTree = "<group>"; };
44DD7D282B7113CA0005F67F /* MockTunnel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockTunnel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2620,7 +2619,6 @@
44DD7D232B6CFFD70005F67F /* StartTunnelOperationTests.swift */,
A9A5F9A12ACB003D0083449F /* TunnelManagerTests.swift */,
F0A0868F2C22D6A700BF83E7 /* TunnelSettingsStrategyTests.swift */,
44BB5F992BE529FE002520EB /* TunnelStateTests.swift */,
F073FCB22C6617D70062EA1D /* TunnelStore+Stubs.swift */,
A9E031792ACB0AE70095D843 /* UIApplication+Stubs.swift */,
58165EBD2A262CBB00688EAD /* WgKeyRotationTests.swift */,
Expand Down
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.setAccessibilityIdentifier(.connectionStatusConnectedLabel)
connectionStatusLabel.setAccessibilityIdentifier(.connectionStatusConnectedLabel)
case .connecting:
secureLabel.setAccessibilityIdentifier(.connectionStatusConnectingLabel)
connectionStatusLabel.setAccessibilityIdentifier(.connectionStatusConnectingLabel)
default:
secureLabel.setAccessibilityIdentifier(.connectionStatusNotConnectedLabel)
connectionStatusLabel.setAccessibilityIdentifier(.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
Loading
Loading