Skip to content

Commit

Permalink
Merge commit '7c13b21414daebbfd5a0e426beae265ca2dceaaa' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Mar 28, 2024
2 parents fba37dc + 7c13b21 commit 6547328
Show file tree
Hide file tree
Showing 3,152 changed files with 588,684 additions and 1,416,849 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ private final class NotificationServiceHandler {
let _ = try? FileManager.default.createDirectory(atPath: logsPath, withIntermediateDirectories: true, attributes: nil)

setupSharedLogger(rootPath: logsPath, path: logsPath)

Logger.shared.log("NotificationService \(episode)", "Started handling notification")

initializeAccountManagement()

Expand Down
296 changes: 293 additions & 3 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings

Large diffs are not rendered by default.

71 changes: 58 additions & 13 deletions Telegram/WidgetKitWidget/TodayViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,22 @@ struct WidgetView: View {
chatUpdateView(size: geometry.size)
})
})
.background(Rectangle().foregroundColor(getBackgroundColor()))
.padding(0.0)
.unredacted()
.widgetBackground(Rectangle().foregroundColor(getBackgroundColor()))
}
}

@available(iOSApplicationExtension 14.0, iOS 14.0, *)
extension View {
func widgetBackground(_ backgroundView: some View) -> some View {
if #available(iOSApplicationExtension 17.0, iOS 17.0, *) {
return containerBackground(for: .widget) {
backgroundView
}
} else {
return background(backgroundView)
}
}
}

Expand Down Expand Up @@ -766,6 +779,17 @@ struct AvatarsWidgetView: View {
}
}

func getBackgroundColor() -> Color {
switch colorScheme {
case .light:
return .white
case .dark:
return Color(.sRGB, red: 28.0 / 255.0, green: 28.0 / 255.0, blue: 30.0 / 255.0, opacity: 1.0)
@unknown default:
return .secondary
}
}

func itemView(index: Int) -> some View {
let peers: ParsedPeers?
var isPlaceholder = false
Expand Down Expand Up @@ -821,6 +845,7 @@ struct AvatarsWidgetView: View {
})
.padding(EdgeInsets(top: 10.0, leading: 10.0, bottom: 10.0, trailing: 10.0))
.unredacted()
.widgetBackground(Rectangle().foregroundColor(getBackgroundColor()))
}
}

