mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 00:03:27 +01:00
Settings: Add Export Logs and commit xcodeproj changes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.";
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user