no message

This commit is contained in:
Peter 2017-09-11 00:05:31 +03:00
parent 28bad79ead
commit ddfb4abd54
8 changed files with 115 additions and 50 deletions

View File

@ -294,3 +294,4 @@ FOUNDATION_EXPORT const unsigned char LegacyComponentsVersionString[];
#import <LegacyComponents/TGClipboardGalleryMixin.h>
#import <LegacyComponents/TGClipboardGalleryPhotoItem.h>
#import <LegacyComponents/TGVideoMessageCaptureController.h>
#import <LegacyComponents/TGModernConversationInputMicButton.h>

View File

@ -105,7 +105,9 @@ static void PGButtonHandlerEnableMonitoring(bool enable)
- (void)setEnabled:(bool)enabled
{
_enabled = enabled;
PGButtonHandlerEnableMonitoring(enabled);
TGDispatchOnMainThread(^{
PGButtonHandlerEnableMonitoring(enabled);
});
}
- (void)enableIn:(NSTimeInterval)timeInterval

View File

@ -22,6 +22,7 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
UIButton *_screenAreaButton;
UIView *_backgroundView;
UIView *_backgroundContentView;
TGModernButton *_playButton;
TGModernButton *_pauseButton;
@ -71,21 +72,23 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
[_screenAreaButton addTarget:self action:@selector(screenAreaPressed) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_screenAreaButton];
if (TGEmbedPlayerControlsTypeFull)
if (type == TGEmbedPlayerControlsTypeFull)
{
if (iosMajorVersion() >= 8)
{
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
_backgroundView = effectView;
_backgroundContentView = effectView.contentView;
UIView *whiteView = [[UIView alloc] initWithFrame:effectView.bounds];
whiteView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
whiteView.backgroundColor = UIColorRGBA(0xffffff, 0.3f);
[_backgroundView addSubview:whiteView];
[effectView.contentView addSubview:whiteView];
}
else
{
_backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
_backgroundContentView = _backgroundView;
}
[self addSubview:_backgroundView];
@ -93,13 +96,13 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
_pauseButton.exclusiveTouch = true;
[_pauseButton setImage:TGComponentsImageNamed(@"EmbedVideoPauseIcon") forState:UIControlStateNormal];
[_pauseButton addTarget:self action:@selector(pauseButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[_backgroundView addSubview:_pauseButton];
[_backgroundContentView addSubview:_pauseButton];
_playButton = [[TGModernButton alloc] initWithFrame:CGRectMake(0, 0, 38, TGEmbedPlayerControlsPanelHeight)];
_playButton.exclusiveTouch = true;
[_playButton setImage:TGComponentsImageNamed(@"EmbedVideoPlayIcon") forState:UIControlStateNormal];
[_playButton addTarget:self action:@selector(playButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[_backgroundView addSubview:_playButton];
[_backgroundContentView addSubview:_playButton];
_positionLabel = [[UILabel alloc] initWithFrame:CGRectMake(24.0f, 0, 56.0f, TGEmbedPlayerControlsPanelHeight)];
_positionLabel.backgroundColor = [UIColor clearColor];
@ -108,7 +111,7 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
_positionLabel.textAlignment = NSTextAlignmentCenter;
_positionLabel.textColor = UIColorRGB(0x302e2e);
_positionLabel.userInteractionEnabled = false;
[_backgroundView addSubview:_positionLabel];
[_backgroundContentView addSubview:_positionLabel];
_remainingLabel = [[UILabel alloc] initWithFrame:CGRectMake(frame.size.width - 56.0f, 0, 56, TGEmbedPlayerControlsPanelHeight)];
_remainingLabel.backgroundColor = [UIColor clearColor];
@ -117,13 +120,13 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
_remainingLabel.textAlignment = NSTextAlignmentCenter;
_remainingLabel.textColor = UIColorRGB(0x302e2e);
_remainingLabel.userInteractionEnabled = false;
[_backgroundView addSubview:_remainingLabel];
[_backgroundContentView addSubview:_remainingLabel];
_pictureInPictureButton = [[TGModernButton alloc] initWithFrame:CGRectMake(frame.size.width - 45.0f, 0, 45.0f, TGEmbedPlayerControlsPanelHeight)];
_pictureInPictureButton.exclusiveTouch = true;
[_pictureInPictureButton setImage:TGComponentsImageNamed(@"EmbedVideoPIPIcon") forState:UIControlStateNormal];
[_pictureInPictureButton addTarget:self action:@selector(pictureInPictureButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[_backgroundView addSubview:_pictureInPictureButton];
[_backgroundContentView addSubview:_pictureInPictureButton];
__weak TGEmbedPlayerControls *weakSelf = self;
_scrubber = [[TGEmbedPlayerScrubber alloc] initWithFrame:CGRectZero];
@ -166,7 +169,7 @@ const CGFloat TGEmbedPlayerControlsPanelHeight = 32.0f;
}
};
[_scrubber setTintColor:UIColorRGB(0x2f2e2e)];
[_backgroundView addSubview:_scrubber];
[_backgroundContentView addSubview:_scrubber];
}
if (type == TGEmbedPlayerControlsTypeSimple)

View File

@ -2,6 +2,15 @@
@class TGModernConversationInputMicButton;
@protocol TGModernConversationInputMicButtonPresentation <NSObject>
- (UIView *)view;
- (void)setUserInteractionEnabled:(bool)enabled;
- (void)present;
- (void)dismiss;
@end
@protocol TGModernConversationInputMicButtonDelegate <NSObject>
@optional
@ -16,18 +25,20 @@
- (bool)micButtonShouldLock;
- (id<TGModernConversationInputMicButtonPresentation>)micButtonPresenter;
@end
@interface TGModernConversationInputMicButton : UIButton
@property (nonatomic, weak) id<TGModernConversationInputMicButtonDelegate> delegate;
@property (nonatomic) CGPoint centerOffset;
@property (nonatomic, strong) UIImage *icon;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, assign) bool blocking;
@property (nonatomic, readonly) bool locked;
@property (nonatomic) bool fadeDisabled;
@property (nonatomic) bool overlayDisabled;
- (void)animateIn;
- (void)animateOut;

View File

@ -59,6 +59,43 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
@end
@interface TGModernConversationInputMicButtonWindowPresentation : NSObject <TGModernConversationInputMicButtonPresentation> {
@public
TGModernConversationInputMicWindow *_overlayWindow;
}
@end
@implementation TGModernConversationInputMicButtonWindowPresentation
- (instancetype)init {
self = [super init];
if (self != nil) {
_overlayWindow = [[TGModernConversationInputMicWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_overlayWindow.windowLevel = 1000000000.0f;
_overlayWindow.rootViewController = [[TGModernConversationInputMicButtonOverlayController alloc] init];
}
return self;
}
- (UIView *)view {
return _overlayWindow.rootViewController.view;
}
- (void)setUserInteractionEnabled:(bool)enabled {
_overlayWindow.userInteractionEnabled = enabled;
}
- (void)present {
_overlayWindow.hidden = false;
}
- (void)dismiss {
_overlayWindow.hidden = true;
}
@end
@interface TGModernConversationInputMicButton () <UIGestureRecognizerDelegate>
{
CGPoint _touchLocation;
@ -70,8 +107,6 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
CFAbsoluteTime _lastTouchTime;
bool _acceptTouchDownAsTouchUp;
UIWindow *_overlayWindow;
UIImageView *_innerCircleView;
UIImageView *_outerCircleView;
@ -97,6 +132,8 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
bool _animatedIn;
UIImage *_icon;
id<TGModernConversationInputMicButtonPresentation> _presentation;
}
@end
@ -193,17 +230,14 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
- (void)updateOverlay
{
UIView *parentView = nil;
if (_overlayWindow == nil) {
if (!_overlayDisabled) {
parentView = self.superview;
}
if (_presentation == nil) {
return;
} else {
parentView = _overlayWindow.rootViewController.view;
}
UIView *parentView = [_presentation view];
CGPoint centerPoint = [self.superview convertPoint:self.center toView:parentView];
centerPoint.x += _centerOffset.x;
centerPoint.y += _centerOffset.y;
_innerCircleView.center = centerPoint;
_outerCircleView.center = centerPoint;
_innerIconWrapperView.center = centerPoint;
@ -220,22 +254,24 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_animatedIn = true;
_animationStartTime = CACurrentMediaTime();
if (_lockPanelWrapperView == nil) {
_overlayWindow = [[TGModernConversationInputMicWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
_overlayWindow.windowLevel = 1000000000.0f;
_overlayWindow.rootViewController = [[TGModernConversationInputMicButtonOverlayController alloc] init];
__weak TGModernConversationInputMicButton *weakSelf = self;
((TGModernConversationInputMicWindow *)_overlayWindow).requestedLockedAction = ^
{
__strong TGModernConversationInputMicButton *strongSelf = weakSelf;
if (strongSelf == nil)
return;
if (_presentation == nil) {
if ([_delegate respondsToSelector:@selector(micButtonPresenter)]) {
_presentation = [_delegate micButtonPresenter];
} else {
_presentation = [[TGModernConversationInputMicButtonWindowPresentation alloc] init];
__weak TGModernConversationInputMicButton *weakSelf = self;
id<TGModernConversationInputMicButtonDelegate> delegate = strongSelf.delegate;
if ([delegate respondsToSelector:@selector(micButtonInteractionRequestedLockedAction)])
[delegate micButtonInteractionRequestedLockedAction];
};
(((TGModernConversationInputMicButtonWindowPresentation *)_presentation)->_overlayWindow).requestedLockedAction = ^
{
__strong TGModernConversationInputMicButton *strongSelf = weakSelf;
if (strongSelf == nil)
return;
id<TGModernConversationInputMicButtonDelegate> delegate = strongSelf.delegate;
if ([delegate respondsToSelector:@selector(micButtonInteractionRequestedLockedAction)])
[delegate micButtonInteractionRequestedLockedAction];
};
}
static dispatch_once_t onceToken;
static UIImage *panelBackgroundView;
@ -271,7 +307,7 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_lockPanelWrapperView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 38.0f, 77.0f)];
_lockPanelWrapperView.userInteractionEnabled = false;
[_overlayWindow.rootViewController.view addSubview:_lockPanelWrapperView];
[[_presentation view] addSubview:_lockPanelWrapperView];
_lockPanelView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 38.0f, 77.0f)];
_lockPanelView.image = panelBackgroundView;
@ -287,11 +323,11 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_innerCircleView = [[UIImageView alloc] initWithImage:[self innerCircleImage]];
_innerCircleView.alpha = 0.0f;
[_overlayWindow.rootViewController.view addSubview:_innerCircleView];
[[_presentation view] addSubview:_innerCircleView];
_outerCircleView = [[UIImageView alloc] initWithImage:[self outerCircleImage]];
_outerCircleView.alpha = 0.0f;
[_overlayWindow.rootViewController.view addSubview:_outerCircleView];
[[_presentation view] addSubview:_outerCircleView];
_innerIconView = [[UIImageView alloc] initWithImage:_icon];
@ -300,7 +336,7 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_innerIconWrapperView.userInteractionEnabled = false;
[_innerIconWrapperView addSubview:_innerIconView];
[_overlayWindow.rootViewController.view addSubview:_innerIconWrapperView];
[[_presentation view] addSubview:_innerIconWrapperView];
_stopButton = [[TGModernButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 38.0f, 38.0f)];
_stopButton.adjustsImageWhenHighlighted = false;
@ -345,11 +381,11 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_stopButton.userInteractionEnabled = false;
_stopButton.alpha = 0.0f;
[_stopButton addTarget:self action:@selector(stopPressed) forControlEvents:UIControlEventTouchUpInside];
[_overlayWindow.rootViewController.view addSubview:_stopButton];
[[_presentation view] addSubview:_stopButton];
}
_overlayWindow.userInteractionEnabled = _blocking;
_overlayWindow.hidden = false;
[_presentation setUserInteractionEnabled:_blocking];
[_presentation present];
_stopButton.userInteractionEnabled = false;
@ -423,7 +459,8 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius
_stopButton.alpha = 0.0f;
} completion:^(BOOL finished) {
if (finished || [[[LegacyComponentsGlobals provider] applicationInstance] applicationState] == UIApplicationStateBackground) {
_overlayWindow.hidden = true;
[_presentation dismiss];
_presentation = nil;
}
if (_previousIcon != nil)

View File

@ -467,10 +467,13 @@ UIImageOrientation TGVideoOrientationForAsset(AVAsset *asset, bool *mirrored)
if (mirrored != NULL)
{
UIView *tempView = [[UIView alloc] init];
CGFloat scaleX = sqrt(t.a * t.a + t.c * t.c);
CGFloat scaleY = sqrt(t.b * t.b + t.d * t.d);
/*UIView *tempView = [[UIView alloc] init];
tempView.transform = t;
CGSize scale = CGSizeMake([[tempView.layer valueForKeyPath: @"transform.scale.x"] floatValue],
[[tempView.layer valueForKeyPath: @"transform.scale.y"] floatValue]);
[[tempView.layer valueForKeyPath: @"transform.scale.y"] floatValue]);*/
CGSize scale = CGSizeMake(scaleX, scaleY);
*mirrored = (scale.width < 0);
}

View File

@ -20,6 +20,7 @@
@property (nonatomic, copy) void(^onDismiss)(bool isAuto);
@property (nonatomic, copy) void(^onStop)(void);
@property (nonatomic, copy) void(^onCancel)(void);
@property (nonatomic, copy) void(^didDismiss)(void);
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context assets:(TGVideoMessageCaptureControllerAssets *)assets transitionInView:(UIView *(^)())transitionInView parentController:(TGViewController *)parentController controlsFrame:(CGRect)controlsFrame isAlreadyLocked:(bool (^)(void))isAlreadyLocked liveUploadInterface:(id<TGLiveUploadInterface>)liveUploadInterface;
- (void)buttonInteractionUpdate:(CGPoint)value;
@ -27,7 +28,7 @@
- (void)complete;
- (void)dismiss;
- (void)stop;
- (bool)stop;
+ (void)clearStartImage;

View File

@ -503,6 +503,10 @@ typedef enum
if (_autorotationWasEnabled)
[TGViewController enableAutorotation];
if (_didDismiss) {
_didDismiss();
}
}
- (void)dismiss
@ -557,14 +561,16 @@ typedef enum
- (void)setLocked
{
((TGVideoMessageCaptureControllerWindow *)self.view.window).locked = true;
if ([self.view.window isKindOfClass:[TGVideoMessageCaptureControllerWindow class]]) {
((TGVideoMessageCaptureControllerWindow *)self.view.window).locked = true;
}
[_controlsView setLocked];
}
- (void)stop
- (bool)stop
{
if (!_capturePipeline.isRecording)
return;
return false;
if ([self.view.window isKindOfClass:[TGVideoMessageCaptureControllerWindow class]]) {
((TGVideoMessageCaptureControllerWindow *)self.view.window).locked = false;
@ -575,14 +581,15 @@ typedef enum
[_activityDisposable dispose];
[self stopRecording];
return true;
}
- (void)sendPressed
{
[self finishWithURL:_url dimensions:CGSizeMake(240.0f, 240.0f) duration:_duration liveUploadData:_liveUploadData thumbnailImage:_thumbnailImage];
_automaticDismiss = true;
[self dismiss:false];
[self finishWithURL:_url dimensions:CGSizeMake(240.0f, 240.0f) duration:_duration liveUploadData:_liveUploadData thumbnailImage:_thumbnailImage];
}
- (void)unmutePressed