Merge branch 'add-sharing-to-about'

This commit is contained in:
Davide De Rosa 2018-10-23 12:59:11 +02:00
commit 1048b558f6
5 changed files with 97 additions and 28 deletions

View File

@ -33,13 +33,16 @@ class AboutViewController: UITableViewController, TableModelHost {
let model: TableModel<SectionType, RowType> = TableModel()
model.add(.info)
model.add(.source)
model.add(.share)
model.add(.feedback)
model.setHeader(L10n.About.Sections.Info.header, for: .info)
model.setHeader(L10n.About.Sections.Source.header, for: .source)
model.setHeader(L10n.About.Sections.Share.header, for: .share)
model.setHeader(L10n.About.Sections.Feedback.header, for: .feedback)
model.set([.version, .credits, .disclaimer, .website], in: .info)
model.set([.sourcePassepartout, .sourceTunnelKit], in: .source)
model.set([.requestSupport, .submitDebugLog, .writeReview], in: .feedback)
model.set([.shareTwitter, .shareGeneric], in: .share)
model.set([.requestSupport, .writeReview], in: .feedback)
return model
}()
@ -82,12 +85,19 @@ class AboutViewController: UITableViewController, TableModelHost {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
private func requestRedditSupport() {
UIApplication.shared.open(AppConstants.URLs.subreddit, options: [:], completionHandler: nil)
private func tweetAboutApp() {
UIApplication.shared.open(AppConstants.URLs.twitterIntent, options: [:], completionHandler: nil)
}
private func reportIssue() {
IssueReporter.shared.present(in: self)
private func inviteFriend(sender: UITableViewCell?) {
let message = "\(L10n.Share.message) \(AppConstants.URLs.website)"
let vc = UIActivityViewController(activityItems: [message], applicationActivities: nil)
vc.popoverPresentationController?.sourceView = sender
present(vc, animated: true, completion: nil)
}
private func postSupportRequest() {
UIApplication.shared.open(AppConstants.URLs.subreddit, options: [:], completionHandler: nil)
}
private func writeReview() {
@ -130,6 +140,8 @@ extension AboutViewController {
case source
case share
case feedback
}
@ -146,10 +158,12 @@ extension AboutViewController {
case sourceTunnelKit
case shareTwitter
case shareGeneric
case requestSupport
case submitDebugLog
case writeReview
}
@ -202,16 +216,21 @@ extension AboutViewController {
cell.leftText = GroupConstants.App.tunnelKitName
return cell
case .shareTwitter:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.ShareTwitter.caption
return cell
case .shareGeneric:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.ShareGeneric.caption
return cell
case .requestSupport:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.RequestSupport.caption
return cell
case .submitDebugLog:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.IssueReporter.title
return cell
case .writeReview:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.About.Cells.WriteReview.caption
@ -239,11 +258,14 @@ extension AboutViewController {
case .sourceTunnelKit:
visitRepository(AppConstants.Repos.tunnelKit)
case .requestSupport:
requestRedditSupport()
case .shareTwitter:
tweetAboutApp()
case .submitDebugLog:
reportIssue()
case .shareGeneric:
inviteFriend(sender: tableView.cellForRow(at: indexPath))
case .requestSupport:
postSupportRequest()
case .writeReview:
writeReview()

View File

@ -354,11 +354,11 @@ class ServiceViewController: UIViewController, TableModelHost {
}
}
private func requestRedditSupport() {
private func postSupportRequest() {
UIApplication.shared.open(AppConstants.URLs.subreddit, options: [:], completionHandler: nil)
}
private func reportIssue() {
private func reportConnectivityIssue() {
IssueReporter.shared.present(in: self)
}
@ -441,7 +441,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
case requestSupport
case submitDebugLog
case reportIssue
}
private var trustedSectionIndex: Int {
@ -662,9 +662,9 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
cell.leftText = L10n.About.Cells.RequestSupport.caption
return cell
case .submitDebugLog:
case .reportIssue:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.IssueReporter.title
cell.leftText = L10n.Service.Cells.ReportIssue.caption
return cell
}
}
@ -761,10 +761,10 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
return true
case .requestSupport:
requestRedditSupport()
postSupportRequest()
case .submitDebugLog:
reportIssue()
case .reportIssue:
reportConnectivityIssue()
default:
break
@ -888,7 +888,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
model.set([.vpnSurvivesSleep], in: .vpnSurvivesSleep)
model.set([.trustedPolicy], in: .trustedPolicy)
model.set([.testConnectivity, .dataCount, .debugLog], in: .diagnostics)
model.set([.requestSupport, .submitDebugLog], in: .feedback)
model.set([.requestSupport, .reportIssue], in: .feedback)
}
trustedNetworks.delegate = self

View File

@ -97,6 +97,7 @@
"service.cells.test_connectivity.caption" = "Test connectivity";
"service.cells.data_count.caption" = "Exchanged bytes count";
"service.cells.debug_log.caption" = "Debug log";
"service.cells.report_issue.caption" = "Report connectivity issue";
"service.alerts.credentials_needed.message" = "You need to enter account credentials first.";
"service.alerts.reconnect_vpn.message" = "Do you want to reconnect to the VPN?";
@ -169,7 +170,7 @@
"vpn.errors.dns" = "DNS failed";
"vpn.errors.network" = "Network changed";
"issue_reporter.title" = "Submit debug log";
"issue_reporter.title" = "Report issue";
"issue_reporter.message" = "The debug log of your latest connections is crucial to resolve your connectivity issues and is completely anonymous.";
"issue_reporter.buttons.accept" = "I understand";
"issue_reporter.alerts.email_not_configured.message" = "No e-mail account is configured.";
@ -179,11 +180,16 @@
"about.title" = "About";
"about.sections.info.header" = "General";
"about.sections.source.header" = "Source code";
"about.sections.share.header" = "Share";
"about.sections.feedback.header" = "Feedback";
"about.cells.version.caption" = "Version";
"about.cells.website.caption" = "Visit website";
"about.cells.share_twitter.caption" = "Tweet about it!";
"about.cells.share_generic.caption" = "Invite a friend";
"about.cells.request_support.caption" = "Request support";
"about.cells.write_review.caption" = "Write a review";
"about.cells.website.caption" = "Visit website";
"share.message" = "Passepartout is an user-friendly, open source OpenVPN client for iOS and macOS";
"version.labels.intro" = "Passepartout and TunnelKit are written and maintained by Davide De Rosa (keeshux).\n\nTunnelKit is a native OpenVPN client originally forked from PIATunnel by Private Internet Access.\n\nSource code for Passepartout and TunnelKit is publicly available on GitHub under the GPLv3.";
"version.buttons.changelog" = "CHANGELOG";

View File

@ -115,6 +115,22 @@ class AppConstants {
static let subreddit = URL(string: "https://www.reddit.com/r/passepartout")!
private static let twitterHashtags = ["OpenVPN", "iOS", "macOS"]
static var twitterIntent: URL {
var text = L10n.Share.message
for ht in twitterHashtags {
text = text.replacingOccurrences(of: ht, with: "#\(ht)")
}
var comps = URLComponents(string: "https://twitter.com/intent/tweet")!
comps.queryItems = [
URLQueryItem(name: "url", value: website.absoluteString),
URLQueryItem(name: "via", value: "keeshux"),
URLQueryItem(name: "text", value: text)
]
return comps.url!
}
static func review(withId id: String) -> URL {
return URL(string: "https://itunes.apple.com/app/id\(id)?action=write-review")!
}

View File

@ -19,6 +19,16 @@ internal enum L10n {
internal static let caption = L10n.tr("Localizable", "about.cells.request_support.caption")
}
internal enum ShareGeneric {
/// Invite a friend
internal static let caption = L10n.tr("Localizable", "about.cells.share_generic.caption")
}
internal enum ShareTwitter {
/// Tweet about it!
internal static let caption = L10n.tr("Localizable", "about.cells.share_twitter.caption")
}
internal enum Version {
/// Version
internal static let caption = L10n.tr("Localizable", "about.cells.version.caption")
@ -47,6 +57,11 @@ internal enum L10n {
internal static let header = L10n.tr("Localizable", "about.sections.info.header")
}
internal enum Share {
/// Share
internal static let header = L10n.tr("Localizable", "about.sections.share.header")
}
internal enum Source {
/// Source code
internal static let header = L10n.tr("Localizable", "about.sections.source.header")
@ -293,7 +308,7 @@ internal enum L10n {
internal enum IssueReporter {
/// The debug log of your latest connections is crucial to resolve your connectivity issues and is completely anonymous.
internal static let message = L10n.tr("Localizable", "issue_reporter.message")
/// Submit debug log
/// Report issue
internal static let title = L10n.tr("Localizable", "issue_reporter.title")
internal enum Alerts {
@ -557,6 +572,11 @@ internal enum L10n {
internal static let caption = L10n.tr("Localizable", "service.cells.reconnect.caption")
}
internal enum ReportIssue {
/// Report connectivity issue
internal static let caption = L10n.tr("Localizable", "service.cells.report_issue.caption")
}
internal enum TestConnectivity {
/// Test connectivity
internal static let caption = L10n.tr("Localizable", "service.cells.test_connectivity.caption")
@ -665,6 +685,11 @@ internal enum L10n {
}
}
internal enum Share {
/// Passepartout is an user-friendly, open source OpenVPN client for iOS and macOS
internal static let message = L10n.tr("Localizable", "share.message")
}
internal enum Version {
internal enum Buttons {