Settings: Add Export Logs and commit xcodeproj changes

This commit is contained in:
naturecodevoid
2023-02-22 13:04:52 -08:00
parent 817d2de5e0
commit df62461d4a
6 changed files with 57 additions and 24 deletions

View File

@@ -66,6 +66,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
UserDefaults.registerDefaults()
LCManager.shared.isVisible = UserDefaults.standard.isConsoleEnabled
LCManager.shared.isCharacterLimitDisabled = false // we want all logs exported
DatabaseManager.shared.start { (error) in
if let error = error

View File

@@ -345,6 +345,8 @@ internal enum L10n {
internal static let credits = L10n.tr("Localizable", "SettingsView.credits", fallback: "Credits")
/// Debug
internal static let debug = L10n.tr("Localizable", "SettingsView.debug", fallback: "Debug")
/// Export Logs
internal static let exportLogs = L10n.tr("Localizable", "SettingsView.exportLogs", fallback: "Export Logs")
/// Refreshing Apps
internal static let refreshingApps = L10n.tr("Localizable", "SettingsView.refreshingApps", fallback: "Refreshing Apps")
/// Enable Background Refresh to automatically refresh apps in the background when connected to WiFi and with Wireguard active.

View File

@@ -61,6 +61,7 @@
"SettingsView.credits" = "Credits";
"SettingsView.title" = "Settings";
"SettingsView.refreshingAppsFooter" = "Enable Background Refresh to automatically refresh apps in the background when connected to WiFi and with Wireguard active.";
"SettingsView.exportLogs" = "Export Logs";
/* ConnectAppleIDView */
"ConnectAppleIDView.startWithSignIn" = "Sign in with your Apple ID to get started.";

View File

@@ -36,6 +36,7 @@ struct SettingsView: View {
@State var isShowingDevModeMenu = false
@State var externalURLToShow: URL?
@State var quickLookURL: URL?
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown Version"
@@ -165,6 +166,8 @@ struct SettingsView: View {
NavigationLink(L10n.AdvancedSettingsView.title) {
AdvancedSettingsView()
}
AsyncFallibleButton(action: self.exportLogs, label: { execute in Text(L10n.SettingsView.exportLogs) })
if MailComposeView.canSendMail {
ModalNavigationLink("Send Feedback") {
@@ -236,6 +239,7 @@ struct SettingsView: View {
.sheet(item: $externalURLToShow) { url in
SafariView(url: url)
}
.quickLookPreview($quickLookURL)
.enableInjection()
}
@@ -319,6 +323,31 @@ struct SettingsView: View {
exit(0)
}
}
func exportLogs() throws {
guard let path = FileManager.default.altstoreSharedDirectory?.appendingPathComponent("logs.txt") else { throw NSError(domain: "Failed to get path.", code: 1) }
var text = LCManager.shared.currentText
// TODO: add more potentially sensitive info to this array like UDID
var remove = [String]()
if let connectedAppleID = connectedTeams.first {
remove.append(connectedAppleID.name)
remove.append(connectedAppleID.account.appleID)
remove.append(connectedAppleID.account.firstName)
remove.append(connectedAppleID.account.lastName)
remove.append(connectedAppleID.account.localizedName)
remove.append(connectedAppleID.account.identifier)
remove.append(connectedAppleID.identifier)
}
for toRemove in remove {
text = text.replacingOccurrences(of: toRemove, with: "[removed]")
}
guard let data = text.data(using: .utf8) else { throw NSError(domain: "Failed to get data.", code: 2) }
try data.write(to: path)
quickLookURL = path
}
}
struct SettingsView_Previews: PreviewProvider {