Skip to content

Commit

Permalink
Merge branch 'move-the-ip-overrides-in-the-vpn-settings-instead-of-it…
Browse files Browse the repository at this point in the history
…-ios-557'
  • Loading branch information
buggmagnet committed Mar 19, 2024
2 parents f13bbbd + 1ddc41a commit 0216554
Show file tree
Hide file tree
Showing 26 changed files with 296 additions and 222 deletions.
2 changes: 1 addition & 1 deletion ios/MullvadSettings/SettingsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public enum SettingsManager {
public static func resetStore(completely: Bool = false) {
logger.debug("Reset store.")

let keys = completely ? SettingsKey.allCases : [.settings, .deviceState, .apiAccessMethods]
let keys = completely ? SettingsKey.allCases : [.settings, .deviceState, .apiAccessMethods, .ipOverrides]

keys.forEach { key in
do {
Expand Down
68 changes: 36 additions & 32 deletions ios/MullvadVPN.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ public enum AccessibilityIdentifier: String {
case problemReportSendButton

// Cells
case preferencesCell
case vpnSettingsCell
case versionCell
case problemReportCell
case faqCell
case apiAccessCell
case ipOverrideCell
case relayFilterOwnershipCell
case relayFilterProviderCell

Expand Down Expand Up @@ -83,6 +82,7 @@ public enum AccessibilityIdentifier: String {

// DNS settings
case dnsSettings
case ipOverrides
case wireGuardCustomPort
case wireGuardObfuscationAutomatic
case wireGuardObfuscationOff
Expand Down
3 changes: 2 additions & 1 deletion ios/MullvadVPN/Coordinators/ApplicationCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
storePaymentManager: storePaymentManager,
tunnelManager: tunnelManager,
apiProxy: apiProxy,
relayCacheTracker: relayCacheTracker
relayCacheTracker: relayCacheTracker,
ipOverrideRepository: ipOverrideRepository
)

let navigationController = CustomNavigationController()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ class IPOverrideCoordinator: Coordinator, Presenting, SettingsChildCoordinator {
private let navigationController: UINavigationController
private let interactor: IPOverrideInteractor

private lazy var ipOverrideViewController: IPOverrideViewController = {
let viewController = IPOverrideViewController(
interactor: interactor,
alertPresenter: AlertPresenter(context: self)
)
viewController.delegate = self
return viewController
}()

var presentationContext: UIViewController {
navigationController
}
Expand All @@ -38,7 +29,14 @@ class IPOverrideCoordinator: Coordinator, Presenting, SettingsChildCoordinator {
}

func start(animated: Bool) {
navigationController.pushViewController(ipOverrideViewController, animated: animated)
let controller = IPOverrideViewController(
interactor: interactor,
alertPresenter: AlertPresenter(context: self)
)

controller.delegate = self

navigationController.pushViewController(controller, animated: animated)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ class IPOverrideViewController: UIViewController {
value: """
On some networks, where various types of censorship are being used, our server IP addresses are \
sometimes blocked.
To circumvent this you can import a file or a text, provided by our support team, \
with new IP addresses that override the default addresses of the servers in the Select location view.
If you are having issues connecting to VPN servers, please contact support.
""",
comment: ""
Expand Down
27 changes: 8 additions & 19 deletions ios/MullvadVPN/Coordinators/Settings/SettingsCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum SettingsNavigationRoute: Equatable {
case root

/// VPN settings.
case preferences
case vpnSettings

/// Problem report.
case problemReport
Expand All @@ -28,9 +28,6 @@ enum SettingsNavigationRoute: Equatable {

/// API access route.
case apiAccess

/// IP override route.
case ipOverride
}

/// Top-level settings coordinator.
Expand Down Expand Up @@ -246,10 +243,11 @@ final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsV
controller.delegate = self
return .viewController(controller)

case .preferences:
return .viewController(PreferencesViewController(
interactor: interactorFactory.makePreferencesInteractor(),
alertPresenter: AlertPresenter(context: self)
case .vpnSettings:
return .childCoordinator(VPNSettingsCoordinator(
navigationController: navigationController,
interactorFactory: interactorFactory,
ipOverrideRepository: ipOverrideRepository
))

case .problemReport:
Expand All @@ -265,13 +263,6 @@ final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsV
proxyConfigurationTester: proxyConfigurationTester
))

case .ipOverride:
return .childCoordinator(IPOverrideCoordinator(
navigationController: navigationController,
repository: ipOverrideRepository,
tunnelManager: interactorFactory.tunnelManager
))

case .faq:
// Handled separately and presented as a modal.
return .failed
Expand All @@ -285,14 +276,12 @@ final class SettingsCoordinator: Coordinator, Presentable, Presenting, SettingsV
switch viewController {
case is SettingsViewController:
return .root
case is PreferencesViewController:
return .preferences
case is VPNSettingsViewController:
return .vpnSettings
case is ProblemReportViewController:
return .problemReport
case is ListAccessMethodViewController:
return .apiAccess
case is IPOverrideViewController:
return .ipOverride
default:
return nil
}
Expand Down
56 changes: 56 additions & 0 deletions ios/MullvadVPN/Coordinators/VPNSettingsCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// VPNSettingsCoordinator.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-03-18.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

import MullvadSettings
import MullvadTypes
import Routing
import UIKit

class VPNSettingsCoordinator: Coordinator, Presenting, SettingsChildCoordinator {
private let navigationController: UINavigationController
private let interactorFactory: SettingsInteractorFactory
private let ipOverrideRepository: IPOverrideRepositoryProtocol

var presentationContext: UIViewController {
navigationController
}

init(
navigationController: UINavigationController,
interactorFactory: SettingsInteractorFactory,
ipOverrideRepository: IPOverrideRepositoryProtocol
) {
self.navigationController = navigationController
self.interactorFactory = interactorFactory
self.ipOverrideRepository = ipOverrideRepository
}

func start(animated: Bool) {
let controller = VPNSettingsViewController(
interactor: interactorFactory.makeVPNSettingsInteractor(),
alertPresenter: AlertPresenter(context: self)
)

controller.delegate = self

navigationController.pushViewController(controller, animated: animated)
}
}

extension VPNSettingsCoordinator: VPNSettingsViewControllerDelegate {
func showIPOverrides() {
let coordinator = IPOverrideCoordinator(
navigationController: navigationController,
repository: ipOverrideRepository,
tunnelManager: interactorFactory.tunnelManager
)

addChild(coordinator)
coordinator.start(animated: true)
}
}

This file was deleted.

17 changes: 2 additions & 15 deletions ios/MullvadVPN/View controllers/Settings/SettingsCellFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct SettingsCellFactory: CellFactoryProtocol {
// swiftlint:disable:next function_body_length
func configureCell(_ cell: UITableViewCell, item: SettingsDataSource.Item, indexPath: IndexPath) {
switch item {
case .preferences:
case .vpnSettings:
guard let cell = cell as? SettingsCell else { return }

cell.titleLabel.text = NSLocalizedString(
"PREFERENCES_CELL_LABEL",
"VPN_SETTINGS_CELL_LABEL",
tableName: "Settings",
value: "VPN settings",
comment: ""
Expand Down Expand Up @@ -92,19 +92,6 @@ struct SettingsCellFactory: CellFactoryProtocol {
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = item.accessibilityIdentifier
cell.disclosureType = .chevron

case .ipOverride:
guard let cell = cell as? SettingsCell else { return }

cell.titleLabel.text = NSLocalizedString(
"IP_OVERRIDE_CELL_LABEL",
tableName: "Settings",
value: "Server IP override",
comment: ""
)
cell.detailTitleLabel.text = nil
cell.accessibilityIdentifier = item.accessibilityIdentifier
cell.disclosureType = .chevron
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource
}

enum Item: String {
case preferences
case vpnSettings
case version
case problemReport
case faq
case apiAccess
case ipOverride

var accessibilityIdentifier: AccessibilityIdentifier {
switch self {
case .preferences:
return .preferencesCell
case .vpnSettings:
return .vpnSettingsCell
case .version:
return .versionCell
case .problemReport:
Expand All @@ -53,8 +52,6 @@ final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource
return .faqCell
case .apiAccess:
return .apiAccessCell
case .ipOverride:
return .ipOverrideCell
}
}

Expand Down Expand Up @@ -149,11 +146,10 @@ final class SettingsDataSource: UITableViewDiffableDataSource<SettingsDataSource
snapshot.appendSections([.main])

if interactor.deviceState.isLoggedIn {
snapshot.appendItems([.preferences], toSection: .main)
snapshot.appendItems([.vpnSettings], toSection: .main)
}

snapshot.appendItems([.apiAccess], toSection: .main)
snapshot.appendItems([.ipOverride], toSection: .main)

snapshot.appendSections([.version, .problemReport])
snapshot.appendItems([.version], toSection: .version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SettingsInputCell: SelectableSettingsCell {
toolbarDoneButton = UIBarButtonItem(
title: NSLocalizedString(
"INPUT_CELL_TOOLBAR_BUTTON_DONE",
tableName: "Preferences",
tableName: "VPNSettings",
value: "Done",
comment: ""
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,33 @@
// Copyright © 2022 Mullvad VPN AB. All rights reserved.
//

import Foundation
import MullvadREST
import MullvadSettings

final class SettingsInteractorFactory {
private let storePaymentManager: StorePaymentManager
private let apiProxy: APIQuerying
private let relayCacheTracker: RelayCacheTracker
private let ipOverrideRepository: IPOverrideRepositoryProtocol

let tunnelManager: TunnelManager

init(
storePaymentManager: StorePaymentManager,
tunnelManager: TunnelManager,
apiProxy: APIQuerying,
relayCacheTracker: RelayCacheTracker
relayCacheTracker: RelayCacheTracker,
ipOverrideRepository: IPOverrideRepositoryProtocol
) {
self.storePaymentManager = storePaymentManager
self.tunnelManager = tunnelManager
self.apiProxy = apiProxy
self.relayCacheTracker = relayCacheTracker
self.ipOverrideRepository = ipOverrideRepository
}

func makePreferencesInteractor() -> PreferencesInteractor {
PreferencesInteractor(tunnelManager: tunnelManager, relayCacheTracker: relayCacheTracker)
func makeVPNSettingsInteractor() -> VPNSettingsInteractor {
VPNSettingsInteractor(tunnelManager: tunnelManager, relayCacheTracker: relayCacheTracker)
}

func makeProblemReportInteractor() -> ProblemReportInteractor {
Expand All @@ -39,4 +42,8 @@ final class SettingsInteractorFactory {
func makeSettingsInteractor() -> SettingsInteractor {
SettingsInteractor(tunnelManager: tunnelManager)
}

func makeIPOverrideInteractor() -> IPOverrideInteractor {
IPOverrideInteractor(repository: ipOverrideRepository, tunnelManager: tunnelManager)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class SettingsViewController: UITableViewController, SettingsDataSourceDelegate
extension SettingsDataSource.Item {
var navigationRoute: SettingsNavigationRoute? {
switch self {
case .preferences:
return .preferences
case .vpnSettings:
return .vpnSettings
case .version:
return nil
case .problemReport:
Expand All @@ -89,8 +89,6 @@ extension SettingsDataSource.Item {
return .faq
case .apiAccess:
return .apiAccess
case .ipOverride:
return .ipOverride
}
}
}
Loading

0 comments on commit 0216554

Please sign in to comment.