From b93000819beb3da3d0fe86c6073e197a5078a757 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 18 Oct 2018 10:17:41 +0200 Subject: [PATCH] Reuse Credits VC to add a Disclaimer --- .../Global/SwiftGen+Storyboards.swift | 1 + .../Organizer/AboutViewController.swift | 38 ++++++++++++++++++- ...roller.swift => LabelViewController.swift} | 26 ++++--------- .../en.lproj/Organizer.storyboard | 12 ++++-- Passepartout.xcodeproj/project.pbxproj | 8 ++-- .../Resources/en.lproj/Localizable.strings | 3 ++ Passepartout/Sources/SwiftGen+Strings.swift | 10 +++++ 7 files changed, 70 insertions(+), 28 deletions(-) rename Passepartout-iOS/Scenes/Organizer/{CreditsViewController.swift => LabelViewController.swift} (59%) diff --git a/Passepartout-iOS/Global/SwiftGen+Storyboards.swift b/Passepartout-iOS/Global/SwiftGen+Storyboards.swift index bd13578a..a101983c 100644 --- a/Passepartout-iOS/Global/SwiftGen+Storyboards.swift +++ b/Passepartout-iOS/Global/SwiftGen+Storyboards.swift @@ -89,6 +89,7 @@ internal enum StoryboardSegue { case aboutSegueIdentifier = "AboutSegueIdentifier" case addProviderSegueIdentifier = "AddProviderSegueIdentifier" case creditsSegueIdentifier = "CreditsSegueIdentifier" + case disclaimerSegueIdentifier = "DisclaimerSegueIdentifier" case selectProfileSegueIdentifier = "SelectProfileSegueIdentifier" case versionSegueIdentifier = "VersionSegueIdentifier" } diff --git a/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift index a2665ae1..5508b5b7 100644 --- a/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/AboutViewController.swift @@ -37,7 +37,7 @@ class AboutViewController: UITableViewController, TableModelHost { model.setHeader(L10n.About.Sections.Info.header, for: .info) model.setHeader(L10n.About.Sections.Source.header, for: .source) model.setHeader(L10n.About.Sections.Feedback.header, for: .feedback) - model.set([.version, .credits, .website], in: .info) + model.set([.version, .credits, .disclaimer, .website], in: .info) model.set([.sourcePassepartout, .sourceTunnelKit], in: .source) model.set([.discussReddit, .reportIssue, .writeReview], in: .feedback) return model @@ -70,6 +70,10 @@ class AboutViewController: UITableViewController, TableModelHost { perform(segue: StoryboardSegue.Organizer.creditsSegueIdentifier) } + private func showDisclaimer() { + perform(segue: StoryboardSegue.Organizer.disclaimerSegueIdentifier) + } + private func visitWebsite() { UIApplication.shared.open(AppConstants.URLs.website, options: [:], completionHandler: nil) } @@ -94,6 +98,28 @@ class AboutViewController: UITableViewController, TableModelHost { @IBAction private func dismiss() { dismiss(animated: true, completion: nil) } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + guard let sid = segue.identifier, let segueType = StoryboardSegue.Organizer(rawValue: sid) else { + return + } + guard let vc = segue.destination as? LabelViewController else { + return + } + + switch segueType { + case .creditsSegueIdentifier: + var notices = AppConstants.Notices.all + notices.insert(L10n.Credits.Labels.thirdParties, at: 0) + vc.text = notices.joined(separator: "\n\n") + + case .disclaimerSegueIdentifier: + vc.text = L10n.Disclaimer.Labels.text + + default: + break + } + } } // MARK: - @@ -112,6 +138,8 @@ extension AboutViewController { case credits + case disclaimer + case website case sourcePassepartout @@ -154,6 +182,11 @@ extension AboutViewController { cell.leftText = L10n.Credits.title return cell + case .disclaimer: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.leftText = L10n.Disclaimer.title + return cell + case .website: let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.leftText = L10n.About.Cells.Website.caption @@ -194,6 +227,9 @@ extension AboutViewController { case .credits: showCredits() + case .disclaimer: + showDisclaimer() + case .website: visitWebsite() diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift similarity index 59% rename from Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift rename to Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index f62b5d0c..9abaef1d 100644 --- a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -1,5 +1,5 @@ // -// CreditsViewController.swift +// LabelViewController.swift // Passepartout-iOS // // Created by Davide De Rosa on 9/26/18. @@ -25,18 +25,12 @@ import UIKit -class CreditsViewController: UIViewController { +class LabelViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView? -// @IBOutlet private weak var labelTitle: UILabel? -// -// @IBOutlet private weak var labelIntro: UILabel? -// -// @IBOutlet private weak var buttonPassepartout: UIButton? -// -// @IBOutlet private weak var buttonTunnelKit: UIButton? - - @IBOutlet private weak var labelThirdParties: UILabel? + @IBOutlet private weak var label: UILabel? + + var text: String? override func awakeFromNib() { super.awakeFromNib() @@ -48,15 +42,9 @@ class CreditsViewController: UIViewController { super.viewDidLoad() title = L10n.Credits.title -// labelIntro?.text = L10n.Credits.Labels.intro -// buttonPassepartout?.setTitle(L10n.Credits.Buttons.passepartout, for: .normal) -// buttonTunnelKit?.setTitle(L10n.Credits.Buttons.tunnelkit, for: .normal) - - var notices = AppConstants.Notices.all - notices.insert(L10n.Credits.Labels.thirdParties, at: 0) - labelThirdParties?.text = notices.joined(separator: "\n\n") + label?.text = text scrollView?.applyPrimaryBackground(Theme.current) - labelThirdParties?.applyLight(Theme.current) + label?.applyLight(Theme.current) } } diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard index 18027ad4..d078b53a 100644 --- a/Passepartout-iOS/en.lproj/Organizer.storyboard +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -415,16 +415,17 @@ + - + - + @@ -438,7 +439,7 @@ - - + @@ -493,4 +494,7 @@ + + + diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj index 638f0a01..6b6b127b 100644 --- a/Passepartout.xcodeproj/project.pbxproj +++ b/Passepartout.xcodeproj/project.pbxproj @@ -83,7 +83,7 @@ 0EF5CF252141CE58004FF1BD /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5CF242141CE58004FF1BD /* HUD.swift */; }; 0EF5CF292141F31F004FF1BD /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; }; 0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943D215BE10800529B64 /* IssueReporter.swift */; }; - 0EFD9440215BED8E00529B64 /* CreditsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */; }; + 0EFD9440215BED8E00529B64 /* LabelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943F215BED8E00529B64 /* LabelViewController.swift */; }; 390EEC911382C4814FB97475 /* Pods_Passepartout_iOS_Tunnel.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D0C619B826C7140001C0F32 /* Pods_Passepartout_iOS_Tunnel.framework */; }; 61E05ED5CCEEA859AD1752F3 /* Pods_Passepartout_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9FBA5419C4B758FB5D68E96 /* Pods_Passepartout_iOS.framework */; }; CB086D724184B22B368E5BEF /* Pods_PassepartoutTests_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E80C2390BBF547A62D4D277 /* Pods_PassepartoutTests_iOS.framework */; }; @@ -204,7 +204,7 @@ 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; }; 0EF5CF242141CE58004FF1BD /* HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; 0EFD943D215BE10800529B64 /* IssueReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporter.swift; sourceTree = ""; }; - 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditsViewController.swift; sourceTree = ""; }; + 0EFD943F215BED8E00529B64 /* LabelViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelViewController.swift; sourceTree = ""; }; 28B2E6590DE79C3B403348DC /* Pods-Passepartout-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Passepartout-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Passepartout-iOS/Pods-Passepartout-iOS.debug.xcconfig"; sourceTree = ""; }; 2F14CE1B8BBCB7B187610A9E /* Pods-PassepartoutTests-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.debug.xcconfig"; sourceTree = ""; }; 3E7BC601C2DEB273955334A5 /* Pods-PassepartoutTests-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PassepartoutTests-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-PassepartoutTests-iOS/Pods-PassepartoutTests-iOS.release.xcconfig"; sourceTree = ""; }; @@ -334,7 +334,7 @@ isa = PBXGroup; children = ( 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */, - 0EFD943F215BED8E00529B64 /* CreditsViewController.swift */, + 0EFD943F215BED8E00529B64 /* LabelViewController.swift */, 0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */, 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */, 0ED38AD8213F33150004D387 /* WizardHostViewController.swift */, @@ -818,7 +818,7 @@ 0E2B494220FD16540094784C /* TransientStore.swift in Sources */, 0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */, 0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */, - 0EFD9440215BED8E00529B64 /* CreditsViewController.swift in Sources */, + 0EFD9440215BED8E00529B64 /* LabelViewController.swift in Sources */, 0ED31C2C20CF2D6F0027975F /* ProviderPoolViewController.swift in Sources */, 0E2B494020FCFF990094784C /* Theme+Titles.swift in Sources */, 0E05C5D520D1645F006EE732 /* SettingTableViewCell.swift in Sources */, diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index b2b1b152..73d53ecd 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -182,3 +182,6 @@ "credits.title" = "Credits"; "credits.labels.third_parties" = "Passepartout is a non-official client and is in no way affiliated with OpenVPN Inc.\n\nThe logo is taken from the awesome Circle Icons set by Nick Roach."; + +"disclaimer.title" = "Disclaimer"; +"disclaimer.labels.text" = "Passepartout is a VPN client based on independent work. As such, the developer -while making his best efforts to avoid it- takes no responsibility about any damage caused by the use of this software.\n\nAdditionally, the developer takes no responsibility about data usage, monitoring, logging etc. by the servers you connect to. Passepartout is not even involved in the above choices, as they're part of server-side policies.\n\nFor more information about data usage by third parties, please review the privacy policy of your VPN provider."; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 4e37c50a..116ce83f 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -239,6 +239,16 @@ internal enum L10n { } } + internal enum Disclaimer { + /// Disclaimer + internal static let title = L10n.tr("Localizable", "disclaimer.title") + + internal enum Labels { + /// Passepartout is a VPN client based on independent work. As such, the developer -while making his best efforts to avoid it- takes no responsibility about any damage caused by the use of this software.\n\nAdditionally, the developer takes no responsibility about data usage, monitoring, logging etc. by the servers you connect to. Passepartout is not even involved in the above choices, as they're part of server-side policies.\n\nFor more information about data usage by third parties, please review the privacy policy of your VPN provider. + internal static let text = L10n.tr("Localizable", "disclaimer.labels.text") + } + } + internal enum Endpoint { internal enum Cells {