Various fixes

This commit is contained in:
Ilya Laktyushin 2026-03-28 18:27:01 +01:00
parent 5532067aa1
commit 53d5425341
8 changed files with 93 additions and 29 deletions

View file

@ -16158,3 +16158,5 @@ Error: %8$@";
"MediaPlayer.PlaylistTitle" = "%@'s Playlist";
"MediaPlayer.PlaylistYourTitle" = "Your Playlist";
"MediaPlayer.AudioForwardedToSavedMesagesTooltip" = "Audio forwarded to Saved Messages.";

View file

@ -113,7 +113,7 @@ typedef NS_ENUM(NSUInteger, TGMediaLivePhotoMode)
- (void)setPrice:(NSNumber *)price forItem:(NSObject<TGMediaEditableItem> *)item;
- (SSignal *)pricesUpdatedSignal;
- (TGMediaLivePhotoMode)livePhotoModeForItem:(NSObject<TGMediaEditableItem> *)item;
- (NSNumber *)livePhotoModeForItem:(NSObject<TGMediaEditableItem> *)item;
- (SSignal *)livePhotoModeSignalForItem:(NSObject<TGMediaEditableItem> *)item;
- (SSignal *)livePhotoModeForIdentifier:(NSString *)identifier;
- (void)setLivePhotoMode:(TGMediaLivePhotoMode)mode forItem:(NSObject<TGMediaEditableItem> *)item;

View file

@ -32,6 +32,33 @@
#import <LegacyComponents/TGModernButton.h>
#import "PGPhotoEditor.h"
static TGMediaAsset *TGMediaAssetsLivePhotoAsset(id<TGMediaEditableItem> item)
{
if ([item isKindOfClass:[TGCameraCapturedVideo class]])
return ((TGCameraCapturedVideo *)item).originalAsset;
if ([item isKindOfClass:[TGMediaAsset class]])
return (TGMediaAsset *)item;
return nil;
}
static TGMediaLivePhotoMode TGMediaAssetsResolvedLivePhotoMode(TGMediaEditingContext *editingContext, NSObject<TGMediaEditableItem> *item)
{
if (editingContext == nil || item == nil)
return TGMediaLivePhotoModeOff;
NSNumber *livePhotoMode = [editingContext livePhotoModeForItem:item];
if (livePhotoMode != nil)
return (TGMediaLivePhotoMode)[livePhotoMode unsignedIntegerValue];
TGMediaAsset *asset = TGMediaAssetsLivePhotoAsset(item);
if ((asset.subtypes & TGMediaAssetSubtypePhotoLive) == 0)
return TGMediaLivePhotoModeOff;
return editingContext.isForceLivePhotoEnabled ? TGMediaLivePhotoModeLive : TGMediaLivePhotoModeOff;
}
@interface TGMediaPickerAccessView: UIView
{
TGMediaAssetsPallete *_pallete;
@ -977,7 +1004,7 @@
grouping = false;
}
TGMediaLivePhotoMode livePhotoMode = [editingContext livePhotoModeForItem:asset];
TGMediaLivePhotoMode livePhotoMode = TGMediaAssetsResolvedLivePhotoMode(editingContext, asset);
if (livePhotoMode == TGMediaLivePhotoModeLoop || livePhotoMode == TGMediaLivePhotoModeBounce) {
grouping = false;
}
@ -995,7 +1022,7 @@
}
NSAttributedString *caption = [editingContext captionForItem:asset];
TGMediaLivePhotoMode livePhotoMode = [editingContext livePhotoModeForItem:asset];
TGMediaLivePhotoMode livePhotoMode = TGMediaAssetsResolvedLivePhotoMode(editingContext, asset);
if (editingContext.isForcedCaption) {
if (grouping && num > 0) {
@ -1546,7 +1573,7 @@
if (adjustments.paintingData.hasAnimation) {
grouping = false;
}
TGMediaLivePhotoMode livePhotoMode = [editingContext livePhotoModeForItem:asset];
TGMediaLivePhotoMode livePhotoMode = TGMediaAssetsResolvedLivePhotoMode(editingContext, asset);
if (livePhotoMode == TGMediaLivePhotoModeLoop || livePhotoMode == TGMediaLivePhotoModeBounce) {
grouping = false;
}

View file

@ -794,20 +794,20 @@
#pragma mark -
- (TGMediaLivePhotoMode)livePhotoModeForItem:(NSObject<TGMediaEditableItem> *)item {
- (NSNumber *)livePhotoModeForItem:(NSObject<TGMediaEditableItem> *)item {
NSString *itemId = [self _contextualIdForItemId:item.uniqueIdentifier];
if (itemId == nil)
return TGMediaLivePhotoModeOff;
return nil;
return [self _livePhotoModeForItemId:itemId];
}
- (TGMediaLivePhotoMode)_livePhotoModeForItemId:(NSString *)itemId
- (NSNumber *)_livePhotoModeForItemId:(NSString *)itemId
{
if (itemId == nil)
return TGMediaLivePhotoModeOff;
return nil;
return (TGMediaLivePhotoMode)[_livePhotoModes[itemId] unsignedIntValue];
return _livePhotoModes[itemId];
}
- (SSignal *)livePhotoModeSignalForItem:(NSObject<TGMediaEditableItem> *)item {
@ -819,7 +819,7 @@
return @(update.mode);
}];
return [[SSignal single:@([self livePhotoModeForItem:item])] then:updateSignal];
return [[SSignal single:[self livePhotoModeForItem:item]] then:updateSignal];
}
- (SSignal *)livePhotoModeForIdentifier:(NSString *)identifier {
@ -831,7 +831,7 @@
return @(update.mode);
}];
return [[SSignal single:@([self _livePhotoModeForItemId:identifier])] then:updateSignal];
return [[SSignal single:[self _livePhotoModeForItemId:identifier]] then:updateSignal];
}
- (void)setLivePhotoMode:(TGMediaLivePhotoMode)mode forItem:(NSObject<TGMediaEditableItem> *)item {
@ -839,10 +839,7 @@
if (itemId == nil)
return;
if (mode != TGMediaLivePhotoModeOff)
_livePhotoModes[itemId] = @(mode);
else
[_livePhotoModes removeObjectForKey:itemId];
_livePhotoModes[itemId] = @(mode);
_livePhotoModePipe.sink([TGMediaLivePhotoModeUpdate livePhotoModeUpdateWithItem:item mode:mode]);
}

