From 4163c0c7d1a773c8062397cbac5bb05af85c8290 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 26 Nov 2018 16:17:45 +0100 Subject: [PATCH 1/7] Add SwiftGen to credits --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cf38215..b6f608be 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,10 @@ By contributing to this project you are agreeing to the terms stated in the [Con The logo is taken from the awesome Circle Icons set by Nick Roach. -- PIATunnel - © 2018-Present Private Internet Access -- SwiftyBeaver - © 2015 Sebastian Kreutzberger - MBProgressHUD - © 2009-2016 Matej Bukovinski +- PIATunnel - © 2018-Present Private Internet Access +- SwiftGen - © 2018 SwiftGen +- SwiftyBeaver - © 2015 Sebastian Kreutzberger © 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc. From a486cb4265fdf992eb25e6b4de137586e84bd540 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 26 Nov 2018 16:27:15 +0100 Subject: [PATCH 2/7] List licenses/notices in full table --- .../Organizer/CreditsViewController.swift | 108 ++++++++++++++++++ .../Organizer/LabelViewController.swift | 1 - .../Organizer/VersionViewController.swift | 10 -- .../en.lproj/Organizer.storyboard | 81 ++++++++++--- Passepartout.xcodeproj/project.pbxproj | 4 + .../Resources/en.lproj/Localizable.strings | 3 +- Passepartout/Sources/AppConstants.swift | 68 +++++++++-- Passepartout/Sources/SwiftGen+Strings.swift | 12 +- 8 files changed, 243 insertions(+), 44 deletions(-) create mode 100644 Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift new file mode 100644 index 00000000..608ad6ea --- /dev/null +++ b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift @@ -0,0 +1,108 @@ +// +// CreditsViewController.swift +// Passepartout-iOS +// +// Created by Davide De Rosa on 11/26/18. +// Copyright (c) 2018 Davide De Rosa. All rights reserved. +// +// https://github.com/passepartoutvpn +// +// This file is part of Passepartout. +// +// Passepartout is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Passepartout is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Passepartout. If not, see . +// + +import UIKit + +class CreditsViewController: UITableViewController, TableModelHost { + private let licenses = AppConstants.License.all + + private let notices = AppConstants.Notice.all + + // MARK: TableModelHost + + var model: TableModel = TableModel() + + func reloadModel() { + model.add(.licenses) + model.add(.notices) + + model.setHeader(L10n.Credits.Sections.Licenses.header, for: .licenses) + model.setHeader(L10n.Credits.Sections.Notices.header, for: .notices) + + model.set(.license, count: licenses.count, in: .licenses) + model.set(.notice, count: notices.count, in: .notices) + } + + // MARK: UIViewController + + override func viewDidLoad() { + super.viewDidLoad() + + title = L10n.Credits.title + reloadModel() + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + guard let vc = segue.destination as? LabelViewController else { + return + } + guard let cell = sender as? SettingTableViewCell else { + return + } + vc.title = cell.leftText + } +} + +extension CreditsViewController { + enum SectionType: Int { + case licenses + + case notices + } + + enum RowType: Int { + case license + + case notice + } + + override func numberOfSections(in tableView: UITableView) -> Int { + return model.count + } + + override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return model.header(for: section) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return model.count(for: section) + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + switch model.row(at: indexPath) { + case .license: + let obj = licenses[indexPath.row] + cell.leftText = obj.name + cell.rightText = obj.type + + case .notice: + let obj = notices[indexPath.row] + cell.leftText = obj.name + cell.rightText = nil + } + return cell + } +} diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index e5344dea..3a2a0f4c 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -41,7 +41,6 @@ class LabelViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - title = L10n.Credits.title label?.text = text scrollView?.applyPrimaryBackground(Theme.current) diff --git a/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift index 0f0993fe..d412bbe7 100644 --- a/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/VersionViewController.swift @@ -65,14 +65,4 @@ class VersionViewController: UIViewController { @IBAction private func visitChangelog() { UIApplication.shared.open(AppConstants.URLs.changelog, options: [:], completionHandler: nil) } - - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - guard let vc = segue.destination as? LabelViewController else { - return - } - vc.title = L10n.Credits.title - var notices = AppConstants.Notices.all - notices.insert(L10n.Credits.Labels.thirdParties, at: 0) - vc.text = notices.joined(separator: "\n\n") - } } diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard index a2ef1afc..2818c92a 100644 --- a/Passepartout-iOS/en.lproj/Organizer.storyboard +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -1,11 +1,11 @@ - + - + @@ -13,13 +13,13 @@ - + - + @@ -80,13 +80,13 @@ - + - + @@ -103,7 +103,7 @@ - + @@ -164,13 +164,13 @@ - + - + @@ -250,13 +250,13 @@ - + - + @@ -319,7 +319,7 @@ - + @@ -367,7 +367,7 @@ - + @@ -433,6 +433,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -452,13 +499,13 @@ - + - + @@ -506,7 +553,7 @@ - + @@ -569,7 +616,7 @@ - + diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj index c58abb03..75cd62e6 100644 --- a/Passepartout.xcodeproj/project.pbxproj +++ b/Passepartout.xcodeproj/project.pbxproj @@ -86,6 +86,7 @@ 0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF56BBA2185AC8500B0C8AB /* SwiftGen+Segues.swift */; }; 0EF5CF252141CE58004FF1BD /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EF5CF242141CE58004FF1BD /* HUD.swift */; }; 0EF5CF292141F31F004FF1BD /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E4FD7ED20D539A0002221FF /* Utils.swift */; }; + 0EFBFAC121AC464800887A8C /* CreditsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFBFAC021AC464800887A8C /* CreditsViewController.swift */; }; 0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EFD943D215BE10800529B64 /* IssueReporter.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 */; }; @@ -211,6 +212,7 @@ 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = ""; }; 0EF56BBA2185AC8500B0C8AB /* SwiftGen+Segues.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Segues.swift"; sourceTree = ""; }; 0EF5CF242141CE58004FF1BD /* HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; + 0EFBFAC021AC464800887A8C /* CreditsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditsViewController.swift; sourceTree = ""; }; 0EFD943D215BE10800529B64 /* IssueReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueReporter.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 = ""; }; @@ -341,6 +343,7 @@ isa = PBXGroup; children = ( 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */, + 0EFBFAC021AC464800887A8C /* CreditsViewController.swift */, 0EB67D6A2184581E00BA6200 /* ImportedHostsViewController.swift */, 0EFD943F215BED8E00529B64 /* LabelViewController.swift */, 0EBE3A78213C4E5400BFA2F5 /* OrganizerViewController.swift */, @@ -849,6 +852,7 @@ 0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */, 0E89DFC8213E8FC500741BA1 /* SessionProxy+Communication.swift in Sources */, 0ED38AEA214054A50004D387 /* OptionViewController.swift in Sources */, + 0EFBFAC121AC464800887A8C /* CreditsViewController.swift in Sources */, 0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */, 0EB60FDA2111136E00AD27F3 /* UITextView+Search.swift in Sources */, 0EB67D6B2184581E00BA6200 /* ImportedHostsViewController.swift in Sources */, diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 583757bc..22cc4b7c 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -206,4 +206,5 @@ "version.buttons.credits" = "CREDITS"; "credits.title" = "Credits"; -"credits.labels.third_parties" = "The logo is taken from the awesome Circle Icons set by Nick Roach."; +"credits.sections.licenses.header" = "Licenses"; +"credits.sections.notices.header" = "Notices"; diff --git a/Passepartout/Sources/AppConstants.swift b/Passepartout/Sources/AppConstants.swift index a3002ba3..e557ef45 100644 --- a/Passepartout/Sources/AppConstants.swift +++ b/Passepartout/Sources/AppConstants.swift @@ -169,23 +169,67 @@ class AppConstants { static let api = githubRaw(repo: "passepartout-api") } - class Notices { - private static let pia = "PIATunnel - Copyright (c) 2018-Present Private Internet Access" + struct License { + let name: String - private static let swiftyBeaver = "SwiftyBeaver - Copyright (c) 2015 Sebastian Kreutzberger" + let type: String - private static let progressHUD = "MBProgressHUD - Copyright (c) 2009-2016 Matej Bukovinski" + let url: URL - private static let openVPN = "© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc." + init(_ name: String, _ type: String, _ urlString: String) { + self.name = name + self.type = type + url = URL(string: urlString)! + } - private static let openSSL = "This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. https://www.openssl.org/" + static let all: [License] = [ + License( + "MBProgressHUD", + "MIT", + "https://raw.githubusercontent.com/jdg/MBProgressHUD/master/LICENSE" + ), + License( + "OpenSSL", + "OpenSSL", + "https://www.openssl.org/source/license.txt" + ), + License( + "PIATunnel", + "MIT", + "https://raw.githubusercontent.com/pia-foss/tunnel-apple/master/LICENSE" + ), + License( + "SwiftGen", + "MIT", + "https://raw.githubusercontent.com/SwiftGen/SwiftGen/master/LICENSE" + ), + License( + "SwiftyBeaver", + "MIT", + "https://raw.githubusercontent.com/SwiftyBeaver/SwiftyBeaver/master/LICENSE" + ) + ] + } + + struct Notice { + let name: String - static let all: [String] = [ - pia, - swiftyBeaver, - progressHUD, - openVPN, - openSSL + let statement: String + + init(_ name: String, _ statement: String) { + self.name = name + self.statement = statement + } + + static let all: [Notice] = [ + Notice( + "Circle Icons", + "The logo is taken from the awesome Circle Icons set by Nick Roach." + ), + Notice( + "OpenVPN", + "© 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc." + ) ] } } diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 01bb24dd..c3e6255c 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -192,9 +192,15 @@ internal enum L10n { internal enum Credits { /// Credits internal static let title = L10n.tr("Localizable", "credits.title") - internal enum Labels { - /// The logo is taken from the awesome Circle Icons set by Nick Roach. - internal static let thirdParties = L10n.tr("Localizable", "credits.labels.third_parties") + internal enum Sections { + internal enum Licenses { + /// Licenses + internal static let header = L10n.tr("Localizable", "credits.sections.licenses.header") + } + internal enum Notices { + /// Notices + internal static let header = L10n.tr("Localizable", "credits.sections.notices.header") + } } } From 8270c20179d00a440fe3f2e4ba0a380a6b3f64f1 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 26 Nov 2018 17:18:58 +0100 Subject: [PATCH 3/7] Fetch license content via URL --- .../Scenes/Organizer/CreditsViewController.swift | 9 ++++++++- .../Scenes/Organizer/LabelViewController.swift | 14 +++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift index 608ad6ea..4abab9d5 100644 --- a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift @@ -58,10 +58,17 @@ class CreditsViewController: UITableViewController, TableModelHost { guard let vc = segue.destination as? LabelViewController else { return } - guard let cell = sender as? SettingTableViewCell else { + guard let cell = sender as? SettingTableViewCell, let indexPath = tableView.indexPath(for: cell) else { return } vc.title = cell.leftText + switch model.row(at: indexPath) { + case .license: + vc.url = licenses[indexPath.row].url + + case .notice: + vc.text = notices[indexPath.row].statement + } } } diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index 3a2a0f4c..078bb475 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -32,6 +32,8 @@ class LabelViewController: UIViewController { var text: String? + var url: URL? + override func awakeFromNib() { super.awakeFromNib() @@ -41,7 +43,17 @@ class LabelViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - label?.text = text + if let url = url { + label?.text = nil + DispatchQueue(label: LabelViewController.description(), qos: .background).async { [weak self] in + let urlText = try? String(contentsOf: url) + DispatchQueue.main.async { + self?.label?.text = urlText + } + } + } else { + label?.text = text + } scrollView?.applyPrimaryBackground(Theme.current) label?.applyLight(Theme.current) From d2ba821c8f5bb228e91f73c8563ae40b7bb24501 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 30 Nov 2018 20:39:28 +0100 Subject: [PATCH 4/7] Add OpenSSL statement in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b6f608be..c3b590df 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ The logo is taken from the awesome Circle Icons set by Nick Roach. - SwiftGen - © 2018 SwiftGen - SwiftyBeaver - © 2015 Sebastian Kreutzberger +This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. ([https://www.openssl.org/][dep-openssl]) + © 2002-2018 OpenVPN Inc. - OpenVPN is a registered trademark of OpenVPN Inc. ## Usage From 534f1e209439b5b236a4dbcb0d34fb45edae7a27 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 1 Dec 2018 09:02:33 +0100 Subject: [PATCH 5/7] Show activity indicator while loading license --- Passepartout-iOS/Global/Theme.swift | 6 ++++++ .../Scenes/Organizer/LabelViewController.swift | 8 ++++++++ Passepartout-iOS/en.lproj/Organizer.storyboard | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/Passepartout-iOS/Global/Theme.swift b/Passepartout-iOS/Global/Theme.swift index fc046b0f..25d4113a 100644 --- a/Passepartout-iOS/Global/Theme.swift +++ b/Passepartout-iOS/Global/Theme.swift @@ -136,6 +136,12 @@ extension UITextField { } } +extension UIActivityIndicatorView { + func applyAccent(_ theme: Theme) { + color = theme.palette.colorAccent1 + } +} + // XXX: status bar is broken extension MFMailComposeViewController { func apply(_ theme: Theme) { diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index 078bb475..8894f6db 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -28,6 +28,8 @@ import UIKit class LabelViewController: UIViewController { @IBOutlet private weak var scrollView: UIScrollView? + @IBOutlet private weak var activity: UIActivityIndicatorView? + @IBOutlet private weak var label: UILabel? var text: String? @@ -43,12 +45,18 @@ class LabelViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + activity?.hidesWhenStopped = true + activity?.applyAccent(Theme.current) + if let url = url { label?.text = nil + activity?.startAnimating() + DispatchQueue(label: LabelViewController.description(), qos: .background).async { [weak self] in let urlText = try? String(contentsOf: url) DispatchQueue.main.async { self?.label?.text = urlText + self?.activity?.stopAnimating() } } } else { diff --git a/Passepartout-iOS/en.lproj/Organizer.storyboard b/Passepartout-iOS/en.lproj/Organizer.storyboard index 2818c92a..94f21074 100644 --- a/Passepartout-iOS/en.lproj/Organizer.storyboard +++ b/Passepartout-iOS/en.lproj/Organizer.storyboard @@ -599,10 +599,15 @@ + + + + + @@ -610,6 +615,7 @@ + From afcb45c614d2347f53800f7c2d70d4c3da7a1371 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 4 Dec 2018 10:41:33 +0100 Subject: [PATCH 6/7] Cache fetched license content And show an error message when unable to fetch license URL. --- .../Organizer/CreditsViewController.swift | 2 +- .../Organizer/LabelViewController.swift | 32 +++++++++++++++---- .../Resources/en.lproj/Localizable.strings | 2 ++ Passepartout/Sources/AppConstants.swift | 4 ++- Passepartout/Sources/SwiftGen+Strings.swift | 7 ++++ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift index 4abab9d5..6186fe41 100644 --- a/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/CreditsViewController.swift @@ -64,7 +64,7 @@ class CreditsViewController: UITableViewController, TableModelHost { vc.title = cell.leftText switch model.row(at: indexPath) { case .license: - vc.url = licenses[indexPath.row].url + vc.license = licenses[indexPath.row] case .notice: vc.text = notices[indexPath.row].statement diff --git a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift index 8894f6db..31950336 100644 --- a/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift +++ b/Passepartout-iOS/Scenes/Organizer/LabelViewController.swift @@ -34,7 +34,7 @@ class LabelViewController: UIViewController { var text: String? - var url: URL? + var license: AppConstants.License? override func awakeFromNib() { super.awakeFromNib() @@ -47,23 +47,41 @@ class LabelViewController: UIViewController { activity?.hidesWhenStopped = true activity?.applyAccent(Theme.current) + scrollView?.applyPrimaryBackground(Theme.current) + label?.applyLight(Theme.current) - if let url = url { + if let license = license { + + // try cache first + if let cachedContent = AppConstants.License.cachedContent[license.name] { + label?.text = cachedContent + return + } + label?.text = nil activity?.startAnimating() DispatchQueue(label: LabelViewController.description(), qos: .background).async { [weak self] in - let urlText = try? String(contentsOf: url) + let content: String + let couldFetch: Bool + do { + content = try String(contentsOf: license.url) + couldFetch = true + } catch { + content = L10n.Label.License.error + couldFetch = false + } DispatchQueue.main.async { - self?.label?.text = urlText + self?.label?.text = content self?.activity?.stopAnimating() + + if couldFetch { + AppConstants.License.cachedContent[license.name] = content + } } } } else { label?.text = text } - - scrollView?.applyPrimaryBackground(Theme.current) - label?.applyLight(Theme.current) } } diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index 22cc4b7c..c676bbc5 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -208,3 +208,5 @@ "credits.title" = "Credits"; "credits.sections.licenses.header" = "Licenses"; "credits.sections.notices.header" = "Notices"; + +"label.license.error" = "Unable to download full license content."; diff --git a/Passepartout/Sources/AppConstants.swift b/Passepartout/Sources/AppConstants.swift index e557ef45..a226d3fb 100644 --- a/Passepartout/Sources/AppConstants.swift +++ b/Passepartout/Sources/AppConstants.swift @@ -175,7 +175,7 @@ class AppConstants { let type: String let url: URL - + init(_ name: String, _ type: String, _ urlString: String) { self.name = name self.type = type @@ -209,6 +209,8 @@ class AppConstants { "https://raw.githubusercontent.com/SwiftyBeaver/SwiftyBeaver/master/LICENSE" ) ] + + static var cachedContent: [String: String] = [:] } struct Notice { diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index c3e6255c..cf2b1ef9 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -293,6 +293,13 @@ internal enum L10n { } } + internal enum Label { + internal enum License { + /// Unable to download full license content. + internal static let error = L10n.tr("Localizable", "label.license.error") + } + } + internal enum Organizer { internal enum Alerts { internal enum AddHost { From 9fa26b340fa4623b40358100b77292afd8f2fa79 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 4 Dec 2018 10:47:12 +0100 Subject: [PATCH 7/7] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82b32c78..b828ffc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.0 RC4 1271 (2018-12-04) + +### Changed + +- Reorganized credits page. + ## 1.0 RC3 1258 (2018-11-15) ### Changed