diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2022-06-22 10:26:23 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2022-06-22 11:39:11 +0200 |
| commit | c6ba4af468a8abbd2448eafd4286afba744a5f15 (patch) | |
| tree | 728e7d9d5503e0d30d73e7812516968ce7edfc6d | |
| parent | 422fe0977ccb928cc079836f015b662101d08edc (diff) | |
| download | mullvadvpn-c6ba4af468a8abbd2448eafd4286afba744a5f15.tar.xz mullvadvpn-c6ba4af468a8abbd2448eafd4286afba744a5f15.zip | |
Rename consent controller and extract TOS helpers
| -rw-r--r-- | ios/MullvadVPN.xcodeproj/project.pbxproj | 20 | ||||
| -rw-r--r-- | ios/MullvadVPN/SceneDelegate.swift | 48 | ||||
| -rw-r--r-- | ios/MullvadVPN/TermsOfService.swift | 21 | ||||
| -rw-r--r-- | ios/MullvadVPN/TermsOfServiceContentView.swift (renamed from ios/MullvadVPN/ConsentContentView.swift) | 12 | ||||
| -rw-r--r-- | ios/MullvadVPN/TermsOfServiceViewController.swift (renamed from ios/MullvadVPN/ConsentViewController.swift) | 6 | ||||
| -rw-r--r-- | ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift | 2 |
6 files changed, 61 insertions, 48 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index 446cd7eb8f..04b69c8b65 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -93,7 +93,7 @@ 58421030282D8A3C00F24E46 /* UpdateAccountDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5842102F282D8A3C00F24E46 /* UpdateAccountDataOperation.swift */; }; 58421032282E42B000F24E46 /* UpdateDeviceDataOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58421031282E42B000F24E46 /* UpdateDeviceDataOperation.swift */; }; 58421034282E4B1500F24E46 /* TunnelSettingsV2+REST.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58421033282E4B1500F24E46 /* TunnelSettingsV2+REST.swift */; }; - 584592612639B4A200EF967F /* ConsentContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584592602639B4A200EF967F /* ConsentContentView.swift */; }; + 584592612639B4A200EF967F /* TermsOfServiceContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584592602639B4A200EF967F /* TermsOfServiceContentView.swift */; }; 5846226526E0D9630035F7C2 /* ProductsRequestOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5846226426E0D9630035F7C2 /* ProductsRequestOperation.swift */; }; 5846227126E229F20035F7C2 /* AppStoreSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5846227026E229F20035F7C2 /* AppStoreSubscription.swift */; }; 5846227326E22A160035F7C2 /* AppStorePaymentObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5846227226E22A160035F7C2 /* AppStorePaymentObserver.swift */; }; @@ -162,6 +162,7 @@ 5871FB96254ADE4E0051A0A4 /* ConsolidatedApplicationLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5871FB95254ADE4E0051A0A4 /* ConsolidatedApplicationLog.swift */; }; 5871FBA0254C26C00051A0A4 /* NSRegularExpression+IPAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5871FB9F254C26BF0051A0A4 /* NSRegularExpression+IPAddress.swift */; }; 58727283265D173C00F315B2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 58727282265D173C00F315B2 /* LaunchScreen.storyboard */; }; + 5872D6E8286304DE00DB5F4E /* TermsOfService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5872D6E7286304DE00DB5F4E /* TermsOfService.swift */; }; 587425C12299833500CA2045 /* RootContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587425C02299833500CA2045 /* RootContainerViewController.swift */; }; 5875960726F36B3A00BF6711 /* TunnelIPCError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5875960626F36B3A00BF6711 /* TunnelIPCError.swift */; }; 5875960A26F371FC00BF6711 /* TunnelIPCSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5875960926F371FC00BF6711 /* TunnelIPCSession.swift */; }; @@ -214,7 +215,7 @@ 58A1AA8C23F5584C009F7EA6 /* ConnectionPanelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A1AA8B23F5584B009F7EA6 /* ConnectionPanelView.swift */; }; 58A8055E2716EA6700681642 /* AnyIPAddress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584D26BE270C550B004EA533 /* AnyIPAddress.swift */; }; 58A8BE81239FBE62006B74AC /* IPEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58561C98239A5D1500BD6B5E /* IPEndpoint.swift */; }; - 58A99ED3240014A0006599E9 /* ConsentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A99ED2240014A0006599E9 /* ConsentViewController.swift */; }; + 58A99ED3240014A0006599E9 /* TermsOfServiceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58A99ED2240014A0006599E9 /* TermsOfServiceViewController.swift */; }; 58ACF6492655365700ACE4B7 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58ACF6482655365700ACE4B7 /* PreferencesViewController.swift */; }; 58ACF64B26553C3F00ACE4B7 /* SettingsSwitchCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58ACF64A26553C3F00ACE4B7 /* SettingsSwitchCell.swift */; }; 58ACF64D26567A5000ACE4B7 /* CustomSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58ACF64C26567A4F00ACE4B7 /* CustomSwitch.swift */; }; @@ -412,7 +413,7 @@ 5842102F282D8A3C00F24E46 /* UpdateAccountDataOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateAccountDataOperation.swift; sourceTree = "<group>"; }; 58421031282E42B000F24E46 /* UpdateDeviceDataOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateDeviceDataOperation.swift; sourceTree = "<group>"; }; 58421033282E4B1500F24E46 /* TunnelSettingsV2+REST.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelSettingsV2+REST.swift"; sourceTree = "<group>"; }; - 584592602639B4A200EF967F /* ConsentContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsentContentView.swift; sourceTree = "<group>"; }; + 584592602639B4A200EF967F /* TermsOfServiceContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServiceContentView.swift; sourceTree = "<group>"; }; 5845F841236CBACD00B2D93C /* TunnelIPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelIPC.swift; sourceTree = "<group>"; }; 5846226426E0D9630035F7C2 /* ProductsRequestOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductsRequestOperation.swift; sourceTree = "<group>"; }; 5846227026E229F20035F7C2 /* AppStoreSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreSubscription.swift; sourceTree = "<group>"; }; @@ -460,6 +461,7 @@ 5871FB95254ADE4E0051A0A4 /* ConsolidatedApplicationLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsolidatedApplicationLog.swift; sourceTree = "<group>"; }; 5871FB9F254C26BF0051A0A4 /* NSRegularExpression+IPAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSRegularExpression+IPAddress.swift"; sourceTree = "<group>"; }; 58727282265D173C00F315B2 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; }; + 5872D6E7286304DE00DB5F4E /* TermsOfService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfService.swift; sourceTree = "<group>"; }; 587425C02299833500CA2045 /* RootContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootContainerViewController.swift; sourceTree = "<group>"; }; 5875960626F36B3A00BF6711 /* TunnelIPCError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelIPCError.swift; sourceTree = "<group>"; }; 5875960926F371FC00BF6711 /* TunnelIPCSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelIPCSession.swift; sourceTree = "<group>"; }; @@ -503,7 +505,7 @@ 58A1AA8623F43901009F7EA6 /* Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Location.swift; sourceTree = "<group>"; }; 58A1AA8B23F5584B009F7EA6 /* ConnectionPanelView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionPanelView.swift; sourceTree = "<group>"; }; 58A94AE326CFD945001CB97C /* TunnelErrorNotificationProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelErrorNotificationProvider.swift; sourceTree = "<group>"; }; - 58A99ED2240014A0006599E9 /* ConsentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsentViewController.swift; sourceTree = "<group>"; }; + 58A99ED2240014A0006599E9 /* TermsOfServiceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsOfServiceViewController.swift; sourceTree = "<group>"; }; 58ACF6482655365700ACE4B7 /* PreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = "<group>"; }; 58ACF64A26553C3F00ACE4B7 /* SettingsSwitchCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSwitchCell.swift; sourceTree = "<group>"; }; 58ACF64C26567A4F00ACE4B7 /* CustomSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSwitch.swift; sourceTree = "<group>"; }; @@ -882,8 +884,8 @@ 58A1AA8B23F5584B009F7EA6 /* ConnectionPanelView.swift */, 58B43C1825F77DB60002C8C3 /* ConnectMainContentView.swift */, 58CCA00F224249A1004F3011 /* ConnectViewController.swift */, - 584592602639B4A200EF967F /* ConsentContentView.swift */, - 58A99ED2240014A0006599E9 /* ConsentViewController.swift */, + 584592602639B4A200EF967F /* TermsOfServiceContentView.swift */, + 58A99ED2240014A0006599E9 /* TermsOfServiceViewController.swift */, 5871FB95254ADE4E0051A0A4 /* ConsolidatedApplicationLog.swift */, 5896AE83246D5889005B36CB /* CustomDateComponentsFormatting.swift */, 582BB1B0229569620055B6EF /* CustomNavigationBar.swift */, @@ -977,6 +979,7 @@ 58FD5BF12424F7D700112C88 /* UserInterfaceInteractionRestriction.swift */, 58F7CA872692E34000FC59FD /* WireguardKeysContentView.swift */, 5877152F23981F7B001F8237 /* WireguardKeysViewController.swift */, + 5872D6E7286304DE00DB5F4E /* TermsOfService.swift */, ); path = MullvadVPN; sourceTree = "<group>"; @@ -1376,7 +1379,7 @@ 5888AD87227B17950051EB06 /* SelectLocationViewController.swift in Sources */, 58293FB3251241B4005D0BB5 /* CustomTextView.swift in Sources */, 58F19E35228C15BA00C7710B /* SpinnerActivityIndicatorView.swift in Sources */, - 58A99ED3240014A0006599E9 /* ConsentViewController.swift in Sources */, + 58A99ED3240014A0006599E9 /* TermsOfServiceViewController.swift in Sources */, 58CCA0162242560B004F3011 /* UIColor+Palette.swift in Sources */, 58095C4F2760BA9100890776 /* AddressCacheStore.swift in Sources */, 587CBFE322807F530028DED3 /* UIColor+Helpers.swift in Sources */, @@ -1434,6 +1437,7 @@ 5820675E26E6839900655B05 /* PresentAlertOperation.swift in Sources */, 5815039D24D6ECE600C9C50E /* TextFileOutputStream.swift in Sources */, 58CE5E64224146200008646E /* AppDelegate.swift in Sources */, + 5872D6E8286304DE00DB5F4E /* TermsOfService.swift in Sources */, 58E0A98827C8F46300FE6BDD /* Tunnel.swift in Sources */, 58ACF64F26567A7100ACE4B7 /* CustomSwitchContainer.swift in Sources */, 5857F24324C8662600CF6F47 /* SelectLocationHeaderView.swift in Sources */, @@ -1456,7 +1460,7 @@ 5868BD33261DCD2600E6027F /* CustomSplitViewController.swift in Sources */, 58CCA01E2242787B004F3011 /* AccountTextField.swift in Sources */, 586E54FB27A2DF6D0029B88B /* TunnelIPCRequestOperation.swift in Sources */, - 584592612639B4A200EF967F /* ConsentContentView.swift in Sources */, + 584592612639B4A200EF967F /* TermsOfServiceContentView.swift in Sources */, 58B5A895280AACC4009FDE99 /* RESTRequestFactory.swift in Sources */, 584EBDBD2747C98F00A0C9FD /* NSAttributedString+Markdown.swift in Sources */, 58059DDC28465E8F002B1049 /* TransformOperation.swift in Sources */, diff --git a/ios/MullvadVPN/SceneDelegate.swift b/ios/MullvadVPN/SceneDelegate.swift index 77ebcb938e..00c8a2ce3e 100644 --- a/ios/MullvadVPN/SceneDelegate.swift +++ b/ios/MullvadVPN/SceneDelegate.swift @@ -244,8 +244,8 @@ extension SceneDelegate { let rootContainerWrapper = makeLoginContainerController() - if !isAgreedToTermsOfService() { - let consentViewController = self.makeConsentController { [weak self] (viewController) in + if !TermsOfService.isAgreed { + let termsOfServiceViewController = self.makeTermsOfServiceController { [weak self] viewController in guard let self = self else { return } if TunnelManager.shared.isAccountSet { @@ -256,7 +256,7 @@ extension SceneDelegate { rootContainerWrapper.pushViewController(self.makeLoginController(), animated: true) } } - rootContainerWrapper.setViewControllers([consentViewController], animated: false) + rootContainerWrapper.setViewControllers([termsOfServiceViewController], animated: false) rootContainer.present(rootContainerWrapper, animated: false) } else if !TunnelManager.shared.isAccountSet { rootContainerWrapper.setViewControllers([makeLoginController()], animated: false) @@ -284,14 +284,14 @@ extension SceneDelegate { } } - if isAgreedToTermsOfService() { + if TermsOfService.isAgreed { showNextController(false) } else { - let consentViewController = self.makeConsentController { (consentController) in + let termsOfServiceController = self.makeTermsOfServiceController { _ in showNextController(true) } - rootContainer.setViewControllers([consentViewController], animated: false) + rootContainer.setViewControllers([termsOfServiceController], animated: false) } } @@ -340,22 +340,25 @@ extension SceneDelegate { return selectLocationController } - private func makeConsentController(completion: @escaping (UIViewController) -> Void) -> ConsentViewController { - let consentViewController = ConsentViewController() + private func makeTermsOfServiceController( + completion: @escaping (UIViewController) -> Void + ) -> TermsOfServiceViewController + { + let controller = TermsOfServiceViewController() if UIDevice.current.userInterfaceIdiom == .pad { - consentViewController.modalPresentationStyle = .formSheet + controller.modalPresentationStyle = .formSheet if #available(iOS 13.0, *) { - consentViewController.isModalInPresentation = true + controller.isModalInPresentation = true } } - consentViewController.completionHandler = { (consentViewController) in - setAgreedToTermsOfService() - completion(consentViewController) + controller.completionHandler = { controller in + TermsOfService.setAgreed() + completion(controller) } - return consentViewController + return controller } private func makeLoginContainerController() -> RootContainerViewController { @@ -366,7 +369,7 @@ extension SceneDelegate { if UIDevice.current.userInterfaceIdiom == .pad { rootContainerWrapper.modalPresentationStyle = .formSheet if #available(iOS 13.0, *) { - // Prevent swiping off the login or consent controllers + // Prevent swiping off the login or terms of service controllers rootContainerWrapper.isModalInPresentation = true } } @@ -702,18 +705,3 @@ struct SceneWindowFactory: WindowFactory { return UIWindow(windowScene: windowScene) } } - -// MARK: - - -/// A enum holding the `UserDefaults` string keys -private let isAgreedToTermsOfServiceKey = "isAgreedToTermsOfService" - -/// Returns true if user agreed to terms of service, otherwise false. -func isAgreedToTermsOfService() -> Bool { - return UserDefaults.standard.bool(forKey: isAgreedToTermsOfServiceKey) -} - -/// Save the boolean flag in preferences indicating that the user agreed to terms of service. -func setAgreedToTermsOfService() { - UserDefaults.standard.set(true, forKey: isAgreedToTermsOfServiceKey) -} diff --git a/ios/MullvadVPN/TermsOfService.swift b/ios/MullvadVPN/TermsOfService.swift new file mode 100644 index 0000000000..fe1cc71003 --- /dev/null +++ b/ios/MullvadVPN/TermsOfService.swift @@ -0,0 +1,21 @@ +// +// TermsOfService.swift +// MullvadVPN +// +// Created by pronebird on 22/06/2022. +// Copyright © 2022 Mullvad VPN AB. All rights reserved. +// + +import Foundation + +enum TermsOfService { + private static let userDefaultsKey = "isAgreedToTermsOfService" + + static var isAgreed: Bool { + return UserDefaults.standard.bool(forKey: userDefaultsKey) + } + + static func setAgreed() { + UserDefaults.standard.set(true, forKey: userDefaultsKey) + } +} diff --git a/ios/MullvadVPN/ConsentContentView.swift b/ios/MullvadVPN/TermsOfServiceContentView.swift index 1578962499..4e18593681 100644 --- a/ios/MullvadVPN/ConsentContentView.swift +++ b/ios/MullvadVPN/TermsOfServiceContentView.swift @@ -1,5 +1,5 @@ // -// ConsentContentView.swift +// TermsOfServiceContentView.swift // MullvadVPN // // Created by pronebird on 28/04/2021. @@ -8,7 +8,7 @@ import UIKit -class ConsentContentView: UIView { +class TermsOfServiceContentView: UIView { let titleLabel: UILabel = { let titleLabel = UILabel() @@ -19,7 +19,7 @@ class ConsentContentView: UIView { titleLabel.allowsDefaultTighteningForTruncation = true titleLabel.text = NSLocalizedString( "PRIVACY_NOTICE_HEADING", - tableName: "Consent", + tableName: "TermsOfService", value: "Do you agree to remaining anonymous?", comment: "" ) @@ -41,7 +41,7 @@ class ConsentContentView: UIView { bodyLabel.numberOfLines = 0 bodyLabel.text = NSLocalizedString( "PRIVACY_NOTICE_BODY", - tableName: "Consent", + tableName: "TermsOfService", value: "You have a right to privacy. That’s why we never store activity logs, don't ask for personal information, and encourage anonymous payments.\n\nIn some situations, as outlined in our privacy policy, we might process personal data that you choose to send, for example if you email us.\n\nWe strongly believe in retaining as little data as possible because we want you to remain anonymous.", comment: "" ) @@ -53,7 +53,7 @@ class ConsentContentView: UIView { button.translatesAutoresizingMaskIntoConstraints = false button.titleString = NSLocalizedString( "PRIVACY_POLICY_LINK_TITLE", - tableName: "Consent", + tableName: "TermsOfService", value: "Privacy policy", comment: "" ) @@ -67,7 +67,7 @@ class ConsentContentView: UIView { button.accessibilityIdentifier = "AgreeButton" button.setTitle(NSLocalizedString( "CONTINUE_BUTTON_TITLE", - tableName: "Consent", + tableName: "TermsOfService", value: "Agree and continue", comment: "" ), for: .normal) diff --git a/ios/MullvadVPN/ConsentViewController.swift b/ios/MullvadVPN/TermsOfServiceViewController.swift index 70d37e8f79..dbc04555dc 100644 --- a/ios/MullvadVPN/ConsentViewController.swift +++ b/ios/MullvadVPN/TermsOfServiceViewController.swift @@ -1,5 +1,5 @@ // -// ConsentViewController.swift +// TermsOfServiceViewController.swift // MullvadVPN // // Created by pronebird on 21/02/2020. @@ -9,7 +9,7 @@ import SafariServices import UIKit -class ConsentViewController: UIViewController, RootContainment, SFSafariViewControllerDelegate { +class TermsOfServiceViewController: UIViewController, RootContainment, SFSafariViewControllerDelegate { var completionHandler: ((UIViewController) -> Void)? @@ -30,7 +30,7 @@ class ConsentViewController: UIViewController, RootContainment, SFSafariViewCont override func viewDidLoad() { super.viewDidLoad() - let contentView = ConsentContentView() + let contentView = TermsOfServiceContentView() contentView.translatesAutoresizingMaskIntoConstraints = false contentView.agreeButton.addTarget(self, action: #selector(handleAgreeButton(_:)), for: .touchUpInside) contentView.privacyPolicyLink.addTarget(self, action: #selector(handlePrivacyPolicyButton(_:)), for: .touchUpInside) diff --git a/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift b/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift index 6de279d85b..ab39539c3f 100644 --- a/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift +++ b/ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift @@ -32,7 +32,7 @@ class MullvadVPNScreenshots: XCTestCase { app.launch() - // Dismiss consent screen + // Dismiss terms of service screen _ = app.buttons["AgreeButton"].waitForExistence(timeout: 10) app.buttons["AgreeButton"].tap() |
