Force System Share sheet tg://sg/debug

This commit is contained in:
Kylmakalle 2024-07-04 02:53:11 +03:00
parent e332801cc9
commit b58e326f38
4 changed files with 24 additions and 3 deletions

View File

@ -26,8 +26,12 @@ private enum SGDebugActions: String {
case clearRegDateCache
}
private enum SGDebugToggles: String {
case forceImmediateShareSheet
}
private typealias SGDebugControllerEntry = SGItemListUIEntry<SGDebugControllerSection, AnyHashable, AnyHashable, AnyHashable, AnyHashable, SGDebugActions>
private typealias SGDebugControllerEntry = SGItemListUIEntry<SGDebugControllerSection, SGDebugToggles, AnyHashable, AnyHashable, AnyHashable, SGDebugActions>
private func SGDebugControllerEntries(presentationData: PresentationData) -> [SGDebugControllerEntry] {
var entries: [SGDebugControllerEntry] = []
@ -37,6 +41,7 @@ private func SGDebugControllerEntries(presentationData: PresentationData) -> [SG
entries.append(.action(id: id.count, section: .base, actionType: .flexing, text: "FLEX", kind: .generic))
#endif
entries.append(.action(id: id.count, section: .base, actionType: .clearRegDateCache, text: "Clear Regdate cache", kind: .generic))
entries.append(.toggle(id: id.count, section: .base, settingName: .forceImmediateShareSheet, value: SGSimpleSettings.shared.forceSystemSharing, text: "Force System Share Sheet", enabled: true))
return entries
}
@ -51,7 +56,12 @@ public func sgDebugController(context: AccountContext) -> ViewController {
let simplePromise = ValuePromise(true, ignoreRepeated: false)
let arguments = SGItemListArguments<AnyHashable, AnyHashable, AnyHashable, AnyHashable, SGDebugActions>(context: context, action: { actionType in
let arguments = SGItemListArguments<SGDebugToggles, AnyHashable, AnyHashable, AnyHashable, SGDebugActions>(context: context, setBoolValue: { toggleName, value in
switch toggleName {
case .forceImmediateShareSheet:
SGSimpleSettings.shared.forceSystemSharing = value
}
}, action: { actionType in
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
switch actionType {
case .clearRegDateCache:

View File

@ -102,6 +102,7 @@ public class SGSimpleSettings {
case forceEmojiTab
case forceBuiltInMic
case hideChannelBottomButton
case forceSystemSharing
}
public enum DownloadSpeedBoostValues: String, CaseIterable {
@ -187,7 +188,8 @@ public class SGSimpleSettings {
Keys.messageDoubleTapActionOutgoing.rawValue: MessageDoubleTapAction.default.rawValue,
Keys.wideChannelPosts.rawValue: false,
Keys.forceEmojiTab.rawValue: false,
Keys.hideChannelBottomButton.rawValue: false
Keys.hideChannelBottomButton.rawValue: false,
Keys.forceSystemSharing.rawValue: false,
]
@UserDefault(key: Keys.hidePhoneInSettings.rawValue)
@ -350,6 +352,9 @@ public class SGSimpleSettings {
@UserDefault(key: Keys.hideChannelBottomButton.rawValue)
public var hideChannelBottomButton: Bool
@UserDefault(key: Keys.forceSystemSharing.rawValue)
public var forceSystemSharing: Bool
}
extension SGSimpleSettings {

View File

@ -1,4 +1,5 @@
import Foundation
import SGSimpleSettings
import UIKit
import Display
import AsyncDisplayKit
@ -461,6 +462,10 @@ public final class ShareController: ViewController {
public var parentNavigationController: NavigationController?
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, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, forceTheme: PresentationTheme? = nil, forcedActionTitle: String? = nil, shareAsLink: Bool = false, collectibleItemInfo: TelegramCollectibleItemInfo? = nil) {
var immediateExternalShare = immediateExternalShare
if SGSimpleSettings.shared.forceSystemSharing {
immediateExternalShare = true
}
self.init(
environment: ShareControllerAppEnvironment(sharedContext: context.sharedContext),
currentContext: ShareControllerAppAccountContext(context: context),

View File

@ -1,4 +1,5 @@
import Foundation
import SGSimpleSettings
import Display
import AsyncDisplayKit
import Postbox