diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorController.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorController.h index 722b36b1a9..e82f3b5c6d 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorController.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoEditorController.h @@ -86,7 +86,7 @@ typedef enum { - (void)setToolbarHidden:(bool)hidden animated:(bool)animated; -+ (TGPhotoEditorTab)defaultTabsForAvatarIntent; ++ (TGPhotoEditorTab)defaultTabsForAvatarIntent:(bool)hasStickers; - (NSTimeInterval)currentTime; - (void)setMinimalVideoDuration:(NSTimeInterval)duration; diff --git a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m index 5854d03db7..e25cce7ab6 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m @@ -919,7 +919,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; intent |= TGPhotoEditorControllerSuggestingAvatarIntent; } - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent:!_disableStickers] selectedTab:TGPhotoEditorCropTab]; controller.editingContext = _editingContext; controller.stickersContext = _stickersContext; controller.dontHideStatusBar = true; diff --git a/submodules/LegacyComponents/Sources/TGCameraController.m b/submodules/LegacyComponents/Sources/TGCameraController.m index b870a8017e..a2319afee4 100644 --- a/submodules/LegacyComponents/Sources/TGCameraController.m +++ b/submodules/LegacyComponents/Sources/TGCameraController.m @@ -1986,7 +1986,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus if (_intent == TGCameraControllerSignupAvatarIntent) { intent = TGPhotoEditorControllerSignupAvatarIntent; } - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:input intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:windowContext item:input intent:(TGPhotoEditorControllerFromCameraIntent | intent) adjustments:nil caption:nil screenImage:image availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent:_intent != TGCameraControllerSignupAvatarIntent] selectedTab:TGPhotoEditorCropTab]; controller.stickersContext = _stickersContext; __weak TGPhotoEditorController *weakController = controller; controller.beginTransitionIn = ^UIView *(CGRect *referenceFrame, __unused UIView **parentView) diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m b/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m index d6d9d2420b..db9e1d96f3 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsPickerController.m @@ -448,7 +448,7 @@ editableItem = [[TGCameraCapturedVideo alloc] initWithAsset:asset livePhoto:false]; } - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableItem intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:_context item:editableItem intent:intent adjustments:nil caption:nil screenImage:thumbnailImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent:_intent != TGMediaAssetsControllerSetSignupProfilePhotoIntent] selectedTab:TGPhotoEditorCropTab]; controller.stickersContext = self.stickersContext; controller.editingContext = self.editingContext; controller.didFinishRenderingFullSizeImage = ^(UIImage *resultImage) diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m index 521eb6c6c5..6dc6c052ad 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarCropView.m @@ -93,10 +93,13 @@ const CGFloat TGPhotoAvatarCropViewCurtainMargin = 200; [_wrapperView addSubview:_fullPaintingView]; _entitiesWrapperView = [[UIView alloc] init]; - _fullEntitiesView = fullEntitiesView; - _fullEntitiesView.frame = CGRectMake(0.0, 0.0, _fullEntitiesView.frame.size.width, _fullEntitiesView.frame.size.height); - _entitiesWrapperView.frame = _fullEntitiesView.frame; - + if (fullEntitiesView != nil) { + _fullEntitiesView = fullEntitiesView; + _fullEntitiesView.frame = CGRectMake(0.0, 0.0, _fullEntitiesView.frame.size.width, _fullEntitiesView.frame.size.height); + _entitiesWrapperView.frame = _fullEntitiesView.frame; + } else { + _entitiesWrapperView.frame = CGRectMake(0.0, 0.0, _fullPreviewView.frame.size.width, _fullPreviewView.frame.size.height); + } CGFloat entitiesScale = _fullPreviewView.frame.size.width / _entitiesWrapperView.frame.size.width; _entitiesWrapperView.transform = CGAffineTransformMakeScale(entitiesScale, entitiesScale); _entitiesWrapperView.frame = _fullPreviewView.frame; diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m index 183cd5a500..cde8a7acbb 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m @@ -951,7 +951,11 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel - (TGPhotoEditorTab)availableTabs { - return TGPhotoEditorRotateTab | TGPhotoEditorMirrorTab | TGPhotoEditorPaintTab | TGPhotoEditorToolsTab; + TGPhotoEditorTab tabs = TGPhotoEditorRotateTab | TGPhotoEditorMirrorTab | TGPhotoEditorToolsTab; + if (self.intent != TGPhotoEditorControllerSignupAvatarIntent) { + tabs |= TGPhotoEditorPaintTab; + } + return tabs; } - (TGPhotoEditorTab)activeTab diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 0ca5fa708b..b9b5dc374d 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -2604,15 +2604,12 @@ }]]; } -+ (TGPhotoEditorTab)defaultTabsForAvatarIntent ++ (TGPhotoEditorTab)defaultTabsForAvatarIntent:(bool)hasStickers { - static dispatch_once_t onceToken; - static TGPhotoEditorTab avatarTabs = TGPhotoEditorNoneTab; - dispatch_once(&onceToken, ^ - { - if (iosMajorVersion() >= 7) - avatarTabs = TGPhotoEditorCropTab | TGPhotoEditorPaintTab | TGPhotoEditorToolsTab; - }); + TGPhotoEditorTab avatarTabs = TGPhotoEditorCropTab | TGPhotoEditorToolsTab; + if (hasStickers) { + avatarTabs |= TGPhotoEditorPaintTab; + } return avatarTabs; } diff --git a/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m b/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m index e84c558420..38e1c6ebdc 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m +++ b/submodules/LegacyComponents/Sources/TGPhotoVideoEditor.m @@ -34,7 +34,7 @@ } void (^present)(UIImage *) = ^(UIImage *screenImage) { - TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:TGPhotoEditorControllerAvatarIntent | TGPhotoEditorControllerSuggestedAvatarIntent adjustments:nil caption:nil screenImage:screenImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab]; + TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:TGPhotoEditorControllerAvatarIntent | TGPhotoEditorControllerSuggestedAvatarIntent adjustments:nil caption:nil screenImage:screenImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent:true] selectedTab:TGPhotoEditorCropTab]; controller.senderName = senderName; controller.stickersContext = stickersContext; diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift index a54cc158d2..15589e06d0 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyPaintStickersContext.swift @@ -423,14 +423,14 @@ public final class LegacyPaintEntityRenderer: NSObject, TGPhotoPaintEntityRender self.isAvatar = ((adjustments as? TGVideoEditAdjustments)?.documentId ?? 0) != 0 var renderEntities: [LegacyPaintEntity] = [] - if let account = account, let paintingData = adjustments.paintingData, let entitiesData = paintingData.entitiesData { + if let paintingData = adjustments.paintingData, let entitiesData = paintingData.entitiesData { let entities = decodeDrawingEntities(data: entitiesData) for entity in entities { - if let sticker = entity as? DrawingStickerEntity { + if let sticker = entity as? DrawingStickerEntity, let account { renderEntities.append(LegacyPaintStickerEntity(account: account, entity: sticker)) } else if let text = entity as? DrawingTextEntity { renderEntities.append(LegacyPaintTextEntity(entity: text)) - if let renderSubEntities = text.renderSubEntities { + if let renderSubEntities = text.renderSubEntities, let account { for entity in renderSubEntities { renderEntities.append(LegacyPaintStickerEntity(account: account, entity: entity)) } diff --git a/submodules/WebSearchUI/Sources/LegacyWebSearchEditor.swift b/submodules/WebSearchUI/Sources/LegacyWebSearchEditor.swift index 15c406f9f9..7649f89917 100644 --- a/submodules/WebSearchUI/Sources/LegacyWebSearchEditor.swift +++ b/submodules/WebSearchUI/Sources/LegacyWebSearchEditor.swift @@ -36,7 +36,7 @@ func presentLegacyWebSearchEditor(context: AccountContext, theme: PresentationTh let paintStickersContext = LegacyPaintStickersContext(context: context) - let controller = TGPhotoEditorController(context: legacyController.context, item: item, intent: TGPhotoEditorControllerAvatarIntent, adjustments: nil, caption: nil, screenImage: screenImage ?? UIImage(), availableTabs: TGPhotoEditorController.defaultTabsForAvatarIntent(), selectedTab: .cropTab)! + let controller = TGPhotoEditorController(context: legacyController.context, item: item, intent: TGPhotoEditorControllerAvatarIntent, adjustments: nil, caption: nil, screenImage: screenImage ?? UIImage(), availableTabs: TGPhotoEditorController.defaultTabs(forAvatarIntent: true), selectedTab: .cropTab)! controller.stickersContext = paintStickersContext legacyController.bind(controller: controller)