View file

@ -43,6 +43,29 @@
#import <LegacyComponents/TGPhotoCaptionInputMixin.h>
static TGMediaAsset *TGMediaPickerGalleryLivePhotoAsset(id<TGMediaEditableItem> editableMediaItem)
{
if ([editableMediaItem isKindOfClass:[TGCameraCapturedVideo class]])
return ((TGCameraCapturedVideo *)editableMediaItem).originalAsset;
if ([editableMediaItem isKindOfClass:[TGMediaAsset class]])
return (TGMediaAsset *)editableMediaItem;
return nil;
}
static TGMediaLivePhotoMode TGMediaPickerGalleryResolvedLivePhotoMode(NSNumber *livePhotoMode, bool forceLivePhotoEnabled, id<TGMediaEditableItem> editableMediaItem)
{
if (livePhotoMode != nil)
return (TGMediaLivePhotoMode)[livePhotoMode unsignedIntegerValue];
TGMediaAsset *asset = TGMediaPickerGalleryLivePhotoAsset(editableMediaItem);
if ((asset.subtypes & TGMediaAssetSubtypePhotoLive) == 0)
return TGMediaLivePhotoModeOff;
return forceLivePhotoEnabled ? TGMediaLivePhotoModeLive : TGMediaLivePhotoModeOff;
}
@interface TGMediaPickerGalleryWrapperView: UIView
{
@ -1088,15 +1111,16 @@
__strong id<TGModernGalleryEditableItem> strongGalleryEditableItem = weakGalleryEditableItem;
if (strongGalleryEditableItem != nil) {
return [[strongGalleryEditableItem.editingContext timerSignalForItem:editableMediaItem] mapToSignal:^id(id timer) {
return [[strongGalleryEditableItem.editingContext livePhotoModeSignalForItem:editableMediaItem] map:^id(id livePhotoMode) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (adjustments != nil)
dict[@"adjustments"] = adjustments;
if (timer != nil)
dict[@"timer"] = timer;
if (livePhotoMode != nil)
dict[@"livePhotoMode"] = livePhotoMode;
return dict;
return [[strongGalleryEditableItem.editingContext forceLivePhotoEnabled] mapToSignal:^SSignal *(NSNumber *forceLivePhotoEnabled) {
return [[strongGalleryEditableItem.editingContext livePhotoModeSignalForItem:editableMediaItem] map:^id(id livePhotoMode) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
if (adjustments != nil)
dict[@"adjustments"] = adjustments;
if (timer != nil)
dict[@"timer"] = timer;
dict[@"livePhotoMode"] = @(TGMediaPickerGalleryResolvedLivePhotoMode(livePhotoMode, [forceLivePhotoEnabled boolValue], editableMediaItem));
return dict;
}];
}];
}];
} else {

View file

@ -33,6 +33,21 @@
#import <AVFoundation/AVFoundation.h>
#import <math.h>
static TGMediaLivePhotoMode TGMediaPickerGalleryResolvedLivePhotoMode(TGMediaEditingContext *editingContext, NSObject<TGMediaEditableItem> *editableItem, TGMediaAsset *asset)
{
if (editingContext == nil || editableItem == nil)
return TGMediaLivePhotoModeOff;
NSNumber *livePhotoMode = [editingContext livePhotoModeForItem:editableItem];
if (livePhotoMode != nil)
return (TGMediaLivePhotoMode)[livePhotoMode unsignedIntegerValue];
if ((asset.subtypes & TGMediaAssetSubtypePhotoLive) == 0)
return TGMediaLivePhotoModeOff;
return editingContext.isForceLivePhotoEnabled ? TGMediaLivePhotoModeLive : TGMediaLivePhotoModeOff;
}
@interface TGMediaPickerGalleryPhotoItemView () <UIGestureRecognizerDelegate>
{
TGMediaPickerGalleryFetchResultItem *_fetchItem;
@ -192,7 +207,7 @@
[super setItem:item synchronously:synchronously];
[self stopAndCleanupLivePhotoPlayback];
_livePhotoMode = (item.editingContext != nil) ? [item.editingContext livePhotoModeForItem:item.editableMediaItem] : TGMediaLivePhotoModeOff;
_livePhotoMode = TGMediaPickerGalleryResolvedLivePhotoMode(item.editingContext, item.editableMediaItem, (TGMediaAsset *)item.asset);
[self updatePaintingImage:[item.editingContext adjustmentsForItem:item.editableMediaItem]];
if (_entitiesView == nil) {
@ -707,7 +722,7 @@
_paintingImageView.hidden = (_paintingImageView.image == nil) || _livePhotoVideoView.alpha <= FLT_EPSILON;
_contentView.hidden = false;
_livePhotoMode = (self.item.editingContext != nil) ? [self.item.editingContext livePhotoModeForItem:self.item.editableMediaItem] : TGMediaLivePhotoModeOff;
_livePhotoMode = TGMediaPickerGalleryResolvedLivePhotoMode(self.item.editingContext, self.item.editableMediaItem, (TGMediaAsset *)self.item.asset);
[self updatePaintingImage:[self currentAdjustments]];
[self layoutEditedSubviews];

View file

@ -1092,7 +1092,7 @@ private func multipartFetchV1(
subscriber.putNext(.dataPart(resourceOffset: dataOffset, data: data, range: 0 ..< Int64(data.count), complete: false))
}, reportCompleteSize: { size in
subscriber.putNext(.resourceSizeUpdated(size))
//subscriber.putCompletion()
subscriber.putCompletion()
}, finishWithError: { error in
subscriber.putError(error)
}, useMainConnection: useMainConnection)

View file

@ -662,10 +662,9 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, ASGestu
let _ = self.context.engine.messages.enqueueOutgoingMessage(to: self.context.account.peerId, replyTo: nil, content: .file(file)).start()
//TODO:localize
let controller = UndoOverlayController(
presentationData: self.presentationData,
content: .forward(savedMessages: true, text: "Audio forwarded to Saved Messages."),
content: .forward(savedMessages: true, text: self.presentationData.strings.MediaPlayer_AudioForwardedToSavedMesagesTooltip),
action: { _ in
return true
}