mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-04-07 13:47:54 +00:00
Version 10.13
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
sgdeps = [
|
||||
"//Swiftgram/SGDebugUI:SGDebugUI",
|
||||
"//Swiftgram/SGLogging:SGLogging",
|
||||
"//Swiftgram/SGSimpleSettings:SGSimpleSettings"
|
||||
]
|
||||
|
||||
swift_library(
|
||||
name = "DebugSettingsUI",
|
||||
module_name = "DebugSettingsUI",
|
||||
@@ -9,7 +15,7 @@ swift_library(
|
||||
copts = [
|
||||
"-warnings-as-errors",
|
||||
],
|
||||
deps = [
|
||||
deps = sgdeps + [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
// MARK: Swiftgram
|
||||
import SGLogging
|
||||
import SGSimpleSettings
|
||||
import SGDebugUI
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
@@ -44,6 +49,7 @@ private final class DebugControllerArguments {
|
||||
}
|
||||
|
||||
private enum DebugControllerSection: Int32 {
|
||||
case swiftgram
|
||||
case sticker
|
||||
case logs
|
||||
case logging
|
||||
@@ -56,6 +62,8 @@ private enum DebugControllerSection: Int32 {
|
||||
}
|
||||
|
||||
private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
case SGDebug(PresentationTheme)
|
||||
case sendSGLogs(PresentationTheme)
|
||||
case testStickerImport(PresentationTheme)
|
||||
case sendLogs(PresentationTheme)
|
||||
case sendOneLog(PresentationTheme)
|
||||
@@ -118,6 +126,8 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
case .sendSGLogs, .SGDebug:
|
||||
return DebugControllerSection.swiftgram.rawValue
|
||||
case .testStickerImport:
|
||||
return DebugControllerSection.sticker.rawValue
|
||||
case .sendLogs, .sendOneLog, .sendShareLogs, .sendGroupCallLogs, .sendStorageStats, .sendNotificationLogs, .sendCriticalLogs, .sendAllLogs:
|
||||
@@ -145,6 +155,11 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var stableId: Int {
|
||||
switch self {
|
||||
// MARK: Swiftgram
|
||||
case .SGDebug:
|
||||
return -110
|
||||
case .sendSGLogs:
|
||||
return -100
|
||||
case .testStickerImport:
|
||||
return 0
|
||||
case .sendLogs:
|
||||
@@ -273,6 +288,13 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
|
||||
let arguments = arguments as! DebugControllerArguments
|
||||
switch self {
|
||||
case .SGDebug:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Swiftgram Debug", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
guard let context = arguments.context else {
|
||||
return
|
||||
}
|
||||
arguments.pushController(sgDebugController(context: context))
|
||||
})
|
||||
case .testStickerImport:
|
||||
return ItemListActionItem(presentationData: presentationData, title: "Simulate Stickers Import", kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||
guard let context = arguments.context else {
|
||||
@@ -372,9 +394,20 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
arguments.presentController(actionSheet, nil)
|
||||
})
|
||||
})
|
||||
case .sendOneLog:
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: "Send Latest Logs (Up to 4 MB)", label: "", sectionId: self.section, style: .blocks, action: {
|
||||
let _ = (Logger.shared.collectLogs()
|
||||
// MARK: Swiftgram
|
||||
case .sendOneLog, .sendSGLogs:
|
||||
var title = "Send Latest Logs (Up to 4 MB)"
|
||||
var logCollectionSignal: Signal<[(String, String)], NoError> = Logger.shared.collectLogs()
|
||||
var fileName = "Log-iOS-Short.txt"
|
||||
var appName = "Telegram"
|
||||
if case .sendSGLogs(_) = self {
|
||||
title = "Send Swiftgram Logs"
|
||||
logCollectionSignal = SGLogger.shared.collectLogs()
|
||||
fileName = "Log-iOS-Swiftgram.txt"
|
||||
appName = "Swiftgram"
|
||||
}
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: title, label: "", sectionId: self.section, style: .blocks, action: {
|
||||
let _ = (logCollectionSignal
|
||||
|> deliverOnMainQueue).start(next: { logs in
|
||||
let presentationData = arguments.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
@@ -421,7 +454,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
let fileResource = LocalFileMediaResource(fileId: id, size: Int64(logData.count), isSecretRelated: false)
|
||||
context.account.postbox.mediaBox.storeResourceData(fileResource.id, data: logData)
|
||||
|
||||
let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(logData.count), attributes: [.FileName(fileName: "Log-iOS-Short.txt")], alternativeRepresentations: [])
|
||||
let file = TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: id), partialReference: nil, resource: fileResource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "application/text", size: Int64(logData.count), attributes: [.FileName(fileName: fileName)], alternativeRepresentations: [])
|
||||
let message: EnqueueMessage = .message(text: "", attributes: [], inlineStickers: [:], mediaReference: .standalone(media: file), threadId: nil, replyToMessageId: nil, replyToStoryId: nil, localGroupingKey: nil, correlationId: nil, bubbleUpEmojiOrStickersets: [])
|
||||
|
||||
let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start()
|
||||
@@ -436,7 +469,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
let composeController = MFMailComposeViewController()
|
||||
composeController.mailComposeDelegate = arguments.mailComposeDelegate
|
||||
composeController.setSubject("Telegram Logs")
|
||||
composeController.setSubject("\(appName) Logs")
|
||||
for (name, path) in logs {
|
||||
if let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe) {
|
||||
composeController.addAttachmentData(data, mimeType: "application/text", fileName: name)
|
||||
@@ -1442,9 +1475,13 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
||||
|
||||
let isMainApp = sharedContext.applicationBindings.isMainApp
|
||||
|
||||
// MARK: Swiftgram
|
||||
entries.append(.SGDebug(presentationData.theme))
|
||||
entries.append(.sendSGLogs(presentationData.theme))
|
||||
|
||||
// entries.append(.testStickerImport(presentationData.theme))
|
||||
entries.append(.sendLogs(presentationData.theme))
|
||||
//entries.append(.sendOneLog(presentationData.theme))
|
||||
entries.append(.sendOneLog(presentationData.theme))
|
||||
entries.append(.sendShareLogs)
|
||||
entries.append(.sendGroupCallLogs)
|
||||
entries.append(.sendNotificationLogs(presentationData.theme))
|
||||
@@ -1464,7 +1501,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
||||
entries.append(.resetWebViewCache(presentationData.theme))
|
||||
|
||||
entries.append(.keepChatNavigationStack(presentationData.theme, experimentalSettings.keepChatNavigationStack))
|
||||
#if DEBUG
|
||||
#if true
|
||||
entries.append(.skipReadHistory(presentationData.theme, experimentalSettings.skipReadHistory))
|
||||
#endif
|
||||
entries.append(.dustEffect(experimentalSettings.dustEffect))
|
||||
|
||||
Reference in New Issue
Block a user