From 0582b5d3d3254f78cf42078e664ded0d0520b66e Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Thu, 3 Aug 2023 12:13:27 -0400 Subject: [PATCH 1/3] Testable Changes --- .../Settings/SettingsViewController.swift | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Sources/Brave/Frontend/Settings/SettingsViewController.swift b/Sources/Brave/Frontend/Settings/SettingsViewController.swift index e8b5852b8cb..544dfc6f7d3 100644 --- a/Sources/Brave/Frontend/Settings/SettingsViewController.swift +++ b/Sources/Brave/Frontend/Settings/SettingsViewController.swift @@ -565,18 +565,25 @@ class SettingsViewController: TableViewController { selection: { [unowned self] in let vc = { () -> UIViewController? in - switch BraveVPN.vpnState { - case .notPurchased, .expired: - return BraveVPN.vpnState.enableVPNDestinationVC - case .purchased: - let vc = BraveVPNSettingsViewController() - vc.openURL = { [unowned self] url in - self.settingsDelegate?.settingsOpenURLInNewTab(url) - self.dismiss(animated: true) - } - - return vc + let vc = BraveVPNSettingsViewController() + vc.openURL = { [unowned self] url in + self.settingsDelegate?.settingsOpenURLInNewTab(url) + self.dismiss(animated: true) } + return vc + +// switch BraveVPN.vpnState { +// case .notPurchased, .expired: +// return BraveVPN.vpnState.enableVPNDestinationVC +// case .purchased: +// let vc = BraveVPNSettingsViewController() +// vc.openURL = { [unowned self] url in +// self.settingsDelegate?.settingsOpenURLInNewTab(url) +// self.dismiss(animated: true) +// } +// +// return vc +// } }() guard let vcToShow = vc else { return } From 781f6da9cbcf5c603a5338e63ebed6f264f06bb4 Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Thu, 3 Aug 2023 15:57:02 -0400 Subject: [PATCH 2/3] Adding Issue selection as second step and forcing user to add the issue --- .../BraveVPNContactFormViewController.swift | 81 +++++++++---------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/Sources/BraveVPN/BraveVPNContactFormViewController.swift b/Sources/BraveVPN/BraveVPNContactFormViewController.swift index bc899a4e2a0..6b9ef4fe727 100644 --- a/Sources/BraveVPN/BraveVPNContactFormViewController.swift +++ b/Sources/BraveVPN/BraveVPNContactFormViewController.swift @@ -207,59 +207,27 @@ class BraveVPNContactFormViewController: TableViewController { } })), cellClass: MultilineSubtitleCell.self) - var section = Section(rows: [ + let section = Section(rows: [ hostnameRow, tunnelProtocolRow, subscriptionTypeRow, receiptRow, appVersionRow, timezoneRow, networkTypeRow, carrierRow, errorLogs ]) - // MARK: Issue - var issueRow = - Row( - text: Strings.VPN.contactFormIssue, detailText: IssueType.other.displayString, - accessory: .disclosureIndicator, cellClass: MultilineSubtitleCell.self) - - let optionChanged = { - [weak self] - (vc: OptionSelectionViewController, option: IssueType) -> Void in - self?.dataSource.reloadCell(row: issueRow, section: section, displayText: option.displayString) - self?.contactForm.issue = option.displayString ?? IssueType.other.displayString - } - - issueRow.selection = { [weak self] in - let optionsVC = - OptionSelectionViewController( - options: IssueType.allCases, - optionChanged: optionChanged) - - self?.navigationController?.pushViewController(optionsVC, animated: true) - } - - section.rows.append(issueRow) - let sendButton = Row( text: Strings.VPN.contactFormSendButton, selection: { [weak self] in guard let self = self else { return } - if !MFMailComposeViewController.canSendMail() { - Logger.module.error("Can't send email on this device") - let alert = UIAlertController( - title: Strings.genericErrorTitle, - message: Strings.VPN.contactFormEmailNotConfiguredBody, - preferredStyle: .alert) - let okAction = UIAlertAction(title: Strings.OKString, style: .default) - alert.addAction(okAction) - self.present(alert, animated: true) - return - } - - let mail = MFMailComposeViewController().then { - $0.mailComposeDelegate = self - $0.setToRecipients([self.supportEmail]) - } - - mail.setSubject(Strings.VPN.contactFormTitle) - mail.setMessageBody(self.composeEmailBody(with: self.contactForm), isHTML: false) - self.present(mail, animated: true) + let optionChanged = { [weak self] (vc: OptionSelectionViewController, option: IssueType) -> Void in + self?.contactForm.issue = option.displayString + self?.createEmailOutline() + } + + let optionsVC = + OptionSelectionViewController( + options: IssueType.allCases, + optionChanged: optionChanged) + + self.navigationController?.pushViewController(optionsVC, animated: true) + }, cellClass: CenteredButtonCell.self) let footerText = @@ -268,6 +236,29 @@ class BraveVPNContactFormViewController: TableViewController { dataSource.sections = [section, buttonSection] } + + private func createEmailOutline() { + if !MFMailComposeViewController.canSendMail() { + Logger.module.error("Can't send email on this device") + let alert = UIAlertController( + title: Strings.genericErrorTitle, + message: Strings.VPN.contactFormEmailNotConfiguredBody, + preferredStyle: .alert) + let okAction = UIAlertAction(title: Strings.OKString, style: .default) + alert.addAction(okAction) + present(alert, animated: true) + return + } + + let mail = MFMailComposeViewController().then { + $0.mailComposeDelegate = self + $0.setToRecipients([self.supportEmail]) + } + + mail.setSubject(Strings.VPN.contactFormTitle) + mail.setMessageBody(self.composeEmailBody(with: self.contactForm), isHTML: false) + present(mail, animated: true) + } private var getNetworkType: String { let status = Reach().connectionStatus() From 2f0d075e5d0489c636f627f2d6e8fd4e4195ea4e Mon Sep 17 00:00:00 2001 From: Soner Yuksel Date: Thu, 3 Aug 2023 16:55:46 -0400 Subject: [PATCH 3/3] Adding description to issue section screen details --- .../Settings/SettingsViewController.swift | 29 +++++++------------ Sources/BraveStrings/BraveStrings.swift | 5 ++++ .../BraveVPNContactFormViewController.swift | 29 ++++++++++++------- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Sources/Brave/Frontend/Settings/SettingsViewController.swift b/Sources/Brave/Frontend/Settings/SettingsViewController.swift index 544dfc6f7d3..e8b5852b8cb 100644 --- a/Sources/Brave/Frontend/Settings/SettingsViewController.swift +++ b/Sources/Brave/Frontend/Settings/SettingsViewController.swift @@ -565,25 +565,18 @@ class SettingsViewController: TableViewController { selection: { [unowned self] in let vc = { () -> UIViewController? in - let vc = BraveVPNSettingsViewController() - vc.openURL = { [unowned self] url in - self.settingsDelegate?.settingsOpenURLInNewTab(url) - self.dismiss(animated: true) + switch BraveVPN.vpnState { + case .notPurchased, .expired: + return BraveVPN.vpnState.enableVPNDestinationVC + case .purchased: + let vc = BraveVPNSettingsViewController() + vc.openURL = { [unowned self] url in + self.settingsDelegate?.settingsOpenURLInNewTab(url) + self.dismiss(animated: true) + } + + return vc } - return vc - -// switch BraveVPN.vpnState { -// case .notPurchased, .expired: -// return BraveVPN.vpnState.enableVPNDestinationVC -// case .purchased: -// let vc = BraveVPNSettingsViewController() -// vc.openURL = { [unowned self] url in -// self.settingsDelegate?.settingsOpenURLInNewTab(url) -// self.dismiss(animated: true) -// } -// -// return vc -// } }() guard let vcToShow = vc else { return } diff --git a/Sources/BraveStrings/BraveStrings.swift b/Sources/BraveStrings/BraveStrings.swift index feecdcc3f31..ab4d630719e 100644 --- a/Sources/BraveStrings/BraveStrings.swift +++ b/Sources/BraveStrings/BraveStrings.swift @@ -2883,6 +2883,11 @@ extension Strings { NSLocalizedString("vpn.contactFormIssue", tableName: "BraveShared", bundle: .module, value: "Issue", comment: "Specific issue field for customer support contact form.") + + public static let contactFormIssueDescription = + NSLocalizedString("vpn.contactFormIssueDescription", tableName: "BraveShared", bundle: .module, + value: "Please choose the cetagory that describes the issue.", + comment: "Description used for specific issue field for customer support contact form.") public static let contactFormFooterSharedWithGuardian = NSLocalizedString("vpn.contactFormFooterSharedWithGuardian", tableName: "BraveShared", bundle: .module, diff --git a/Sources/BraveVPN/BraveVPNContactFormViewController.swift b/Sources/BraveVPN/BraveVPNContactFormViewController.swift index 6b9ef4fe727..ef8edab34c1 100644 --- a/Sources/BraveVPN/BraveVPNContactFormViewController.swift +++ b/Sources/BraveVPN/BraveVPNContactFormViewController.swift @@ -223,6 +223,8 @@ class BraveVPNContactFormViewController: TableViewController { let optionsVC = OptionSelectionViewController( + headerText: Strings.VPN.contactFormIssue, + footerText: Strings.VPN.contactFormIssueDescription, options: IssueType.allCases, optionChanged: optionChanged) @@ -255,7 +257,12 @@ class BraveVPNContactFormViewController: TableViewController { $0.setToRecipients([self.supportEmail]) } - mail.setSubject(Strings.VPN.contactFormTitle) + var formTitle = Strings.VPN.contactFormTitle + if let issue = contactForm.issue { + formTitle += " + \(issue)" + } + + mail.setSubject(formTitle) mail.setMessageBody(self.composeEmailBody(with: self.contactForm), isHTML: false) present(mail, animated: true) } @@ -282,10 +289,18 @@ class BraveVPNContactFormViewController: TableViewController { } private func composeEmailBody(with contactForm: ContactForm) -> String { - var body = "\n\n" + var body = "\n" body.append(contentsOf: "#### \(Strings.VPN.contactFormDoNotEditText) ####\n\n") + body.append(Strings.VPN.contactFormPlatform) + body.append("\n\(UIDevice.current.systemName)\n\n") + + if let issue = contactForm.issue { + body.append(Strings.VPN.contactFormIssue) + body.append("\n\(issue)\n\n") + } + if let hostname = contactForm.hostname { body.append(Strings.VPN.contactFormHostname) body.append("\n\(hostname)\n\n") @@ -305,10 +320,7 @@ class BraveVPNContactFormViewController: TableViewController { body.append(Strings.VPN.contactFormAppVersion) body.append("\n\(appVersion)\n\n") } - - body.append(Strings.VPN.contactFormPlatform) - body.append("\n\(UIDevice.current.systemName)\n\n") - + if let timezone = contactForm.timezone { body.append(Strings.VPN.contactFormTimezone) body.append("\n\(timezone)\n\n") @@ -337,11 +349,6 @@ class BraveVPNContactFormViewController: TableViewController { body.append("\n") } - if let issue = contactForm.issue { - body.append(Strings.VPN.contactFormIssue) - body.append("\n\(issue)\n\n") - } - if let receipt = contactForm.receipt { body.append(Strings.VPN.contactFormAppStoreReceipt) body.append("\n\(receipt)\n\n")