Merge tgcalls update

This commit is contained in:
Ali 2020-08-24 22:14:28 +01:00
parent b040434c23
commit ece4f6ed86
12 changed files with 69 additions and 34 deletions

View File

@ -99,15 +99,15 @@ public func childWindowHostView(parent: UIView) -> WindowHostView {
}
view.invalidateDeferScreenEdgeGestureImpl = { [weak hostView] in
return hostView?.invalidateDeferScreenEdgeGesture?()
hostView?.invalidateDeferScreenEdgeGesture?()
}
view.invalidatePrefersOnScreenNavigationHiddenImpl = { [weak hostView] in
return hostView?.invalidatePrefersOnScreenNavigationHidden?()
hostView?.invalidatePrefersOnScreenNavigationHidden?()
}
view.invalidateSupportedOrientationsImpl = { [weak hostView] in
return hostView?.invalidateSupportedOrientations?()
hostView?.invalidateSupportedOrientations?()
}
view.cancelInteractiveKeyboardGesturesImpl = { [weak hostView] in

View File

@ -409,15 +409,15 @@ public func nativeWindowHostView() -> (UIWindow & WindowHost, WindowHostView) {
}
window.invalidateDeferScreenEdgeGestureImpl = { [weak hostView] in
return hostView?.invalidateDeferScreenEdgeGesture?()
hostView?.invalidateDeferScreenEdgeGesture?()
}
window.invalidatePrefersOnScreenNavigationHiddenImpl = { [weak hostView] in
return hostView?.invalidatePrefersOnScreenNavigationHidden?()
hostView?.invalidatePrefersOnScreenNavigationHidden?()
}
window.invalidateSupportedOrientationsImpl = { [weak hostView] in
return hostView?.invalidateSupportedOrientations?()
hostView?.invalidateSupportedOrientations?()
}
window.cancelInteractiveKeyboardGesturesImpl = { [weak hostView] in

View File

@ -100,7 +100,7 @@
};
[model.interfaceView updateSelectionInterface:selectionContext.count counterVisible:(selectionContext.count > 0) animated:false];
model.interfaceView.donePressed = ^(TGClipboardGalleryPhotoItem *item)
model.interfaceView.donePressed = ^(id<TGModernGalleryItem> item)
{
__strong TGClipboardGalleryMixin *strongSelf = weakSelf;
if (strongSelf == nil)
@ -109,18 +109,18 @@
strongSelf->_galleryModel.dismiss(true, false);
if (strongSelf.completeWithItem != nil)
strongSelf.completeWithItem(item);
strongSelf.completeWithItem((TGClipboardGalleryPhotoItem *)item);
};
modernGallery.model = model;
modernGallery.itemFocused = ^(TGClipboardGalleryPhotoItem *item)
modernGallery.itemFocused = ^(id<TGModernGalleryItem> item)
{
__strong TGClipboardGalleryMixin *strongSelf = weakSelf;
if (strongSelf != nil && strongSelf.itemFocused != nil)
strongSelf.itemFocused(item);
strongSelf.itemFocused((TGClipboardGalleryPhotoItem *)item);
};
modernGallery.beginTransitionIn = ^UIView *(TGClipboardGalleryPhotoItem *item, TGModernGalleryItemView *itemView)
modernGallery.beginTransitionIn = ^UIView *(id<TGModernGalleryItem> item, TGModernGalleryItemView *itemView)
{
__strong TGClipboardGalleryMixin *strongSelf = weakSelf;
if (strongSelf == nil)
@ -130,12 +130,12 @@
strongSelf.willTransitionIn();
if (strongSelf.referenceViewForItem != nil)
return strongSelf.referenceViewForItem(item);
return strongSelf.referenceViewForItem((TGClipboardGalleryPhotoItem *)item);
return nil;
};
modernGallery.finishedTransitionIn = ^(__unused TGClipboardGalleryPhotoItem *item, __unused TGModernGalleryItemView *itemView)
modernGallery.finishedTransitionIn = ^(__unused id<TGModernGalleryItem> item, __unused TGModernGalleryItemView *itemView)
{
__strong TGClipboardGalleryMixin *strongSelf = weakSelf;
if (strongSelf == nil)
@ -144,7 +144,7 @@
[strongSelf->_galleryModel.interfaceView setSelectedItemsModel:strongSelf->_galleryModel.selectedItemsModel];
};
modernGallery.beginTransitionOut = ^UIView *(TGClipboardGalleryPhotoItem *item, TGModernGalleryItemView *itemView)
modernGallery.beginTransitionOut = ^UIView *(id<TGModernGalleryItem> item, TGModernGalleryItemView *itemView)
{
__strong TGClipboardGalleryMixin *strongSelf = weakSelf;
if (strongSelf != nil)
@ -153,7 +153,7 @@
strongSelf.willTransitionOut();
if (strongSelf.referenceViewForItem != nil)
return strongSelf.referenceViewForItem(item);
return strongSelf.referenceViewForItem((TGClipboardGalleryPhotoItem *)item);
}
return nil;
};

