From ffde687d50c46023994e542ac83fa5d685d0e852 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 11 Mar 2025 20:00:36 -0400 Subject: [PATCH] Use JSON attachment for email feedback technical information. #1823 --- Resources/en.lproj/Localizable.strings | 1 - Sources/About/AboutController.swift | 43 ++++++++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 05401c5a2..76e4e836e 100644 --- a/Resources/en.lproj/Localizable.strings +++ b/Resources/en.lproj/Localizable.strings @@ -545,7 +545,6 @@ "FORCE_RESCAN_MESSAGE" = "Do you want to force VLC to rescan your media library?\nIt could take some time."; "FEEDBACK_EMAIL_TITLE" = "Feedback about VLC on iOS and iPad"; -"FEEDBACK_EMAIL_BODY" = "Please enter your feedback above this line.\n\nAnonymous information:"; "FEEDBACK_EMAIL_NOT_POSSIBLE_TITLE" = "Mail account not configured"; "FEEDBACK_EMAIL_NOT_POSSIBLE_LONG" = "Contact us through %@ from another device."; diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 3072c947a..5c2df1a0c 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -166,7 +166,9 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI mailComposerVC.mailComposeDelegate = self mailComposerVC.setToRecipients([feedbackEmail]) mailComposerVC.setSubject(NSLocalizedString("FEEDBACK_EMAIL_TITLE", comment: "")) - mailComposerVC.setMessageBody(generateFeedbackEmailPrefill(), isHTML: false) + mailComposerVC.addAttachmentData(generateFeedbackEmailAttachment(), + mimeType: "application/json", + fileName: "details.json") self.present(mailComposerVC, animated: true) } else { let alert = UIAlertController(title: NSLocalizedString("FEEDBACK_EMAIL_NOT_POSSIBLE_TITLE", comment: ""), @@ -178,26 +180,33 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI } } - func generateFeedbackEmailPrefill() -> String { + func generateFeedbackEmailAttachment() -> Data { let bundleShortVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String let device = UIDevice.current let defaults = UserDefaults.standard let locale = NSLocale.autoupdatingCurrent - let prefilledFeedback = String(format: "\n\n\n----------------------------------------\n%@\nDevice: %@\nOS: %@ - %@\nLocale: %@ (%@)\nVLC app version: %@\nlibvlc version: %@\nhardware decoding: %i\nnetwork caching level: %i\nskip loop filter: %i\nRTSP over TCP: %i\nAudio time stretching: %i", - NSLocalizedString("FEEDBACK_EMAIL_BODY", comment: ""), - generateDeviceIdentifier(), - device.systemName, - device.systemVersion, - locale.languageCode!, - locale.regionCode!, - bundleShortVersionString, - VLCLibrary.shared().changeset, - defaults.integer(forKey: kVLCSettingHardwareDecoding), - defaults.integer(forKey: kVLCSettingNetworkCaching), - defaults.integer(forKey: kVLCSettingSkipLoopFilter), - defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), - defaults.integer(forKey: kVLCSettingStretchAudio)) - return prefilledFeedback + + let json: [String: Any] = [ + "Device": generateDeviceIdentifier(), + "OS": "\(device.systemName) - \(device.systemVersion)", + "Locale": "\(locale.languageCode!) (\(locale.regionCode!))", + "VLC app version": bundleShortVersionString, + "libvlc version": VLCLibrary.shared().changeset, + "hardware decoding": defaults.integer(forKey: kVLCSettingHardwareDecoding), + "network caching level": defaults.integer(forKey: kVLCSettingNetworkCaching), + "skip loop filter": defaults.integer(forKey: kVLCSettingSkipLoopFilter), + "RTSP over TCP": defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), + "Audio time stretching": defaults.integer(forKey: kVLCSettingStretchAudio) + ] + + do { + let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted) + return jsonData + } catch { + print("Error encoding JSON: \(error.localizedDescription)") + return Data() + } + } func generateDeviceIdentifier() -> String { -- GitLab