diff --git a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift index 100cc441c0..9f7bc8ba75 100644 --- a/submodules/PremiumUI/Sources/PremiumLimitScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumLimitScreen.swift @@ -255,7 +255,7 @@ public class PremiumLimitDisplayComponent: Component { let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation.z") rotateAnimation.fromValue = 0.0 as NSNumber - rotateAnimation.toValue = -0.38 as NSNumber + rotateAnimation.toValue = -0.3 as NSNumber rotateAnimation.duration = 0.15 rotateAnimation.fillMode = .forwards rotateAnimation.timingFunction = CAMediaTimingFunction(name: .easeOut) @@ -264,7 +264,7 @@ public class PremiumLimitDisplayComponent: Component { Queue.mainQueue().after(0.5, { let bounceAnimation = CABasicAnimation(keyPath: "transform.rotation.z") - bounceAnimation.fromValue = -0.38 as NSNumber + bounceAnimation.fromValue = -0.3 as NSNumber bounceAnimation.toValue = 0.05 as NSNumber bounceAnimation.duration = 0.15 bounceAnimation.fillMode = .forwards diff --git a/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditor.swift b/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditor.swift index 6b3ed5ec5e..6f495aec89 100644 --- a/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditor.swift +++ b/submodules/TelegramUI/Components/MediaEditor/Sources/MediaEditor.swift @@ -370,6 +370,7 @@ public final class MediaEditor { } self.audioDelayTimer?.invalidate() + self.audioDelayTimer = nil } public func replaceSource(_ image: UIImage, additionalImage: UIImage?, time: CMTime) { @@ -1066,7 +1067,12 @@ public final class MediaEditor { if let audioPlayer = self.audioPlayer { audioPlayer.pause() - self.destroyTimeObservers() + if self.sourceIsVideo { + self.audioDelayTimer?.invalidate() + self.audioDelayTimer = nil + } else { + self.destroyTimeObservers() + } self.audioPlayer = nil if !self.sourceIsVideo { diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index aaeaebe1cd..bd9680ce54 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -2096,7 +2096,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } let mediaEditor = MediaEditor(context: self.context, subject: subject.editorSubject, values: initialValues, hasHistogram: true) - if let initialVideoPosition = self.controller?.initialVideoPosition { + if let initialVideoPosition = controller.initialVideoPosition { mediaEditor.seek(initialVideoPosition, andPlay: true) } mediaEditor.attachPreviewView(self.previewView) @@ -2157,7 +2157,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate Queue.mainQueue().async { self.gradientView.image = gradientImage - if self.controller?.isEditingStory == true && subject.isVideo { + if self.controller?.isEditingStory == true { } else { self.previewContainerView.alpha = 1.0 @@ -2178,11 +2178,20 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate self.mediaEditor = mediaEditor self.mediaEditorPromise.set(.single(mediaEditor)) - if self.controller?.isEditingStory == true && subject.isVideo { + if controller.isEditingStory == true { mediaEditor.onFirstDisplay = { [weak self] in if let self { - self.previewContainerView.alpha = 1.0 - self.backgroundDimView.isHidden = false + if subject.isPhoto { + self.previewContainerView.layer.allowsGroupOpacity = true + self.previewContainerView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25, completion: { _ in + self.previewContainerView.layer.allowsGroupOpacity = false + self.previewContainerView.alpha = 1.0 + self.backgroundDimView.isHidden = false + }) + } else { + self.previewContainerView.alpha = 1.0 + self.backgroundDimView.isHidden = false + } } } } @@ -3177,14 +3186,27 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate return } + func maybeFixMisencodedText(_ text: String) -> String { + let charactersToSearchFor = CharacterSet(charactersIn: "àåèîóûþÿ") + if text.lowercased().rangeOfCharacter(from: charactersToSearchFor) != nil { + if let data = text.data(using: .windowsCP1252), let string = String(data: data, encoding: .windowsCP1251) { + return string + } else { + return text + } + } else { + return text + } + } + var artist: String? var title: String? for data in audioAsset.commonMetadata { - if data.commonKey == .commonKeyArtist { - artist = data.stringValue + if data.commonKey == .commonKeyArtist, let value = data.stringValue { + artist = maybeFixMisencodedText(value) } - if data.commonKey == .commonKeyTitle { - title = data.stringValue + if data.commonKey == .commonKeyTitle, let value = data.stringValue { + title = maybeFixMisencodedText(value) } } diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/VideoScrubberComponent.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/VideoScrubberComponent.swift index fa12da559d..b6c05fc156 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/VideoScrubberComponent.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/VideoScrubberComponent.swift @@ -643,26 +643,39 @@ final class VideoScrubberComponent: Component { } let audioTitle = NSAttributedString(string: trackTitle, font: Font.semibold(13.0), textColor: .white) - let audioTitleSize = self.audioTitle.update( - transition: transition, - component: AnyComponent( - MultilineTextComponent( - text: .plain(audioTitle) - ) - ), - environment: {}, - containerSize: availableSize - ) + let audioTitleSize: CGSize + if !trackTitle.isEmpty { + audioTitleSize = self.audioTitle.update( + transition: transition, + component: AnyComponent( + MultilineTextComponent( + text: .plain(audioTitle) + ) + ), + environment: {}, + containerSize: availableSize + ) + } else { + if let audioTitleView = self.audioTitle.view { + audioTitleSize = audioTitleView.bounds.size + } else { + audioTitleSize = .zero + } + } let spacing: CGFloat = 4.0 let iconSize = CGSize(width: 14.0, height: 14.0) let contentTotalWidth = iconSize.width + audioTitleSize.width + spacing + var audioContentTransition = audioTransition + if animateAudioAppearance, component.audioData != nil { + audioContentTransition = .immediate + } audioTransition.setAlpha(view: self.audioIconView, alpha: self.isAudioSelected ? 0.0 : 1.0) - + let audioIconFrame = CGRect(origin: CGPoint(x: max(8.0, floorToScreenPixels((deselectedAudioClipWidth - contentTotalWidth) / 2.0)), y: floorToScreenPixels((audioScrubberHeight - iconSize.height) / 2.0)), size: iconSize) - audioTransition.setBounds(view: self.audioIconView, bounds: CGRect(origin: .zero, size: audioIconFrame.size)) - audioTransition.setPosition(view: self.audioIconView, position: audioIconFrame.center) + audioContentTransition.setBounds(view: self.audioIconView, bounds: CGRect(origin: .zero, size: audioIconFrame.size)) + audioContentTransition.setPosition(view: self.audioIconView, position: audioIconFrame.center) let trackTitleIsVisible = !self.isAudioSelected && !component.audioOnly && !trackTitle.isEmpty if let view = self.audioTitle.view { @@ -677,7 +690,7 @@ final class VideoScrubberComponent: Component { let audioTitleFrame = CGRect(origin: CGPoint(x: audioIconFrame.maxX + spacing, y: floorToScreenPixels((audioScrubberHeight - audioTitleSize.height) / 2.0)), size: audioTitleSize) view.bounds = CGRect(origin: .zero, size: audioTitleFrame.size) - audioTransition.setPosition(view: view, position: audioTitleFrame.center) + audioContentTransition.setPosition(view: view, position: audioTitleFrame.center) } audioTransition.setAlpha(view: self.audioIconView, alpha: trackTitleIsVisible ? 1.0 : 0.0)