mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Send logs via share
This commit is contained in:
parent
24c26f0952
commit
c74d80a01f
26
submodules/DebugSettingsUI/BUILD
Normal file
26
submodules/DebugSettingsUI/BUILD
Normal file
@ -0,0 +1,26 @@
|
||||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
|
||||
|
||||
swift_library(
|
||||
name = "DebugSettingsUI",
|
||||
module_name = "DebugSettingsUI",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/SyncCore:SyncCore",
|
||||
"//submodules/MtProtoKit:MtProtoKit",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
"//submodules/ItemListUI:ItemListUI",
|
||||
"//submodules/PresentationDataUtils:PresentationDataUtils",
|
||||
"//submodules/OverlayStatusController:OverlayStatusController",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
)
|
@ -13,7 +13,6 @@ import ItemListUI
|
||||
import PresentationDataUtils
|
||||
import OverlayStatusController
|
||||
import AccountContext
|
||||
import TelegramCallsUI
|
||||
|
||||
@objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate {
|
||||
public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||
@ -191,7 +190,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
|
||||
if let context = arguments.context {
|
||||
if let context = arguments.context, context.sharedContext.applicationBindings.isMainApp {
|
||||
items.append(ActionSheetButtonItem(title: "Via Telegram", color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
@ -261,7 +260,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
|
||||
if let context = arguments.context {
|
||||
if let context = arguments.context, context.sharedContext.applicationBindings.isMainApp {
|
||||
items.append(ActionSheetButtonItem(title: "Via Telegram", color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
@ -343,7 +342,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
|
||||
if let context = arguments.context {
|
||||
if let context = arguments.context, context.sharedContext.applicationBindings.isMainApp {
|
||||
items.append(ActionSheetButtonItem(title: "Via Telegram", color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
@ -438,7 +437,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
|
||||
var items: [ActionSheetButtonItem] = []
|
||||
|
||||
if let context = arguments.context {
|
||||
if let context = arguments.context, context.sharedContext.applicationBindings.isMainApp {
|
||||
items.append(ActionSheetButtonItem(title: "Via Telegram", color: .accent, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
|
||||
@ -781,42 +780,49 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
||||
}
|
||||
}
|
||||
|
||||
private func debugControllerEntries(presentationData: PresentationData, loggingSettings: LoggingSettings, mediaInputSettings: MediaInputSettings, experimentalSettings: ExperimentalUISettings, networkSettings: NetworkSettings?, hasLegacyAppData: Bool) -> [DebugControllerEntry] {
|
||||
private func debugControllerEntries(sharedContext: SharedAccountContext, presentationData: PresentationData, loggingSettings: LoggingSettings, mediaInputSettings: MediaInputSettings, experimentalSettings: ExperimentalUISettings, networkSettings: NetworkSettings?, hasLegacyAppData: Bool) -> [DebugControllerEntry] {
|
||||
var entries: [DebugControllerEntry] = []
|
||||
|
||||
let isMainApp = sharedContext.applicationBindings.isMainApp
|
||||
|
||||
entries.append(.sendLogs(presentationData.theme))
|
||||
entries.append(.sendOneLog(presentationData.theme))
|
||||
entries.append(.sendShareLogs)
|
||||
entries.append(.sendNotificationLogs(presentationData.theme))
|
||||
entries.append(.sendCriticalLogs(presentationData.theme))
|
||||
entries.append(.accounts(presentationData.theme))
|
||||
if isMainApp {
|
||||
entries.append(.accounts(presentationData.theme))
|
||||
}
|
||||
|
||||
entries.append(.logToFile(presentationData.theme, loggingSettings.logToFile))
|
||||
entries.append(.logToConsole(presentationData.theme, loggingSettings.logToConsole))
|
||||
entries.append(.redactSensitiveData(presentationData.theme, loggingSettings.redactSensitiveData))
|
||||
|
||||
entries.append(.enableRaiseToSpeak(presentationData.theme, mediaInputSettings.enableRaiseToSpeak))
|
||||
entries.append(.keepChatNavigationStack(presentationData.theme, experimentalSettings.keepChatNavigationStack))
|
||||
#if DEBUG
|
||||
entries.append(.skipReadHistory(presentationData.theme, experimentalSettings.skipReadHistory))
|
||||
#endif
|
||||
if isMainApp {
|
||||
entries.append(.enableRaiseToSpeak(presentationData.theme, mediaInputSettings.enableRaiseToSpeak))
|
||||
entries.append(.keepChatNavigationStack(presentationData.theme, experimentalSettings.keepChatNavigationStack))
|
||||
#if DEBUG
|
||||
entries.append(.skipReadHistory(presentationData.theme, experimentalSettings.skipReadHistory))
|
||||
#endif
|
||||
}
|
||||
entries.append(.crashOnSlowQueries(presentationData.theme, experimentalSettings.crashOnLongQueries))
|
||||
entries.append(.clearTips(presentationData.theme))
|
||||
if hasLegacyAppData {
|
||||
entries.append(.reimport(presentationData.theme))
|
||||
if isMainApp {
|
||||
entries.append(.clearTips(presentationData.theme))
|
||||
}
|
||||
entries.append(.resetData(presentationData.theme))
|
||||
entries.append(.resetDatabase(presentationData.theme))
|
||||
entries.append(.resetDatabaseAndCache(presentationData.theme))
|
||||
entries.append(.resetHoles(presentationData.theme))
|
||||
entries.append(.reindexUnread(presentationData.theme))
|
||||
if isMainApp {
|
||||
entries.append(.reindexUnread(presentationData.theme))
|
||||
}
|
||||
entries.append(.optimizeDatabase(presentationData.theme))
|
||||
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))
|
||||
entries.append(.demoVideoChats(experimentalSettings.demoVideoChats))
|
||||
entries.append(.playerEmbedding(experimentalSettings.playerEmbedding))
|
||||
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))
|
||||
|
||||
entries.append(.voiceConference)
|
||||
if isMainApp {
|
||||
entries.append(.knockoutWallpaper(presentationData.theme, experimentalSettings.knockoutWallpaper))
|
||||
entries.append(.demoVideoChats(experimentalSettings.demoVideoChats))
|
||||
entries.append(.playerEmbedding(experimentalSettings.playerEmbedding))
|
||||
entries.append(.playlistPlayback(experimentalSettings.playlistPlayback))
|
||||
}
|
||||
|
||||
let codecs: [(String, String?)] = [
|
||||
("No Preference", nil),
|
||||
@ -830,8 +836,10 @@ private func debugControllerEntries(presentationData: PresentationData, loggingS
|
||||
entries.append(.preferredVideoCodec(i, codecs[i].0, codecs[i].1, experimentalSettings.preferredVideoCodec == codecs[i].1))
|
||||
}
|
||||
|
||||
entries.append(.disableVideoAspectScaling(experimentalSettings.disableVideoAspectScaling))
|
||||
entries.append(.enableVoipTcp(experimentalSettings.enableVoipTcp))
|
||||
if isMainApp {
|
||||
entries.append(.disableVideoAspectScaling(experimentalSettings.disableVideoAspectScaling))
|
||||
entries.append(.enableVoipTcp(experimentalSettings.enableVoipTcp))
|
||||
}
|
||||
|
||||
if let backupHostOverride = networkSettings?.backupHostOverride {
|
||||
entries.append(.hostInfo(presentationData.theme, "Host: \(backupHostOverride)"))
|
||||
@ -900,7 +908,7 @@ public func debugController(sharedContext: SharedAccountContext, context: Accoun
|
||||
}
|
||||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text("Debug"), leftNavigationButton: leftNavigationButton, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: debugControllerEntries(presentationData: presentationData, loggingSettings: loggingSettings, mediaInputSettings: mediaInputSettings, experimentalSettings: experimentalSettings, networkSettings: networkSettings, hasLegacyAppData: hasLegacyAppData), style: .blocks)
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: debugControllerEntries(sharedContext: sharedContext, presentationData: presentationData, loggingSettings: loggingSettings, mediaInputSettings: mediaInputSettings, experimentalSettings: experimentalSettings, networkSettings: networkSettings, hasLegacyAppData: hasLegacyAppData), style: .blocks)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
}
|
@ -88,6 +88,7 @@ swift_library(
|
||||
"//submodules/AuthTransferUI:AuthTransferUI",
|
||||
"//submodules/WidgetSetupScreen:WidgetSetupScreen",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
"//submodules/DebugSettingsUI:DebugSettingsUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -327,6 +327,8 @@ public final class ShareController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public var debugAction: (() -> Void)?
|
||||
|
||||
public convenience init(context: AccountContext, subject: ShareControllerSubject, presetText: String? = nil, preferredAction: ShareControllerPreferredAction = .default, showInChat: ((Message) -> Void)? = nil, fromForeignApp: Bool = false, segmentedValues: [ShareControllerSegmentedValue]? = nil, externalShare: Bool = true, immediateExternalShare: Bool = false, switchableAccounts: [AccountWithInfo] = [], immediatePeerId: PeerId? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil) {
|
||||
self.init(sharedContext: context.sharedContext, currentContext: context, subject: subject, presetText: presetText, preferredAction: preferredAction, showInChat: showInChat, fromForeignApp: fromForeignApp, segmentedValues: segmentedValues, externalShare: externalShare, immediateExternalShare: immediateExternalShare, switchableAccounts: switchableAccounts, immediatePeerId: immediatePeerId, forceTheme: forceTheme, forcedActionTitle: forcedActionTitle)
|
||||
}
|
||||
@ -800,6 +802,9 @@ public final class ShareController: ViewController {
|
||||
strongSelf.view.endEditing(true)
|
||||
strongSelf.present(controller, in: .window(.root), with: ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
||||
}
|
||||
self.controllerNode.debugAction = { [weak self] in
|
||||
self?.debugAction?()
|
||||
}
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
self.peersDisposable.set((self.peers.get()
|
||||
|
@ -61,6 +61,7 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
var share: ((String, [PeerId]) -> Signal<ShareState, NoError>)?
|
||||
var shareExternal: (() -> Signal<ShareExternalState, NoError>)?
|
||||
var switchToAnotherAccount: (() -> Void)?
|
||||
var debugAction: (() -> Void)?
|
||||
var openStats: (() -> Void)?
|
||||
var completed: (([PeerId]) -> Void)?
|
||||
|
||||
@ -730,6 +731,8 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
|
||||
let animated = self.peersContentNode == nil
|
||||
let peersContentNode = SharePeersContainerNode(sharedContext: self.sharedContext, context: context, switchableAccounts: switchableAccounts, theme: self.presentationData.theme, strings: self.presentationData.strings, nameDisplayOrder: self.presentationData.nameDisplayOrder, peers: peers, accountPeer: accountPeer, controllerInteraction: self.controllerInteraction!, externalShare: self.externalShare, switchToAnotherAccount: { [weak self] in
|
||||
self?.switchToAnotherAccount?()
|
||||
}, debugAction: { [weak self] in
|
||||
self?.debugAction?()
|
||||
}, extendedInitialReveal: self.presetText != nil, segmentedValues: self.segmentedValues)
|
||||
self.peersContentNode = peersContentNode
|
||||
peersContentNode.openSearch = { [weak self] in
|
||||
|
@ -81,6 +81,7 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
||||
private let nameDisplayOrder: PresentationPersonNameOrder
|
||||
private let controllerInteraction: ShareControllerInteraction
|
||||
private let switchToAnotherAccount: () -> Void
|
||||
private let debugAction: () -> Void
|
||||
private let extendedInitialReveal: Bool
|
||||
|
||||
let accountPeer: Peer
|
||||
@ -113,7 +114,7 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
||||
|
||||
let peersValue = Promise<[(RenderedPeer, PeerPresence?)]>()
|
||||
|
||||
init(sharedContext: SharedAccountContext, context: AccountContext, switchableAccounts: [AccountWithInfo], theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, peers: [(RenderedPeer, PeerPresence?)], accountPeer: Peer, controllerInteraction: ShareControllerInteraction, externalShare: Bool, switchToAnotherAccount: @escaping () -> Void, extendedInitialReveal: Bool, segmentedValues: [ShareControllerSegmentedValue]?) {
|
||||
init(sharedContext: SharedAccountContext, context: AccountContext, switchableAccounts: [AccountWithInfo], theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, peers: [(RenderedPeer, PeerPresence?)], accountPeer: Peer, controllerInteraction: ShareControllerInteraction, externalShare: Bool, switchToAnotherAccount: @escaping () -> Void, debugAction: @escaping () -> Void, extendedInitialReveal: Bool, segmentedValues: [ShareControllerSegmentedValue]?) {
|
||||
self.sharedContext = sharedContext
|
||||
self.context = context
|
||||
self.theme = theme
|
||||
@ -122,6 +123,7 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
||||
self.controllerInteraction = controllerInteraction
|
||||
self.accountPeer = accountPeer
|
||||
self.switchToAnotherAccount = switchToAnotherAccount
|
||||
self.debugAction = debugAction
|
||||
self.extendedInitialReveal = extendedInitialReveal
|
||||
self.segmentedValues = segmentedValues
|
||||
|
||||
@ -240,6 +242,8 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
||||
self.segmentedNode.selectedIndexChanged = { [weak self] index in
|
||||
self?.segmentedSelectedIndexUpdated?(index)
|
||||
}
|
||||
|
||||
self.contentTitleNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.debugTapGesture(_:))))
|
||||
}
|
||||
|
||||
deinit {
|
||||
@ -464,4 +468,27 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
||||
@objc private func accountTapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
self.switchToAnotherAccount()
|
||||
}
|
||||
|
||||
private var debugTapCounter: (Double, Int) = (0.0, 0)
|
||||
|
||||
@objc private func debugTapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
let timestamp = CACurrentMediaTime()
|
||||
if self.debugTapCounter.0 < timestamp - 0.4 {
|
||||
self.debugTapCounter.0 = timestamp
|
||||
self.debugTapCounter.1 = 0
|
||||
}
|
||||
|
||||
if self.debugTapCounter.0 >= timestamp - 0.4 {
|
||||
self.debugTapCounter.0 = timestamp
|
||||
self.debugTapCounter.1 += 1
|
||||
}
|
||||
|
||||
if self.debugTapCounter.1 >= 10 {
|
||||
self.debugTapCounter.1 = 0
|
||||
|
||||
self.debugAction()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,6 +219,7 @@ swift_library(
|
||||
"//submodules/ConfettiEffect:ConfettiEffect",
|
||||
"//submodules/Speak:Speak",
|
||||
"//submodules/PeerInfoAvatarListNode:PeerInfoAvatarListNode",
|
||||
"//submodules/DebugSettingsUI:DebugSettingsUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -12,6 +12,7 @@ import AccountContext
|
||||
import CountrySelectionUI
|
||||
import SettingsUI
|
||||
import PhoneNumberFormat
|
||||
import DebugSettingsUI
|
||||
|
||||
final class AuthorizationSequencePhoneEntryController: ViewController {
|
||||
private var controllerNode: AuthorizationSequencePhoneEntryControllerNode {
|
||||
|
@ -23,6 +23,7 @@ import PresentationDataUtils
|
||||
import ChatImportUI
|
||||
import ZipArchive
|
||||
import ActivityIndicator
|
||||
import DebugSettingsUI
|
||||
|
||||
private let inForeground = ValuePromise<Bool>(false, ignoreRepeated: true)
|
||||
|
||||
@ -393,6 +394,16 @@ public class ShareRootControllerImpl {
|
||||
shareController.dismissed = { _ in
|
||||
self?.getExtensionContext()?.completeRequest(returningItems: nil, completionHandler: nil)
|
||||
}
|
||||
shareController.debugAction = {
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
let presentationData = internalContext.sharedContext.currentPresentationData.with { $0 }
|
||||
let navigationController = NavigationController(mode: .single, theme: NavigationControllerTheme(presentationTheme: presentationData.theme))
|
||||
strongSelf.navigationController = navigationController
|
||||
navigationController.viewControllers = [debugController(sharedContext: context.sharedContext, context: context)]
|
||||
strongSelf.mainWindow?.present(navigationController, on: .root)
|
||||
}
|
||||
|
||||
cancelImpl = { [weak shareController] in
|
||||
shareController?.dismiss(completion: { [weak self] in
|
||||
|
@ -14,6 +14,7 @@ import ChatListUI
|
||||
import SettingsUI
|
||||
import AppBundle
|
||||
import DatePickerNode
|
||||
import DebugSettingsUI
|
||||
|
||||
public final class TelegramRootController: NavigationController {
|
||||
private let context: AccountContext
|
||||
|
Loading…
x
Reference in New Issue
Block a user