Expand Down Expand Up @@ -854,12 +879,22 @@ struct Static_Widget: Widget {
public var body: some WidgetConfiguration {
let presentationData = WidgetPresentationData.getForExtension()

return IntentConfiguration(kind: kind, intent: SelectFriendsIntent.self, provider: Provider(), content: { entry in
WidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetChatsGalleryTitle)
.description(presentationData.widgetChatsGalleryDescription)
if #available(iOSApplicationExtension 15.0, iOS 15.0, *) {
return IntentConfiguration(kind: kind, intent: SelectFriendsIntent.self, provider: Provider(), content: { entry in
WidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetChatsGalleryTitle)
.contentMarginsDisabled()
.description(presentationData.widgetChatsGalleryDescription)
} else {
return IntentConfiguration(kind: kind, intent: SelectFriendsIntent.self, provider: Provider(), content: { entry in
WidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetChatsGalleryTitle)
.description(presentationData.widgetChatsGalleryDescription)
}
}
}

Expand All @@ -870,12 +905,22 @@ struct Static_AvatarsWidget: Widget {
public var body: some WidgetConfiguration {
let presentationData = WidgetPresentationData.getForExtension()

return IntentConfiguration(kind: kind, intent: SelectAvatarFriendsIntent.self, provider: AvatarsProvider(), content: { entry in
AvatarsWidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetShortcutsGalleryTitle)
.description(presentationData.widgetShortcutsGalleryDescription)
if #available(iOSApplicationExtension 15.0, iOS 15.0, *) {
return IntentConfiguration(kind: kind, intent: SelectAvatarFriendsIntent.self, provider: AvatarsProvider(), content: { entry in
AvatarsWidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetShortcutsGalleryTitle)
.contentMarginsDisabled()
.description(presentationData.widgetShortcutsGalleryDescription)
} else {
return IntentConfiguration(kind: kind, intent: SelectAvatarFriendsIntent.self, provider: AvatarsProvider(), content: { entry in
AvatarsWidgetView(data: getWidgetData(contents: entry.contents), presentationData: presentationData)
})
.supportedFamilies([.systemMedium])
.configurationDisplayName(presentationData.widgetShortcutsGalleryTitle)
.description(presentationData.widgetShortcutsGalleryDescription)
}
}
}

Expand Down
45 changes: 40 additions & 5 deletions submodules/AccountContext/Sources/AccountContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public enum TextLinkItemActionType {
case longTap
}

public enum TextLinkItem {
public enum TextLinkItem: Equatable {
case url(url: String, concealed: Bool)
case mention(String)
case hashtag(String?, String)
Expand Down Expand Up @@ -307,6 +307,7 @@ public enum ResolvedUrl {
case boost(peerId: PeerId?, status: ChannelBoostStatus?, myBoostStatus: MyBoostStatus?)
case premiumGiftCode(slug: String)
case premiumMultiGift(reference: String?)
case messageLink(link: TelegramResolvedMessageLink?)
}

public enum ResolveUrlResult {
Expand Down Expand Up @@ -844,7 +845,9 @@ public protocol TelegramRootControllerInterface: NavigationController {

func getContactsController() -> ViewController?
func getChatsController() -> ViewController?
func getPrivacySettings() -> Promise<AccountPrivacySettings?>?
func openSettings()
func openBirthdaySetup()
}

public protocol QuickReplySetupScreenInitialData: AnyObject {
Expand All @@ -856,6 +859,21 @@ public protocol AutomaticBusinessMessageSetupScreenInitialData: AnyObject {
public protocol ChatbotSetupScreenInitialData: AnyObject {
}

public protocol BusinessIntroSetupScreenInitialData: AnyObject {
}

public protocol CollectibleItemInfoScreenInitialData: AnyObject {
var collectibleItemInfo: TelegramCollectibleItemInfo { get }
}

public protocol BusinessLinksSetupScreenInitialData: AnyObject {
}

public enum CollectibleItemInfoScreenSubject {
case phoneNumber(String)
case username(String)
}

public protocol SharedAccountContext: AnyObject {
var sharedContainerPath: String { get }
var basePath: String { get }
Expand Down Expand Up @@ -889,7 +907,7 @@ public protocol SharedAccountContext: AnyObject {

var activeAccountContexts: Signal<(primary: AccountContext?, accounts: [(AccountRecordId, AccountContext, Int32)], currentAuth: UnauthorizedAccount?), NoError> { get }
var activeAccountsWithInfo: Signal<(primary: AccountRecordId?, accounts: [AccountWithInfo]), NoError> { get }

var presentGlobalController: (ViewController, Any?) -> Void { get }
var presentCrossfadeController: () -> Void { get }

Expand Down Expand Up @@ -934,6 +952,8 @@ public protocol SharedAccountContext: AnyObject {
func makeCreateGroupController(context: AccountContext, peerIds: [PeerId], initialTitle: String?, mode: CreateGroupMode, completion: ((PeerId, @escaping () -> Void) -> Void)?) -> ViewController
func makeChatRecentActionsController(context: AccountContext, peer: Peer, adminPeerId: PeerId?) -> ViewController
func makePrivacyAndSecurityController(context: AccountContext) -> ViewController
func makeBioPrivacyController(context: AccountContext, settings: Promise<AccountPrivacySettings?>, present: @escaping (ViewController) -> Void)
func makeBirthdayPrivacyController(context: AccountContext, settings: Promise<AccountPrivacySettings?>, openedFromBirthdayScreen: Bool, present: @escaping (ViewController) -> Void)
func makeSetupTwoFactorAuthController(context: AccountContext) -> ViewController
func makeStorageManagementController(context: AccountContext) -> ViewController
func makeAttachmentFileController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, bannedSendMedia: (Int32, Bool)?, presentGallery: @escaping () -> Void, presentFiles: @escaping () -> Void, send: @escaping (AnyMediaReference) -> Void) -> AttachmentFileController
Expand All @@ -951,6 +971,14 @@ public protocol SharedAccountContext: AnyObject {
func makeAutomaticBusinessMessageSetupScreenInitialData(context: AccountContext) -> Signal<AutomaticBusinessMessageSetupScreenInitialData, NoError>
func makeQuickReplySetupScreen(context: AccountContext, initialData: QuickReplySetupScreenInitialData) -> ViewController
func makeQuickReplySetupScreenInitialData(context: AccountContext) -> Signal<QuickReplySetupScreenInitialData, NoError>
func makeBusinessIntroSetupScreen(context: AccountContext, initialData: BusinessIntroSetupScreenInitialData) -> ViewController
func makeBusinessIntroSetupScreenInitialData(context: AccountContext) -> Signal<BusinessIntroSetupScreenInitialData, NoError>
func makeBusinessLinksSetupScreen(context: AccountContext, initialData: BusinessLinksSetupScreenInitialData) -> ViewController
func makeBusinessLinksSetupScreenInitialData(context: AccountContext) -> Signal<BusinessLinksSetupScreenInitialData, NoError>
func makeCollectibleItemInfoScreen(context: AccountContext, initialData: CollectibleItemInfoScreenInitialData) -> ViewController
func makeCollectibleItemInfoScreenInitialData(context: AccountContext, peerId: EnginePeer.Id, subject: CollectibleItemInfoScreenSubject) -> Signal<CollectibleItemInfoScreenInitialData?, NoError>
func makeBotSettingsScreen(context: AccountContext, peerId: EnginePeer.Id?) -> ViewController

func navigateToChatController(_ params: NavigateToChatControllerParams)
func navigateToForumChannel(context: AccountContext, peerId: EnginePeer.Id, navigationController: NavigationController)
func navigateToForumThread(context: AccountContext, peerId: EnginePeer.Id, threadId: Int64, messageId: EngineMessage.Id?, navigationController: NavigationController, activateInput: ChatControllerActivateInput?, keepStack: NavigateToChatKeepStack) -> Signal<Never, NoError>
Expand Down Expand Up @@ -980,14 +1008,19 @@ public protocol SharedAccountContext: AnyObject {
func makePremiumLimitController(context: AccountContext, subject: PremiumLimitSubject, count: Int32, forceDark: Bool, cancel: @escaping () -> Void, action: @escaping () -> Bool) -> ViewController
func makePremiumGiftController(context: AccountContext, source: PremiumGiftSource, completion: (() -> Void)?) -> ViewController
func makePremiumPrivacyControllerController(context: AccountContext, subject: PremiumPrivacySubject, peerId: EnginePeer.Id) -> ViewController
func makePremiumBoostLevelsController(context: AccountContext, peerId: EnginePeer.Id, boostStatus: ChannelBoostStatus, myBoostStatus: MyBoostStatus, forceDark: Bool, openStats: (() -> Void)?) -> ViewController
func makePremiumBoostLevelsController(context: AccountContext, peerId: EnginePeer.Id, subject: BoostSubject, boostStatus: ChannelBoostStatus, myBoostStatus: MyBoostStatus, forceDark: Bool, openStats: (() -> Void)?) -> ViewController

func makeStickerPackScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], loadedStickerPacks: [LoadedStickerPack], parentNavigationController: NavigationController?, sendSticker: ((FileMediaReference, UIView, CGRect) -> Bool)?) -> ViewController
func makeStickerPackScreen(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, mainStickerPack: StickerPackReference, stickerPacks: [StickerPackReference], loadedStickerPacks: [LoadedStickerPack], isEditing: Bool, expandIfNeeded: Bool, parentNavigationController: NavigationController?, sendSticker: ((FileMediaReference, UIView, CGRect) -> Bool)?) -> ViewController

func makeMediaPickerScreen(context: AccountContext, hasSearch: Bool, completion: @escaping (Any) -> Void) -> ViewController

func makeStickerEditorScreen(context: AccountContext, source: Any?, transitionArguments: (UIView, CGRect, UIImage?)?, completion: @escaping (TelegramMediaFile, [String], @escaping () -> Void) -> Void) -> ViewController

func makeStickerMediaPickerScreen(context: AccountContext, getSourceRect: @escaping () -> CGRect, completion: @escaping (Any?, UIView?, CGRect, UIImage?, @escaping (Bool?) -> (UIView, CGRect)?, @escaping () -> Void) -> Void, dismissed: @escaping () -> Void) -> ViewController
func makeStoryMediaPickerScreen(context: AccountContext, getSourceRect: @escaping () -> CGRect, completion: @escaping (Any, UIView, CGRect, UIImage?, @escaping (Bool?) -> (UIView, CGRect)?, @escaping () -> Void) -> Void, dismissed: @escaping () -> Void, groupsPresented: @escaping () -> Void) -> ViewController

func makeStickerPickerScreen(context: AccountContext, inputData: Promise<StickerPickerInput>, completion: @escaping (TelegramMediaFile) -> Void) -> ViewController

func makeProxySettingsController(sharedContext: SharedAccountContext, account: UnauthorizedAccount) -> ViewController

func makeInstalledStickerPacksController(context: AccountContext, mode: InstalledStickerPacksControllerMode, forceTheme: PresentationTheme?) -> ViewController
Expand Down Expand Up @@ -1051,7 +1084,9 @@ public protocol AccountContext: AnyObject {
var animationCache: AnimationCache { get }
var animationRenderer: MultiAnimationRenderer { get }

var animatedEmojiStickers: [String: [StickerPackItem]] { get }
var animatedEmojiStickers: Signal<[String: [StickerPackItem]], NoError> { get }
var animatedEmojiStickersValue: [String: [StickerPackItem]] { get }
var additionalAnimatedEmojiStickers: Signal<[String: [Int: StickerPackItem]], NoError> { get }

var isPremium: Bool { get }
var userLimits: EngineConfiguration.UserLimits { get }
Expand Down
6 changes: 6 additions & 0 deletions submodules/AccountContext/Sources/ChatController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ public final class PeerInfoNavigationSourceTag {

public protocol PeerInfoScreen: ViewController {
var peerId: PeerId { get }
var privacySettings: Promise<AccountPrivacySettings?> { get }

func openBirthdaySetup()
}

public extension Peer {
Expand Down Expand Up @@ -992,6 +995,7 @@ public protocol ChatController: ViewController {
var isSelectingMessagesUpdated: ((Bool) -> Void)? { get set }
func cancelSelectingMessages()
func activateSearch(domain: ChatSearchDomain, query: String)
func activateInput(type: ChatControllerActivateInput)
func beginClearHistory(type: InteractiveHistoryClearingType)

func performScrollToTop() -> Bool
Expand Down Expand Up @@ -1088,6 +1092,7 @@ public enum ChatQuickReplyShortcutType {

public enum ChatCustomContentsKind: Equatable {
case quickReplyMessageInput(shortcut: String, shortcutType: ChatQuickReplyShortcutType)
case businessLinkSetup(link: TelegramBusinessChatLinks.Link)
}

public protocol ChatCustomContentsProtocol: AnyObject {
Expand All @@ -1100,6 +1105,7 @@ public protocol ChatCustomContentsProtocol: AnyObject {
func editMessage(id: EngineMessage.Id, text: String, media: RequestEditMessageMedia, entities: TextEntitiesMessageAttribute?, webpagePreviewAttribute: WebpagePreviewMessageAttribute?, disableUrlPreview: Bool)

func quickReplyUpdateShortcut(value: String)
func businessLinkUpdate(message: String, entities: [MessageTextEntity], title: String?)
}

public enum ChatHistoryListDisplayHeaders {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public enum ContactMultiselectionControllerMode {
public var displayAutoremoveTimeout: Bool
public var displayPresence: Bool
public var onlyUsers: Bool
public var disableChannels: Bool
public var disableBots: Bool

public init(
title: String,
Expand All @@ -55,7 +57,9 @@ public enum ContactMultiselectionControllerMode {
chatListFilters: [ChatListFilter]?,
displayAutoremoveTimeout: Bool = false,
displayPresence: Bool = false,
onlyUsers: Bool = false
onlyUsers: Bool = false,
disableChannels: Bool = false,
disableBots: Bool = false
) {
self.title = title
self.searchPlaceholder = searchPlaceholder
Expand All @@ -65,14 +69,16 @@ public enum ContactMultiselectionControllerMode {
self.displayAutoremoveTimeout = displayAutoremoveTimeout
self.displayPresence = displayPresence
self.onlyUsers = onlyUsers
self.disableChannels = disableChannels
self.disableBots = disableBots
}
}

case groupCreation
case peerSelection(searchChatList: Bool, searchGroups: Bool, searchChannels: Bool)
case channelCreation
case chatSelection(ChatSelection)
case premiumGifting
case premiumGifting(birthdays: [EnginePeer.Id: TelegramBirthday]?, selectToday: Bool)
case requestedUsersSelection
}

Expand All @@ -90,19 +96,21 @@ public final class ContactMultiselectionControllerParams {
public let options: [ContactListAdditionalOption]
public let filters: [ContactListFilter]
public let onlyWriteable: Bool
public let isGroupInvitation: Bool
public let isPeerEnabled: ((EnginePeer) -> Bool)?
public let attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)?
public let alwaysEnabled: Bool
public let limit: Int32?
public let reachedLimit: ((Int32) -> Void)?

public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter] = [.excludeSelf], onlyWriteable: Bool = false, isPeerEnabled: ((EnginePeer) -> Bool)? = nil, attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)? = nil, alwaysEnabled: Bool = false, limit: Int32? = nil, reachedLimit: ((Int32) -> Void)? = nil) {
public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter] = [.excludeSelf], onlyWriteable: Bool = false, isGroupInvitation: Bool = false, isPeerEnabled: ((EnginePeer) -> Bool)? = nil, attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)? = nil, alwaysEnabled: Bool = false, limit: Int32? = nil, reachedLimit: ((Int32) -> Void)? = nil) {
self.context = context
self.updatedPresentationData = updatedPresentationData
self.mode = mode
self.options = options
self.filters = filters
self.onlyWriteable = onlyWriteable
self.isGroupInvitation = isGroupInvitation
self.isPeerEnabled = isPeerEnabled
self.attemptDisabledItemSelection = attemptDisabledItemSelection
self.alwaysEnabled = alwaysEnabled
Expand Down
8 changes: 8 additions & 0 deletions submodules/AccountContext/Sources/GalleryController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ public final class GalleryControllerActionInteraction {
self.updateCanReadHistory = updateCanReadHistory
}
}

public protocol StickerPackScreen {

}

public protocol StickerPickerInput {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import Foundation
public struct GlobalExperimentalSettings {
public static var isAppStoreBuild: Bool = false
public static var enableFeed: Bool = false
public static var enableWIPStickers: Bool = false
}
Loading

0 comments on commit 6547328

Please sign in to comment.