From 194f25d4e48a5b9748aee26c3487c8fb57efb265 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 5 Aug 2021 00:02:35 +0200 Subject: [PATCH] Fix more warnings --- build-system/Make/Make.py | 14 +- .../Display/Source/StatusBarProxyNode.swift | 2 +- submodules/LegacyComponents/BUILD | 1 + .../TGAttachmentCarouselItemView.h | 5 +- .../LegacyComponents/TGConversation.h | 4 +- .../LegacyComponents/TGDateUtils.h | 1 - .../PublicHeaders/LegacyComponents/TGHacks.h | 5 + .../TGMediaAssetsController.h | 2 +- .../PublicHeaders/LegacyComponents/TGUser.h | 4 +- .../Sources/GPUImageContext.m | 2 +- .../Sources/GPUImageCropFilter.m | 1 + .../Sources/PGCameraCaptureSession.m | 146 ++++----- .../Sources/POPAnimatableProperty.mm | 282 ------------------ .../Sources/POPAnimationRuntime.mm | 26 -- .../LegacyComponents/Sources/POPCGUtils.h | 33 -- .../LegacyComponents/Sources/POPGeometry.mm | 22 -- .../LegacyComponents/Sources/POPVector.h | 14 - .../LegacyComponents/Sources/POPVector.mm | 31 -- .../Sources/TGAlphacodePanelCell.m | 10 +- .../Sources/TGAttachmentAssetCell.m | 6 +- .../Sources/TGAttachmentCameraView.m | 3 +- .../Sources/TGAttachmentCarouselItemView.m | 3 +- .../Sources/TGAttachmentVideoCell.m | 3 +- submodules/LegacyComponents/Sources/TGCache.m | 5 - .../Sources/TGCameraController.m | 24 +- .../Sources/TGCameraMainPhoneView.m | 4 +- .../Sources/TGCameraMainView.m | 10 + .../Sources/TGCameraPreviewView.m | 13 +- .../Sources/TGClipboardPreviewItemView.m | 3 +- .../LegacyComponents/Sources/TGConversation.m | 6 +- .../Sources/TGGradientLabel.m | 100 +------ .../Sources/TGHashtagPanelCell.m | 3 + .../LegacyComponents/Sources/TGImageUtils.mm | 16 - .../Sources/TGLetteredAvatarView.m | 3 +- .../Sources/TGMediaAssetModernImageSignals.m | 3 + .../Sources/TGMediaAssetsController.m | 36 ++- .../Sources/TGMediaAssetsGifCell.m | 3 +- .../Sources/TGMediaAssetsVideoCell.m | 3 +- .../Sources/TGMediaAvatarEditorTransition.m | 3 +- .../Sources/TGMediaAvatarMenuMixin.m | 7 +- .../Sources/TGMediaGroupCell.m | 17 +- .../Sources/TGMediaGroupsController.m | 3 +- .../Sources/TGMediaOriginInfo.m | 3 + .../Sources/TGMediaPickerCaptionInputPanel.m | 6 + .../Sources/TGMediaPickerCell.m | 6 +- .../Sources/TGMediaPickerController.m | 20 +- .../TGMediaPickerGalleryInterfaceView.m | 2 +- .../Sources/TGMediaPickerGalleryModel.m | 6 +- .../TGMediaPickerGallerySelectedItemsModel.m | 2 - .../TGMediaPickerGalleryVideoItemView.m | 18 +- .../Sources/TGMediaPickerModernGalleryMixin.m | 4 +- .../Sources/TGMediaPickerPhotoCounterButton.m | 6 +- .../Sources/TGMediaPickerPhotoStripView.m | 3 +- .../Sources/TGMediaPickerToolbarView.m | 4 + .../Sources/TGMediaSelectionContext.m | 2 +- .../Sources/TGMentionPanelCell.m | 10 +- .../Sources/TGMenuSheetButtonItemView.m | 5 +- .../Sources/TGMenuSheetController.m | 43 ++- .../Sources/TGMenuSheetDimView.m | 3 +- .../Sources/TGMenuSheetTitleItemView.m | 3 +- .../Sources/TGMenuSheetView.m | 6 +- .../LegacyComponents/Sources/TGMenuView.m | 6 + .../LegacyComponents/Sources/TGMessage.mm | 8 +- .../Sources/TGMessageImageViewOverlayView.m | 62 +--- ...odernConversationHashtagsAssociatedPanel.m | 3 +- ...odernConversationMentionsAssociatedPanel.m | 3 +- .../Sources/TGModernGalleryController.m | 3 +- .../TGModernGalleryDefaultInterfaceView.m | 3 +- .../Sources/TGModernGalleryVideoView.m | 3 +- .../Sources/TGModernGalleryView.m | 6 +- .../Sources/TGModernMediaListItemView.m | 2 + .../Sources/TGNavigationBar.m | 11 +- .../Sources/TGNavigationController.m | 6 +- .../Sources/TGPassportICloud.m | 6 + .../LegacyComponents/Sources/TGPassportOCR.mm | 56 ++-- .../Sources/TGPhotoAvatarPreviewController.m | 3 + .../Sources/TGPhotoCropController.m | 6 +- .../Sources/TGPhotoEditorBlurAreaView.m | 2 + .../Sources/TGPhotoEditorController.m | 28 +- .../TGPhotoEditorCurvesHistogramView.m | 2 + .../Sources/TGPhotoEditorInterfaceAssets.m | 6 + .../Sources/TGPhotoEditorSliderView.m | 1 + .../Sources/TGPhotoEditorTabController.m | 18 +- .../Sources/TGPhotoEditorToolButtonsView.m | 5 +- .../Sources/TGPhotoPaintController.m | 2 +- .../Sources/TGPhotoQualityController.m | 25 +- .../Sources/TGPhotoTextEntityView.m | 5 +- .../Sources/TGPhotoToolCell.m | 2 + .../Sources/TGPhotoToolsController.m | 8 +- .../Sources/TGProgressWindow.m | 2 +- .../LegacyComponents/Sources/TGStringUtils.mm | 16 +- .../LegacyComponents/Sources/TGTextField.m | 10 +- .../LegacyComponents/Sources/TGTooltipView.m | 6 + .../Sources/TGVideoCameraPipeline.m | 23 +- .../Sources/TGVideoMessageCaptureController.m | 19 +- .../Sources/TGVideoMessageControls.m | 6 +- .../Sources/TGVideoMessageRingView.m | 4 +- .../Sources/TGViewController.mm | 62 +++- .../LegacyComponents/Sources/TGWebDocument.m | 4 +- .../YUGPUImageHighPassSkinSmoothingFilter.m | 2 + submodules/LegacyComponents/Sources/ocr.mm | 2 +- submodules/LegacyMediaPickerUI/BUILD | 3 + .../Source/ObjCRuntimeUtils/RuntimeUtils.h | 16 +- submodules/UIKitRuntimeUtils/BUILD | 3 + .../Source/UIKitRuntimeUtils/UIKitUtils.h | 2 +- .../UIViewController+Navigation.m | 14 - .../UIWindow+OrientationChange.m | 10 + 107 files changed, 620 insertions(+), 909 deletions(-) diff --git a/build-system/Make/Make.py b/build-system/Make/Make.py index 1ab6a9176e..2325ac0911 100644 --- a/build-system/Make/Make.py +++ b/build-system/Make/Make.py @@ -249,6 +249,9 @@ class BazelCommandLine: '--disk_cache={path}'.format(path=self.cache_dir) ] + if self.continue_on_error: + combined_arguments += ['--keep_going'] + return combined_arguments def get_additional_build_arguments(self): @@ -365,6 +368,8 @@ def generate_project(arguments): elif arguments.cacheHost is not None: bazel_command_line.add_remote_cache(arguments.cacheHost) + bazel_command_line.set_continue_on_error(arguments.continueOnError) + resolve_configuration(bazel_command_line, arguments) bazel_command_line.set_build_number(arguments.buildNumber) @@ -388,7 +393,7 @@ def generate_project(arguments): disable_provisioning_profiles=disable_provisioning_profiles, generate_dsym=generate_dsym, configuration_path=bazel_command_line.configuration_path, - bazel_app_arguments=bazel_command_line.get_project_generation_arguments() + bazel_app_arguments=bazel_command_line.get_project_generation_arguments(), ) @@ -528,6 +533,13 @@ if __name__ == '__main__': ''' ) + generateProjectParser.add_argument( + '--continueOnError', + action='store_true', + default=False, + help='Continue build process after an error.', + ) + generateProjectParser.add_argument( '--disableProvisioningProfiles', action='store_true', diff --git a/submodules/Display/Source/StatusBarProxyNode.swift b/submodules/Display/Source/StatusBarProxyNode.swift index c429a8c176..cb29181ec1 100644 --- a/submodules/Display/Source/StatusBarProxyNode.swift +++ b/submodules/Display/Source/StatusBarProxyNode.swift @@ -118,7 +118,7 @@ private class StatusBarItemNode: ASDisplayNode { } } } else { - if self.targetView.checkIsKind(of: timeViewClass) { + if let timeViewClass = timeViewClass, self.targetView.checkIsKind(of: timeViewClass) { context.withContext { c in c.translateBy(x: containingBounds.minX, y: -containingBounds.minY) UIGraphicsPushContext(c) diff --git a/submodules/LegacyComponents/BUILD b/submodules/LegacyComponents/BUILD index d1bfde2cc1..16ddc7c99f 100644 --- a/submodules/LegacyComponents/BUILD +++ b/submodules/LegacyComponents/BUILD @@ -30,6 +30,7 @@ objc_library( ]), copts = [ "-I{}/PublicHeaders/LegacyComponents".format(package_name()), + "-Werror", ], includes = [ "PublicHeaders", diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGAttachmentCarouselItemView.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGAttachmentCarouselItemView.h index ed3b3f3ae3..80103834ca 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGAttachmentCarouselItemView.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGAttachmentCarouselItemView.h @@ -10,14 +10,13 @@ @class TGViewController; @class TGAttachmentCameraView; @class TGVideoEditAdjustments; -@protocol TGModernGalleryTransitionHostScrollView; @protocol TGPhotoPaintStickersContext; @interface TGAttachmentCarouselCollectionView : UICollectionView @end -@interface TGAttachmentCarouselItemView : TGMenuSheetItemView +@interface TGAttachmentCarouselItemView : TGMenuSheetItemView @property (nonatomic, weak) TGViewController *parentController; @@ -45,7 +44,7 @@ @property (nonatomic, copy) void (^cameraPressed)(TGAttachmentCameraView *cameraView); @property (nonatomic, copy) void (^sendPressed)(TGMediaAsset *currentItem, bool asFiles, bool silentPosting, int32_t scheduleTime, bool isFromPicker); @property (nonatomic, copy) void (^avatarCompletionBlock)(UIImage *image); -@property (nonatomic, copy) void (^avatarVideoCompletionBlock)(UIImage *image, AVAsset *asset, TGVideoEditAdjustments *adjustments); +@property (nonatomic, copy) void (^avatarVideoCompletionBlock)(UIImage *image, id asset, TGVideoEditAdjustments *adjustments); @property (nonatomic, copy) void (^editorOpened)(void); @property (nonatomic, copy) void (^editorClosed)(void); diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGConversation.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGConversation.h index 1640dd7cc0..ab466872e0 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGConversation.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGConversation.h @@ -211,8 +211,8 @@ typedef enum { @property (nonatomic) NSData *chatPhotoFileReferenceSmall; @property (nonatomic) NSData *chatPhotoFileReferenceBig; -@property (nonatomic, strong) NSString *chatPhotoFullSmall; -@property (nonatomic, strong) NSString *chatPhotoFullBig; +@property (nonatomic, strong, readonly) NSString *chatPhotoFullSmall; +@property (nonatomic, strong, readonly) NSString *chatPhotoFullBig; @property (nonatomic) int chatParticipantCount; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGDateUtils.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGDateUtils.h index a4833b6a16..8087dcd8ff 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGDateUtils.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGDateUtils.h @@ -12,7 +12,6 @@ + (NSString *)stringForMonthOfYear:(int)date; + (NSString *)stringForPreciseDate:(int)date; + (NSString *)stringForMessageListDate:(int)date; -+ (NSString *)stringForLastSeen:(int)date; + (NSString *)stringForApproximateDate:(int)date; + (NSString *)stringForRelativeLastSeen:(int)date; + (NSString *)stringForRelativeUpdate:(int)date; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGHacks.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGHacks.h index 916a57346c..25e0484904 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGHacks.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGHacks.h @@ -14,8 +14,13 @@ void InjectInstanceMethodFromAnotherClass(Class toClass, Class fromClass, SEL fr } #endif +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + typedef void (^TGAlertHandler)(UIAlertView *alertView); +#pragma clang diagnostic pop + typedef enum { TGStatusBarAppearanceAnimationSlideDown = 1, TGStatusBarAppearanceAnimationSlideUp = 2, diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaAssetsController.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaAssetsController.h index 5d94419416..c94f239e0b 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaAssetsController.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGMediaAssetsController.h @@ -95,7 +95,7 @@ typedef enum - (NSArray *)resultSignalsWithCurrentItem:(TGMediaAsset *)currentItem descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *, NSString *))descriptionGenerator; - (void)completeWithAvatarImage:(UIImage *)image; -- (void)completeWithAvatarVideo:(AVAsset *)asset adjustments:(TGVideoEditAdjustments *)adjustments image:(UIImage *)image; +- (void)completeWithAvatarVideo:(id)asset adjustments:(TGVideoEditAdjustments *)adjustments image:(UIImage *)image; - (void)completeWithCurrentItem:(TGMediaAsset *)currentItem silentPosting:(bool)silentPosting scheduleTime:(int32_t)scheduleTime; - (void)dismiss; diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h index ed10bebfca..8a23f9cf54 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGUser.h @@ -81,8 +81,8 @@ typedef enum { @property (nonatomic) NSData *photoFileReferenceSmall; @property (nonatomic) NSData *photoFileReferenceBig; -@property (nonatomic) NSString *photoFullUrlSmall; -@property (nonatomic) NSString *photoFullUrlBig; +@property (nonatomic, strong, readonly) NSString *photoFullUrlSmall; +@property (nonatomic, strong, readonly) NSString *photoFullUrlBig; @property (nonatomic) TGUserPresence presence; diff --git a/submodules/LegacyComponents/Sources/GPUImageContext.m b/submodules/LegacyComponents/Sources/GPUImageContext.m index 941c37601c..81acd833ae 100755 --- a/submodules/LegacyComponents/Sources/GPUImageContext.m +++ b/submodules/LegacyComponents/Sources/GPUImageContext.m @@ -259,7 +259,7 @@ static void *openGLESContextQueueKey; #if TARGET_IPHONE_SIMULATOR return NO; #else - return (CVOpenGLESTextureCacheCreate != NULL); + return true; #endif } diff --git a/submodules/LegacyComponents/Sources/GPUImageCropFilter.m b/submodules/LegacyComponents/Sources/GPUImageCropFilter.m index 401392a05f..84b162659c 100755 --- a/submodules/LegacyComponents/Sources/GPUImageCropFilter.m +++ b/submodules/LegacyComponents/Sources/GPUImageCropFilter.m @@ -153,6 +153,7 @@ NSString *const kGPUImageCropFragmentShaderString = SHADER_STRING cropTextureCoordinates[7] = minY; }; break; case kGPUImageFlipHorizonal: // Works for me + case kGPUImageRotate180FlipHorizontal: { cropTextureCoordinates[0] = maxX; // 1,0 cropTextureCoordinates[1] = minY; diff --git a/submodules/LegacyComponents/Sources/PGCameraCaptureSession.m b/submodules/LegacyComponents/Sources/PGCameraCaptureSession.m index 8968d24479..2b015fd8fe 100644 --- a/submodules/LegacyComponents/Sources/PGCameraCaptureSession.m +++ b/submodules/LegacyComponents/Sources/PGCameraCaptureSession.m @@ -393,12 +393,8 @@ const NSInteger PGCameraFrameRate = 30; - (void)_enableVideoStabilization { AVCaptureConnection *videoConnection = [_videoOutput connectionWithMediaType:AVMediaTypeVideo]; - if (videoConnection.supportsVideoStabilization) - { - if ([videoConnection respondsToSelector:@selector(setPreferredVideoStabilizationMode:)]) - videoConnection.preferredVideoStabilizationMode = AVCaptureVideoStabilizationModeStandard; - else - videoConnection.enablesVideoStabilizationWhenAvailable = true; + if (videoConnection.supportsVideoStabilization) { + videoConnection.preferredVideoStabilizationMode = AVCaptureVideoStabilizationModeStandard; } } @@ -454,7 +450,7 @@ const NSInteger PGCameraFrameRate = 30; #pragma mark - Zoom - (bool)hasUltrawideCamera { - if (iosMajorVersion() >= 13.0) { + if (@available(iOS 13.0, *)) { if (self.videoDevice.isVirtualDevice && self.videoDevice.constituentDevices.firstObject.deviceType == AVCaptureDeviceTypeBuiltInUltraWideCamera) { return true; } @@ -463,7 +459,7 @@ const NSInteger PGCameraFrameRate = 30; } - (bool)hasTelephotoCamera { - if (iosMajorVersion() >= 13.0) { + if (@available(iOS 13.0, *)) { if (self.videoDevice.isVirtualDevice && self.videoDevice.constituentDevices.lastObject.deviceType == AVCaptureDeviceTypeBuiltInTelephotoCamera) { return true; } @@ -475,41 +471,43 @@ const NSInteger PGCameraFrameRate = 30; { if (![self.videoDevice respondsToSelector:@selector(videoZoomFactor)]) return 1.0f; - - if (iosMajorVersion() >= 13.0 && self.videoDevice.isVirtualDevice) { - CGFloat backingLevel = self.videoDevice.videoZoomFactor; - CGFloat realLevel = backingLevel; - - NSArray *marks = self.videoDevice.virtualDeviceSwitchOverVideoZoomFactors; - if (marks.count == 2) { - CGFloat firstMark = [marks.firstObject floatValue]; - CGFloat secondMark = [marks.lastObject floatValue]; - - if (backingLevel < firstMark) { - realLevel = 0.5 + 0.5 * (backingLevel - 1.0) / (firstMark - 1.0); - } else if (backingLevel < secondMark) { - realLevel = 1.0 + 1.0 * (backingLevel - firstMark) / (secondMark - firstMark); - } else { - realLevel = 2.0 + 6.0 * (backingLevel - secondMark) / (self.maxZoomLevel - secondMark); - } - } else if (marks.count == 1) { - CGFloat mark = [marks.firstObject floatValue]; - if ([self hasTelephotoCamera]) { - if (backingLevel < mark) { - realLevel = 1.0 + 1.0 * (backingLevel - 1.0) / (mark - 1.0); + + if (@available(iOS 13.0, *)) { + if (self.videoDevice.isVirtualDevice) { + CGFloat backingLevel = self.videoDevice.videoZoomFactor; + CGFloat realLevel = backingLevel; + + NSArray *marks = self.videoDevice.virtualDeviceSwitchOverVideoZoomFactors; + if (marks.count == 2) { + CGFloat firstMark = [marks.firstObject floatValue]; + CGFloat secondMark = [marks.lastObject floatValue]; + + if (backingLevel < firstMark) { + realLevel = 0.5 + 0.5 * (backingLevel - 1.0) / (firstMark - 1.0); + } else if (backingLevel < secondMark) { + realLevel = 1.0 + 1.0 * (backingLevel - firstMark) / (secondMark - firstMark); } else { - realLevel = 2.0 + 6.0 * (backingLevel - mark) / (self.maxZoomLevel - mark); + realLevel = 2.0 + 6.0 * (backingLevel - secondMark) / (self.maxZoomLevel - secondMark); } - } else if ([self hasUltrawideCamera]) { - if (backingLevel < mark) { - realLevel = 0.5 + 0.5 * (backingLevel - 1.0) / (mark - 1.0); - } else { - realLevel = 1.0 + 7.0 * (backingLevel - mark) / (self.maxZoomLevel - mark); + } else if (marks.count == 1) { + CGFloat mark = [marks.firstObject floatValue]; + if ([self hasTelephotoCamera]) { + if (backingLevel < mark) { + realLevel = 1.0 + 1.0 * (backingLevel - 1.0) / (mark - 1.0); + } else { + realLevel = 2.0 + 6.0 * (backingLevel - mark) / (self.maxZoomLevel - mark); + } + } else if ([self hasUltrawideCamera]) { + if (backingLevel < mark) { + realLevel = 0.5 + 0.5 * (backingLevel - 1.0) / (mark - 1.0); + } else { + realLevel = 1.0 + 7.0 * (backingLevel - mark) / (self.maxZoomLevel - mark); + } } } + + return realLevel; } - - return realLevel; } return self.videoDevice.videoZoomFactor; @@ -548,33 +546,35 @@ const NSInteger PGCameraFrameRate = 30; CGFloat level = zoomLevel; CGFloat backingLevel = zoomLevel; - if (iosMajorVersion() >= 13.0 && device.isVirtualDevice) { - NSArray *marks = device.virtualDeviceSwitchOverVideoZoomFactors; - if (marks.count == 2) { - CGFloat firstMark = [marks.firstObject floatValue]; - CGFloat secondMark = [marks.lastObject floatValue]; - if (level < 1.0) { - level = MAX(0.5, level); - backingLevel = 1.0 + ((level - 0.5) / 0.5) * (firstMark - 1.0); - } else if (zoomLevel < 2.0) { - backingLevel = firstMark + ((level - 1.0) / 1.0) * (secondMark - firstMark); - } else { - backingLevel = secondMark + ((level - 2.0) / 6.0) * (self.maxZoomLevel - secondMark); - } - } else if (marks.count == 1) { - CGFloat mark = [marks.firstObject floatValue]; - if ([self hasTelephotoCamera]) { - if (zoomLevel < 2.0) { - backingLevel = 1.0 + ((level - 1.0) / 1.0) * (mark - 1.0); - } else { - backingLevel = mark + ((level - 2.0) / 6.0) * (self.maxZoomLevel - mark); - } - } else if ([self hasUltrawideCamera]) { + if (@available(iOS 13.0, *)) { + if (device.isVirtualDevice) { + NSArray *marks = device.virtualDeviceSwitchOverVideoZoomFactors; + if (marks.count == 2) { + CGFloat firstMark = [marks.firstObject floatValue]; + CGFloat secondMark = [marks.lastObject floatValue]; if (level < 1.0) { level = MAX(0.5, level); - backingLevel = 1.0 + ((level - 0.5) / 0.5) * (mark - 1.0); + backingLevel = 1.0 + ((level - 0.5) / 0.5) * (firstMark - 1.0); + } else if (zoomLevel < 2.0) { + backingLevel = firstMark + ((level - 1.0) / 1.0) * (secondMark - firstMark); } else { - backingLevel = mark + ((level - 1.0) / 7.0) * (self.maxZoomLevel - mark); + backingLevel = secondMark + ((level - 2.0) / 6.0) * (self.maxZoomLevel - secondMark); + } + } else if (marks.count == 1) { + CGFloat mark = [marks.firstObject floatValue]; + if ([self hasTelephotoCamera]) { + if (zoomLevel < 2.0) { + backingLevel = 1.0 + ((level - 1.0) / 1.0) * (mark - 1.0); + } else { + backingLevel = mark + ((level - 2.0) / 6.0) * (self.maxZoomLevel - mark); + } + } else if ([self hasUltrawideCamera]) { + if (level < 1.0) { + level = MAX(0.5, level); + backingLevel = 1.0 + ((level - 0.5) / 0.5) * (mark - 1.0); + } else { + backingLevel = mark + ((level - 1.0) / 7.0) * (self.maxZoomLevel - mark); + } } } } @@ -844,16 +844,18 @@ const NSInteger PGCameraFrameRate = 30; + (AVCaptureDevice *)_deviceWithPosition:(AVCaptureDevicePosition)position { - if (iosMajorVersion() >= 13 && position != AVCaptureDevicePositionFront) { - AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInTripleCamera mediaType:AVMediaTypeVideo position:position]; - if (device == nil) { - device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualCamera mediaType:AVMediaTypeVideo position:position]; - } - if (device == nil) { - device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualWideCamera mediaType:AVMediaTypeVideo position:position]; - } - if (device != nil) { - return device; + if (@available(iOS 13.0, *)) { + if (position != AVCaptureDevicePositionFront) { + AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInTripleCamera mediaType:AVMediaTypeVideo position:position]; + if (device == nil) { + device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualCamera mediaType:AVMediaTypeVideo position:position]; + } + if (device == nil) { + device = [AVCaptureDevice defaultDeviceWithDeviceType:AVCaptureDeviceTypeBuiltInDualWideCamera mediaType:AVMediaTypeVideo position:position]; + } + if (device != nil) { + return device; + } } } diff --git a/submodules/LegacyComponents/Sources/POPAnimatableProperty.mm b/submodules/LegacyComponents/Sources/POPAnimatableProperty.mm index 8cd843659a..fef591ccdf 100644 --- a/submodules/LegacyComponents/Sources/POPAnimatableProperty.mm +++ b/submodules/LegacyComponents/Sources/POPAnimatableProperty.mm @@ -13,10 +13,6 @@ #import -#if SCENEKIT_SDK_AVAILABLE -#import -#endif - #import "POPLayerExtras.h" #if TARGET_OS_IPHONE @@ -542,284 +538,6 @@ static POPStaticAnimatablePropertyState _staticStates[] = }, 0.01 }, -#if SCENEKIT_SDK_AVAILABLE - - /* SceneKit */ - - {kPOPSCNNodePosition, - ^(SCNNode *obj, CGFloat values[]) { - values_from_vec3(values, obj.position); - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.position = values_to_vec3(values); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodePositionX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.position.x; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.position = SCNVector3Make(values[0], obj.position.y, obj.position.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodePositionY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.position.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.position = SCNVector3Make(obj.position.x, values[0], obj.position.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodePositionZ, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.position.z; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.position = SCNVector3Make(obj.position.x, obj.position.y, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeTranslation, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.transform.m41; - values[1] = obj.transform.m42; - values[2] = obj.transform.m43; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.transform = SCNMatrix4MakeTranslation(values[0], values[1], values[2]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeTranslationX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.transform.m41; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.transform = SCNMatrix4MakeTranslation(values[0], obj.transform.m42, obj.transform.m43); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeTranslationY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.transform.m42; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.transform = SCNMatrix4MakeTranslation(obj.transform.m41, values[0], obj.transform.m43); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeTranslationY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.transform.m43; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.transform = SCNMatrix4MakeTranslation(obj.transform.m41, obj.transform.m42, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeRotation, - ^(SCNNode *obj, CGFloat values[]) { - values_from_vec4(values, obj.rotation); - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.rotation = values_to_vec4(values); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeRotationX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.rotation.x; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.rotation = SCNVector4Make(1.0, obj.rotation.y, obj.rotation.z, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeRotationY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.rotation.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.rotation = SCNVector4Make(obj.rotation.x, 1.0, obj.rotation.z, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeRotationZ, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.rotation.z; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.rotation = SCNVector4Make(obj.rotation.x, obj.rotation.y, 1.0, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeRotationW, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.rotation.w; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.rotation = SCNVector4Make(obj.rotation.x, obj.rotation.y, obj.rotation.z, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeEulerAngles, - ^(SCNNode *obj, CGFloat values[]) { - values_from_vec3(values, obj.eulerAngles); - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.eulerAngles = values_to_vec3(values); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeEulerAnglesX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.eulerAngles.x; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.eulerAngles = SCNVector3Make(values[0], obj.eulerAngles.y, obj.eulerAngles.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeEulerAnglesY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.eulerAngles.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.eulerAngles = SCNVector3Make(obj.eulerAngles.x, values[0], obj.eulerAngles.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeEulerAnglesZ, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.eulerAngles.z; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.eulerAngles = SCNVector3Make(obj.eulerAngles.x, obj.eulerAngles.y, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeOrientation, - ^(SCNNode *obj, CGFloat values[]) { - values_from_vec4(values, obj.orientation); - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.orientation = values_to_vec4(values); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeOrientationX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.orientation.x; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.orientation = SCNVector4Make(values[0], obj.orientation.y, obj.orientation.z, obj.orientation.w); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeOrientationY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.orientation.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.orientation = SCNVector4Make(obj.orientation.x, values[0], obj.orientation.z, obj.orientation.w); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeOrientationZ, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.orientation.z; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.orientation = SCNVector4Make(obj.orientation.x, obj.orientation.y, values[0], obj.orientation.w); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeOrientationW, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.orientation.w; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.orientation = SCNVector4Make(obj.orientation.x, obj.orientation.y, obj.orientation.z, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeScale, - ^(SCNNode *obj, CGFloat values[]) { - values_from_vec3(values, obj.scale); - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.scale = values_to_vec3(values); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeScaleX, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.scale.x; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.scale = SCNVector3Make(values[0], obj.scale.y, obj.scale.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeScaleY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.scale.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.position = SCNVector3Make(obj.scale.x, values[0], obj.scale.z); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeScaleZ, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.scale.z; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.scale = SCNVector3Make(obj.scale.x, obj.scale.y, values[0]); - }, - kPOPThresholdScale - }, - - {kPOPSCNNodeScaleXY, - ^(SCNNode *obj, CGFloat values[]) { - values[0] = obj.scale.x; - values[1] = obj.scale.y; - }, - ^(SCNNode *obj, const CGFloat values[]) { - obj.scale = SCNVector3Make(values[0], values[1], obj.scale.z); - }, - kPOPThresholdScale - }, - -#endif #if TARGET_OS_IPHONE diff --git a/submodules/LegacyComponents/Sources/POPAnimationRuntime.mm b/submodules/LegacyComponents/Sources/POPAnimationRuntime.mm index 28412a0e8b..4e27a6e006 100644 --- a/submodules/LegacyComponents/Sources/POPAnimationRuntime.mm +++ b/submodules/LegacyComponents/Sources/POPAnimationRuntime.mm @@ -124,18 +124,10 @@ static bool FBCompareTypeEncoding(const char *objctype, POPValueType type) ); case kPOPValueSCNVector3: -#if SCENEKIT_SDK_AVAILABLE - return strcmp(objctype, @encode(SCNVector3)) == 0; -#else return false; -#endif case kPOPValueSCNVector4: -#if SCENEKIT_SDK_AVAILABLE - return strcmp(objctype, @encode(SCNVector4)) == 0; -#else return false; -#endif default: return false; @@ -229,16 +221,6 @@ id POPBox(VectorConstRef vec, POPValueType type, bool force) return (__bridge_transfer id)vec->cg_color(); break; } -#if SCENEKIT_SDK_AVAILABLE - case kPOPValueSCNVector3: { - return [NSValue valueWithSCNVector3:vec->scn_vector3()]; - break; - } - case kPOPValueSCNVector4: { - return [NSValue valueWithSCNVector4:vec->scn_vector4()]; - break; - } -#endif default: return force ? [NSValue valueWithCGPoint:vec->cg_point()] : nil; break; @@ -274,14 +256,6 @@ static VectorRef vectorize(id value, POPValueType type) case kPOPValueColor: vec = Vector::new_cg_color(POPCGColorWithColor(value)); break; -#if SCENEKIT_SDK_AVAILABLE - case kPOPValueSCNVector3: - vec = Vector::new_scn_vector3([value SCNVector3Value]); - break; - case kPOPValueSCNVector4: - vec = Vector::new_scn_vector4([value SCNVector4Value]); - break; -#endif default: break; } diff --git a/submodules/LegacyComponents/Sources/POPCGUtils.h b/submodules/LegacyComponents/Sources/POPCGUtils.h index a170750d07..f754d66140 100644 --- a/submodules/LegacyComponents/Sources/POPCGUtils.h +++ b/submodules/LegacyComponents/Sources/POPCGUtils.h @@ -13,10 +13,6 @@ #endif #import "POPDefines.h" -#if SCENEKIT_SDK_AVAILABLE -#import -#endif - #if TARGET_OS_IPHONE @class UIColor; #endif @@ -38,18 +34,6 @@ NS_INLINE CGRect values_to_rect(const CGFloat values[]) return CGRectMake(values[0], values[1], values[2], values[3]); } -#if SCENEKIT_SDK_AVAILABLE -NS_INLINE SCNVector3 values_to_vec3(const CGFloat values[]) -{ - return SCNVector3Make(values[0], values[1], values[2]); -} - -NS_INLINE SCNVector4 values_to_vec4(const CGFloat values[]) -{ - return SCNVector4Make(values[0], values[1], values[2], values[3]); -} -#endif - #if TARGET_OS_IPHONE NS_INLINE UIEdgeInsets values_to_edge_insets(const CGFloat values[]) @@ -79,23 +63,6 @@ NS_INLINE void values_from_rect(CGFloat values[], CGRect r) values[3] = r.size.height; } -#if SCENEKIT_SDK_AVAILABLE -NS_INLINE void values_from_vec3(CGFloat values[], SCNVector3 v) -{ - values[0] = v.x; - values[1] = v.y; - values[2] = v.z; -} - -NS_INLINE void values_from_vec4(CGFloat values[], SCNVector4 v) -{ - values[0] = v.x; - values[1] = v.y; - values[2] = v.z; - values[3] = v.w; -} -#endif - #if TARGET_OS_IPHONE NS_INLINE void values_from_edge_insets(CGFloat values[], UIEdgeInsets i) diff --git a/submodules/LegacyComponents/Sources/POPGeometry.mm b/submodules/LegacyComponents/Sources/POPGeometry.mm index 41998b10b2..64d11341c9 100644 --- a/submodules/LegacyComponents/Sources/POPGeometry.mm +++ b/submodules/LegacyComponents/Sources/POPGeometry.mm @@ -69,26 +69,4 @@ #if TARGET_OS_IPHONE #import "POPDefines.h" -#if SCENEKIT_SDK_AVAILABLE -#import - -/** - Dirty hacks because iOS is weird and decided to define both SCNVector3's and SCNVector4's objCType as "t". However @encode(SCNVector3) and @encode(SCNVector4) both return the proper definition ("{SCNVector3=fff}" and "{SCNVector4=ffff}" respectively) - - [[NSValue valueWithSCNVector3:SCNVector3Make(0.0, 0.0, 0.0)] objcType] returns "t", whereas it should return "{SCNVector3=fff}". - - *flips table* - */ -@implementation NSValue (SceneKitFixes) - -+ (NSValue *)valueWithSCNVector3:(SCNVector3)vec3 { - return [NSValue valueWithBytes:&vec3 objCType:@encode(SCNVector3)]; -} - -+ (NSValue *)valueWithSCNVector4:(SCNVector4)vec4 { - return [NSValue valueWithBytes:&vec4 objCType:@encode(SCNVector4)]; -} - -@end -#endif #endif diff --git a/submodules/LegacyComponents/Sources/POPVector.h b/submodules/LegacyComponents/Sources/POPVector.h index 630f17307b..48a0f72617 100644 --- a/submodules/LegacyComponents/Sources/POPVector.h +++ b/submodules/LegacyComponents/Sources/POPVector.h @@ -22,10 +22,6 @@ #import "POPMath.h" #import "POPDefines.h" -#if SCENEKIT_SDK_AVAILABLE -#import -#endif - namespace POP { /** Fixed two-size vector class */ @@ -342,16 +338,6 @@ namespace POP { // CGColorRef support CGColorRef cg_color() const CF_RETURNS_RETAINED; static Vector *new_cg_color(CGColorRef color); - -#if SCENEKIT_SDK_AVAILABLE - // SCNVector3 support - SCNVector3 scn_vector3() const; - static Vector *new_scn_vector3(const SCNVector3 &vec3); - - // SCNVector4 support - SCNVector4 scn_vector4() const; - static Vector *new_scn_vector4(const SCNVector4 &vec4); -#endif // operator overloads CGFloat &operator[](size_t i) const { diff --git a/submodules/LegacyComponents/Sources/POPVector.mm b/submodules/LegacyComponents/Sources/POPVector.mm index 98007ef172..481e5ebe75 100644 --- a/submodules/LegacyComponents/Sources/POPVector.mm +++ b/submodules/LegacyComponents/Sources/POPVector.mm @@ -250,37 +250,6 @@ namespace POP POPCGColorGetRGBAComponents(color, rgba); return new_vector(4, rgba); } - -#if SCENEKIT_SDK_AVAILABLE - SCNVector3 Vector::scn_vector3() const - { - return _count < 3 ? SCNVector3Make(0.0, 0.0, 0.0) : SCNVector3Make(_values[0], _values[1], _values[2]); - } - - Vector *Vector::new_scn_vector3(const SCNVector3 &vec3) - { - Vector *v = new Vector(3); - v->_values[0] = vec3.x; - v->_values[1] = vec3.y; - v->_values[2] = vec3.z; - return v; - } - - SCNVector4 Vector::scn_vector4() const - { - return _count < 4 ? SCNVector4Make(0.0, 0.0, 0.0, 0.0) : SCNVector4Make(_values[0], _values[1], _values[2], _values[3]); - } - - Vector *Vector::new_scn_vector4(const SCNVector4 &vec4) - { - Vector *v = new Vector(4); - v->_values[0] = vec4.x; - v->_values[1] = vec4.y; - v->_values[2] = vec4.z; - v->_values[3] = vec4.w; - return v; - } -#endif void Vector::subRound(CGFloat sub) { diff --git a/submodules/LegacyComponents/Sources/TGAlphacodePanelCell.m b/submodules/LegacyComponents/Sources/TGAlphacodePanelCell.m index 7845f7c863..792388471b 100644 --- a/submodules/LegacyComponents/Sources/TGAlphacodePanelCell.m +++ b/submodules/LegacyComponents/Sources/TGAlphacodePanelCell.m @@ -95,12 +95,18 @@ NSString *const TGAlphacodePanelCellKind = @"TGAlphacodePanelCell"; CGFloat leftInset = 11.0f; CGFloat rightInset = 6.0f; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize titleSize = [_emojiLabel.text sizeWithFont:_emojiLabel.font]; +#pragma clang diagnostic pop titleSize.width = CGCeil(MIN((boundsSize.width - leftInset - rightInset) * 3.0f / 4.0f, titleSize.width)); titleSize.height = CGCeil(titleSize.height); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize descriptionSize = [_descriptionLabel.text sizeWithFont:_descriptionLabel.font]; +#pragma clang diagnostic pop descriptionSize.width = CGCeil(MIN(boundsSize.width - leftInset - 40.0f, descriptionSize.width)); _emojiLabel.frame = CGRectMake(leftInset, CGFloor((boundsSize.height - titleSize.height) / 2.0f), titleSize.width, titleSize.height); diff --git a/submodules/LegacyComponents/Sources/TGAttachmentAssetCell.m b/submodules/LegacyComponents/Sources/TGAttachmentAssetCell.m index 51b23a8596..b50fa2fcdb 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentAssetCell.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentAssetCell.m @@ -59,8 +59,7 @@ _gradientView.hidden = true; [self addSubview:_gradientView]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _imageView.accessibilityIgnoresInvertColors = true; _gradientView.accessibilityIgnoresInvertColors = true; } @@ -87,8 +86,9 @@ [_checkButton addTarget:self action:@selector(checkButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:_checkButton]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _checkButton.accessibilityIgnoresInvertColors = true; + } } if (_itemSelectedDisposable == nil) diff --git a/submodules/LegacyComponents/Sources/TGAttachmentCameraView.m b/submodules/LegacyComponents/Sources/TGAttachmentCameraView.m index 3cea35671f..2c0c95f510 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentCameraView.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentCameraView.m @@ -104,8 +104,7 @@ _zoomedView.userInteractionEnabled = false; [self addSubview:_zoomedView]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _fadeView.accessibilityIgnoresInvertColors = true; _iconView.accessibilityIgnoresInvertColors = true; } diff --git a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m index cc036da905..420fe63797 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentCarouselItemView.m @@ -246,8 +246,9 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500; } _collectionView = [[TGAttachmentCarouselCollectionView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, TGAttachmentZoomedPhotoHeight + TGAttachmentEdgeInset * 2) collectionViewLayout:_smallLayout]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _collectionView.backgroundColor = [UIColor clearColor]; _collectionView.dataSource = self; _collectionView.delegate = self; diff --git a/submodules/LegacyComponents/Sources/TGAttachmentVideoCell.m b/submodules/LegacyComponents/Sources/TGAttachmentVideoCell.m index 4feda8a385..1df73fed2f 100644 --- a/submodules/LegacyComponents/Sources/TGAttachmentVideoCell.m +++ b/submodules/LegacyComponents/Sources/TGAttachmentVideoCell.m @@ -39,8 +39,9 @@ NSString *const TGAttachmentVideoCellIdentifier = @"AttachmentVideoCell"; _adjustmentsDisposable = [[SMetaDisposable alloc] init]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _durationLabel.accessibilityIgnoresInvertColors = true; + } } return self; } diff --git a/submodules/LegacyComponents/Sources/TGCache.m b/submodules/LegacyComponents/Sources/TGCache.m index e202bfe64e..6fc28ec3d4 100644 --- a/submodules/LegacyComponents/Sources/TGCache.m +++ b/submodules/LegacyComponents/Sources/TGCache.m @@ -449,11 +449,6 @@ static NSFileManager *cacheFileManager = nil; { cacheRecord.date = CFAbsoluteTimeGetCurrent(); - if (false) - { - dataImage = [[UIImage alloc] initWithData:cacheRecord.object]; - } - else { NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:true] forKey:(id)kCGImageSourceShouldCache]; CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)cacheRecord.object, nil); diff --git a/submodules/LegacyComponents/Sources/TGCameraController.m b/submodules/LegacyComponents/Sources/TGCameraController.m index 5258fe8e96..811813ec86 100644 --- a/submodules/LegacyComponents/Sources/TGCameraController.m +++ b/submodules/LegacyComponents/Sources/TGCameraController.m @@ -454,8 +454,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus if (_intent != TGCameraControllerGenericIntent && _intent != TGCameraControllerAvatarIntent) [_interfaceView setHasModeControl:false]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _backgroundView.accessibilityIgnoresInvertColors = true; _interfaceView.accessibilityIgnoresInvertColors = true; _focusControl.accessibilityIgnoresInvertColors = true; @@ -675,7 +674,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus }); }]; - if (iosMajorVersion() >= 13.0) { + if (@available(iOS 13.0, *)) { [strongSelf->_feedbackGenerator impactOccurredWithIntensity:0.5]; } else { [strongSelf->_feedbackGenerator impactOccurred]; @@ -1020,7 +1019,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus - (void)shutterPressed { - if (iosMajorVersion() >= 13.0) { + if (@available(iOS 13.0, *)) { [_feedbackGenerator impactOccurredWithIntensity:0.5]; } else { [_feedbackGenerator impactOccurred]; @@ -1060,7 +1059,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus - (void)shutterReleased { - if (iosMajorVersion() >= 13.0) { + if (@available(iOS 13.0, *)) { [_feedbackGenerator impactOccurredWithIntensity:0.6]; } else { [_feedbackGenerator impactOccurred]; @@ -2366,21 +2365,6 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus } [self dismiss]; }]; - - return; - - [UIView animateWithDuration:0.3 delay:0.0f options:(7 << 16) animations:^ - { - resultController.view.frame = CGRectOffset(resultController.view.frame, 0, resultController.view.frame.size.height); - } completion:^(__unused BOOL finished) - { - if (resultController.customDismissSelf) { - resultController.customDismissSelf(); - } else { - [resultController dismiss]; - } - [self dismiss]; - }]; } - (void)simpleTransitionOutWithVelocity:(CGFloat)velocity completion:(void (^)())completion diff --git a/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m b/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m index 53f5f94e89..c71d45d351 100644 --- a/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m +++ b/submodules/LegacyComponents/Sources/TGCameraMainPhoneView.m @@ -213,7 +213,7 @@ if (!strongSelf->_zoomWheelView.isHidden) { NSInteger counter = strongSelf->_dismissingWheelCounter + 1; - strongSelf->_dismissingWheelCounter = counter; + strongSelf->_dismissingWheelCounter = (int)counter; TGDispatchAfter(1.5, dispatch_get_main_queue(), ^{ if (strongSelf->_dismissingWheelCounter == counter) { @@ -224,7 +224,7 @@ } } else { NSInteger counter = strongSelf->_dismissingWheelCounter + 1; - strongSelf->_dismissingWheelCounter = counter; + strongSelf->_dismissingWheelCounter = (int)counter; [strongSelf->_zoomWheelView setZoomLevel:zoomLevel panning:true]; [strongSelf->_zoomModeView setHidden:true animated:true]; [strongSelf->_zoomWheelView setHidden:false animated:true]; diff --git a/submodules/LegacyComponents/Sources/TGCameraMainView.m b/submodules/LegacyComponents/Sources/TGCameraMainView.m index bc2cd5d7bb..f5a363e0dd 100644 --- a/submodules/LegacyComponents/Sources/TGCameraMainView.m +++ b/submodules/LegacyComponents/Sources/TGCameraMainView.m @@ -70,6 +70,16 @@ @dynamic thumbnailSignalForItem; @dynamic editingContext; +- (instancetype)initWithFrame:(CGRect)frame avatar:(bool)avatar hasUltrawideCamera:(bool)hasUltrawideCamera hasTelephotoCamera:(bool)hasTelephotoCamera { + self = [super init]; + if (self != nil) { + } + return self; +} + +- (void)setResults:(NSArray *)__unused results { +} + #pragma mark - Mode - (void)setInterfaceHiddenForVideoRecording:(bool)__unused hidden animated:(bool)__unused animated diff --git a/submodules/LegacyComponents/Sources/TGCameraPreviewView.m b/submodules/LegacyComponents/Sources/TGCameraPreviewView.m index abed3a0e18..4d54e51c3d 100644 --- a/submodules/LegacyComponents/Sources/TGCameraPreviewView.m +++ b/submodules/LegacyComponents/Sources/TGCameraPreviewView.m @@ -59,11 +59,8 @@ { self.backgroundColor = [UIColor blackColor]; self.clipsToBounds = true; - - if (false && iosMajorVersion() >= 8) - _wrapperView = [[TGCameraPreviewLayerWrapperView alloc] init]; - else - _wrapperView = [[TGCameraLegacyPreviewLayerWrapperView alloc] init]; + + _wrapperView = [[TGCameraLegacyPreviewLayerWrapperView alloc] init]; [self addSubview:_wrapperView]; _wrapperView.videoGravity = AVLayerVideoGravityResizeAspectFill; @@ -74,8 +71,9 @@ _fadeView.userInteractionEnabled = false; [self addSubview:_fadeView]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _fadeView.accessibilityIgnoresInvertColors = true; + } #if TARGET_IPHONE_SIMULATOR _fadeView.backgroundColor = [UIColor redColor]; @@ -230,8 +228,9 @@ snapshotView.image = image; [self insertSubview:snapshotView aboveSubview:_wrapperView]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { snapshotView.accessibilityIgnoresInvertColors = true; + } _snapshotView = snapshotView; diff --git a/submodules/LegacyComponents/Sources/TGClipboardPreviewItemView.m b/submodules/LegacyComponents/Sources/TGClipboardPreviewItemView.m index b36c74226d..c51cd1f32e 100644 --- a/submodules/LegacyComponents/Sources/TGClipboardPreviewItemView.m +++ b/submodules/LegacyComponents/Sources/TGClipboardPreviewItemView.m @@ -50,8 +50,9 @@ const CGFloat TGClipboardPreviewEdgeInset = 8.0f; _collectionLayout.minimumLineSpacing = 8.0f; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, TGClipboardPreviewCellHeight + TGClipboardPreviewEdgeInset * 2) collectionViewLayout:_collectionLayout]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _collectionView.backgroundColor = [UIColor whiteColor]; _collectionView.dataSource = self; _collectionView.delegate = self; diff --git a/submodules/LegacyComponents/Sources/TGConversation.m b/submodules/LegacyComponents/Sources/TGConversation.m index 6bdd274cb8..b250f6d810 100644 --- a/submodules/LegacyComponents/Sources/TGConversation.m +++ b/submodules/LegacyComponents/Sources/TGConversation.m @@ -1367,8 +1367,7 @@ return TGPeerIdIsAd(_conversationId); } -- (NSString *)chatPhotoFullSmall -{ +- (NSString *)chatPhotoFullSmall { NSString *finalAvatarUrl = self.chatPhotoSmall; if (finalAvatarUrl.length == 0) return finalAvatarUrl; @@ -1389,8 +1388,7 @@ return finalAvatarUrl; } -- (NSString *)chatPhotoFullBig -{ +- (NSString *)chatPhotoFullBig { NSString *finalAvatarUrl = self.chatPhotoBig; if (finalAvatarUrl.length == 0) return finalAvatarUrl; diff --git a/submodules/LegacyComponents/Sources/TGGradientLabel.m b/submodules/LegacyComponents/Sources/TGGradientLabel.m index ca5f4212dd..23dc4e2943 100644 --- a/submodules/LegacyComponents/Sources/TGGradientLabel.m +++ b/submodules/LegacyComponents/Sources/TGGradientLabel.m @@ -31,12 +31,8 @@ { if (_text == nil || _font == nil) return; - - if (iosMajorVersion() >= 7) { - _textSize = [self.text boundingRectWithSize:CGSizeMake(1000.0f, 1000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: _font} context:nil].size; - } else { - _textSize = [self.text sizeWithFont:_font]; - } + + _textSize = [self.text boundingRectWithSize:CGSizeMake(1000.0f, 1000.0f) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: _font} context:nil].size; CGRect frame = self.frame; frame.size = _textSize; @@ -126,98 +122,20 @@ { CGPoint drawingOffset = CGPointMake(CGFloor((bounds.size.width - _textSize.width) / 2.0f), CGFloor((bounds.size.height - _textSize.height) / 2.0f)); - if (false) - { - memset(_offscreenMemory, 0x00, (int)(_offscreenContextStride * _offscreenContextHeight)); - UIGraphicsPushContext(_offscreenContext); - [_text drawAtPoint:CGPointMake(2.0f, 2.0f) withFont:_font]; - UIGraphicsPopContext(); - - int minX = _offscreenContextWidth; - int minY = _offscreenContextHeight; - int maxX = 0; - int maxY = 0; - - const void *offscreenMemory = _offscreenMemory; - const int offscreenStride = _offscreenContextStride; - for (int y = 0; y < _offscreenContextHeight; y++) - { - for (int x = 0; x < _offscreenContextWidth; x++) - { - if ((*((uint32_t *)&offscreenMemory[y * offscreenStride + x * 4]) & 0xff000000) == 0xff000000) - { - if (x < minX) - minX = x; - if (y < minY) - minY = y; - if (x > maxX) - maxX = x; - if (y > maxY) - maxY = y; - } - } - } - - const int halfY = (maxY + minY) / 2; - const int halfX = (maxX + minX) / 2; - - int topHalf = 0; - int bottomHalf = 0; - int rightHalf = 0; - int leftHalf = 0; - for (int y = minY; y <= maxY; y++) - { - for (int x = minX; x <= maxX; x++) - { - if ((*((uint32_t *)&offscreenMemory[y * offscreenStride + x * 4]) & 0xff000000) == 0xff000000) - { - if (x < halfX) - leftHalf++; - else - rightHalf++; - - if (y < halfY) - topHalf++; - else - bottomHalf++; - } - } - } - - CGFloat topOffset = 0.0f; - CGFloat leftOffset = 0.0f; - - if (topHalf != 0 && bottomHalf != 0 && leftHalf != 0 && rightHalf != 0) - { - topOffset = topHalf / (CGFloat)bottomHalf - 1.0f; - leftOffset = leftHalf / (CGFloat)rightHalf - 1.0f; - } - - minY = _offscreenContextHeight - minY; - maxY = _offscreenContextHeight - maxY; - int tmp = maxY; - maxY = minY; - minY = tmp; - - CGSize realSize = CGSizeMake(maxX - minX, maxY - minY); - CGPoint realOffset = CGPointMake(minX - 2.0f, minY - 2.0f); - - if (realSize.width > FLT_EPSILON && realSize.height > FLT_EPSILON) - { - drawingOffset = CGPointMake(CGFloor((bounds.size.width - realSize.width) / 2.0f) - realOffset.x, CGFloor((bounds.size.height - realSize.height) / 2.0f) - realOffset.y); - //drawingOffset.x += leftOffset; - //drawingOffset.y += topOffset; - } - } - CGContextSetFillColorWithColor(context, _textColor.CGColor); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [_text drawAtPoint:drawingOffset withFont:_font]; +#pragma clang diagnostic pop } else { CGContextSetTextDrawingMode(context, kCGTextClip); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [_text drawAtPoint:CGPointMake(CGFloor((bounds.size.width - _textSize.width) / 2.0f), CGFloor((bounds.size.height - _textSize.height) / 2.0f)) withFont:_font]; +#pragma clang diagnostic pop CGColorRef colors[2] = { CGColorRetain(UIColorRGB(_topColor).CGColor), diff --git a/submodules/LegacyComponents/Sources/TGHashtagPanelCell.m b/submodules/LegacyComponents/Sources/TGHashtagPanelCell.m index eaf52ced26..ea19909e4c 100644 --- a/submodules/LegacyComponents/Sources/TGHashtagPanelCell.m +++ b/submodules/LegacyComponents/Sources/TGHashtagPanelCell.m @@ -103,7 +103,10 @@ NSString *const TGHashtagPanelCellKind = @"TGHashtagPanelCell"; [super layoutSubviews]; CGFloat inset = 15.0f; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize labelSize = [_label.text sizeWithFont:_label.font]; +#pragma clang diagnostic pop labelSize.width = CGCeil(MIN(labelSize.width, self.frame.size.width - inset * 2.0f)); labelSize.height = CGCeil(labelSize.height); _label.frame = CGRectMake(inset, CGFloor((self.frame.size.height - labelSize.height) / 2.0f), labelSize.width, labelSize.height); diff --git a/submodules/LegacyComponents/Sources/TGImageUtils.mm b/submodules/LegacyComponents/Sources/TGImageUtils.mm index c10be6021b..0734f8b066 100644 --- a/submodules/LegacyComponents/Sources/TGImageUtils.mm +++ b/submodules/LegacyComponents/Sources/TGImageUtils.mm @@ -229,22 +229,6 @@ UIImage *TGScaleAndBlurImage(NSData *data, __unused CGSize size, __autoreleasing return returnImage; } -static void matrixMul(CGFloat *a, CGFloat *b, CGFloat *result) -{ - for (int i = 0; i != 4; ++i) - { - for (int j = 0; j != 4; ++j) - { - CGFloat sum = 0; - for (int k = 0; k != 4; ++k) - { - sum += a[i + k * 4] * b[k + j * 4]; - } - result[i + j * 4] = sum; - } - } -} - UIImage *TGScaleImageToPixelSize(UIImage *image, CGSize size) { UIGraphicsBeginImageContextWithOptions(size, true, 1.0f); diff --git a/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m b/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m index daf1f0c3fa..fcdc4ea406 100644 --- a/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m +++ b/submodules/LegacyComponents/Sources/TGLetteredAvatarView.m @@ -27,8 +27,9 @@ self = [super initWithFrame:frame]; if (self != nil) { - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } _label = [[TGGradientLabel alloc] init]; _label.backgroundColor = [UIColor clearColor]; diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetModernImageSignals.m b/submodules/LegacyComponents/Sources/TGMediaAssetModernImageSignals.m index e63a2daeb3..003bf452f9 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetModernImageSignals.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetModernImageSignals.m @@ -311,7 +311,10 @@ { fileUrl = tmpURL; dataUTI = @"public.jpeg"; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" imageData = [[NSData alloc] initWithContentsOfMappedFile:fileUrl.path]; +#pragma clang diagnostic pop NSString *lowcaseString = [fileName lowercaseString]; NSRange range = [lowcaseString rangeOfString:@".heic"]; diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsController.m b/submodules/LegacyComponents/Sources/TGMediaAssetsController.m index 37058dca22..b3e558fba3 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsController.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsController.m @@ -583,12 +583,15 @@ hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; } } - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat inset = [TGViewController safeAreaInsetForOrientation:self.interfaceOrientation hasOnScreenNavigation:hasOnScreenNavigation].bottom; _toolbarView = [[TGMediaPickerToolbarView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - TGMediaPickerToolbarHeight - inset, self.view.frame.size.width, TGMediaPickerToolbarHeight + inset)]; if (_pallete != nil) _toolbarView.pallete = _pallete; _toolbarView.safeAreaInset = [TGViewController safeAreaInsetForOrientation:self.interfaceOrientation hasOnScreenNavigation:hasOnScreenNavigation]; +#pragma clang diagnostic pop _toolbarView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; if ((_intent != TGMediaAssetsControllerSendFileIntent && _intent != TGMediaAssetsControllerSendMediaIntent && _intent != TGMediaAssetsControllerPassportMultipleIntent) || _selectionContext == nil) [_toolbarView setRightButtonHidden:true]; @@ -609,19 +612,24 @@ }; } [self.view addSubview:_toolbarView]; - - if (iosMajorVersion() >= 14 && [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite] == PHAuthorizationStatusLimited) { - _accessView = [[TGMediaPickerAccessView alloc] init]; - _accessView.autoresizingMask = UIViewAutoresizingFlexibleWidth; - _accessView.safeAreaInset = [TGViewController safeAreaInsetForOrientation:self.interfaceOrientation hasOnScreenNavigation:hasOnScreenNavigation]; - [_accessView setPallete:_pallete]; - _accessView.pressed = ^{ - __strong TGMediaAssetsController *strongSelf = weakSelf; - if (strongSelf != nil) { - [strongSelf manageAccess]; - } - }; - [self.view addSubview:_accessView]; + + if (@available(iOS 14.0, *)) { + if ([PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite] == PHAuthorizationStatusLimited) { + _accessView = [[TGMediaPickerAccessView alloc] init]; + _accessView.autoresizingMask = UIViewAutoresizingFlexibleWidth; + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdeprecated-declarations" + _accessView.safeAreaInset = [TGViewController safeAreaInsetForOrientation:self.interfaceOrientation hasOnScreenNavigation:hasOnScreenNavigation]; + #pragma clang diagnostic pop + [_accessView setPallete:_pallete]; + _accessView.pressed = ^{ + __strong TGMediaAssetsController *strongSelf = weakSelf; + if (strongSelf != nil) { + [strongSelf manageAccess]; + } + }; + [self.view addSubview:_accessView]; + } } } diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m b/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m index ca3015a6e4..2052108aa3 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsGifCell.m @@ -64,8 +64,7 @@ NSString *const TGMediaAssetsGifCellKind = @"TGMediaAssetsGifCellKind"; [_typeLabel sizeToFit]; [self addSubview:_typeLabel]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _shadowView.accessibilityIgnoresInvertColors = true; _typeLabel.accessibilityIgnoresInvertColors = true; } diff --git a/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m b/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m index 2e1eab68a8..51953e671a 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaAssetsVideoCell.m @@ -74,8 +74,7 @@ NSString *const TGMediaAssetsVideoCellKind = @"TGMediaAssetsVideoCellKind"; _adjustmentsDisposable = [[SMetaDisposable alloc] init]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _shadowView.accessibilityIgnoresInvertColors = true; _durationLabel.accessibilityIgnoresInvertColors = true; } diff --git a/submodules/LegacyComponents/Sources/TGMediaAvatarEditorTransition.m b/submodules/LegacyComponents/Sources/TGMediaAvatarEditorTransition.m index e23598e047..256b51d0f6 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAvatarEditorTransition.m +++ b/submodules/LegacyComponents/Sources/TGMediaAvatarEditorTransition.m @@ -76,8 +76,9 @@ orientation = UIInterfaceOrientationPortrait; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = _controller.view.safeAreaInsets.bottom > FLT_EPSILON; + } CGSize referenceViewSize = [_controller referenceViewSizeForOrientation:orientation]; CGRect containerFrame = [TGPhotoEditorTabController photoContainerFrameForParentViewFrame:CGRectMake(0, 0, referenceViewSize.width, referenceViewSize.height) toolbarLandscapeSize:_controller.toolbarLandscapeSize orientation:orientation panelSize:0.0f hasOnScreenNavigation:hasOnScreenNavigation]; diff --git a/submodules/LegacyComponents/Sources/TGMediaAvatarMenuMixin.m b/submodules/LegacyComponents/Sources/TGMediaAvatarMenuMixin.m index c482f564ce..191aac1ce9 100644 --- a/submodules/LegacyComponents/Sources/TGMediaAvatarMenuMixin.m +++ b/submodules/LegacyComponents/Sources/TGMediaAvatarMenuMixin.m @@ -63,11 +63,8 @@ - (TGMenuSheetController *)present { [_parentController.view endEditing:true]; - - if (true || [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) - return [self _presentAvatarMenu]; - else - return [self _presentLegacyAvatarMenu]; + + return [self _presentAvatarMenu]; } - (TGMenuSheetController *)_presentAvatarMenu diff --git a/submodules/LegacyComponents/Sources/TGMediaGroupCell.m b/submodules/LegacyComponents/Sources/TGMediaGroupCell.m index cc458c004c..0da21877b6 100644 --- a/submodules/LegacyComponents/Sources/TGMediaGroupCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaGroupCell.m @@ -124,8 +124,7 @@ const CGFloat TGMediaGroupCellHeight = 86.0f; _iconView.contentMode = UIViewContentModeCenter; [self.contentView addSubview:_iconView]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _shadowView.accessibilityIgnoresInvertColors = true; _iconView.accessibilityIgnoresInvertColors = true; } @@ -227,8 +226,9 @@ const CGFloat TGMediaGroupCellHeight = 86.0f; imageType:TGMediaAssetImageTypeThumbnail size:CGSizeMake(138, 138)]]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { imageView.accessibilityIgnoresInvertColors = true; + } } else { @@ -237,8 +237,9 @@ const CGFloat TGMediaGroupCellHeight = 86.0f; [imageView reset]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { imageView.accessibilityIgnoresInvertColors = false; + } } } } @@ -254,8 +255,9 @@ const CGFloat TGMediaGroupCellHeight = 86.0f; [imageView reset]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { imageView.accessibilityIgnoresInvertColors = false; + } } [(TGImageView *)_imageViews.firstObject setImage:TGComponentsImageNamed(@"ModernMediaEmptyAlbumIcon")]; @@ -345,8 +347,11 @@ const CGFloat TGMediaGroupCellHeight = 86.0f; CGSize titleSize = [_nameLabel sizeThatFits:CGSizeMake(self.contentView.frame.size.width - _nameLabel.frame.origin.x - 20, _nameLabel.frame.size.height)]; _nameLabel.frame = CGRectMake(_nameLabel.frame.origin.x, y, ceil(titleSize.width), ceil(titleSize.height)); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize countSize = [_countLabel.text sizeWithFont:_countLabel.font]; +#pragma clang diagnostic pop _countLabel.frame = (CGRect){ _countLabel.frame.origin, { ceil(countSize.width), ceil(countSize.height) } }; } diff --git a/submodules/LegacyComponents/Sources/TGMediaGroupsController.m b/submodules/LegacyComponents/Sources/TGMediaGroupsController.m index c079d3ce7d..6a748cc4f3 100644 --- a/submodules/LegacyComponents/Sources/TGMediaGroupsController.m +++ b/submodules/LegacyComponents/Sources/TGMediaGroupsController.m @@ -50,8 +50,9 @@ self.view.backgroundColor = self.pallete != nil ? self.pallete.backgroundColor : [UIColor whiteColor]; _tableView = [[UITableView alloc] initWithFrame:self.view.bounds]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _tableView.alwaysBounceVertical = true; _tableView.backgroundColor = self.view.backgroundColor; _tableView.delaysContentTouches = true; diff --git a/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m b/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m index ee602dcd42..b7b62db4d2 100644 --- a/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m +++ b/submodules/LegacyComponents/Sources/TGMediaOriginInfo.m @@ -114,8 +114,11 @@ case TGMediaOriginTypeWebpage: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *url = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, (CFStringRef)keyComponents[1], CFSTR(""), kCFStringEncodingUTF8); info->_webpageUrl = url; +#pragma clang diagnostic pop } break; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m b/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m index c253a45589..446bccd311 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerCaptionInputPanel.m @@ -92,14 +92,20 @@ static void setViewFrame(UIView *view, CGRect frame) localizationPlaceholderText = TGLocalized(@"MediaPicker.AddCaption"); NSString *placeholderText = TGLocalized(@"MediaPicker.AddCaption"); UIFont *placeholderFont = TGSystemFontOfSize(17); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize placeholderSize = [placeholderText sizeWithFont:placeholderFont]; +#pragma clang diagnostic pop placeholderSize.width += 2.0f; placeholderSize.height += 2.0f; UIGraphicsBeginImageContextWithOptions(placeholderSize, false, 0.0f); CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, UIColorRGB(0xffffff).CGColor); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [placeholderText drawAtPoint:CGPointMake(1.0f, 1.0f) withFont:placeholderFont]; +#pragma clang diagnostic pop placeholderImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerCell.m b/submodules/LegacyComponents/Sources/TGMediaPickerCell.m index 6e4ae434c8..ff25ee6009 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerCell.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerCell.m @@ -31,8 +31,9 @@ _imageView.clipsToBounds = true; [self addSubview:_imageView]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _imageView.accessibilityIgnoresInvertColors = true; + } _typeIconView = [[UIImageView alloc] init]; _typeIconView.contentMode = UIViewContentModeCenter; @@ -69,8 +70,9 @@ [_checkButton addTarget:self action:@selector(checkButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:_checkButton]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _checkButton.accessibilityIgnoresInvertColors = true; + } } if (_itemSelectedDisposable == nil) diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerController.m b/submodules/LegacyComponents/Sources/TGMediaPickerController.m index 7e90bc9fd0..903335590e 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerController.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerController.m @@ -62,8 +62,9 @@ [self.view addSubview:_wrapperView]; _collectionView = [[[self _collectionViewClass] alloc] initWithFrame:_wrapperView.bounds collectionViewLayout:[self _collectionLayout]]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _collectionView.alwaysBounceVertical = true; _collectionView.backgroundColor = self.view.backgroundColor; _collectionView.delaysContentTouches = true; @@ -101,8 +102,9 @@ [super viewDidLoad]; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait; if (self.view.frame.size.width > self.view.frame.size.height) @@ -267,12 +269,16 @@ if (!self.isViewLoaded) { return; } - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIEdgeInsets contentInset = [self controllerInsetForInterfaceOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } CGPoint contentOffset = CGPointMake(0, _collectionView.contentSize.height - _collectionView.frame.size.height + contentInset.bottom); if (contentOffset.y < -contentInset.top) @@ -308,8 +314,9 @@ orientation = UIInterfaceOrientationLandscapeLeft; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } UIEdgeInsets safeAreaInset = [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; @@ -326,7 +333,10 @@ } else if (lastOffset < -_collectionView.contentInset.top + 2) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIEdgeInsets contentInset = [self controllerInsetForInterfaceOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop CGPoint contentOffset = CGPointMake(0, -contentInset.top); [_collectionView setContentOffset:contentOffset animated:false]; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m index 079ea3250d..d0b13eb90d 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m @@ -1701,7 +1701,7 @@ } - (CGRect)doneButtonFrame { - if (UIDeviceOrientationIsPortrait([self interfaceOrientation])) { + if (UIDeviceOrientationIsPortrait((UIDeviceOrientation)[self interfaceOrientation])) { return [_portraitToolbarView.doneButton convertRect:_portraitToolbarView.doneButton.bounds toView:nil]; } else { return [_landscapeToolbarView.doneButton convertRect:_landscapeToolbarView.doneButton.bounds toView:nil]; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m index 8da4a30f77..745859dc26 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryModel.m @@ -278,8 +278,9 @@ }]; }; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _interfaceView.accessibilityIgnoresInvertColors = true; + } } return _interfaceView; } @@ -564,8 +565,9 @@ [_context setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; } - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { [strongSelf.controller setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + } }; controller.requestThumbnailImage = ^SSignal *(id editableItem) diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGallerySelectedItemsModel.m b/submodules/LegacyComponents/Sources/TGMediaPickerGallerySelectedItemsModel.m index da3b641321..ffa3a3abd9 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGallerySelectedItemsModel.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGallerySelectedItemsModel.m @@ -97,8 +97,6 @@ - (void)clear { - NSInteger index = 0; - [_items enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id item, NSUInteger index, __unused BOOL *stop) { if (self.selectionUpdated != nil) diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m index dfdea64019..24c07a0634 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryVideoItemView.m @@ -794,17 +794,12 @@ CGSize rotatedCropSize = cropRect.size; if (orientation == UIImageOrientationLeft || orientation == UIImageOrientationRight) rotatedCropSize = CGSizeMake(rotatedCropSize.height, rotatedCropSize.width); - - CGSize containerSize = _imageView.frame.size; - CGSize fittedSize = TGScaleToSize(rotatedCropSize, containerSize); - CGRect previewFrame = CGRectMake((containerSize.width - fittedSize.width) / 2, (containerSize.height - fittedSize.height) / 2, fittedSize.width, fittedSize.height); CGAffineTransform rotationTransform = CGAffineTransformMakeRotation(TGRotationForOrientation(orientation)); _contentView.transform = rotationTransform; _contentView.frame = _imageView.frame; CGSize fittedContentSize = [TGPhotoPaintController fittedContentSize:cropRect orientation:orientation originalSize:originalSize]; - CGRect fittedCropRect = [TGPhotoPaintController fittedCropRect:cropRect originalSize:originalSize keepOriginalSize:false]; _contentWrapperView.frame = CGRectMake(0.0f, 0.0f, fittedContentSize.width, fittedContentSize.height); CGFloat contentScale = ratio; @@ -817,13 +812,7 @@ CGSize fittedOriginalSize = TGScaleToSize(originalSize, [TGPhotoPaintController maximumPaintingSize]); CGSize rotatedSize = TGRotatedContentSize(fittedOriginalSize, 0.0); - CGPoint centerPoint = CGPointMake(rotatedSize.width / 2.0f, rotatedSize.height / 2.0f); - - CGFloat scale = fittedOriginalSize.width / originalSize.width; - CGPoint offset = TGPaintSubtractPoints(centerPoint, [TGPhotoPaintController fittedCropRect:cropRect centerScale:scale]); - - CGPoint boundsCenter = TGPaintCenterOfRect(_contentWrapperView.bounds); -// _entitiesContainerView.center = TGPaintAddPoints(boundsCenter, CGPointMake(offset.x / contentScale, offset.y / contentScale)); + __unused CGPoint centerPoint = CGPointMake(rotatedSize.width / 2.0f, rotatedSize.height / 2.0f); } - (TGPhotoEntitiesContainerView *)entitiesView { @@ -1423,7 +1412,7 @@ TGVideoEditAdjustments *adjustments = (TGVideoEditAdjustments *)[self.item.editingContext adjustmentsForItem:self.item.editableMediaItem]; if ([self itemIsLivePhoto]) { if (adjustments.sendAsGif) { - return [[TGCameraCapturedVideo alloc] initWithAsset:self.item.editableMediaItem livePhoto:true]; + return [[TGCameraCapturedVideo alloc] initWithAsset:(TGMediaAsset *)self.item.editableMediaItem livePhoto:true]; } else { return self.item.editableMediaItem; } @@ -1595,8 +1584,7 @@ { if (timestamps.count == 0) return; - - SSignal *avAsset = self.item.avAsset ?: [SSignal single:_player.currentItem.asset]; + TGMediaEditingContext *editingContext = self.item.editingContext; id editableItem = self.editableMediaItem; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerModernGalleryMixin.m b/submodules/LegacyComponents/Sources/TGMediaPickerModernGalleryMixin.m index 702201f77c..ed80d1c179 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerModernGalleryMixin.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerModernGalleryMixin.m @@ -370,7 +370,7 @@ { case TGMediaAssetVideoType: { - galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:asset]; + galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:(id)asset]; } break; @@ -386,7 +386,7 @@ // if (asset.subtypes & TGMediaAssetSubtypePhotoLive) // galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:asset]; // else - galleryItem = [[TGMediaPickerGalleryPhotoItem alloc] initWithAsset:asset]; + galleryItem = [[TGMediaPickerGalleryPhotoItem alloc] initWithAsset:(id)asset]; } break; } diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerPhotoCounterButton.m b/submodules/LegacyComponents/Sources/TGMediaPickerPhotoCounterButton.m index 8a94b4c4e2..68bce634d9 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerPhotoCounterButton.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerPhotoCounterButton.m @@ -83,8 +83,12 @@ const CGFloat TGPhotoCounterButtonMaskFade = 18; CGFloat maskWidth = 50.0f; if (iosMajorVersion() >= 7) maskWidth += CGCeil([TGLocalized(@"MediaPicker.Processing") sizeWithAttributes:@{ NSFontAttributeName:TGSystemFontOfSize(16) }].width); - else + else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" maskWidth += CGCeil([TGLocalized(@"MediaPicker.Processing") sizeWithFont:TGSystemFontOfSize(16)].width); +#pragma clang diagnostic pop + } _processingMaskView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, maskWidth, 38)]; [_wrapperView addSubview:_processingMaskView]; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerPhotoStripView.m b/submodules/LegacyComponents/Sources/TGMediaPickerPhotoStripView.m index 610595961d..a87b7b010f 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerPhotoStripView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerPhotoStripView.m @@ -82,8 +82,9 @@ _collectionViewLayout.minimumLineSpacing = 4.0f; _collectionView = [[TGDraggableCollectionView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) collectionViewLayout:_collectionViewLayout]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _collectionView.alwaysBounceHorizontal = false; _collectionView.alwaysBounceVertical = false; _collectionView.backgroundColor = [UIColor clearColor]; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerToolbarView.m b/submodules/LegacyComponents/Sources/TGMediaPickerToolbarView.m index 2a855cccd6..b1e1ed3127 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerToolbarView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerToolbarView.m @@ -267,6 +267,8 @@ const CGFloat TGMediaPickerToolbarHeight = 44.0f; - (void)setCenterButtonImage:(UIImage *)centerButtonImage { + _centerButtonImage = centerButtonImage; + if (_centerButton == nil) { _centerButton = [[TGModernButton alloc] initWithFrame:CGRectMake(round((self.frame.size.width - 60.0f) / 2.0f), 0, 60, 44)]; @@ -281,6 +283,8 @@ const CGFloat TGMediaPickerToolbarHeight = 44.0f; - (void)setCenterButtonSelectedImage:(UIImage *)centerButtonSelectedImage { + _centerButtonSelectedImage = centerButtonSelectedImage; + [_centerButton setImage:centerButtonSelectedImage forState:UIControlStateSelected]; [_centerButton setImage:centerButtonSelectedImage forState:UIControlStateSelected | UIControlStateHighlighted]; } diff --git a/submodules/LegacyComponents/Sources/TGMediaSelectionContext.m b/submodules/LegacyComponents/Sources/TGMediaSelectionContext.m index bc24af169c..9881c0d674 100644 --- a/submodules/LegacyComponents/Sources/TGMediaSelectionContext.m +++ b/submodules/LegacyComponents/Sources/TGMediaSelectionContext.m @@ -276,7 +276,7 @@ + (instancetype)changeWithItem:(id)item selected:(bool)selected animated:(bool)animated sender:(id)sender { TGMediaSelectionChange *change = [[TGMediaSelectionChange alloc] init]; - change->_item = item; + change->_item = (NSObject *)item; change->_selected = selected; change->_animated = animated; change->_sender = sender; diff --git a/submodules/LegacyComponents/Sources/TGMentionPanelCell.m b/submodules/LegacyComponents/Sources/TGMentionPanelCell.m index c316003e8a..2d75e3c26f 100644 --- a/submodules/LegacyComponents/Sources/TGMentionPanelCell.m +++ b/submodules/LegacyComponents/Sources/TGMentionPanelCell.m @@ -154,12 +154,18 @@ NSString *const TGMentionPanelCellKind = @"TGMentionPanelCell"; CGFloat leftInset = 51.0f; CGFloat spacing = 6.0f; CGFloat rightInset = 6.0f; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize nameSize = [_nameLabel.text sizeWithFont:_nameLabel.font]; +#pragma clang diagnostic pop nameSize.width = CGCeil(MIN((boundsSize.width - leftInset - rightInset) * 3.0f / 4.0f, nameSize.width)); nameSize.height = CGCeil(nameSize.height); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize usernameSize = [_usernameLabel.text sizeWithFont:_usernameLabel.font]; +#pragma clang diagnostic pop usernameSize.width = CGCeil(MIN(boundsSize.width - leftInset - rightInset - nameSize.width - spacing, usernameSize.width)); _nameLabel.frame = CGRectMake(leftInset, CGFloor((boundsSize.height - nameSize.height) / 2.0f), nameSize.width, nameSize.height); diff --git a/submodules/LegacyComponents/Sources/TGMenuSheetButtonItemView.m b/submodules/LegacyComponents/Sources/TGMenuSheetButtonItemView.m index db4462f238..8b5d049437 100644 --- a/submodules/LegacyComponents/Sources/TGMenuSheetButtonItemView.m +++ b/submodules/LegacyComponents/Sources/TGMenuSheetButtonItemView.m @@ -95,8 +95,9 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f; _button.highlightBackgroundColor = nil; [self _updateForType:_buttonType]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } } - (void)setPallete:(TGMenuSheetPallete *)pallete @@ -176,6 +177,8 @@ const CGFloat TGMenuSheetButtonItemViewHeight = 57.0f; - (void)setThickDivider:(bool)thickDivider { + _thickDivider = thickDivider; + if (thickDivider && _customDivider == nil) { _customDivider = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, self.bounds.size.width, TGScreenPixel)]; diff --git a/submodules/LegacyComponents/Sources/TGMenuSheetController.m b/submodules/LegacyComponents/Sources/TGMenuSheetController.m index 8e10f799dc..465792e80c 100644 --- a/submodules/LegacyComponents/Sources/TGMenuSheetController.m +++ b/submodules/LegacyComponents/Sources/TGMenuSheetController.m @@ -45,7 +45,7 @@ typedef enum @end -@interface TGMenuSheetController () +@interface TGMenuSheetController () { bool _dark; @@ -75,8 +75,11 @@ typedef enum bool _checked3dTouch; NSDictionary *_3dTouchHandlers; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIPopoverController *_popoverController; +#pragma clang diagnostic pop id _context; } @@ -99,8 +102,11 @@ typedef enum self.pallete = [[LegacyComponentsGlobals provider] darkMenuSheetPallete]; else if (!dark && [[LegacyComponentsGlobals provider] respondsToSelector:@selector(menuSheetPallete)]) self.pallete = [[LegacyComponentsGlobals provider] menuSheetPallete]; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" self.wantsFullScreenLayout = true; +#pragma clang diagnostic pop } return self; } @@ -373,6 +379,8 @@ typedef enum *rect = self.sourceRect(); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" - (void)popoverControllerDidDismissPopover:(UIPopoverController *)__unused popoverController { _popoverController = nil; @@ -383,6 +391,7 @@ typedef enum if (self.sourceRect != nil) *rect = self.sourceRect(); } +#pragma clang diagnostic pop #pragma mark - @@ -417,7 +426,10 @@ typedef enum } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" _popoverController = [[UIPopoverController alloc] initWithContentViewController:self]; +#pragma clang diagnostic pop UIColor *backgroundColor = self.pallete != nil ? self.pallete.backgroundColor : [UIColor whiteColor]; if ([_popoverController respondsToSelector:@selector(setBackgroundColor:)]) @@ -574,6 +586,8 @@ typedef enum if (animated) { self.view.userInteractionEnabled = false; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self animateSheetViewToPosition:_sheetView.menuHeight + [self safeAreaInsetForOrientation:self.interfaceOrientation].bottom velocity:0 type:TGMenuSheetAnimationDismiss completion:^ { [self.view removeFromSuperview]; @@ -586,6 +600,7 @@ typedef enum if (completion != nil) completion(); }]; +#pragma clang diagnostic pop } else { @@ -807,10 +822,13 @@ typedef enum if (velocity > 200.0f && allowDismissal) { [self setDimViewHidden:true animated:true]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self animateSheetViewToPosition:_sheetView.menuHeight + [self safeAreaInsetForOrientation:self.interfaceOrientation].bottom velocity:velocity type:TGMenuSheetAnimationDismiss completion:^ { [self dismissAnimated:false]; }]; +#pragma clang diagnostic pop } else { @@ -924,7 +942,10 @@ typedef enum _containerView.frame = CGRectMake(_containerView.frame.origin.x, _containerView.frame.origin.y, viewWidth, self.view.frame.size.height); _dimView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" _sheetView.safeAreaInset = [self safeAreaInsetForOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop CGFloat minSide = MIN(referenceSize.width, referenceSize.height); _sheetView.narrowInLandscape = self.narrowInLandscape; @@ -943,8 +964,9 @@ typedef enum - (UIEdgeInsets)safeAreaInsetForOrientation:(UIInterfaceOrientation)orientation { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } UIEdgeInsets safeAreaInset = [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; if (safeAreaInset.bottom > FLT_EPSILON) @@ -955,14 +977,19 @@ typedef enum - (UIEdgeInsets)safeAreaInset { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self safeAreaInsetForOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop } - (void)repositionMenuWithReferenceSize:(CGSize)referenceSize { if ([self sizeClass] == UIUserInterfaceSizeClassRegular && !_forceFullScreen) return; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIEdgeInsets safeAreaInset = [self safeAreaInsetForOrientation:self.interfaceOrientation]; if (_keyboardOffset > FLT_EPSILON) safeAreaInset.bottom = 0.0f; @@ -970,6 +997,7 @@ typedef enum CGFloat defaultStatusBarHeight = TGMenuSheetDefaultStatusBarHeight; if (!TGIsPad() && iosMajorVersion() >= 11 && UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) defaultStatusBarHeight = 0.0; +#pragma clang diagnostic pop CGFloat statusBarHeight = !UIEdgeInsetsEqualToEdgeInsets(safeAreaInset, UIEdgeInsetsZero) ? safeAreaInset.top : defaultStatusBarHeight; referenceSize.height = referenceSize.height + statusBarHeight - [self statusBarHeight]; @@ -995,7 +1023,9 @@ typedef enum CGSize statusBarSize = [_context statusBarFrame].size; CGFloat statusBarHeight = MIN(statusBarSize.width, statusBarSize.height); statusBarHeight = MAX(TGMenuSheetDefaultStatusBarHeight, statusBarHeight); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (!TGIsPad() && iosMajorVersion() >= 11 && UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { return 0.0f; @@ -1006,6 +1036,7 @@ typedef enum if (!UIEdgeInsetsEqualToEdgeInsets(safeAreaInset, UIEdgeInsetsZero)) statusBarHeight = 44.0f; } +#pragma clang diagnostic pop return statusBarHeight; } diff --git a/submodules/LegacyComponents/Sources/TGMenuSheetDimView.m b/submodules/LegacyComponents/Sources/TGMenuSheetDimView.m index b1b844ac19..0f8cbb75c1 100644 --- a/submodules/LegacyComponents/Sources/TGMenuSheetDimView.m +++ b/submodules/LegacyComponents/Sources/TGMenuSheetDimView.m @@ -111,8 +111,9 @@ setupView(_topView); } - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } } return self; } diff --git a/submodules/LegacyComponents/Sources/TGMenuSheetTitleItemView.m b/submodules/LegacyComponents/Sources/TGMenuSheetTitleItemView.m index 8f7208edc5..6eea101534 100644 --- a/submodules/LegacyComponents/Sources/TGMenuSheetTitleItemView.m +++ b/submodules/LegacyComponents/Sources/TGMenuSheetTitleItemView.m @@ -57,8 +57,9 @@ _subtitleLabel.backgroundColor = [UIColor clearColor]; _subtitleLabel.textColor = UIColorRGB(0x777777); - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } } - (void)setPallete:(TGMenuSheetPallete *)pallete diff --git a/submodules/LegacyComponents/Sources/TGMenuSheetView.m b/submodules/LegacyComponents/Sources/TGMenuSheetView.m index 7691d17acd..f54332f2ba 100644 --- a/submodules/LegacyComponents/Sources/TGMenuSheetView.m +++ b/submodules/LegacyComponents/Sources/TGMenuSheetView.m @@ -63,8 +63,9 @@ const CGFloat TGMenuSheetInterSectionSpacing = 8.0f; _effectView.frame = self.bounds; [self addSubview:_effectView]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _effectView.accessibilityIgnoresInvertColors = true; + } } else { @@ -211,8 +212,9 @@ const CGFloat TGMenuSheetInterSectionSpacing = 8.0f; _mainBackgroundView.backgroundColor = _pallete.backgroundColor; _scrollView = [[TGMenuSheetScrollView alloc] initWithFrame:CGRectZero]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _scrollView.delegate = self; [_mainBackgroundView addSubview:_scrollView]; } diff --git a/submodules/LegacyComponents/Sources/TGMenuView.m b/submodules/LegacyComponents/Sources/TGMenuView.m index 04be557c73..6797ac4953 100644 --- a/submodules/LegacyComponents/Sources/TGMenuView.m +++ b/submodules/LegacyComponents/Sources/TGMenuView.m @@ -169,12 +169,18 @@ static UIImage *pagerLeftButtonHighlightedImage() { { if (self.isMultiline) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize size = [title sizeWithFont:self.titleLabel.font constrainedToSize:CGSizeMake(self.maxWidth - 18.0f, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping]; +#pragma clang diagnostic pop self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, ceil(size.width) + 18, MAX(41.0f, ceil(size.height) + 20.0f)); } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, [title sizeWithFont:self.titleLabel.font].width + 34, 41); +#pragma clang diagnostic pop } } else diff --git a/submodules/LegacyComponents/Sources/TGMessage.mm b/submodules/LegacyComponents/Sources/TGMessage.mm index d480477a9f..0a48ed23d4 100644 --- a/submodules/LegacyComponents/Sources/TGMessage.mm +++ b/submodules/LegacyComponents/Sources/TGMessage.mm @@ -409,7 +409,10 @@ typedef enum { NSString *link = [text substringWithRange:entity.range]; NSURL *url = [NSURL URLWithString:link]; if (url == nil) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" url = [NSURL URLWithString:[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; +#pragma clang diagnostic pop } [textCheckingResults addObject:[NSTextCheckingResult linkCheckingResultWithRange:entity.range URL:url]]; } else if ([entity isKindOfClass:[TGMessageEntityCashtag class]]) { @@ -876,7 +879,10 @@ typedef enum { NSString *link = [_text substringWithRange:entity.range]; NSURL *url = [NSURL URLWithString:link]; if (url == nil) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" url = [NSURL URLWithString:[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; +#pragma clang diagnostic pop } [textCheckingResults addObject:[NSTextCheckingResult linkCheckingResultWithRange:entity.range URL:url]]; } else if ([entity isKindOfClass:[TGMessageEntityCashtag class]]) { @@ -1359,7 +1365,7 @@ typedef enum { - (NSUInteger)hash { if (_cachedHash == 0) - _cachedHash = (int)(((_itemId >> 32) ^ _itemId & 0xffffffff) + (int)_type); + _cachedHash = (int)((((_itemId >> 32) ^ _itemId) & 0xffffffff) + (int)_type); return _cachedHash; } diff --git a/submodules/LegacyComponents/Sources/TGMessageImageViewOverlayView.m b/submodules/LegacyComponents/Sources/TGMessageImageViewOverlayView.m index 7d02043b76..6343d6fc6e 100644 --- a/submodules/LegacyComponents/Sources/TGMessageImageViewOverlayView.m +++ b/submodules/LegacyComponents/Sources/TGMessageImageViewOverlayView.m @@ -490,18 +490,10 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; if (_overlayStyle == TGMessageImageViewOverlayStyleDefault) CGContextSetStrokeColorWithColor(context, TGColorWithHexAndAlpha(0xff000000, 0.55f).CGColor); else if (_overlayStyle == TGMessageImageViewOverlayStyleIncoming) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x4f9ef3).CGColor); - } + CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); } else if (_overlayStyle == TGMessageImageViewOverlayStyleOutgoing) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x64b15e).CGColor); - } + CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); } else CGContextSetStrokeColorWithColor(context, TGAccentColor().CGColor); @@ -566,20 +558,12 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; } else if (_overlayStyle == TGMessageImageViewOverlayStyleIncoming) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetFillColorWithColor(context, incomingButtonColor.CGColor); - } else { - CGContextSetFillColorWithColor(context, TGColorWithHexAndAlpha(0x85baf2, 0.15f).CGColor); - } + CGContextSetFillColorWithColor(context, incomingButtonColor.CGColor); CGContextFillEllipseInRect(context, CGRectMake(0.0f, 0.0f, diameter, diameter)); } else if (_overlayStyle == TGMessageImageViewOverlayStyleOutgoing) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetFillColorWithColor(context, outgoingButtonColor.CGColor); - } else { - CGContextSetFillColorWithColor(context, TGColorWithHexAndAlpha(0x4fb212, 0.15f).CGColor); - } + CGContextSetFillColorWithColor(context, outgoingButtonColor.CGColor); CGContextFillEllipseInRect(context, CGRectMake(0.0f, 0.0f, diameter, diameter)); } else if (_overlayStyle == TGMessageImageViewOverlayStyleAccent) @@ -602,18 +586,10 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; if (_overlayStyle == TGMessageImageViewOverlayStyleDefault) CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); else if (_overlayStyle == TGMessageImageViewOverlayStyleIncoming) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x4f9ef3).CGColor); - } + CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); } else if (_overlayStyle == TGMessageImageViewOverlayStyleOutgoing) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x64b15e).CGColor); - } + CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); } else CGContextSetStrokeColorWithColor(context, TGAccentColor().CGColor); @@ -644,18 +620,10 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; if (_overlayStyle == TGMessageImageViewOverlayStyleDefault) CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); else if (_overlayStyle == TGMessageImageViewOverlayStyleIncoming) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x4f9ef3).CGColor); - } + CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); } else if (_overlayStyle == TGMessageImageViewOverlayStyleOutgoing) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x64b15e).CGColor); - } + CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); } else CGContextSetStrokeColorWithColor(context, TGAccentColor().CGColor); @@ -697,8 +665,6 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; case TGMessageImageViewOverlayViewTypePlay: { const CGFloat diameter = self.radius; - CGFloat width = round(diameter * 0.4); - CGFloat height = round(width * 1.2f); CGFloat offset = round(diameter * 0.06f); CGFloat verticalOffset = 0.0f; CGFloat alpha = 0.8f; @@ -925,18 +891,10 @@ const NSInteger TGMessageImageViewOverlayParticlesCount = 40; if (_overlayStyle == TGMessageImageViewOverlayStyleDefault) CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor); else if (_overlayStyle == TGMessageImageViewOverlayStyleIncoming) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x4f9ef3).CGColor); - } + CGContextSetStrokeColorWithColor(context, incomingIconColor.CGColor); } else if (_overlayStyle == TGMessageImageViewOverlayStyleOutgoing) { - if (true || ABS(diameter - 37.0f) < 0.1) { - CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); - } else { - CGContextSetStrokeColorWithColor(context, TGColorWithHex(0x64b15e).CGColor); - } + CGContextSetStrokeColorWithColor(context, outgoingIconColor.CGColor); } else CGContextSetStrokeColorWithColor(context, TGAccentColor().CGColor); diff --git a/submodules/LegacyComponents/Sources/TGModernConversationHashtagsAssociatedPanel.m b/submodules/LegacyComponents/Sources/TGModernConversationHashtagsAssociatedPanel.m index e180a926fb..969b62ee10 100644 --- a/submodules/LegacyComponents/Sources/TGModernConversationHashtagsAssociatedPanel.m +++ b/submodules/LegacyComponents/Sources/TGModernConversationHashtagsAssociatedPanel.m @@ -75,8 +75,9 @@ [self addSubview:_bottomView]; _tableView = [[UITableView alloc] init]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _tableView.delegate = self; _tableView.dataSource = self; _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; diff --git a/submodules/LegacyComponents/Sources/TGModernConversationMentionsAssociatedPanel.m b/submodules/LegacyComponents/Sources/TGModernConversationMentionsAssociatedPanel.m index 7524af1b24..1deb889455 100644 --- a/submodules/LegacyComponents/Sources/TGModernConversationMentionsAssociatedPanel.m +++ b/submodules/LegacyComponents/Sources/TGModernConversationMentionsAssociatedPanel.m @@ -87,8 +87,9 @@ [self addSubview:_tableViewBackground]; _tableView = [[UITableView alloc] init]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } _tableView.delegate = self; _tableView.dataSource = self; _tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; diff --git a/submodules/LegacyComponents/Sources/TGModernGalleryController.m b/submodules/LegacyComponents/Sources/TGModernGalleryController.m index c9bb0800e3..d2bd0a5a07 100644 --- a/submodules/LegacyComponents/Sources/TGModernGalleryController.m +++ b/submodules/LegacyComponents/Sources/TGModernGalleryController.m @@ -307,8 +307,9 @@ { [_view showHideInterface]; - if ([self respondsToSelector:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden)]) + if (@available(iOS 11.0, *)) { [self setNeedsUpdateOfHomeIndicatorAutoHidden]; + } } - (void)itemViewDidRequestGalleryDismissal:(TGModernGalleryItemView *)__unused itemView animated:(bool)animated diff --git a/submodules/LegacyComponents/Sources/TGModernGalleryDefaultInterfaceView.m b/submodules/LegacyComponents/Sources/TGModernGalleryDefaultInterfaceView.m index 24f07ca128..7f1720a598 100644 --- a/submodules/LegacyComponents/Sources/TGModernGalleryDefaultInterfaceView.m +++ b/submodules/LegacyComponents/Sources/TGModernGalleryDefaultInterfaceView.m @@ -79,8 +79,9 @@ _closeButton.frame = [self closeButtonFrameForSize:frame.size]; [_navigationBarView addSubview:_closeButton]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } } return self; } diff --git a/submodules/LegacyComponents/Sources/TGModernGalleryVideoView.m b/submodules/LegacyComponents/Sources/TGModernGalleryVideoView.m index f7ae948ab0..8915c81ec1 100644 --- a/submodules/LegacyComponents/Sources/TGModernGalleryVideoView.m +++ b/submodules/LegacyComponents/Sources/TGModernGalleryVideoView.m @@ -53,8 +53,9 @@ _key = key; self.playerLayer.player = player; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } } return self; } diff --git a/submodules/LegacyComponents/Sources/TGModernGalleryView.m b/submodules/LegacyComponents/Sources/TGModernGalleryView.m index b9ccd8f6f8..4c6d3e8dad 100644 --- a/submodules/LegacyComponents/Sources/TGModernGalleryView.m +++ b/submodules/LegacyComponents/Sources/TGModernGalleryView.m @@ -50,8 +50,9 @@ static const CGFloat swipeDistanceThreshold = 128.0f; _context = context; _itemPadding = itemPadding; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.accessibilityIgnoresInvertColors = true; + } self.opaque = false; self.backgroundColor = UIColorRGBA(0x000000, 1.0f); @@ -62,8 +63,9 @@ static const CGFloat swipeDistanceThreshold = 128.0f; [self addSubview:_scrollViewContainer]; _scrollView = [[TGModernGalleryScrollView alloc] initWithFrame:CGRectMake(-_itemPadding, 0.0f, frame.size.width + itemPadding * 2.0f, frame.size.height)]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } [_scrollViewContainer addSubview:_scrollView]; _interfaceView = interfaceView; diff --git a/submodules/LegacyComponents/Sources/TGModernMediaListItemView.m b/submodules/LegacyComponents/Sources/TGModernMediaListItemView.m index 0e124599e2..a3a7c27945 100644 --- a/submodules/LegacyComponents/Sources/TGModernMediaListItemView.m +++ b/submodules/LegacyComponents/Sources/TGModernMediaListItemView.m @@ -7,6 +7,8 @@ - (void)prepareForReuse { [self _recycleItemContentView]; + + [super prepareForReuse]; } - (void)_recycleItemContentView diff --git a/submodules/LegacyComponents/Sources/TGNavigationBar.m b/submodules/LegacyComponents/Sources/TGNavigationBar.m index 57a2ba7d6c..fb338ba368 100644 --- a/submodules/LegacyComponents/Sources/TGNavigationBar.m +++ b/submodules/LegacyComponents/Sources/TGNavigationBar.m @@ -133,10 +133,11 @@ static id _musicPlayerProvider; self.tintColor = pallete.tintColor; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" attributes[UITextAttributeTextColor] = pallete.titleColor; attributes[UITextAttributeTextShadowColor] = [UIColor clearColor]; - if (iosMajorVersion() < 7) - attributes[UITextAttributeFont] = TGBoldSystemFontOfSize(17.0f); +#pragma clang diagnostic pop [self setTitleTextAttributes:attributes]; } @@ -228,8 +229,10 @@ static id _musicPlayerProvider; if (_backgroundContainerView != nil) { CGFloat backgroundOverflow = iosMajorVersion() >= 7 ? 20.0f : 0.0f; - if (iosMajorVersion() >= 11 && self.superview.safeAreaInsets.top > FLT_EPSILON) - backgroundOverflow = self.superview.safeAreaInsets.top; + if (@available(iOS 11.0, *)) { + if (self.superview.safeAreaInsets.top > FLT_EPSILON) + backgroundOverflow = self.superview.safeAreaInsets.top; + } CGFloat heightAddition = 0.0; if (iosMajorVersion() < 11) { diff --git a/submodules/LegacyComponents/Sources/TGNavigationController.m b/submodules/LegacyComponents/Sources/TGNavigationController.m index d3bb25fb1b..ff761925af 100644 --- a/submodules/LegacyComponents/Sources/TGNavigationController.m +++ b/submodules/LegacyComponents/Sources/TGNavigationController.m @@ -130,7 +130,7 @@ { [super loadView]; - if (iosMajorVersion() >= 11) { + if (@available(iOS 11.0, *)) { self.navigationBar.prefersLargeTitles = false; } @@ -493,7 +493,7 @@ { UIBarStyle barStyle = UIBarStyleDefault; bool navigationBarShouldBeHidden = false; - UIStatusBarStyle statusBarStyle = UIStatusBarStyleBlackOpaque; + UIStatusBarStyle statusBarStyle = UIStatusBarStyleLightContent; bool statusBarShouldBeHidden = false; if ([viewController conformsToProtocol:@protocol(TGViewControllerNavigationBarAppearance)]) @@ -830,7 +830,7 @@ TGNavigationController *findNavigationController() return self.topViewController.preferredStatusBarStyle; } -- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)())completion { +- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { if (_customDismissSelf) { _customDismissSelf(); if (completion) { diff --git a/submodules/LegacyComponents/Sources/TGPassportICloud.m b/submodules/LegacyComponents/Sources/TGPassportICloud.m index 08228489a2..cb46ac0813 100644 --- a/submodules/LegacyComponents/Sources/TGPassportICloud.m +++ b/submodules/LegacyComponents/Sources/TGPassportICloud.m @@ -21,7 +21,10 @@ return nil; NSError *error; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *urlData = [[url bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile includingResourceValuesForKeys:nil relativeToURL:nil error:&error] base64Encoding]; +#pragma clang diagnostic pop if (error != nil || urlData == nil) return nil; @@ -118,7 +121,10 @@ { return [[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSData *urlData = [[NSData alloc] initWithBase64Encoding:description.urlData]; +#pragma clang diagnostic pop if (urlData == nil) { [subscriber putCompletion]; diff --git a/submodules/LegacyComponents/Sources/TGPassportOCR.mm b/submodules/LegacyComponents/Sources/TGPassportOCR.mm index 17e14f9a8f..37d3b733fa 100644 --- a/submodules/LegacyComponents/Sources/TGPassportOCR.mm +++ b/submodules/LegacyComponents/Sources/TGPassportOCR.mm @@ -40,33 +40,37 @@ + (SSignal *)recognizeBarcodeInImage:(UIImage *)image { - return [[[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { - VNDetectBarcodesRequest *barcodeRequest = [[VNDetectBarcodesRequest alloc] initWithCompletionHandler:^(VNRequest * _Nonnull request, NSError * _Nullable error) - { - TGPassportMRZ *mrz = nil; - NSArray *results = request.results; - for (VNBarcodeObservation *barcode in results) + if (@available(iOS 11.0, *)) { + return [[[SSignal alloc] initWithGenerator:^id(SSubscriber *subscriber) { + VNDetectBarcodesRequest *barcodeRequest = [[VNDetectBarcodesRequest alloc] initWithCompletionHandler:^(VNRequest * _Nonnull request, NSError * _Nullable error) { - if (![barcode isKindOfClass:[VNBarcodeObservation class]]) - continue; - - if (barcode.symbology != VNBarcodeSymbologyPDF417) - continue; - - NSString *payload = barcode.payloadStringValue; - mrz = [TGPassportMRZ parseBarcodePayload:payload]; - } - - [subscriber putNext:mrz]; - [subscriber putCompletion]; - }]; - - NSError *error; - VNImageRequestHandler *handler = [[VNImageRequestHandler alloc] initWithCGImage:image.CGImage options:@{}]; - [handler performRequests:@[barcodeRequest] error:&error]; - - return nil; - }] startOn:[SQueue concurrentDefaultQueue]]; + TGPassportMRZ *mrz = nil; + NSArray *results = request.results; + for (VNBarcodeObservation *barcode in results) + { + if (![barcode isKindOfClass:[VNBarcodeObservation class]]) + continue; + + if (barcode.symbology != VNBarcodeSymbologyPDF417) + continue; + + NSString *payload = barcode.payloadStringValue; + mrz = [TGPassportMRZ parseBarcodePayload:payload]; + } + + [subscriber putNext:mrz]; + [subscriber putCompletion]; + }]; + + NSError *error; + VNImageRequestHandler *handler = [[VNImageRequestHandler alloc] initWithCGImage:image.CGImage options:@{}]; + [handler performRequests:@[barcodeRequest] error:&error]; + + return nil; + }] startOn:[SQueue concurrentDefaultQueue]]; + } else { + return [SSignal complete]; + } } @end diff --git a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m index aa54d305f6..7b2ef48fdf 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoAvatarPreviewController.m @@ -715,7 +715,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel - (void)updateToolViews { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIInterfaceOrientation orientation = self.interfaceOrientation; +#pragma clang diagnostic pop if ([self inFormSheet] || TGIsPad()) { _landscapeToolsWrapperView.hidden = true; diff --git a/submodules/LegacyComponents/Sources/TGPhotoCropController.m b/submodules/LegacyComponents/Sources/TGPhotoCropController.m index e64c049c3d..5fd4e04506 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoCropController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoCropController.m @@ -345,8 +345,9 @@ NSString * const TGPhotoCropOriginalAspectRatio = @"original"; { CGSize referenceSize = [self referenceViewSize]; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } CGRect containerFrame = [TGPhotoCropController photoContainerFrameForParentViewFrame:CGRectMake(0, 0, referenceSize.width, referenceSize.height) toolbarLandscapeSize:self.toolbarLandscapeSize orientation:self.effectiveOrientation hasArbitraryRotation:_cropView.hasArbitraryRotation hasOnScreenNavigation:hasOnScreenNavigation]; containerFrame = CGRectInset(containerFrame, TGPhotoCropAreaInsetSize.width, TGPhotoCropAreaInsetSize.height); @@ -761,8 +762,9 @@ NSString * const TGPhotoCropOriginalAspectRatio = @"original"; _wrapperView.frame = CGRectMake((referenceSize.width - screenSide) / 2, (referenceSize.height - screenSide) / 2, screenSide, screenSide); bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } UIEdgeInsets safeAreaInset = [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; UIEdgeInsets screenEdges = UIEdgeInsetsMake((screenSide - referenceSize.height) / 2 , (screenSide - referenceSize.width) / 2, (screenSide + referenceSize.height) / 2, (screenSide + referenceSize.width) / 2); diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorBlurAreaView.m b/submodules/LegacyComponents/Sources/TGPhotoEditorBlurAreaView.m index 6ba6fa788c..77e0efbfd5 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorBlurAreaView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorBlurAreaView.m @@ -169,4 +169,6 @@ } } +@synthesize interactionBegan; + @end diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 166715d56b..cda57e13a9 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -208,8 +208,9 @@ self.view.frame = (CGRect){ CGPointZero, [self referenceViewSize]}; self.view.clipsToBounds = true; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { self.view.accessibilityIgnoresInvertColors = true; + } if ([self presentedForAvatarCreation] && ![self presentedFromCamera]) self.view.backgroundColor = [UIColor blackColor]; @@ -888,9 +889,11 @@ self.navigationController.interactivePopGestureRecognizer.enabled = true; } - - if ([self respondsToSelector:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]) - [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + + if (@available(iOS 11.0, *)) { + if ([self respondsToSelector:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]) + [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + } [super viewWillDisappear:animated]; } @@ -1274,6 +1277,8 @@ if ([self presentedFromCamera] && [self presentedForAvatarCreation]) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { transitionReferenceFrame = CGRectMake(self.view.frame.size.width - transitionReferenceFrame.size.height - transitionReferenceFrame.origin.y, @@ -1286,6 +1291,7 @@ self.view.frame.size.height - transitionReferenceFrame.size.width - transitionReferenceFrame.origin.x, transitionReferenceFrame.size.height, transitionReferenceFrame.size.width); } +#pragma clang diagnostic pop } if ([self presentedForAvatarCreation] && ![self presentedFromCamera]) @@ -1719,9 +1725,11 @@ [_landscapeToolbarView setDoneButtonType:doneButtonType]; [self updateEditorButtons]; - - if ([self respondsToSelector:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]) - [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + + if (@available(iOS 11.0, *)) { + if ([self respondsToSelector:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures)]) + [self setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + } } - (void)updatePreviewView:(bool)full @@ -2352,13 +2360,17 @@ - (bool)hasOnScreenNavigation { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } return hasOnScreenNavigation; } - (UIInterfaceOrientation)effectiveOrientation { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self effectiveOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop } - (UIInterfaceOrientation)effectiveOrientation:(UIInterfaceOrientation)orientation { diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorCurvesHistogramView.m b/submodules/LegacyComponents/Sources/TGPhotoEditorCurvesHistogramView.m index 678074367e..d727abbf0d 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorCurvesHistogramView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorCurvesHistogramView.m @@ -228,4 +228,6 @@ }]]; } +@synthesize interactionBegan; + @end diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorInterfaceAssets.m b/submodules/LegacyComponents/Sources/TGPhotoEditorInterfaceAssets.m index 0f24694816..778a56f6c6 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorInterfaceAssets.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorInterfaceAssets.m @@ -261,9 +261,12 @@ CGContextStrokePath(context); UIFont *font = [TGFont roundedFontOfSize:11]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize textSize = [label sizeWithFont:font]; [[UIColor whiteColor] setFill]; [label drawInRect:CGRectMake((size.width - textSize.width) / 2.0f + TGScreenPixel, 4.0f, textSize.width, textSize.height) withFont:font]; +#pragma clang diagnostic pop UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); @@ -294,8 +297,11 @@ NSString *label = [NSString stringWithFormat:@"%ld", value]; UIFont *font = [TGFont roundedFontOfSize:11]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize size = [label sizeWithFont:font]; [label drawInRect:CGRectMake(floor(background.size.width - size.width) / 2.0f, 9.0f, size.width, size.height) withFont:font]; +#pragma clang diagnostic pop UIImage *result = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorSliderView.m b/submodules/LegacyComponents/Sources/TGPhotoEditorSliderView.m index 96f847a378..acfe8a1e31 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorSliderView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorSliderView.m @@ -447,6 +447,7 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f; } - (void)setEnablePanHandling:(bool)enablePanHandling { + _enablePanHandling = enablePanHandling; _panGestureRecognizer.enabled = enablePanHandling; } diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorTabController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorTabController.m index be182acce2..3a9492964d 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorTabController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorTabController.m @@ -84,13 +84,17 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; - (bool)hasOnScreenNavigation { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } return hasOnScreenNavigation; } - (UIInterfaceOrientation)effectiveOrientation { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self effectiveOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop } - (UIInterfaceOrientation)effectiveOrientation:(UIInterfaceOrientation)orientation { @@ -227,6 +231,8 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; if (self.intent & TGPhotoEditorControllerFromCameraIntent && self.intent & (TGPhotoEditorControllerAvatarIntent | TGPhotoEditorControllerSignupAvatarIntent)) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { referenceFrame = CGRectMake(referenceSize.height - referenceFrame.size.height - referenceFrame.origin.y, @@ -239,6 +245,7 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; referenceFrame.origin.x, referenceFrame.size.height, referenceFrame.size.width); } +#pragma clang diagnostic pop } if (self.beginTransitionOut != nil) @@ -249,6 +256,8 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; if (self.intent & TGPhotoEditorControllerFromCameraIntent && self.intent & (TGPhotoEditorControllerAvatarIntent | TGPhotoEditorControllerSignupAvatarIntent)) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { referenceFrame = CGRectMake(referenceSize.width - referenceFrame.size.height - referenceFrame.origin.y, @@ -261,6 +270,7 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; referenceSize.height - referenceFrame.size.width - referenceFrame.origin.x, referenceFrame.size.height, referenceFrame.size.width); } +#pragma clang diagnostic pop } if (saving) @@ -343,8 +353,9 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; - (CGRect)transitionOutSourceFrameForReferenceFrame:(CGRect)referenceFrame orientation:(UIInterfaceOrientation)orientation { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } CGRect containerFrame = [TGPhotoEditorTabController photoContainerFrameForParentViewFrame:self.view.frame toolbarLandscapeSize:self.toolbarLandscapeSize orientation:orientation panelSize:TGPhotoEditorPanelSize hasOnScreenNavigation:hasOnScreenNavigation]; CGSize fittedSize = TGScaleToSize(referenceFrame.size, containerFrame.size); @@ -367,8 +378,9 @@ const CGFloat TGPhotoEditorToolbarSize = 49.0f; UIInterfaceOrientation orientation = self.effectiveOrientation; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } CGRect containerFrame = [TGPhotoEditorTabController photoContainerFrameForParentViewFrame:CGRectMake(0, 0, referenceSize.width, referenceSize.height) toolbarLandscapeSize:self.toolbarLandscapeSize orientation:orientation panelSize:TGPhotoEditorPanelSize hasOnScreenNavigation:hasOnScreenNavigation]; CGSize fittedSize = TGScaleToSize(fromFrame.size, containerFrame.size); diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorToolButtonsView.m b/submodules/LegacyComponents/Sources/TGPhotoEditorToolButtonsView.m index de088068e8..6fa8aaf7c2 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorToolButtonsView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorToolButtonsView.m @@ -106,10 +106,7 @@ const CGFloat TGPhotoEditorToolButtonsViewSize = 53; for (NSString *title in possibleButtonTitles) { CGFloat width = 0.0f; - if ([title respondsToSelector:@selector(sizeWithAttributes:)]) - width = CGCeil([title sizeWithAttributes:@{ NSFontAttributeName:TGSystemFontOfSize(17) }].width - 1); - else - width = CGCeil([title sizeWithFont:TGSystemFontOfSize(17)].width - 1); + width = CGCeil([title sizeWithAttributes:@{ NSFontAttributeName:TGSystemFontOfSize(17) }].width - 1); if (width > maxWidth) maxWidth = width; diff --git a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m index dc759ae6d3..8a5fa607e9 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoPaintController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoPaintController.m @@ -194,7 +194,7 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f; self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _scrollView = [[TGModernGalleryZoomableScrollView alloc] initWithFrame:self.view.bounds hasDoubleTap:false]; - if (iosMajorVersion() >= 11) { + if (@available(iOS 11.0, *)) { _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; } _scrollView.contentInset = UIEdgeInsetsZero; diff --git a/submodules/LegacyComponents/Sources/TGPhotoQualityController.m b/submodules/LegacyComponents/Sources/TGPhotoQualityController.m index ad9327dbb4..30e065f806 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoQualityController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoQualityController.m @@ -222,7 +222,9 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; _portraitToolsWrapperView.alpha = 1.0f; _landscapeToolsWrapperView.alpha = 1.0f; }]; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) _portraitToolControlView.layer.shouldRasterize = true; else @@ -259,6 +261,7 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; else _landscapeToolsWrapperView.frame = toolTargetFrame; }; +#pragma clang diagnostic pop [UIView animateWithDuration:0.3f animations:^ { @@ -280,6 +283,8 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; - (void)transitionOutSwitching:(bool)__unused switching completion:(void (^)(void))completion { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" _wrapperView.backgroundColor = [UIColor clearColor]; if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) @@ -347,6 +352,7 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; if (completion != nil) completion(); }]; +#pragma clang diagnostic pop } - (void)_animatePreviewViewTransitionOutToFrame:(CGRect)targetFrame saving:(bool)saving parentView:(UIView *)__unused parentView completion:(void (^)(void))completion @@ -446,8 +452,9 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; - (CGRect)transitionOutSourceFrameForReferenceFrame:(CGRect)referenceFrame orientation:(UIInterfaceOrientation)orientation { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } CGRect containerFrame = [TGPhotoQualityController photoContainerFrameForParentViewFrame:self.view.frame toolbarLandscapeSize:self.toolbarLandscapeSize orientation:orientation panelSize:TGPhotoEditorQualityPanelSize hasOnScreenNavigation:hasOnScreenNavigation]; CGSize fittedSize = TGScaleToSize(referenceFrame.size, containerFrame.size); @@ -459,14 +466,18 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; - (CGRect)_targetFrameForTransitionInFromFrame:(CGRect)fromFrame { CGSize referenceSize = [self referenceViewSize]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIInterfaceOrientation orientation = self.interfaceOrientation; +#pragma clang diagnostic pop if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) orientation = UIInterfaceOrientationPortrait; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } CGRect containerFrame = [TGPhotoQualityController photoContainerFrameForParentViewFrame:CGRectMake(0, 0, referenceSize.width, referenceSize.height) toolbarLandscapeSize:self.toolbarLandscapeSize orientation:orientation panelSize:TGPhotoEditorQualityPanelSize hasOnScreenNavigation:hasOnScreenNavigation]; CGSize fittedSize = TGScaleToSize(fromFrame.size, containerFrame.size); @@ -519,8 +530,9 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; CGFloat panelToolbarLandscapeSize = panelToolbarPortraitSize; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON; + } UIEdgeInsets safeAreaInset = [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; UIEdgeInsets screenEdges = UIEdgeInsetsMake((screenSide - referenceSize.height) / 2 , (screenSide - referenceSize.width) / 2, (screenSide + referenceSize.height) / 2, (screenSide + referenceSize.width) / 2); @@ -741,8 +753,11 @@ const NSTimeInterval TGPhotoQualityPreviewDuration = 15.0f; [strongSelf.view insertSubview:strongSelf->_videoView belowSubview:belowView]; [strongSelf->_player play]; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [strongSelf updateLayout:strongSelf.interfaceOrientation]; +#pragma clang diagnostic pop strongSelf->_overlayView.hidden = true; [strongSelf->_overlayView setProgress:0.03f cancelEnabled:false animated:true]; diff --git a/submodules/LegacyComponents/Sources/TGPhotoTextEntityView.m b/submodules/LegacyComponents/Sources/TGPhotoTextEntityView.m index 28446ca58d..cdce772876 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoTextEntityView.m +++ b/submodules/LegacyComponents/Sources/TGPhotoTextEntityView.m @@ -640,7 +640,7 @@ const CGFloat TGPhotoTextSelectionViewHandleSide = 30.0f; _path = nil; [self.rectArray removeAllObjects]; - [self enumerateLineFragmentsForGlyphRange:NSMakeRange(0, self.textStorage.string) usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer * _Nonnull textContainer, NSRange glyphRange, BOOL * _Nonnull stop) { + [self enumerateLineFragmentsForGlyphRange:NSMakeRange(0, self.textStorage.string.length) usingBlock:^(CGRect rect, CGRect usedRect, NSTextContainer * _Nonnull textContainer, NSRange glyphRange, BOOL * _Nonnull stop) { bool ignoreRange = false; NSRange characterRange = [self characterRangeForGlyphRange:glyphRange actualGlyphRange:nil]; NSString *substring = [[self.textStorage string] substringWithRange:characterRange]; @@ -662,9 +662,6 @@ const CGFloat TGPhotoTextSelectionViewHandleSide = 30.0f; // [super drawBackgroundForGlyphRange:glyphsToShow atPoint:origin]; if (self.frameColor != nil) { - NSRange range = [self characterRangeForGlyphRange:glyphsToShow actualGlyphRange:NULL]; - NSRange glyphRange = [self glyphRangeForCharacterRange:range actualCharacterRange:NULL]; - CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextTranslateCTM(context, origin.x, origin.y); diff --git a/submodules/LegacyComponents/Sources/TGPhotoToolCell.m b/submodules/LegacyComponents/Sources/TGPhotoToolCell.m index dc42d9922f..9147522e4e 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoToolCell.m +++ b/submodules/LegacyComponents/Sources/TGPhotoToolCell.m @@ -29,6 +29,8 @@ NSString * const TGPhotoToolCellKind = @"TGPhotoToolCellKind"; { [_toolView removeFromSuperview]; _toolView = nil; + + [super prepareForReuse]; } - (void)setPhotoTool:(PGPhotoTool *)photoTool landscape:(bool)landscape nameWidth:(CGFloat)nameWidth changeBlock:(void (^)(PGPhotoTool *, id, bool))changeBlock interactionBegan:(void (^)(void))interactionBegan interactionEnded:(void (^)(void))interactionEnded diff --git a/submodules/LegacyComponents/Sources/TGPhotoToolsController.m b/submodules/LegacyComponents/Sources/TGPhotoToolsController.m index ac04824727..778c836b45 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoToolsController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoToolsController.m @@ -250,10 +250,7 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize { NSString *title = tool.title; CGFloat width = 0.0f; - if ([title respondsToSelector:@selector(sizeWithAttributes:)]) - width = CGCeil([title sizeWithAttributes:@{ NSFontAttributeName:[TGPhotoEditorInterfaceAssets editorItemTitleFont] }].width); - else - width = CGCeil([title sizeWithFont:[TGPhotoEditorInterfaceAssets editorItemTitleFont]].width); + width = CGCeil([title sizeWithAttributes:@{ NSFontAttributeName:[TGPhotoEditorInterfaceAssets editorItemTitleFont] }].width); if (width > maxTitleWidth) maxTitleWidth = width; @@ -844,7 +841,10 @@ const CGFloat TGPhotoEditorToolsLandscapePanelSize = TGPhotoEditorToolsPanelSize - (void)updateToolViews { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" UIInterfaceOrientation orientation = self.interfaceOrientation; +#pragma clang diagnostic pop if ([self inFormSheet] || TGIsPad()) { _landscapeToolsWrapperView.hidden = true; diff --git a/submodules/LegacyComponents/Sources/TGProgressWindow.m b/submodules/LegacyComponents/Sources/TGProgressWindow.m index a0f31d94a4..09e78ad1d1 100644 --- a/submodules/LegacyComponents/Sources/TGProgressWindow.m +++ b/submodules/LegacyComponents/Sources/TGProgressWindow.m @@ -121,7 +121,7 @@ static bool TGProgressWindowIsLight = true; [self dismiss:animated completion:nil]; } -- (void)dismiss:(bool)animated completion:(void (^)())completion +- (void)dismiss:(bool)animated completion:(void (^)(void))completion { TGProgressWindow *window = (TGProgressWindow *)_weakWindow; diff --git a/submodules/LegacyComponents/Sources/TGStringUtils.mm b/submodules/LegacyComponents/Sources/TGStringUtils.mm index c01d95a906..872fdd1411 100644 --- a/submodules/LegacyComponents/Sources/TGStringUtils.mm +++ b/submodules/LegacyComponents/Sources/TGStringUtils.mm @@ -306,23 +306,29 @@ static HTMLEscapeMap gAsciiHTMLEscapeMap[] = { + (NSString *)stringByEscapingForURL:(NSString *)string { static NSString * const kAFLegalCharactersToBeEscaped = @"?!@#$^&%*+=,.:;'\"`<>()[]{}/\\|~ "; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *unescapedString = [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; if (unescapedString == nil) unescapedString = string; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)unescapedString, NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); +#pragma clang diagnostic pop } + (NSString *)stringByEscapingForActorURL:(NSString *)string { static NSString * const kAFLegalCharactersToBeEscaped = @"?!@#$^&%*+=,:;'\"`<>()[]{}/\\|~ "; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *unescapedString = [string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; if (unescapedString == nil) unescapedString = string; return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)unescapedString, NULL, (CFStringRef)kAFLegalCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); +#pragma clang diagnostic pop } + (NSString *)stringByEncodingInBase64:(NSData *)data @@ -503,9 +509,11 @@ static HTMLEscapeMap gAsciiHTMLEscapeMap[] = { { NSRange equalsSignRange = [keyValuePair rangeOfString:@"="]; if (equalsSignRange.location != NSNotFound) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" NSString *key = [keyValuePair substringToIndex:equalsSignRange.location]; NSString *value = [[[keyValuePair substringFromIndex:equalsSignRange.location + equalsSignRange.length] stringByReplacingOccurrencesOfString:@"+" withString:@" "] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - +#pragma clang diagnostic pop [queryStringDictionary setObject:value forKey:key]; } @@ -1389,7 +1397,7 @@ static unsigned char strToChar (char a, char b) buf[1] = [hex characterAtIndex:i+1]; char *b2 = NULL; *bp++ = strtol(buf, &b2, 16); - NSAssert(b2 == buf + 2, @"String should be all hex digits: %@ (bad digit around %d)", hex, i); + NSAssert(b2 == buf + 2, @"String should be all hex digits: %@ (bad digit around %d)", hex, (int)i); } return [NSData dataWithBytesNoCopy:bytes length:[hex length]/2 freeWhenDone:YES]; diff --git a/submodules/LegacyComponents/Sources/TGTextField.m b/submodules/LegacyComponents/Sources/TGTextField.m index 48b0c62e1e..1f5a5d67b4 100644 --- a/submodules/LegacyComponents/Sources/TGTextField.m +++ b/submodules/LegacyComponents/Sources/TGTextField.m @@ -12,8 +12,11 @@ else { CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), _placeholderColor.CGColor); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize placeholderSize = [self.placeholder sizeWithFont:_placeholderFont]; +#pragma clang diagnostic pop CGPoint placeholderOrigin = CGPointMake(0.0f, CGFloor((rect.size.height - placeholderSize.height) / 2.0f) - TGRetinaPixel); if (self.textAlignment == NSTextAlignmentCenter) @@ -22,8 +25,11 @@ placeholderOrigin.x = rect.size.width - placeholderSize.width; placeholderOrigin.y += TGScreenPixel + _placeholderOffset; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self.placeholder drawAtPoint:placeholderOrigin withFont:_placeholderFont]; +#pragma clang diagnostic pop } } diff --git a/submodules/LegacyComponents/Sources/TGTooltipView.m b/submodules/LegacyComponents/Sources/TGTooltipView.m index d052801764..9c9e3c23c6 100644 --- a/submodules/LegacyComponents/Sources/TGTooltipView.m +++ b/submodules/LegacyComponents/Sources/TGTooltipView.m @@ -91,7 +91,10 @@ if (_numberOfLines == 1) { [_textLabel sizeToFit]; } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize textSize = [_textLabel.text sizeWithFont:_textLabel.font constrainedToSize:CGSizeMake(_maxWidth - 20.0f, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping]; +#pragma clang diagnostic pop textSize.width = CGCeil(textSize.width); textSize.height = CGCeil(textSize.height); _textLabel.frame = CGRectMake(_textLabel.frame.origin.x, _textLabel.frame.origin.y, textSize.width, textSize.height); @@ -110,7 +113,10 @@ if (_numberOfLines == 1) { [_textLabel sizeToFit]; } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGSize textSize = [_textLabel.text sizeWithFont:_textLabel.font constrainedToSize:CGSizeMake(maxWidth - 20.0f, CGFLOAT_MAX) lineBreakMode:NSLineBreakByWordWrapping]; +#pragma clang diagnostic pop textSize.width = CGCeil(textSize.width); textSize.height = CGCeil(textSize.height); _textLabel.frame = CGRectMake(_textLabel.frame.origin.x, _textLabel.frame.origin.y, textSize.width, textSize.height); diff --git a/submodules/LegacyComponents/Sources/TGVideoCameraPipeline.m b/submodules/LegacyComponents/Sources/TGVideoCameraPipeline.m index cadce56928..1334fe08f1 100644 --- a/submodules/LegacyComponents/Sources/TGVideoCameraPipeline.m +++ b/submodules/LegacyComponents/Sources/TGVideoCameraPipeline.m @@ -257,19 +257,20 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16; { if ([notification.name isEqualToString:AVCaptureSessionWasInterruptedNotification]) { - [self captureSessionDidStopRunning]; + NSInteger reason = [notification.userInfo[AVCaptureSessionInterruptionReasonKey] integerValue]; + if (reason == AVCaptureSessionInterruptionReasonVideoDeviceNotAvailableInBackground) { + if (_running) + _startCaptureSessionOnEnteringForeground = true; + } else { + [self captureSessionDidStopRunning]; + } } else if ([notification.name isEqualToString:AVCaptureSessionRuntimeErrorNotification]) { [self captureSessionDidStopRunning]; NSError *error = notification.userInfo[AVCaptureSessionErrorKey]; - if (error.code == AVErrorDeviceIsNotAvailableInBackground) - { - if (_running) - _startCaptureSessionOnEnteringForeground = true; - } - else if (error.code == AVErrorMediaServicesWereReset) + if (error.code == AVErrorMediaServicesWereReset) { [self handleRecoverableCaptureSessionRuntimeError:error]; } @@ -994,12 +995,8 @@ static CGFloat angleOffsetFromPortraitOrientationToOrientation(AVCaptureVideoOri - (void)_enableVideoStabilization { AVCaptureConnection *videoConnection = [_videoOutput connectionWithMediaType:AVMediaTypeVideo]; - if (videoConnection.supportsVideoStabilization) - { - if ([videoConnection respondsToSelector:@selector(setPreferredVideoStabilizationMode:)]) - videoConnection.preferredVideoStabilizationMode = AVCaptureVideoStabilizationModeStandard; - else - videoConnection.enablesVideoStabilizationWhenAvailable = true; + if (videoConnection.supportsVideoStabilization) { + videoConnection.preferredVideoStabilizationMode = AVCaptureVideoStabilizationModeStandard; } } diff --git a/submodules/LegacyComponents/Sources/TGVideoMessageCaptureController.m b/submodules/LegacyComponents/Sources/TGVideoMessageCaptureController.m index 28d75d6496..34f9280861 100644 --- a/submodules/LegacyComponents/Sources/TGVideoMessageCaptureController.m +++ b/submodules/LegacyComponents/Sources/TGVideoMessageCaptureController.m @@ -60,7 +60,7 @@ typedef enum @end -@interface TGVideoMessageCaptureController () +@interface TGVideoMessageCaptureController () { SQueue *_queue; @@ -334,8 +334,7 @@ typedef enum [_shimmerView updateAbsoluteRect:_circleView.bounds containerSize:_circleView.bounds.size]; [_circleView addSubview:_shimmerView]; - if (iosMajorVersion() >= 11) - { + if (@available(iOS 11.0, *)) { _shadowView.accessibilityIgnoresInvertColors = true; _placeholderView.accessibilityIgnoresInvertColors = true; } @@ -487,8 +486,9 @@ typedef enum _previewView = [[TGVideoCameraGLView alloc] initWithFrame:_circleView.bounds]; [_circleView insertSubview:_previewView belowSubview:_placeholderView]; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { _previewView.accessibilityIgnoresInvertColors = true; + } [self captureStarted]; } @@ -593,6 +593,8 @@ typedef enum .x = _wrapperView.frame.size.width / 2.0f, .y = _wrapperView.frame.size.height / 2.0f - _controlsView.frame.size.height }; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" switch (self.interfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: @@ -606,6 +608,7 @@ typedef enum targetPosition.y = MAX(_circleWrapperView.bounds.size.height / 2.0f + 40.0f, targetPosition.y); break; } +#pragma clang diagnostic pop if (TGIsPad()) { _circleWrapperView.center = targetPosition; @@ -771,8 +774,6 @@ typedef enum [_generator impactOccurred]; } - bool effectiveHasSchedule = true; - TGMediaPickerSendActionSheetController *controller = [[TGMediaPickerSendActionSheetController alloc] initWithContext:_context isDark:self.pallete.isDark sendButtonFrame:[_controlsView convertRect:[_controlsView frameForSendButton] toView:nil] canSendSilently:_canSendSilently canSchedule:_canSchedule reminder:_reminder hasTimer:false]; __weak TGVideoMessageCaptureController *weakSelf = self; controller.send = ^{ @@ -1213,7 +1214,10 @@ typedef enum - (void)configureCamera { _capturePipeline = [[TGVideoCameraPipeline alloc] initWithDelegate:self position:_preferredPosition callbackQueue:dispatch_get_main_queue() liveUploadInterface:_liveUploadInterface]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" _capturePipeline.orientation = (AVCaptureVideoOrientation)self.interfaceOrientation; +#pragma clang diagnostic pop __weak TGVideoMessageCaptureController *weakSelf = self; _capturePipeline.micLevel = ^(CGFloat level) @@ -1548,12 +1552,15 @@ static UIImage *startImage = nil; if (cropOrientation != NULL) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) *cropOrientation = UIImageOrientationUp; else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) *cropOrientation = UIImageOrientationRight; else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) *cropOrientation = UIImageOrientationLeft; +#pragma clang diagnostic pop } if (cropMirrored != NULL) diff --git a/submodules/LegacyComponents/Sources/TGVideoMessageControls.m b/submodules/LegacyComponents/Sources/TGVideoMessageControls.m index d7e68bb320..40bd7ad5c8 100644 --- a/submodules/LegacyComponents/Sources/TGVideoMessageControls.m +++ b/submodules/LegacyComponents/Sources/TGVideoMessageControls.m @@ -300,9 +300,11 @@ static CGRect viewFrame(UIView *view) static CGFloat freeOffsetLimit = 35.0f; static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^ - { + dispatch_once(&onceToken, ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat labelWidth = [TGLocalized(@"Conversation.SlideToCancel") sizeWithFont:TGSystemFontOfSize(14.0f)].width; +#pragma clang diagnostic pop CGFloat arrowOrigin = CGFloor((TGScreenSize().width - labelWidth) / 2.0f) - 9.0f - 6.0f; CGFloat timerWidth = 90.0f; diff --git a/submodules/LegacyComponents/Sources/TGVideoMessageRingView.m b/submodules/LegacyComponents/Sources/TGVideoMessageRingView.m index e623de4111..38bf502dc5 100644 --- a/submodules/LegacyComponents/Sources/TGVideoMessageRingView.m +++ b/submodules/LegacyComponents/Sources/TGVideoMessageRingView.m @@ -128,7 +128,7 @@ if (self != nil) { self.clipsToBounds = true; self.layer.cornerRadius = frame.size.width / 2.0f; - if (iosMajorVersion() >= 13) { + if (@available(iOS 13.0, *)) { self.layer.cornerCurve = kCACornerCurveCircular; } @@ -141,7 +141,7 @@ _borderMaskView.layer.borderWidth = 1.0; _borderMaskView.layer.borderColor = [UIColor whiteColor].CGColor; _borderMaskView.layer.cornerRadius = frame.size.width / 2.0f; - if (iosMajorVersion() >= 13) { + if (@available(iOS 13.0, *)) { _borderMaskView.layer.cornerCurve = kCACornerCurveCircular; } _borderView.maskView = _borderMaskView; diff --git a/submodules/LegacyComponents/Sources/TGViewController.mm b/submodules/LegacyComponents/Sources/TGViewController.mm index 0a35d3fb26..41ded68f86 100644 --- a/submodules/LegacyComponents/Sources/TGViewController.mm +++ b/submodules/LegacyComponents/Sources/TGViewController.mm @@ -375,12 +375,20 @@ static id _defaultContext = nil; return self; } +- (id)initWithCoder:(NSCoder *)coder { + return [self init]; +} + - (void)_commonViewControllerInit:(id)context { assert(context != nil); _context = context; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" self.wantsFullScreenLayout = true; +#pragma clang diagnostic pop + self.automaticallyManageScrollViewInsets = true; self.autoManageStatusBarBackground = true; __block bool initializedSizeClass = false; @@ -467,7 +475,10 @@ static id _defaultContext = nil; - (bool)shouldIgnoreStatusBar { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self shouldIgnoreStatusBarInOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop } - (bool)shouldIgnoreNavigationBar @@ -625,15 +636,21 @@ static id _defaultContext = nil; if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && iosMajorVersion() < 7) { CGSize size = CGSizeMake(320, 491); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" self.contentSizeForViewInPopover = size; +#pragma clang diagnostic pop } if ([self.navigationController isKindOfClass:[TGNavigationController class]]) [(TGNavigationController *)self.navigationController setupNavigationBarForController:self animated:animated]; - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation force:false notify:true]; [self adjustToInterfaceOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop [super viewWillAppear:animated]; @@ -808,12 +825,18 @@ static id _defaultContext = nil; CGFloat minStatusBarHeight = [self prefersStatusBarHidden] ? 0.0f : 20.0f; CGFloat statusBarHeight = MAX(minStatusBarHeight, MIN(statusBarFrame.size.width, statusBarFrame.size.height)); statusBarHeight = MIN(40.0f, statusBarHeight + _additionalStatusBarHeight); - + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat keyboardHeight = [self _currentKeyboardHeight:self.interfaceOrientation]; +#pragma clang diagnostic pop [UIView animateWithDuration:0.35 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } completion:nil]; } } @@ -854,14 +877,20 @@ static id _defaultContext = nil; { [UIView performWithoutAnimation:^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop }]; } else { [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } completion:nil]; } } @@ -884,14 +913,20 @@ static id _defaultContext = nil; { [UIView performWithoutAnimation:^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop }]; } else { [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^ { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } completion:nil]; } } @@ -982,9 +1017,12 @@ static id _defaultContext = nil; _additionalNavigationBarHeight = additionalNavigationBarHeight; CGFloat statusBarHeight = [self _currentStatusBarHeight]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat keyboardHeight = [self _currentKeyboardHeight:self.interfaceOrientation]; [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } - (void)setAdditionalStatusBarHeight:(CGFloat)additionalStatusBarHeight @@ -992,9 +1030,12 @@ static id _defaultContext = nil; _additionalStatusBarHeight = additionalStatusBarHeight; CGFloat statusBarHeight = [self _currentStatusBarHeight]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat keyboardHeight = [self _currentKeyboardHeight:self.interfaceOrientation]; [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } - (void)setExplicitTableInset:(UIEdgeInsets)explicitTableInset scrollIndicatorInset:(UIEdgeInsets)scrollIndicatorInset @@ -1003,14 +1044,20 @@ static id _defaultContext = nil; _explicitScrollIndicatorInset = scrollIndicatorInset; CGFloat statusBarHeight = [self _currentStatusBarHeight]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat keyboardHeight = [self _currentKeyboardHeight:self.interfaceOrientation]; [self _updateControllerInsetForOrientation:self.interfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:keyboardHeight force:false notify:true]; +#pragma clang diagnostic pop } - (bool)_updateControllerInset:(bool)force { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" return [self _updateControllerInsetForOrientation:self.interfaceOrientation force:force notify:true]; +#pragma clang diagnostic pop } - (bool)_updateControllerInsetForOrientation:(UIInterfaceOrientation)orientation force:(bool)force notify:(bool)notify @@ -1060,8 +1107,9 @@ static id _defaultContext = nil; orientation = UIInterfaceOrientationLandscapeLeft; bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } return [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; } @@ -1093,8 +1141,9 @@ static id _defaultContext = nil; - (bool)_updateControllerInsetForOrientation:(UIInterfaceOrientation)orientation statusBarHeight:(CGFloat)statusBarHeight keyboardHeight:(CGFloat)keyboardHeight force:(bool)force notify:(bool)notify { bool hasOnScreenNavigation = false; - if (iosMajorVersion() >= 11) + if (@available(iOS 11.0, *)) { hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || _context.safeAreaInset.bottom > FLT_EPSILON; + } UIEdgeInsets safeAreaInset = [TGViewController safeAreaInsetForOrientation:orientation hasOnScreenNavigation:hasOnScreenNavigation]; CGFloat navigationBarHeight = ([self navigationBarShouldBeHidden] || [self shouldIgnoreNavigationBar]) ? 0 : [self navigationBarHeightForInterfaceOrientation:orientation]; @@ -1260,12 +1309,15 @@ static id _defaultContext = nil; { if (navigationBarHidden != self.navigationController.navigationBarHidden) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" CGFloat barHeight = [self navigationBarHeightForInterfaceOrientation:self.interfaceOrientation]; CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; if ([self shouldIgnoreStatusBarInOrientation:self.interfaceOrientation]) statusBarHeight = 0.0f; CGSize screenSize = [TGViewController screenSizeForInterfaceOrientation:self.interfaceOrientation]; +#pragma clang diagnostic pop if (!navigationBarHidden) { diff --git a/submodules/LegacyComponents/Sources/TGWebDocument.m b/submodules/LegacyComponents/Sources/TGWebDocument.m index eb312f0e1a..c5e13250c5 100644 --- a/submodules/LegacyComponents/Sources/TGWebDocument.m +++ b/submodules/LegacyComponents/Sources/TGWebDocument.m @@ -31,7 +31,7 @@ - (instancetype)initWithString:(NSString *)string { if ([string hasPrefix:@"webdoc"]) { - NSData *data = iosMajorVersion() >= 7 ? [[NSData alloc] initWithBase64EncodedString:[string substringFromIndex:6] options:NSDataBase64DecodingIgnoreUnknownCharacters] : [[NSData alloc] initWithBase64Encoding:[string substringFromIndex:6]]; + NSData *data = [[NSData alloc] initWithBase64EncodedString:[string substringFromIndex:6] options:NSDataBase64DecodingIgnoreUnknownCharacters]; if (data != nil) { PSKeyValueDecoder *decoder = [[PSKeyValueDecoder alloc] initWithData:data]; return [[TGWebDocumentReference alloc] initWithKeyValueCoder:decoder]; @@ -46,7 +46,7 @@ - (NSString *)toString { PSKeyValueEncoder *encoder = [[PSKeyValueEncoder alloc] init]; [self encodeWithKeyValueCoder:encoder]; - return [@"webdoc" stringByAppendingString:[[encoder data] base64Encoding]]; + return [@"webdoc" stringByAppendingString:[[encoder data] base64EncodedStringWithOptions:0]]; } @end diff --git a/submodules/LegacyComponents/Sources/YUGPUImageHighPassSkinSmoothingFilter.m b/submodules/LegacyComponents/Sources/YUGPUImageHighPassSkinSmoothingFilter.m index 683c2c9ade..734535e414 100644 --- a/submodules/LegacyComponents/Sources/YUGPUImageHighPassSkinSmoothingFilter.m +++ b/submodules/LegacyComponents/Sources/YUGPUImageHighPassSkinSmoothingFilter.m @@ -127,7 +127,9 @@ SHADER_STRING return self; } + - (void)setHighPassRadiusInPixels:(CGFloat)highPassRadiusInPixels { + _highPassRadiusInPixels = highPassRadiusInPixels; self.highPassFilter.radiusInPixels = highPassRadiusInPixels; } diff --git a/submodules/LegacyComponents/Sources/ocr.mm b/submodules/LegacyComponents/Sources/ocr.mm index 4e6e8940e1..b81744efe8 100755 --- a/submodules/LegacyComponents/Sources/ocr.mm +++ b/submodules/LegacyComponents/Sources/ocr.mm @@ -669,7 +669,7 @@ UIImage *normalizeImage(UIImage *image) if (image.imageOrientation == UIImageOrientationUp) return image; UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); - [image drawInRect:(CGRect){0, 0, image.size}]; + [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return normalizedImage; diff --git a/submodules/LegacyMediaPickerUI/BUILD b/submodules/LegacyMediaPickerUI/BUILD index db58fe1bdc..f148332d77 100644 --- a/submodules/LegacyMediaPickerUI/BUILD +++ b/submodules/LegacyMediaPickerUI/BUILD @@ -6,6 +6,9 @@ swift_library( srcs = glob([ "Sources/**/*.swift", ]), + copts = [ + #"-warnings-as-errors", + ], deps = [ "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", diff --git a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h index 891eab4a7b..3a06e3c3bf 100644 --- a/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h +++ b/submodules/ObjCRuntimeUtils/Source/ObjCRuntimeUtils/RuntimeUtils.h @@ -8,20 +8,20 @@ typedef enum { @interface RuntimeUtils : NSObject -+ (void)swizzleInstanceMethodOfClass:(Class)targetClass currentSelector:(SEL)currentSelector newSelector:(SEL)newSelector; -+ (void)swizzleInstanceMethodOfClass:(Class)targetClass currentSelector:(SEL)currentSelector withAnotherClass:(Class)anotherClass newSelector:(SEL)newSelector; -+ (void)swizzleClassMethodOfClass:(Class)targetClass currentSelector:(SEL)currentSelector newSelector:(SEL)newSelector; ++ (void)swizzleInstanceMethodOfClass:(Class _Nonnull)targetClass currentSelector:(SEL _Nonnull)currentSelector newSelector:(SEL _Nonnull)newSelector; ++ (void)swizzleInstanceMethodOfClass:(Class _Nonnull)targetClass currentSelector:(SEL _Nonnull)currentSelector withAnotherClass:(Class _Nonnull)anotherClass newSelector:(SEL _Nonnull)newSelector; ++ (void)swizzleClassMethodOfClass:(Class _Nonnull)targetClass currentSelector:(SEL _Nonnull)currentSelector newSelector:(SEL _Nonnull)newSelector; + (CALayer * _Nonnull)makeLayerHostCopy:(CALayer * _Nonnull)another; @end @interface NSObject (AssociatedObject) -- (void)setAssociatedObject:(id)object forKey:(void const *)key; -- (void)setAssociatedObject:(id)object forKey:(void const *)key associationPolicy:(NSObjectAssociationPolicy)associationPolicy; -- (id)associatedObjectForKey:(void const *)key; -- (bool)checkObjectIsKindOfClass:(Class)targetClass; -- (void)setClass:(Class)newClass; +- (void)setAssociatedObject:(id _Nullable)object forKey:(void const * _Nonnull)key; +- (void)setAssociatedObject:(id _Nullable)object forKey:(void const * _Nonnull)key associationPolicy:(NSObjectAssociationPolicy)associationPolicy; +- (id _Nullable)associatedObjectForKey:(void const * _Nonnull)key; +- (bool)checkObjectIsKindOfClass:(Class _Nonnull)targetClass; +- (void)setClass:(Class _Nonnull)newClass; @end diff --git a/submodules/UIKitRuntimeUtils/BUILD b/submodules/UIKitRuntimeUtils/BUILD index 8086d92521..d189926c6c 100644 --- a/submodules/UIKitRuntimeUtils/BUILD +++ b/submodules/UIKitRuntimeUtils/BUILD @@ -6,6 +6,9 @@ objc_library( srcs = glob([ "Source/UIKitRuntimeUtils/*.m", ]), + copts = [ + "-Werror", + ], hdrs = glob([ "Source/UIKitRuntimeUtils/*.h", ]), diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIKitUtils.h b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIKitUtils.h index 96e40fc67d..f335aae7a1 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIKitUtils.h +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIKitUtils.h @@ -7,5 +7,5 @@ CABasicAnimation * _Nonnull makeSpringAnimationImpl(NSString * _Nonnull keyPath) CABasicAnimation * _Nonnull makeSpringBounceAnimationImpl(NSString * _Nonnull keyPath, CGFloat initialVelocity, CGFloat damping); CGFloat springAnimationValueAtImpl(CABasicAnimation * _Nonnull animation, CGFloat t); -UIBlurEffect *makeCustomZoomBlurEffectImpl(bool isLight); +UIBlurEffect * _Nonnull makeCustomZoomBlurEffectImpl(bool isLight); void applySmoothRoundedCornersImpl(CALayer * _Nonnull layer); diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m index 4000be50b1..a59590d627 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m @@ -302,20 +302,6 @@ static bool notyfyingShiftState = false; @end -static NSString *TGEncodeText(NSString *string, int key) -{ - NSMutableString *result = [[NSMutableString alloc] init]; - - for (int i = 0; i < (int)[string length]; i++) - { - unichar c = [string characterAtIndex:i]; - c += key; - [result appendString:[NSString stringWithCharacters:&c length:1]]; - } - - return result; -} - void applyKeyboardAutocorrection(UITextView * _Nonnull textView) { NSRange rangeCopy = textView.selectedRange; NSRange fakeRange = rangeCopy; diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIWindow+OrientationChange.m b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIWindow+OrientationChange.m index 88d51c4cce..5b85419517 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIWindow+OrientationChange.m +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIWindow+OrientationChange.m @@ -16,6 +16,12 @@ static NSMutableArray *postDeviceDidChangeOrientationBlocks() { static bool _isDeviceRotating = false; +@interface UIView (OrientationChangeDeps) + +- (void)_updateToInterfaceOrientation:(int)arg1 duration:(double)arg2 force:(BOOL)arg3; + +@end + @implementation UIWindow (OrientationChange) + (void)load { @@ -114,4 +120,8 @@ static bool _isDeviceRotating = false; return _isDeviceRotating; } +- (void)_updateToInterfaceOrientation:(int)arg1 duration:(double)arg2 force:(BOOL)arg3 { + [super _updateToInterfaceOrientation:arg1 duration:arg2 force:arg3]; +} + @end