From 7e4a7df596ea2e66671842c02c7146342f1f935e Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sat, 1 Feb 2020 23:34:19 +0400 Subject: [PATCH] Don't link unused code --- BUCK | 4 +-- submodules/AccountContext/BUCK | 2 +- .../Sources/AccountContext.swift | 18 +++++++++++++ .../Sources/ChatListController.swift | 6 ++--- submodules/SettingsUI/BUCK | 2 +- .../SettingsUI/Sources/DebugController.swift | 1 - .../Sources/LogoutOptionsController.swift | 4 +++ .../Search/SettingsSearchableItems.swift | 2 ++ .../Sources/SettingsController.swift | 25 +++++++++++++++++-- submodules/TelegramUI/BUCK | 4 +-- .../TelegramUI/AccountContext.swift | 11 +++++++- .../TelegramUI/TelegramUI/AppDelegate.swift | 15 +++++++++-- .../TelegramUI/ChatController.swift | 6 +++-- .../ChatRecentActionsControllerNode.swift | 2 ++ .../TelegramUI/OpenResolvedUrl.swift | 2 ++ .../TelegramUI/TelegramUI/OpenUrl.swift | 4 +++ .../TelegramUI/ShareExtensionContext.swift | 2 +- .../TelegramUI/SharedAccountContext.swift | 8 ++++-- .../TelegramUI/TextLinkHandling.swift | 2 ++ .../TelegramUI/WalletContextImpl.swift | 4 +++ submodules/UrlHandling/BUCK | 2 +- .../UrlHandling/Sources/UrlHandling.swift | 4 +++ submodules/WalletUI/BUCK | 4 +-- 23 files changed, 111 insertions(+), 23 deletions(-) diff --git a/BUCK b/BUCK index aa8a301c7e..aff0dc7694 100644 --- a/BUCK +++ b/BUCK @@ -48,8 +48,8 @@ resource_dependencies = [ "//submodules/LegacyComponents:LegacyComponentsResources", "//submodules/TelegramUI:TelegramUIAssets", "//submodules/TelegramUI:TelegramUIResources", - "//submodules/WalletUI:WalletUIAssets", - "//submodules/WalletUI:WalletUIResources", + #"//submodules/WalletUI:WalletUIAssets", + #"//submodules/WalletUI:WalletUIResources", "//submodules/PasswordSetupUI:PasswordSetupUIResources", "//submodules/PasswordSetupUI:PasswordSetupUIAssets", "//submodules/OverlayStatusController:OverlayStatusControllerResources", diff --git a/submodules/AccountContext/BUCK b/submodules/AccountContext/BUCK index 120fec2a7e..6a3a3d431f 100644 --- a/submodules/AccountContext/BUCK +++ b/submodules/AccountContext/BUCK @@ -16,7 +16,7 @@ static_library( "//submodules/Postbox:Postbox#shared", "//submodules/TelegramCore:TelegramCore#shared", "//submodules/SyncCore:SyncCore#shared", - "//submodules/WalletCore:WalletCore", + #"//submodules/WalletCore:WalletCore", ], frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 620bf03962..831b3539d4 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -8,7 +8,10 @@ import SwiftSignalKit import Display import DeviceLocationManager import TemporaryCachedPeerDataManager + +#if ENABLE_WALLET import WalletCore +#endif public final class TelegramApplicationOpenUrlCompletion { public let completion: (Bool) -> Void @@ -175,7 +178,9 @@ public enum ResolvedUrl { case share(url: String?, text: String?, to: String?) case wallpaper(WallpaperUrlParameter) case theme(String) + #if ENABLE_WALLET case wallet(address: String, amount: Int64?, comment: String?) + #endif case settings(ResolvedUrlSettingsSection) } @@ -378,10 +383,12 @@ public final class ContactSelectionControllerParams { } } +#if ENABLE_WALLET public enum OpenWalletContext { case generic case send(address: String, amount: Int64?, comment: String?) } +#endif public let defaultContactLabel: String = "_$!!$_" @@ -464,7 +471,9 @@ public protocol SharedAccountContext: class { func openAddContact(context: AccountContext, firstName: String, lastName: String, phoneNumber: String, label: String, present: @escaping (ViewController, Any?) -> Void, pushController: @escaping (ViewController) -> Void, completed: @escaping () -> Void) func openAddPersonContact(context: AccountContext, peerId: PeerId, pushController: @escaping (ViewController) -> Void, present: @escaping (ViewController, Any?) -> Void) func presentContactsWarningSuppression(context: AccountContext, present: (ViewController, Any?) -> Void) + #if ENABLE_WALLET func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void) + #endif func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void) func makeRecentSessionsController(context: AccountContext, activeSessionsContext: ActiveSessionsContext) -> ViewController & RecentSessionsController @@ -477,6 +486,7 @@ public protocol SharedAccountContext: class { func beginNewAuth(testingEnvironment: Bool) } +#if ENABLE_WALLET private final class TonInstanceData { var config: String? var blockchainName: String? @@ -541,10 +551,15 @@ public final class TonContext { } } +#endif + public protocol AccountContext: class { var sharedContext: SharedAccountContext { get } var account: Account { get } + + #if ENABLE_WALLET var tonContext: StoredTonContext? { get } + #endif var liveLocationManager: LiveLocationManager? { get } var fetchManager: FetchManager { get } @@ -552,8 +567,11 @@ public protocol AccountContext: class { var peerChannelMemberCategoriesContextsManager: PeerChannelMemberCategoriesContextsManager { get } var wallpaperUploadManager: WallpaperUploadManager? { get } var watchManager: WatchManager? { get } + + #if ENABLE_WALLET var hasWallets: Signal { get } var hasWalletAccess: Signal { get } + #endif var currentLimitsConfiguration: Atomic { get } var currentContentSettings: Atomic { get } diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 57510f6e06..61391e300a 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -99,7 +99,7 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent } } -public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate, TabBarContainedController { +public class ChatListControllerImpl: TelegramBaseController, ChatListController, UIViewControllerPreviewingDelegate/*, TabBarContainedController*/ { private var validLayout: ContainerViewLayout? public let context: AccountContext @@ -1808,7 +1808,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, } } - public func presentTabBarPreviewingController(sourceNodes: [ASDisplayNode]) { + /*public func presentTabBarPreviewingController(sourceNodes: [ASDisplayNode]) { if self.isNodeLoaded { let _ = (self.context.account.postbox.transaction { transaction -> [ChatListFilterPreset] in let settings = transaction.getPreferencesEntry(key: ApplicationSpecificPreferencesKeys.chatListFilterSettings) as? ChatListFilterSettings ?? ChatListFilterSettings.default @@ -1852,5 +1852,5 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController, public func updateTabBarPreviewingControllerPresentation(_ update: TabBarContainedControllerPresentationUpdate) { - } + }*/ } diff --git a/submodules/SettingsUI/BUCK b/submodules/SettingsUI/BUCK index df9f9d6aa7..de8449bf1c 100644 --- a/submodules/SettingsUI/BUCK +++ b/submodules/SettingsUI/BUCK @@ -78,7 +78,7 @@ static_library( "//submodules/InstantPageCache:InstantPageCache", "//submodules/AppBundle:AppBundle", "//submodules/ContextUI:ContextUI", - "//submodules/WalletUI:WalletUI", + #"//submodules/WalletUI:WalletUI", "//submodules/Markdown:Markdown", "//submodules/UndoUI:UndoUI", "//submodules/DeleteChatPeerActionSheetItem:DeleteChatPeerActionSheetItem", diff --git a/submodules/SettingsUI/Sources/DebugController.swift b/submodules/SettingsUI/Sources/DebugController.swift index be90bdccfa..e33c1130f8 100644 --- a/submodules/SettingsUI/Sources/DebugController.swift +++ b/submodules/SettingsUI/Sources/DebugController.swift @@ -17,7 +17,6 @@ import ItemListUI import PresentationDataUtils import OverlayStatusController import AccountContext -import WalletUI @objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate { public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { diff --git a/submodules/SettingsUI/Sources/LogoutOptionsController.swift b/submodules/SettingsUI/Sources/LogoutOptionsController.swift index e7c8a6abc4..e549426303 100644 --- a/submodules/SettingsUI/Sources/LogoutOptionsController.swift +++ b/submodules/SettingsUI/Sources/LogoutOptionsController.swift @@ -219,7 +219,11 @@ func logoutOptionsController(context: AccountContext, navigationController: Navi presentControllerImpl?(alertController, nil) }) + #if ENABLE_WALLET let hasWallets = context.hasWallets + #else + let hasWallets: Signal = .single(false) + #endif let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, diff --git a/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift b/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift index 7bd19427e9..43bdedb823 100644 --- a/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift +++ b/submodules/SettingsUI/Sources/Search/SettingsSearchableItems.swift @@ -882,6 +882,7 @@ func settingsSearchableItems(context: AccountContext, notificationExceptionsList }) allItems.append(passport) + #if ENABLE_WALLET if hasWallet { let wallet = SettingsSearchableItem(id: .wallet(0), title: strings.Settings_Wallet, alternate: synonyms(strings.SettingsSearch_Synonyms_Wallet), icon: .wallet, breadcrumbs: [], present: { context, _, present in context.sharedContext.openWallet(context: context, walletContext: .generic, present: { c in @@ -890,6 +891,7 @@ func settingsSearchableItems(context: AccountContext, notificationExceptionsList }) allItems.append(wallet) } + #endif let support = SettingsSearchableItem(id: .support(0), title: strings.Settings_Support, alternate: synonyms(strings.SettingsSearch_Synonyms_Support), icon: .support, breadcrumbs: [], present: { context, _, present in let _ = (supportPeerId(account: context.account) diff --git a/submodules/SettingsUI/Sources/SettingsController.swift b/submodules/SettingsUI/Sources/SettingsController.swift index 280b6055f8..6417452b5e 100644 --- a/submodules/SettingsUI/Sources/SettingsController.swift +++ b/submodules/SettingsUI/Sources/SettingsController.swift @@ -33,7 +33,9 @@ import PeerAvatarGalleryUI import MapResourceToAvatarSizes import AppBundle import ContextUI +#if ENABLE_WALLET import WalletUI +#endif import PhoneNumberFormat import AccountUtils import AuthTransferUI @@ -221,7 +223,9 @@ private indirect enum SettingsEntry: ItemListNodeEntry { case themes(PresentationTheme, UIImage?, String) case language(PresentationTheme, UIImage?, String, String) case passport(PresentationTheme, UIImage?, String, String) + #if ENABLE_WALLET case wallet(PresentationTheme, UIImage?, String, String) + #endif case watch(PresentationTheme, UIImage?, String, String) case askAQuestion(PresentationTheme, UIImage?, String) @@ -243,8 +247,12 @@ private indirect enum SettingsEntry: ItemListNodeEntry { return SettingsSection.media.rawValue case .notificationsAndSounds, .privacyAndSecurity, .dataAndStorage, .themes, .language, .contentStickers: return SettingsSection.generalSettings.rawValue - case .passport, .wallet, .watch : + case .passport, .watch: return SettingsSection.advanced.rawValue + #if ENABLE_WALLET + case .wallet: + return SettingsSection.advanced.rawValue + #endif case .askAQuestion, .faq: return SettingsSection.help.rawValue } @@ -290,8 +298,10 @@ private indirect enum SettingsEntry: ItemListNodeEntry { return 1012 case .contentStickers: return 1013 + #if ENABLE_WALLET case .wallet: return 1014 + #endif case .passport: return 1015 case .watch: @@ -457,12 +467,14 @@ private indirect enum SettingsEntry: ItemListNodeEntry { } else { return false } + #if ENABLE_WALLET case let .wallet(lhsTheme, lhsImage, lhsText, lhsValue): if case let .wallet(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue { return true } else { return false } + #endif case let .watch(lhsTheme, lhsImage, lhsText, lhsValue): if case let .watch(rhsTheme, rhsImage, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsImage === rhsImage, lhsText == rhsText, lhsValue == rhsValue { return true @@ -596,10 +608,12 @@ private indirect enum SettingsEntry: ItemListNodeEntry { return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { arguments.openPassport() }) + #if ENABLE_WALLET case let .wallet(theme, image, text, value): return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { arguments.openWallet() }) + #endif case let .watch(theme, image, text, value): return ItemListDisclosureItem(presentationData: presentationData, icon: image, title: text, label: value, sectionId: ItemListSectionId(self.section), style: .blocks, action: { arguments.openWatch() @@ -685,9 +699,11 @@ private func settingsEntries(account: Account, presentationData: PresentationDat entries.append(.language(presentationData.theme, PresentationResourcesSettings.language, presentationData.strings.Settings_AppLanguage, languageName.isEmpty ? presentationData.strings.Localization_LanguageName : languageName)) entries.append(.contentStickers(presentationData.theme, PresentationResourcesSettings.stickers, presentationData.strings.ChatSettings_Stickers, unreadTrendingStickerPacks == 0 ? "" : "\(unreadTrendingStickerPacks)", archivedPacks)) + #if ENABLE_WALLET if hasWallet { entries.append(.wallet(presentationData.theme, PresentationResourcesSettings.wallet, "Gram Wallet", "")) } + #endif if hasPassport { entries.append(.passport(presentationData.theme, PresentationResourcesSettings.passport, presentationData.strings.Settings_Passport, "")) } @@ -989,6 +1005,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM pushControllerImpl?(SecureIdAuthController(context: context, mode: .list)) }) }, openWallet: { + #if ENABLE_WALLET let _ = (contextValue.get() |> deliverOnMainQueue |> take(1)).start(next: { context in @@ -996,6 +1013,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM pushControllerImpl?(c) }) }) + #endif }, openWatch: { let _ = (contextValue.get() |> deliverOnMainQueue @@ -1252,11 +1270,14 @@ public func settingsController(context: AccountContext, accountManager: AccountM } ) ) - + #if ENABLE_WALLET let hasWallet = contextValue.get() |> mapToSignal { context in return context.hasWalletAccess } + #else + let hasWallet: Signal = .single(false) + #endif let hasPassport = ValuePromise(false) let updatePassport: () -> Void = { diff --git a/submodules/TelegramUI/BUCK b/submodules/TelegramUI/BUCK index 9a62dca17e..6eb5520ee9 100644 --- a/submodules/TelegramUI/BUCK +++ b/submodules/TelegramUI/BUCK @@ -186,8 +186,8 @@ framework( "//submodules/MessageReactionListUI:MessageReactionListUI", "//submodules/SegmentedControlNode:SegmentedControlNode", "//submodules/AppBundle:AppBundle", - "//submodules/WalletUI:WalletUI", - "//submodules/WalletCore:WalletCore", + #"//submodules/WalletUI:WalletUI", + #"//submodules/WalletCore:WalletCore", "//submodules/Markdown:Markdown", "//submodules/SearchPeerMembers:SearchPeerMembers", "//submodules/WidgetItems:WidgetItems", diff --git a/submodules/TelegramUI/TelegramUI/AccountContext.swift b/submodules/TelegramUI/TelegramUI/AccountContext.swift index 706fbe8488..02fefc79c0 100644 --- a/submodules/TelegramUI/TelegramUI/AccountContext.swift +++ b/submodules/TelegramUI/TelegramUI/AccountContext.swift @@ -10,8 +10,10 @@ import TelegramPresentationData import AccountContext import LiveLocationManager import TemporaryCachedPeerDataManager +#if ENABLE_WALLET import WalletCore import WalletUI +#endif import PhoneNumberFormat private final class DeviceSpecificContactImportContext { @@ -106,7 +108,9 @@ public final class AccountContextImpl: AccountContext { } public let account: Account + #if ENABLE_WALLET public let tonContext: StoredTonContext? + #endif public let fetchManager: FetchManager private let prefetchManager: PrefetchManager? @@ -142,6 +146,7 @@ public final class AccountContextImpl: AccountContext { private let deviceSpecificContactImportContexts: QueueLocalObject private var managedAppSpecificContactsDisposable: Disposable? + #if ENABLE_WALLET public var hasWallets: Signal { return WalletStorageInterfaceImpl(postbox: self.account.postbox).getWalletRecords() |> map { records in @@ -164,11 +169,15 @@ public final class AccountContextImpl: AccountContext { } |> distinctUntilChanged } + #endif - public init(sharedContext: SharedAccountContextImpl, account: Account, tonContext: StoredTonContext?, limitsConfiguration: LimitsConfiguration, contentSettings: ContentSettings, temp: Bool = false) { + public init(sharedContext: SharedAccountContextImpl, account: Account, /*tonContext: StoredTonContext?, */limitsConfiguration: LimitsConfiguration, contentSettings: ContentSettings, temp: Bool = false) + { self.sharedContextImpl = sharedContext self.account = account + #if ENABLE_WALLET self.tonContext = tonContext + #endif self.downloadedMediaStoreManager = DownloadedMediaStoreManagerImpl(postbox: account.postbox, accountManager: sharedContext.accountManager) diff --git a/submodules/TelegramUI/TelegramUI/AppDelegate.swift b/submodules/TelegramUI/TelegramUI/AppDelegate.swift index 02bcf8dd75..34183420de 100644 --- a/submodules/TelegramUI/TelegramUI/AppDelegate.swift +++ b/submodules/TelegramUI/TelegramUI/AppDelegate.swift @@ -26,10 +26,14 @@ import WatchBridge import LegacyDataImport import SettingsUI import AppBundle +#if ENABLE_WALLET import WalletUI +#endif import UrlHandling +#if ENABLE_WALLET import WalletUrl import WalletCore +#endif import OpenSSLEncryptionProvider import AppLock import PresentationDataUtils @@ -680,6 +684,7 @@ final class SharedApplicationContext { }) } + #if ENABLE_WALLET let tonKeychain: TonKeychain #if targetEnvironment(simulator) @@ -741,6 +746,7 @@ final class SharedApplicationContext { } }) #endif + #endif let sharedContextSignal = accountManagerSignal |> deliverOnMainQueue @@ -1003,8 +1009,10 @@ final class SharedApplicationContext { |> deliverOnMainQueue |> map { accountAndSettings -> AuthorizedApplicationContext? in return accountAndSettings.flatMap { account, limitsConfiguration, callListSettings, contentSettings in + #if ENABLE_WALLET let tonContext = StoredTonContext(basePath: account.basePath, postbox: account.postbox, network: account.network, keychain: tonKeychain) - let context = AccountContextImpl(sharedContext: sharedApplicationContext.sharedContext, account: account, tonContext: tonContext, limitsConfiguration: limitsConfiguration, contentSettings: contentSettings) + #endif + let context = AccountContextImpl(sharedContext: sharedApplicationContext.sharedContext, account: account/*, tonContext: tonContext*/, limitsConfiguration: limitsConfiguration, contentSettings: contentSettings) return AuthorizedApplicationContext(sharedApplicationContext: sharedApplicationContext, mainWindow: self.mainWindow, watchManagerArguments: watchManagerArgumentsPromise.get(), context: context, accountManager: sharedApplicationContext.sharedContext.accountManager, showCallsTab: callListSettings.showTab, reinitializedNotificationSettings: { let _ = (self.context.get() |> take(1) @@ -1741,10 +1749,13 @@ final class SharedApplicationContext { }), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {}) } else if let confirmationCode = parseConfirmationCodeUrl(url) { authContext.rootController.applyConfirmationCode(confirmationCode) - } else if let _ = parseWalletUrl(url) { + } + #if ENABLE_WALLET + if let _ = parseWalletUrl(url) { let presentationData = authContext.sharedContext.currentPresentationData.with { $0 } authContext.rootController.currentWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: "Please log in to your account to use Gram Wallet.", actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), on: .root, blockInteraction: false, completion: {}) } + #endif } }) } diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index 8e92f38297..e19a44ca6e 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -49,8 +49,10 @@ import ReactionSelectionNode import AvatarNode import MessageReactionListUI import AppBundle +#if ENABLE_WALLET import WalletUI import WalletUrl +#endif import LocalizedPeerData import PhoneNumberFormat import SettingsUI @@ -5695,9 +5697,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { if let (host, port, username, password, secret) = parseProxyUrl(code) { strongSelf.openResolved(ResolvedUrl.proxy(host: host, port: port, username: username, password: password, secret: secret)) - } else if let url = URL(string: code), let parsedWalletUrl = parseWalletUrl(url) { + }/* else if let url = URL(string: code), let parsedWalletUrl = parseWalletUrl(url) { //strongSelf.openResolved(ResolvedUrl.wallet(address: parsedWalletUrl.address, amount: parsedWalletUrl.amount, comment: parsedWalletUrl.comment)) - } + }*/ } }, presentSchedulePicker: { [weak self] done in if let strongSelf = self { diff --git a/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift index 271975abbe..4f299bb032 100644 --- a/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatRecentActionsControllerNode.swift @@ -813,8 +813,10 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { break case .theme: break + #if ENABLE_WALLET case .wallet: break + #endif case .settings: break } diff --git a/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift b/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift index 31c5965dd5..3ac3a2bf4f 100644 --- a/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/TelegramUI/OpenResolvedUrl.swift @@ -371,11 +371,13 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur present(textAlertController(context: context, title: nil, text: errorText, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) })) dismissInput() + #if ENABLE_WALLET case let .wallet(address, amount, comment): dismissInput() context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in navigationController?.pushViewController(c) } + #endif case let .settings(section): dismissInput() switch section { diff --git a/submodules/TelegramUI/TelegramUI/OpenUrl.swift b/submodules/TelegramUI/TelegramUI/OpenUrl.swift index b7f18394e6..8257e50929 100644 --- a/submodules/TelegramUI/TelegramUI/OpenUrl.swift +++ b/submodules/TelegramUI/TelegramUI/OpenUrl.swift @@ -16,8 +16,10 @@ import AccountContext import UrlEscaping import PassportUI import UrlHandling +#if ENABLE_WALLET import WalletUI import WalletUrl +#endif import OpenInExternalAppUI public struct ParsedSecureIdUrl { @@ -144,6 +146,7 @@ func formattedConfirmationCode(_ code: Int) -> String { } func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, url: String, forceExternal: Bool, presentationData: PresentationData, navigationController: NavigationController?, dismissInput: @escaping () -> Void) { + #if ENABLE_WALLET if url.hasPrefix("ton://") { if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) { context.sharedContext.openWallet(context: context, walletContext: .send(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment)) { c in @@ -153,6 +156,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur return } + #endif if forceExternal || url.lowercased().hasPrefix("tel:") || url.lowercased().hasPrefix("calshow:") { context.sharedContext.applicationBindings.openUrl(url) diff --git a/submodules/TelegramUI/TelegramUI/ShareExtensionContext.swift b/submodules/TelegramUI/TelegramUI/ShareExtensionContext.swift index ce660a1158..831d15766c 100644 --- a/submodules/TelegramUI/TelegramUI/ShareExtensionContext.swift +++ b/submodules/TelegramUI/TelegramUI/ShareExtensionContext.swift @@ -271,7 +271,7 @@ public class ShareRootControllerImpl { |> castError(ShareAuthorizationError.self) |> map { sharedData, limitsConfigurationAndContentSettings, data -> (AccountContext, PostboxAccessChallengeData, [AccountWithInfo]) in updateLegacyLocalization(strings: sharedContext.currentPresentationData.with({ $0 }).strings) - let context = AccountContextImpl(sharedContext: sharedContext, account: account, tonContext: nil, limitsConfiguration: limitsConfigurationAndContentSettings.0, contentSettings: limitsConfigurationAndContentSettings.1) + let context = AccountContextImpl(sharedContext: sharedContext, account: account/*, tonContext: nil*/, limitsConfiguration: limitsConfigurationAndContentSettings.0, contentSettings: limitsConfigurationAndContentSettings.1) return (context, data.data, otherAccounts) } } diff --git a/submodules/TelegramUI/TelegramUI/SharedAccountContext.swift b/submodules/TelegramUI/TelegramUI/SharedAccountContext.swift index f6fa41cde3..716a3d0b16 100644 --- a/submodules/TelegramUI/TelegramUI/SharedAccountContext.swift +++ b/submodules/TelegramUI/TelegramUI/SharedAccountContext.swift @@ -15,13 +15,15 @@ import PeersNearbyUI import PeerInfoUI import SettingsUI import UrlHandling +#if ENABLE_WALLET import WalletUI +import WalletCore +#endif import LegacyMediaPickerUI import LocalMediaResources import OverlayStatusController import AlertUI import PresentationDataUtils -import WalletCore private enum CallStatusText: Equatable { case none @@ -892,7 +894,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { } public func makeTempAccountContext(account: Account) -> AccountContext { - return AccountContextImpl(sharedContext: self, account: account, tonContext: nil, limitsConfiguration: .defaultValue, contentSettings: .default, temp: true) + return AccountContextImpl(sharedContext: self, account: account/*, tonContext: nil*/, limitsConfiguration: .defaultValue, contentSettings: .default, temp: true) } public func openChatMessage(_ params: OpenChatMessageParams) -> Bool { @@ -1146,6 +1148,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { return ChatMessageDateHeader(timestamp: timestamp, scheduled: false, presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: theme, wallpaper: wallpaper), fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameOrder, disableAnimations: false, largeEmoji: false, chatBubbleCorners: chatBubbleCorners, animatedEmojiScale: 1.0, isPreview: true), context: context) } + #if ENABLE_WALLET public func openWallet(context: AccountContext, walletContext: OpenWalletContext, present: @escaping (ViewController) -> Void) { guard let storedContext = context.tonContext else { return @@ -1205,6 +1208,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { } }) } + #endif public func openImagePicker(context: AccountContext, completion: @escaping (UIImage) -> Void, present: @escaping (ViewController) -> Void) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } diff --git a/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift b/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift index cc46c4172e..ed51dcace7 100644 --- a/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift +++ b/submodules/TelegramUI/TelegramUI/TextLinkHandling.swift @@ -66,10 +66,12 @@ func handleTextLinkActionImpl(context: AccountContext, peerId: PeerId?, navigate controller.present(JoinLinkPreviewController(context: context, link: link, navigateToPeer: { peerId in openResolvedPeerImpl(peerId, .chat(textInputState: nil, subject: nil)) }, parentNavigationController: controller.navigationController as? NavigationController), in: .window(.root)) + #if ENABLE_WALLET case let .wallet(address, amount, comment): context.sharedContext.openWallet(context: context, walletContext: .send(address: address, amount: amount, comment: comment)) { c in (controller.navigationController as? NavigationController)?.pushViewController(c) } + #endif default: break } diff --git a/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift b/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift index d3ecede9b6..f4e6630aa5 100644 --- a/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift +++ b/submodules/TelegramUI/TelegramUI/WalletContextImpl.swift @@ -1,3 +1,5 @@ +#if ENABLE_WALLET + import Foundation import UIKit import Display @@ -278,3 +280,5 @@ final class WalletContextImpl: WalletContext { }) } } + +#endif diff --git a/submodules/UrlHandling/BUCK b/submodules/UrlHandling/BUCK index b676eb77ce..ace74ae785 100644 --- a/submodules/UrlHandling/BUCK +++ b/submodules/UrlHandling/BUCK @@ -13,7 +13,7 @@ static_library( "//submodules/MtProtoKit:MtProtoKit#shared", "//submodules/AccountContext:AccountContext", "//submodules/TelegramUIPreferences:TelegramUIPreferences", - "//submodules/WalletUrl:WalletUrl", + #"//submodules/WalletUrl:WalletUrl", ], frameworks = [ "$SDKROOT/System/Library/Frameworks/Foundation.framework", diff --git a/submodules/UrlHandling/Sources/UrlHandling.swift b/submodules/UrlHandling/Sources/UrlHandling.swift index bd53d7861c..d55894f190 100644 --- a/submodules/UrlHandling/Sources/UrlHandling.swift +++ b/submodules/UrlHandling/Sources/UrlHandling.swift @@ -12,7 +12,9 @@ import MtProtoKitDynamic import TelegramPresentationData import TelegramUIPreferences import AccountContext +#if ENABLE_WALLET import WalletUrl +#endif public enum ParsedInternalPeerUrlParameter { case botStart(String) @@ -425,11 +427,13 @@ public func parseWallpaperUrl(_ url: String) -> WallpaperUrlParameter? { } public func resolveUrlImpl(account: Account, url: String) -> Signal { + #if ENABLE_WALLET if url.hasPrefix("ton://") { if let url = URL(string: url), let parsedUrl = parseWalletUrl(url) { return .single(.wallet(address: parsedUrl.address, amount: parsedUrl.amount, comment: parsedUrl.comment)) } } + #endif let schemes = ["http://", "https://", ""] let baseTelegramMePaths = ["telegram.me", "t.me"] for basePath in baseTelegramMePaths { diff --git a/submodules/WalletUI/BUCK b/submodules/WalletUI/BUCK index 5194a2e218..cbda117102 100644 --- a/submodules/WalletUI/BUCK +++ b/submodules/WalletUI/BUCK @@ -37,8 +37,8 @@ static_library( "//submodules/LocalAuth:LocalAuth", "//submodules/ScreenCaptureDetection:ScreenCaptureDetection", "//submodules/AnimatedStickerNode:AnimatedStickerNode", - "//submodules/WalletUrl:WalletUrl", - "//submodules/WalletCore:WalletCore", + #"//submodules/WalletUrl:WalletUrl", + #"//submodules/WalletCore:WalletCore", "//submodules/StringPluralization:StringPluralization", "//submodules/ActivityIndicator:ActivityIndicator", "//submodules/ProgressNavigationButtonNode:ProgressNavigationButtonNode",