From 4069dc467a9a1cfd8257fe2ddf7d971b4bfc5ac5 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 18 Apr 2023 12:49:43 +0400 Subject: [PATCH 1/3] Move Recent Actions to profile screen --- .../Sources/ChannelAdminsController.swift | 2 +- .../Sources/PeerInfo/PeerInfoScreen.swift | 38 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift index 1e05478f0f..066a127e4c 100644 --- a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift @@ -349,7 +349,7 @@ private func channelAdminsControllerEntries(presentationData: PresentationData, if case .group = peer.info { isGroup = true } - entries.append(.recentActions(presentationData.theme, presentationData.strings.Group_Info_AdminLog)) + //entries.append(.recentActions(presentationData.theme, presentationData.strings.Group_Info_AdminLog)) if isGroup && peer.hasPermission(.deleteAllMessages) && (antiSpamAvailable || antiSpamEnabled) { entries.append(.antiSpam(presentationData.theme, presentationData.strings.Group_Management_AntiSpam, antiSpamEnabled)) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index f5c09d23b4..8fcbad3449 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -514,6 +514,7 @@ private final class PeerInfoInteraction { let editingOpenDiscussionGroupSetup: () -> Void let editingToggleMessageSignatures: (Bool) -> Void let openParticipantsSection: (PeerInfoParticipantsSection) -> Void + let openRecentActions: () -> Void let editingOpenPreHistorySetup: () -> Void let editingOpenAutoremoveMesages: () -> Void let openPermissions: () -> Void @@ -564,6 +565,7 @@ private final class PeerInfoInteraction { editingOpenDiscussionGroupSetup: @escaping () -> Void, editingToggleMessageSignatures: @escaping (Bool) -> Void, openParticipantsSection: @escaping (PeerInfoParticipantsSection) -> Void, + openRecentActions: @escaping () -> Void, editingOpenPreHistorySetup: @escaping () -> Void, editingOpenAutoremoveMesages: @escaping () -> Void, openPermissions: @escaping () -> Void, @@ -613,6 +615,7 @@ private final class PeerInfoInteraction { self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup self.editingToggleMessageSignatures = editingToggleMessageSignatures self.openParticipantsSection = openParticipantsSection + self.openRecentActions = openRecentActions self.editingOpenPreHistorySetup = editingOpenPreHistorySetup self.editingOpenAutoremoveMesages = editingOpenAutoremoveMesages self.openPermissions = openPermissions @@ -1486,6 +1489,7 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL let ItemMembers = 9 let ItemMemberRequests = 10 let ItemBanned = 11 + let ItemRecentActions = 12 let isCreator = channel.flags.contains(.isCreator) @@ -1602,6 +1606,10 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemBanned, label: .text("\(bannedCount == 0 ? "" : "\(presentationStringsFormattedNumber(bannedCount, presentationData.dateTimeFormat.groupingSeparator))")"), text: presentationData.strings.GroupInfo_Permissions_Removed, icon: UIImage(bundleImageName: "Chat/Info/GroupRemovedIcon"), action: { interaction.openParticipantsSection(.banned) })) + + items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemRecentActions, label: .none, text: presentationData.strings.Group_Info_AdminLog, icon: UIImage(bundleImageName: "Chat/Info/RecentActionsIcon"), action: { + interaction.openRecentActions() + })) } } @@ -1621,13 +1629,14 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL let ItemAdmins = 108 let ItemMemberRequests = 109 let ItemRemovedUsers = 110 - let ItemLocationHeader = 111 - let ItemLocation = 112 - let ItemLocationSetup = 113 - let ItemDeleteGroup = 114 - let ItemReactions = 115 - let ItemTopics = 116 - let ItemTopicsText = 117 + let ItemRecentActions = 111 + let ItemLocationHeader = 112 + let ItemLocation = 113 + let ItemLocationSetup = 114 + let ItemDeleteGroup = 115 + let ItemReactions = 116 + let ItemTopics = 117 + let ItemTopicsText = 118 let isCreator = channel.flags.contains(.isCreator) let isPublic = channel.addressName != nil @@ -1832,6 +1841,10 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemRemovedUsers, label: .text(cachedData.participantsSummary.kickedCount.flatMap { $0 > 0 ? "\(presentationStringsFormattedNumber($0, presentationData.dateTimeFormat.groupingSeparator))" : "" } ?? ""), text: presentationData.strings.GroupInfo_Permissions_Removed, icon: UIImage(bundleImageName: "Chat/Info/GroupRemovedIcon"), action: { interaction.openParticipantsSection(.banned) })) + + items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemRecentActions, label: .none, text: presentationData.strings.Group_Info_AdminLog, icon: UIImage(bundleImageName: "Chat/Info/RecentActionsIcon"), action: { + interaction.openRecentActions() + })) } if isCreator { @@ -2207,6 +2220,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate openParticipantsSection: { [weak self] section in self?.openParticipantsSection(section: section) }, + openRecentActions: { [weak self] in + self?.openRecentActions() + }, editingOpenPreHistorySetup: { [weak self] in self?.editingOpenPreHistorySetup() }, @@ -6726,6 +6742,14 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } } + private func openRecentActions() { + guard let peer = self.data?.peer else { + return + } + let controller = self.context.sharedContext.makeChatRecentActionsController(context: self.context, peer: peer, adminPeerId: nil) + self.controller?.push(controller) + } + private func editingOpenPreHistorySetup() { guard let data = self.data, let peer = data.peer else { return From 447fc13416dddc496e2a01b42e5cfe33bbbb4247 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 18 Apr 2023 14:18:10 +0400 Subject: [PATCH 2/3] Don't create recorder's audio unit until audio session is activated (or else it won't work with headphones and music playing in other app) --- .../Sources/ManagedAudioRecorder.swift | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/submodules/TelegramUI/Sources/ManagedAudioRecorder.swift b/submodules/TelegramUI/Sources/ManagedAudioRecorder.swift index 0f5126ed12..9c564f72cd 100644 --- a/submodules/TelegramUI/Sources/ManagedAudioRecorder.swift +++ b/submodules/TelegramUI/Sources/ManagedAudioRecorder.swift @@ -337,11 +337,10 @@ final class ManagedAudioRecorderContext { self.toneTimer?.invalidate() } - func start() { - assert(self.queue.isCurrent()) - - self.paused = false - + private func setupAudioUnit() { + guard self.audioUnit.with({ $0 }) == nil else { + return + } var desc = AudioComponentDescription() desc.componentType = kAudioUnitType_Output desc.componentSubType = kAudioUnitSubType_RemoteIO @@ -395,6 +394,12 @@ final class ManagedAudioRecorderContext { } let _ = self.audioUnit.swap(audioUnit) + } + + func start() { + assert(self.queue.isCurrent()) + + self.paused = false if self.audioSessionDisposable == nil { let queue = self.queue @@ -402,6 +407,7 @@ final class ManagedAudioRecorderContext { queue.async { if let strongSelf = self, !strongSelf.paused { strongSelf.hasAudioSession = true + strongSelf.setupAudioUnit() strongSelf.audioSessionAcquired(headset: state.isHeadsetConnected) } } From a3fc5f5340cbce1a54b87f72b60be02ac182d8ad Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 18 Apr 2023 14:19:19 +0400 Subject: [PATCH 3/3] Limit avatar photo editor processed image size --- .../PublicHeaders/LegacyComponents/TGPhotoEditorUtils.h | 1 + submodules/LegacyComponents/Sources/TGPhotoEditorController.m | 2 +- submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorUtils.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorUtils.h index 86a85c0067..d63003e1e7 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorUtils.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorUtils.h @@ -47,6 +47,7 @@ CGSize TGPhotoEditorScreenImageMaxSize(); extern const CGSize TGPhotoEditorResultImageMaxSize; extern const CGSize TGPhotoEditorResultImageWallpaperMaxSize; +extern const CGSize TGPhotoEditorResultImageAvatarMaxSize; #ifdef __cplusplus } diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 7b296a5ff6..8ca9315893 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -498,7 +498,7 @@ }] map:^UIImage *(UIImage *image) { if (avatar) { - CGFloat maxSide = [GPUImageContext maximumTextureSizeForThisDevice]; + CGFloat maxSide = MIN(TGPhotoEditorResultImageAvatarMaxSize.width, [GPUImageContext maximumTextureSizeForThisDevice]); if (MAX(image.size.width, image.size.height) > maxSide) { CGSize fittedSize = TGScaleToFit(image.size, CGSizeMake(maxSide, maxSide)); return TGScaleImageToPixelSize(image, fittedSize); diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m b/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m index 949bb0b510..ec3e9d2888 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorUtils.m @@ -8,6 +8,7 @@ const CGSize TGPhotoEditorResultImageMaxSize = { 1280, 1280 }; const CGSize TGPhotoEditorResultImageWallpaperMaxSize = { 2048, 2048 }; +const CGSize TGPhotoEditorResultImageAvatarMaxSize = { 2048, 2048 }; const CGSize TGPhotoEditorScreenImageHardLimitSize = { 1280, 1280 }; const CGSize TGPhotoEditorScreenImageHardLimitLegacySize = { 750, 750 };