View File

@ -100,7 +100,7 @@
[strongSelf setCurrentItemWithIndex:index];
};
_interfaceView.captionSet = ^(id<TGModernGalleryEditableItem> item, NSString *caption, NSArray *entities)
_interfaceView.captionSet = ^(id<TGModernGalleryItem> item, NSString *caption, NSArray *entities)
{
__strong TGClipboardGalleryModel *strongSelf = weakSelf;
if (strongSelf == nil || strongSelf.saveItemCaption == nil)

View File

@ -359,10 +359,11 @@
NSString *text = nil;
__block bool hasPhoto = false;
__block bool hasVideo = false;
[strongSelf->_selectionContext enumerateSelectedItems:^(TGMediaAsset *asset) {
if (![asset isKindOfClass:[TGMediaAsset class]])
[strongSelf->_selectionContext enumerateSelectedItems:^(id<TGMediaSelectableItem> asset) {
NSObject *value = (NSObject *)asset;
if (![value isKindOfClass:[TGMediaAsset class]])
return;
if (asset.isVideo) {
if (((TGMediaAsset *)asset).isVideo) {
hasVideo = true;
} else {
hasPhoto = true;

View File

@ -210,7 +210,7 @@
[strongSelf setCurrentItemWithIndex:index];
};
_interfaceView.captionSet = ^(id<TGModernGalleryEditableItem> item, NSString *caption, NSArray *entities)
_interfaceView.captionSet = ^(id<TGModernGalleryItem> item, NSString *caption, NSArray *entities)
{
__strong TGMediaPickerGalleryModel *strongSelf = weakSelf;
if (strongSelf == nil || strongSelf.saveItemCaption == nil)

View File

@ -1274,16 +1274,48 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
insets.left = interpolate(from: expandedInset, to: insets.left, value: 1.0 - self.pictureInPictureTransitionFraction)
insets.right = interpolate(from: expandedInset, to: insets.right, value: 1.0 - self.pictureInPictureTransitionFraction)
let previewVideoSide = interpolate(from: 350.0, to: 200.0, value: 1.0 - self.pictureInPictureTransitionFraction)
let previewVideoSide = interpolate(from: 300.0, to: 150.0, value: 1.0 - self.pictureInPictureTransitionFraction)
var previewVideoSize = layout.size.aspectFitted(CGSize(width: previewVideoSide, height: previewVideoSide))
previewVideoSize = CGSize(width: 30.0, height: 45.0).aspectFitted(previewVideoSize)
if let minimizedVideoNode = self.minimizedVideoNode {
switch minimizedVideoNode.currentOrientation {
case .rotation90, .rotation270:
break
default:
previewVideoSize = CGSize(width: previewVideoSize.height, height: previewVideoSize.width)
var aspect = minimizedVideoNode.currentAspect
var rotationCount = 0
if minimizedVideoNode === self.outgoingVideoNodeValue {
aspect = 3.0 / 4.0
} else {
if aspect < 1.0 {
aspect = 3.0 / 4.0
} else {
aspect = 4.0 / 3.0
}
switch minimizedVideoNode.currentOrientation {
case .rotation90, .rotation270:
rotationCount += 1
default:
break
}
var mappedDeviceOrientation = self.deviceOrientation
if case .regular = layout.metrics.widthClass, case .regular = layout.metrics.heightClass {
mappedDeviceOrientation = .portrait
}
switch mappedDeviceOrientation {
case .landscapeLeft, .landscapeRight:
rotationCount += 1
default:
break
}
if rotationCount % 2 != 0 {
aspect = 1.0 / aspect
}
}
let unboundVideoSize = CGSize(width: aspect * 10000.0, height: 10000.0)
previewVideoSize = unboundVideoSize.aspectFitted(CGSize(width: previewVideoSide, height: previewVideoSide))
}
let previewVideoY: CGFloat
let previewVideoX: CGFloat
@ -1530,7 +1562,7 @@ final class CallControllerNode: ViewControllerTracingNode, CallControllerNodePro
self.animationForExpandedVideoSnapshotView = nil
}
minimizedVideoTransition.updateFrame(node: minimizedVideoNode, frame: previewVideoFrame)
minimizedVideoNode.updateLayout(size: previewVideoFrame.size, cornerRadius: interpolate(from: 14.0, to: 24.0, value: self.pictureInPictureTransitionFraction), isOutgoing: minimizedVideoNode === self.outgoingVideoNodeValue, deviceOrientation: .portrait, isCompactLayout: false, transition: minimizedVideoTransition)
minimizedVideoNode.updateLayout(size: previewVideoFrame.size, cornerRadius: interpolate(from: 14.0, to: 24.0, value: self.pictureInPictureTransitionFraction), isOutgoing: minimizedVideoNode === self.outgoingVideoNodeValue, deviceOrientation: mappedDeviceOrientation, isCompactLayout: false, transition: minimizedVideoTransition)
if transition.isAnimated && didAppear {
minimizedVideoNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.5)
}

View File

@ -246,6 +246,7 @@ public final class PresentationCallImpl: PresentationCall {
private var droppedCall = false
private var dropCallKitCallTimer: SwiftSignalKit.Timer?
private var useFrontCamera: Bool = true
private var videoCapturer: OngoingCallVideoCapturer?
init(
@ -1029,6 +1030,7 @@ public final class PresentationCallImpl: PresentationCall {
}
public func switchVideoCamera() {
self.videoCapturer?.switchCamera()
self.useFrontCamera = !self.useFrontCamera
self.videoCapturer?.switchVideoInput(isFront: self.useFrontCamera)
}
}

View File

@ -336,8 +336,8 @@ public final class OngoingCallVideoCapturer {
self.impl = OngoingCallThreadLocalContextVideoCapturer()
}
public func switchCamera() {
self.impl.switchVideoCamera()
public func switchVideoInput(isFront: Bool) {
self.impl.switchVideoInput(isFront)
}
public func makeOutgoingVideoView(completion: @escaping (OngoingCallContextPresentationCallVideoView?) -> Void) {

View File

@ -109,7 +109,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
- (instancetype _Nonnull)init;
- (void)switchVideoCamera;
- (void)switchVideoInput:(bool)isFront;
- (void)setIsVideoEnabled:(bool)isVideoEnabled;
- (void)makeOutgoingVideoView:(void (^_Nonnull)(UIView<OngoingCallThreadLocalContextWebrtcVideoView> * _Nullable))completion;

View File

@ -152,8 +152,8 @@
- (void)dealloc {
}
- (void)switchVideoCamera {
_interface->switchCamera();
- (void)switchVideoInput:(bool)isFront {
_interface->switchToDevice(isFront ? "" : "back");
}
- (void)setIsVideoEnabled:(bool)isVideoEnabled {

@ -1 +1 @@
Subproject commit d27912dcedcd9f223fbdbbb5589b01839c256a8d
Subproject commit 744762e065ddcde3a20c1c434fcc7c456aac3126