From 5b4fafb3d0d85597c92123880b86bc31cf386465 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 31 Aug 2017 19:45:56 +0300 Subject: [PATCH 1/2] no message --- LegacyComponents.xcodeproj/project.pbxproj | 70 +++++++++++++++++++ LegacyComponents/LegacyComponents.h | 3 + LegacyComponents/TGLocationPickerController.h | 5 +- LegacyComponents/TGLocationPickerController.m | 11 ++- LegacyComponents/TGLocationVenueCell.m | 2 +- LegacyComponents/TGLocationViewController.h | 1 + LegacyComponents/TGLocationViewController.m | 16 ++--- 7 files changed, 86 insertions(+), 22 deletions(-) diff --git a/LegacyComponents.xcodeproj/project.pbxproj b/LegacyComponents.xcodeproj/project.pbxproj index 942957428b..4e6372e96a 100644 --- a/LegacyComponents.xcodeproj/project.pbxproj +++ b/LegacyComponents.xcodeproj/project.pbxproj @@ -5084,6 +5084,74 @@ }; name = Hockeyapp; }; + D02660951F34DCBF000E2DC5 /* Release Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = "Release Hockeyapp"; + }; + D02660961F34DCBF000E2DC5 /* Release Hockeyapp */ = { + isa = XCBuildConfiguration; + buildSettings = { + APPLICATION_EXTENSION_API_ONLY = YES; + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = LegacyComponents/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACH_O_TYPE = staticlib; + PRODUCT_BUNDLE_IDENTIFIER = org.Telegram.LegacyComponents; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SKIP_INSTALL = YES; + }; + name = "Release Hockeyapp"; + }; D07BCBFF1F2B79AE00ED97AA /* Debug Hockeyapp */ = { isa = XCBuildConfiguration; buildSettings = { @@ -5238,6 +5306,7 @@ D017772E1F1F8F100044446D /* Release */, D07BCC011F2B79B900ED97AA /* Release AppStore */, D01778951F1FA5960044446D /* Hockeyapp */, + D02660951F34DCBF000E2DC5 /* Release Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -5251,6 +5320,7 @@ D01777311F1F8F100044446D /* Release */, D07BCC021F2B79B900ED97AA /* Release AppStore */, D01778961F1FA5960044446D /* Hockeyapp */, + D02660961F34DCBF000E2DC5 /* Release Hockeyapp */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/LegacyComponents/LegacyComponents.h b/LegacyComponents/LegacyComponents.h index 300712924f..83ef657346 100644 --- a/LegacyComponents/LegacyComponents.h +++ b/LegacyComponents/LegacyComponents.h @@ -283,6 +283,9 @@ FOUNDATION_EXPORT const unsigned char LegacyComponentsVersionString[]; #import #import +#import #import #import #import + +#import diff --git a/LegacyComponents/TGLocationPickerController.h b/LegacyComponents/TGLocationPickerController.h index 51b3a2bdfe..0fde660738 100644 --- a/LegacyComponents/TGLocationPickerController.h +++ b/LegacyComponents/TGLocationPickerController.h @@ -1,4 +1,5 @@ -#import +#import +#import #import @@ -13,6 +14,6 @@ typedef enum { @property (nonatomic, copy) void (^locationPicked)(CLLocationCoordinate2D coordinate, TGVenueAttachment *venue); -- (instancetype)initWithIntent:(TGLocationPickerControllerIntent)intent; +- (instancetype)initWithContext:(id)context intent:(TGLocationPickerControllerIntent)intent; @end diff --git a/LegacyComponents/TGLocationPickerController.m b/LegacyComponents/TGLocationPickerController.m index b150474991..a5e3498f2f 100644 --- a/LegacyComponents/TGLocationPickerController.m +++ b/LegacyComponents/TGLocationPickerController.m @@ -2,6 +2,8 @@ #import "LegacyComponentsInternal.h" #import "TGColor.h" +#import "TGImageUtils.h" +#import "TGFont.h" #import @@ -126,14 +128,9 @@ const TGLocationPlacesService TGLocationPickerPlacesProvider = TGLocationPlacesS @implementation TGLocationPickerController -- (instancetype)init +- (instancetype)initWithContext:(id)context intent:(TGLocationPickerControllerIntent)intent { - return [self initWithIntent:TGLocationPickerControllerDefaultIntent]; -} - -- (instancetype)initWithIntent:(TGLocationPickerControllerIntent)intent -{ - self = [super init]; + self = [super initWithContext:context]; if (self != nil) { _intent = intent; diff --git a/LegacyComponents/TGLocationVenueCell.m b/LegacyComponents/TGLocationVenueCell.m index dc9cb4ba0c..1ddbe8366a 100644 --- a/LegacyComponents/TGLocationVenueCell.m +++ b/LegacyComponents/TGLocationVenueCell.m @@ -69,7 +69,7 @@ const CGFloat TGLocationVenueCellHeight = 48.5f; } else { - [_iconView loadUri:@"embedded://" withOptions:@{ TGImageViewOptionEmbeddedImage:TGComponentsImageNamed(@"LocationGenericIcon.png)] }]; + [_iconView loadUri:@"embedded://" withOptions:@{ TGImageViewOptionEmbeddedImage:TGComponentsImageNamed(@"LocationGenericIcon.png") }]; } } diff --git a/LegacyComponents/TGLocationViewController.h b/LegacyComponents/TGLocationViewController.h index a771771e33..b466385c41 100644 --- a/LegacyComponents/TGLocationViewController.h +++ b/LegacyComponents/TGLocationViewController.h @@ -9,6 +9,7 @@ @interface TGLocationViewController : TGViewController +@property (nonatomic, assign) bool modalMode; @property (nonatomic, assign) bool previewMode; @property (nonatomic, copy) bool (^presentShareMenu)(TGMenuSheetController *, CLLocationCoordinate2D); diff --git a/LegacyComponents/TGLocationViewController.m b/LegacyComponents/TGLocationViewController.m index 3f32de00a4..b4e2413554 100644 --- a/LegacyComponents/TGLocationViewController.m +++ b/LegacyComponents/TGLocationViewController.m @@ -55,23 +55,15 @@ @implementation TGLocationViewController -- (instancetype)init +- (instancetype)initWithContext:(id)context coordinate:(CLLocationCoordinate2D)coordinate venue:(TGVenueAttachment *)venue peer:(id)peer { - self = [super init]; + self = [self initWithContext:context]; if (self != nil) { self.titleText = TGLocalized(@"Map.LocationTitle"); _locationManager = [[CLLocationManager alloc] init]; - } - return self; -} - -- (instancetype)initWithContext:(id)context coordinate:(CLLocationCoordinate2D)coordinate venue:(TGVenueAttachment *)venue peer:(id)peer -{ - self = [self init]; - if (self != nil) - { + _context = context; _location = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude]; _venue = venue; @@ -137,7 +129,7 @@ [_toolbarView addSubview:_mapModeControl]; NSString *backButtonTitle = TGLocalized(@"Common.Back"); - if (TGIsPad()) + if (TGIsPad() || _modalMode) { backButtonTitle = TGLocalized(@"Common.Done"); [self setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:backButtonTitle style:UIBarButtonItemStyleDone target:self action:@selector(dismissButtonPressed)]]; From ddfb4abd54f12707b1d6048e4b9d95b1e8269a3a Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 11 Sep 2017 00:05:31 +0300 Subject: [PATCH 2/2] no message --- LegacyComponents/LegacyComponents.h | 1 + .../PGCameraVolumeButtonHandler.m | 4 +- LegacyComponents/TGEmbedPlayerControls.m | 19 ++-- .../TGModernConversationInputMicButton.h | 13 ++- .../TGModernConversationInputMicButton.m | 101 ++++++++++++------ LegacyComponents/TGPhotoEditorUtils.m | 7 +- .../TGVideoMessageCaptureController.h | 3 +- .../TGVideoMessageCaptureController.m | 17 ++- 8 files changed, 115 insertions(+), 50 deletions(-) diff --git a/LegacyComponents/LegacyComponents.h b/LegacyComponents/LegacyComponents.h index 03685d512d..3cb10d82a4 100644 --- a/LegacyComponents/LegacyComponents.h +++ b/LegacyComponents/LegacyComponents.h @@ -294,3 +294,4 @@ FOUNDATION_EXPORT const unsigned char LegacyComponentsVersionString[]; #import #import #import +#import diff --git a/LegacyComponents/PGCameraVolumeButtonHandler.m b/LegacyComponents/PGCameraVolumeButtonHandler.m index 116b7cbddf..f6c60f6039 100644 --- a/LegacyComponents/PGCameraVolumeButtonHandler.m +++ b/LegacyComponents/PGCameraVolumeButtonHandler.m @@ -105,7 +105,9 @@ static void PGButtonHandlerEnableMonitoring(bool enable) - (void)setEnabled:(bool)enabled { _enabled = enabled; - PGButtonHandlerEnableMonitoring(enabled); + TGDispatchOnMainThread(^{ + PGButtonHandlerEnableMonitoring(enabled); + }); } - (void)enableIn:(NSTimeInterval)timeInterval diff --git a/LegacyComponents/TGEmbedPlayerControls.m b/LegacyComponents/TGEmbedPlayerControls.m index 8e84ed8828..52dcf186d2 100644 --- a/LegacyComponents/TGEmbedPlayerControls.m +++ b/LegacyComponents/TGEmbedPlayerControls.m @@ -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) diff --git a/LegacyComponents/TGModernConversationInputMicButton.h b/LegacyComponents/TGModernConversationInputMicButton.h index 3de4f24371..01d330738e 100644 --- a/LegacyComponents/TGModernConversationInputMicButton.h +++ b/LegacyComponents/TGModernConversationInputMicButton.h @@ -2,6 +2,15 @@ @class TGModernConversationInputMicButton; +@protocol TGModernConversationInputMicButtonPresentation + +- (UIView *)view; +- (void)setUserInteractionEnabled:(bool)enabled; +- (void)present; +- (void)dismiss; + +@end + @protocol TGModernConversationInputMicButtonDelegate @optional @@ -16,18 +25,20 @@ - (bool)micButtonShouldLock; +- (id)micButtonPresenter; + @end @interface TGModernConversationInputMicButton : UIButton @property (nonatomic, weak) id 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; diff --git a/LegacyComponents/TGModernConversationInputMicButton.m b/LegacyComponents/TGModernConversationInputMicButton.m index 3c5445c14c..ece9441806 100644 --- a/LegacyComponents/TGModernConversationInputMicButton.m +++ b/LegacyComponents/TGModernConversationInputMicButton.m @@ -59,6 +59,43 @@ static const CGFloat outerCircleMinScale = innerCircleRadius / outerCircleRadius @end +@interface TGModernConversationInputMicButtonWindowPresentation : NSObject { + @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 () { 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 _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 delegate = strongSelf.delegate; - if ([delegate respondsToSelector:@selector(micButtonInteractionRequestedLockedAction)]) - [delegate micButtonInteractionRequestedLockedAction]; - }; + (((TGModernConversationInputMicButtonWindowPresentation *)_presentation)->_overlayWindow).requestedLockedAction = ^ + { + __strong TGModernConversationInputMicButton *strongSelf = weakSelf; + if (strongSelf == nil) + return; + + id 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) diff --git a/LegacyComponents/TGPhotoEditorUtils.m b/LegacyComponents/TGPhotoEditorUtils.m index 8f0ad36d9f..e0005d879e 100644 --- a/LegacyComponents/TGPhotoEditorUtils.m +++ b/LegacyComponents/TGPhotoEditorUtils.m @@ -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); } diff --git a/LegacyComponents/TGVideoMessageCaptureController.h b/LegacyComponents/TGVideoMessageCaptureController.h index 2cbcc012d6..204e1adf8e 100644 --- a/LegacyComponents/TGVideoMessageCaptureController.h +++ b/LegacyComponents/TGVideoMessageCaptureController.h @@ -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)context assets:(TGVideoMessageCaptureControllerAssets *)assets transitionInView:(UIView *(^)())transitionInView parentController:(TGViewController *)parentController controlsFrame:(CGRect)controlsFrame isAlreadyLocked:(bool (^)(void))isAlreadyLocked liveUploadInterface:(id)liveUploadInterface; - (void)buttonInteractionUpdate:(CGPoint)value; @@ -27,7 +28,7 @@ - (void)complete; - (void)dismiss; -- (void)stop; +- (bool)stop; + (void)clearStartImage; diff --git a/LegacyComponents/TGVideoMessageCaptureController.m b/LegacyComponents/TGVideoMessageCaptureController.m index c0151dd82a..07f55fc6a0 100644 --- a/LegacyComponents/TGVideoMessageCaptureController.m +++ b/LegacyComponents/TGVideoMessageCaptureController.m @@ -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