mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-24 14:31:48 +00:00
Video avatar fixes
This commit is contained in:
parent
019946f600
commit
33538b46b9
@ -5555,8 +5555,8 @@ Any member of this group will be able to see messages in the channel.";
|
||||
"ProfilePhoto.MainPhoto" = "Main Photo";
|
||||
"ProfilePhoto.SetMainPhoto" = "Set as Main Photo";
|
||||
|
||||
"ProfilePhoto.MainVideo" = "Main Photo";
|
||||
"ProfilePhoto.SetMainVideo" = "Set as Main Photo";
|
||||
"ProfilePhoto.MainVideo" = "Main Video";
|
||||
"ProfilePhoto.SetMainVideo" = "Set as Main Video";
|
||||
|
||||
"Stats.GroupOverview" = "OVERVIEW";
|
||||
"Stats.GroupMembers" = "Members";
|
||||
|
@ -830,7 +830,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
||||
{
|
||||
for (TGAttachmentAssetCell *cell in [_collectionView visibleCells])
|
||||
{
|
||||
if ([cell.asset isEqual:asset])
|
||||
if ([cell.asset.uniqueIdentifier isEqual:asset.uniqueIdentifier])
|
||||
return cell;
|
||||
}
|
||||
|
||||
@ -1073,7 +1073,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
||||
- (void)updateHiddenCellAnimated:(bool)animated
|
||||
{
|
||||
for (TGAttachmentAssetCell *cell in [_collectionView visibleCells])
|
||||
[cell setHidden:([cell.asset isEqual:_hiddenItem]) animated:animated];
|
||||
[cell setHidden:([cell.asset.uniqueIdentifier isEqual:_hiddenItem.uniqueIdentifier]) animated:animated];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
@ -14,7 +14,8 @@
|
||||
{
|
||||
CGSize _cachedSize;
|
||||
NSTimeInterval _cachedDuration;
|
||||
|
||||
|
||||
SVariable *_avAssetVariable;
|
||||
AVURLAsset *_cachedAVAsset;
|
||||
bool _livePhoto;
|
||||
}
|
||||
@ -90,8 +91,14 @@
|
||||
_cachedAVAsset = [AVURLAsset assetWithURL:videoUrl];
|
||||
return [SSignal single:_cachedAVAsset];
|
||||
} else {
|
||||
if (_avAssetVariable != nil) {
|
||||
return [_avAssetVariable signal];
|
||||
}
|
||||
|
||||
_avAssetVariable = [[SVariable alloc] init];
|
||||
|
||||
if (_originalAsset.type == TGMediaAssetGifType) {
|
||||
return [[SSignal single:@0.0] then:[[[TGMediaAssetImageSignals imageDataForAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(TGMediaAssetImageData *assetData) {
|
||||
[_avAssetVariable set:[[SSignal single:@0.0] then:[[[TGMediaAssetImageSignals imageDataForAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(TGMediaAssetImageData *assetData) {
|
||||
NSData *data = assetData.imageData;
|
||||
|
||||
const char *gif87Header = "GIF87";
|
||||
@ -110,14 +117,16 @@
|
||||
}
|
||||
}] onNext:^(id next) {
|
||||
_cachedAVAsset = next;
|
||||
}]];
|
||||
}]]];
|
||||
} else {
|
||||
return [[[TGMediaAssetImageSignals avAssetForVideoAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(AVURLAsset *asset) {
|
||||
[_avAssetVariable set:[[[TGMediaAssetImageSignals avAssetForVideoAsset:_originalAsset allowNetworkAccess:false] mapToSignal:^SSignal *(AVURLAsset *asset) {
|
||||
return [SSignal single:asset];
|
||||
}] onNext:^(id next) {
|
||||
_cachedAVAsset = next;
|
||||
}];
|
||||
}]];
|
||||
}
|
||||
|
||||
return [_avAssetVariable signal];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -161,6 +170,7 @@
|
||||
if (_cachedAVAsset != nil) {
|
||||
_cachedDuration = CMTimeGetSeconds(_cachedAVAsset.duration);
|
||||
}
|
||||
|
||||
return _cachedDuration;
|
||||
}
|
||||
|
||||
|
@ -285,8 +285,11 @@
|
||||
|
||||
for (TGMediaPickerCell *cell in [strongSelf->_collectionView visibleCells])
|
||||
{
|
||||
if ([cell.item isEqual:item.asset])
|
||||
if ([cell.item respondsToSelector:@selector(uniqueIdentifier)] && [[(id)cell.item uniqueIdentifier] isEqual:item.asset.uniqueIdentifier]) {
|
||||
return cell;
|
||||
} else if ([cell.item isEqual:item.asset.uniqueIdentifier]) {
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
@ -334,8 +334,13 @@
|
||||
{
|
||||
_hiddenItem = item;
|
||||
|
||||
for (TGMediaPickerCell *cell in [_collectionView visibleCells])
|
||||
[cell setHidden:([cell.item isEqual:_hiddenItem]) animated:animated];
|
||||
for (TGMediaPickerCell *cell in [_collectionView visibleCells]) {
|
||||
if ([cell.item respondsToSelector:@selector(uniqueIdentifier)] && [_hiddenItem respondsToSelector:@selector(uniqueIdentifier)]) {
|
||||
[cell setHidden:([[(id)cell.item uniqueIdentifier] isEqual:[_hiddenItem uniqueIdentifier]]) animated:animated];
|
||||
} else {
|
||||
[cell setHidden:([cell.item isEqual:_hiddenItem]) animated:animated];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)_setupSelectionGesture
|
||||
|
@ -38,8 +38,18 @@
|
||||
if ([self.asset isKindOfClass:[TGMediaAsset class]])
|
||||
return ((TGMediaAsset *)self.asset).actualVideoDuration;
|
||||
|
||||
if ([self.asset respondsToSelector:@selector(originalDuration)])
|
||||
if ([self.asset respondsToSelector:@selector(originalDuration)]) {
|
||||
if ([self.asset isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||
return [[(TGCameraCapturedVideo *)self.asset avAsset] mapToSignal:^SSignal *(id next) {
|
||||
if ([next isKindOfClass:[AVAsset class]]) {
|
||||
return [SSignal single:@(CMTimeGetSeconds(((AVAsset *)next).duration))];
|
||||
} else {
|
||||
return [SSignal complete];
|
||||
}
|
||||
}];
|
||||
}
|
||||
return [SSignal single:@(self.asset.originalDuration)];
|
||||
}
|
||||
|
||||
return [SSignal single:@0];
|
||||
}
|
||||
|
@ -127,6 +127,8 @@
|
||||
self = [super initWithFrame:frame];
|
||||
if (self != nil)
|
||||
{
|
||||
_chaseTime = kCMTimeInvalid;
|
||||
|
||||
_currentAudioSession = [[SMetaDisposable alloc] init];
|
||||
_playerItemDisposable = [[SMetaDisposable alloc] init];
|
||||
|
||||
@ -1244,7 +1246,12 @@
|
||||
|
||||
- (void)playerItemDidPlayToEndTime:(NSNotification *)__unused notification
|
||||
{
|
||||
if (!_sendAsGif)
|
||||
bool isGif = _sendAsGif;
|
||||
if (!_sendAsGif && [self.item.asset isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||
isGif = ((TGCameraCapturedVideo *)self.item.asset).originalAsset.type == TGMediaAssetGifType;
|
||||
}
|
||||
|
||||
if (!isGif)
|
||||
{
|
||||
self.isPlaying = false;
|
||||
[_player pause];
|
||||
@ -1289,10 +1296,12 @@
|
||||
CMTime currentChasingTime = _chaseTime;
|
||||
|
||||
[self.player.currentItem seekToTime:currentChasingTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:^(BOOL finished) {
|
||||
if (CMTIME_COMPARE_INLINE(currentChasingTime, ==, _chaseTime))
|
||||
if (CMTIME_COMPARE_INLINE(currentChasingTime, ==, _chaseTime)) {
|
||||
_chasingTime = false;
|
||||
else
|
||||
_chaseTime = kCMTimeInvalid;
|
||||
} else {
|
||||
[self chaseTime];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -76,10 +76,11 @@
|
||||
__block id<TGModernGalleryItem> focusItem = nil;
|
||||
void (^enumerationBlock)(TGMediaPickerGalleryItem *) = ^(TGMediaPickerGalleryItem *galleryItem)
|
||||
{
|
||||
if (focusItem == nil && [galleryItem.asset isEqual:item])
|
||||
{
|
||||
focusItem = galleryItem;
|
||||
galleryItem.immediateThumbnailImage = thumbnailImage;
|
||||
if (focusItem == nil) {
|
||||
if (([item isKindOfClass:[TGMediaAsset class]] && [galleryItem.asset.uniqueIdentifier isEqual:((TGMediaAsset *)item).uniqueIdentifier]) || [galleryItem.asset isEqual:item]) {
|
||||
focusItem = galleryItem;
|
||||
galleryItem.immediateThumbnailImage = thumbnailImage;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -372,7 +373,6 @@
|
||||
{
|
||||
TGCameraCapturedVideo *convertedAsset = [[TGCameraCapturedVideo alloc] initWithAsset:asset livePhoto:false];
|
||||
galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:convertedAsset];
|
||||
// galleryItem = [[TGMediaPickerGalleryGifItem alloc] initWithAsset:asset];
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -183,8 +183,12 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
||||
}
|
||||
}
|
||||
|
||||
- (void)transitionOutSwitching:(bool)__unused switching completion:(void (^)(void))completion
|
||||
- (void)transitionOutSwitching:(bool)switching completion:(void (^)(void))completion
|
||||
{
|
||||
if (switching) {
|
||||
_dismissing = true;
|
||||
}
|
||||
|
||||
TGPhotoEditorPreviewView *previewView = self.previewView;
|
||||
previewView.touchedUp = nil;
|
||||
previewView.touchedDown = nil;
|
||||
|
@ -157,6 +157,8 @@
|
||||
|
||||
_thumbnailsDisposable = [[SMetaDisposable alloc] init];
|
||||
|
||||
_chaseTime = kCMTimeInvalid;
|
||||
|
||||
self.customAppearanceMethodsForwarding = true;
|
||||
}
|
||||
return self;
|
||||
@ -596,10 +598,12 @@
|
||||
CMTime currentChasingTime = _chaseTime;
|
||||
|
||||
[_player.currentItem seekToTime:currentChasingTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:^(BOOL finished) {
|
||||
if (CMTIME_COMPARE_INLINE(currentChasingTime, ==, _chaseTime))
|
||||
if (CMTIME_COMPARE_INLINE(currentChasingTime, ==, _chaseTime)) {
|
||||
_chasingTime = false;
|
||||
else
|
||||
_chaseTime = kCMTimeInvalid;
|
||||
} else {
|
||||
[self chaseTime];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,6 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
||||
TGPhotoEditorPreviewView *previewView = _previewView;
|
||||
previewView.userInteractionEnabled = false;
|
||||
previewView.hidden = true;
|
||||
[_containerView addSubview:_previewView];
|
||||
|
||||
__weak TGPhotoPaintController *weakSelf = self;
|
||||
_paintingWrapperView = [[TGPaintingWrapperView alloc] init];
|
||||
@ -2044,7 +2043,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
||||
- (CGRect)transitionOutReferenceFrame
|
||||
{
|
||||
TGPhotoEditorPreviewView *previewView = _previewView;
|
||||
return previewView.frame;
|
||||
return [previewView convertRect:previewView.bounds toView:self.view];
|
||||
}
|
||||
|
||||
- (UIView *)transitionOutReferenceView
|
||||
|
@ -410,14 +410,11 @@ typedef enum
|
||||
else
|
||||
return;
|
||||
|
||||
if (!reset && _summaryThumbnailViews.count > 0 && _summaryThumbnailSnapshotView == nil)
|
||||
{
|
||||
if (!reset && _summaryThumbnailViews.count > 0 && _summaryThumbnailSnapshotView == nil) {
|
||||
_summaryThumbnailSnapshotView = [_summaryThumbnailWrapperView snapshotViewAfterScreenUpdates:false];
|
||||
_summaryThumbnailSnapshotView.frame = _summaryThumbnailWrapperView.frame;
|
||||
[_summaryThumbnailWrapperView.superview insertSubview:_summaryThumbnailSnapshotView aboveSubview:_summaryThumbnailWrapperView];
|
||||
}
|
||||
else if (reset)
|
||||
{
|
||||
} else if (reset) {
|
||||
[_summaryThumbnailSnapshotView removeFromSuperview];
|
||||
_summaryThumbnailSnapshotView = nil;
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
||||
|
||||
private var currentNameText: String?
|
||||
private var currentDateText: String?
|
||||
private var currentTypeText: String?
|
||||
|
||||
private var validLayout: (CGSize, LayoutMetrics, CGFloat, CGFloat, CGFloat, CGFloat)?
|
||||
|
||||
var delete: (() -> Void)? {
|
||||
didSet {
|
||||
@ -77,13 +80,11 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
||||
|
||||
self.setMainButton = HighlightableButtonNode()
|
||||
self.setMainButton.isHidden = true
|
||||
self.setMainButton.setAttributedTitle(NSAttributedString(string: self.strings.ProfilePhoto_SetMainPhoto, font: Font.regular(17.0), textColor: .white), for: .normal)
|
||||
|
||||
self.mainNode = ASTextNode()
|
||||
self.mainNode.maximumNumberOfLines = 1
|
||||
self.mainNode.isUserInteractionEnabled = false
|
||||
self.mainNode.displaysAsynchronously = false
|
||||
self.mainNode.attributedText = NSAttributedString(string: self.strings.ProfilePhoto_MainPhoto, font: Font.regular(17.0), textColor: UIColor(rgb: 0x808080))
|
||||
|
||||
super.init()
|
||||
|
||||
@ -103,10 +104,20 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
||||
func setEntry(_ entry: AvatarGalleryEntry, content: AvatarGalleryItemFooterContent) {
|
||||
var nameText: String?
|
||||
var dateText: String?
|
||||
var typeText: String?
|
||||
var buttonText: String?
|
||||
switch entry {
|
||||
case let .image(_, _, _, _, peer, date, _, _):
|
||||
case let .image(_, _, _, videoRepresentations, peer, date, _, _):
|
||||
nameText = peer?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
||||
dateText = humanReadableStringForTimestamp(strings: self.strings, dateTimeFormat: self.dateTimeFormat, timestamp: date)
|
||||
|
||||
if (!videoRepresentations.isEmpty) {
|
||||
typeText = self.strings.ProfilePhoto_MainVideo
|
||||
buttonText = self.strings.ProfilePhoto_SetMainVideo
|
||||
} else {
|
||||
typeText = self.strings.ProfilePhoto_MainPhoto
|
||||
buttonText = self.strings.ProfilePhoto_SetMainPhoto
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -128,6 +139,17 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
||||
}
|
||||
}
|
||||
|
||||
if self.currentTypeText != typeText {
|
||||
self.currentTypeText = typeText
|
||||
|
||||
self.mainNode.attributedText = NSAttributedString(string: typeText ?? "", font: Font.regular(17.0), textColor: UIColor(rgb: 0x808080))
|
||||
self.setMainButton.setAttributedTitle(NSAttributedString(string: buttonText ?? "", font: Font.regular(17.0), textColor: .white), for: .normal)
|
||||
|
||||
if let validLayout = self.validLayout {
|
||||
let _ = self.updateLayout(size: validLayout.0, metrics: validLayout.1, leftInset: validLayout.2, rightInset: validLayout.3, bottomInset: validLayout.4, contentInset: validLayout.5, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
switch content {
|
||||
case .info:
|
||||
self.nameNode.isHidden = false
|
||||
@ -143,6 +165,8 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
||||
}
|
||||
|
||||
override func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, contentInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||
self.validLayout = (size, metrics, leftInset, rightInset, bottomInset, contentInset)
|
||||
|
||||
let width = size.width
|
||||
var panelHeight: CGFloat = 44.0 + bottomInset
|
||||
panelHeight += contentInset
|
||||
|
Loading…
x
Reference in New Issue
Block a user