Fix more warnings

This commit is contained in:
Ali 2021-08-05 00:02:35 +02:00
parent c87725579d
commit 194f25d4e4
107 changed files with 620 additions and 909 deletions

View File

@ -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',

View File

@ -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)

View File

@ -30,6 +30,7 @@ objc_library(
]),
copts = [
"-I{}/PublicHeaders/LegacyComponents".format(package_name()),
"-Werror",
],
includes = [
"PublicHeaders",

View File

@ -10,14 +10,13 @@
@class TGViewController;
@class TGAttachmentCameraView;
@class TGVideoEditAdjustments;
@protocol TGModernGalleryTransitionHostScrollView;
@protocol TGPhotoPaintStickersContext;
@interface TGAttachmentCarouselCollectionView : UICollectionView
@end
@interface TGAttachmentCarouselItemView : TGMenuSheetItemView <TGModernGalleryTransitionHostScrollView>
@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);

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -259,7 +259,7 @@ static void *openGLESContextQueueKey;
#if TARGET_IPHONE_SIMULATOR
return NO;
#else
return (CVOpenGLESTextureCacheCreate != NULL);
return true;
#endif
}

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -13,10 +13,6 @@
#import <QuartzCore/QuartzCore.h>
#if SCENEKIT_SDK_AVAILABLE
#import <SceneKit/SceneKit.h>
#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

View File

@ -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;
}

View File

@ -13,10 +13,6 @@
#endif
#import "POPDefines.h"
#if SCENEKIT_SDK_AVAILABLE
#import <SceneKit/SceneKit.h>
#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)

View File

@ -69,26 +69,4 @@
#if TARGET_OS_IPHONE
#import "POPDefines.h"
#if SCENEKIT_SDK_AVAILABLE
#import <SceneKit/SceneKit.h>
/**
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

View File

@ -22,10 +22,6 @@
#import "POPMath.h"
#import "POPDefines.h"
#if SCENEKIT_SDK_AVAILABLE
#import <SceneKit/SceneKit.h>
#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 {

View File

@ -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)
{

View File

@ -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);

View File

@ -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)

View File

@ -104,8 +104,7 @@
_zoomedView.userInteractionEnabled = false;
[self addSubview:_zoomedView];
if (iosMajorVersion() >= 11)
{
if (@available(iOS 11.0, *)) {
_fadeView.accessibilityIgnoresInvertColors = true;
_iconView.accessibilityIgnoresInvertColors = true;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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

View File

@ -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];

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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),

View File

@ -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);

View File

@ -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);

View File

@ -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];

View File

@ -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"];

View File

@ -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];
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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];

View File

@ -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

View File

@ -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) } };
}

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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)

View File

@ -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];

View File

@ -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];

View File

@ -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<TGMediaEditableItem> editableItem)

View File

@ -97,8 +97,6 @@
- (void)clear
{
NSInteger index = 0;
[_items enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id<TGMediaSelectableItem> item, NSUInteger index, __unused BOOL *stop)
{
if (self.selectionUpdated != nil)

View File

@ -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<TGMediaEditableItem> editableItem = self.editableMediaItem;

View File

@ -370,7 +370,7 @@
{
case TGMediaAssetVideoType:
{
galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:asset];
galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:(id<TGMediaEditableItem,TGMediaSelectableItem>)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<TGMediaEditableItem,TGMediaSelectableItem>)asset];
}
break;
}

View File

@ -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];

View File

@ -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];

View File

@ -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];
}

View File

@ -276,7 +276,7 @@
+ (instancetype)changeWithItem:(id<TGMediaSelectableItem>)item selected:(bool)selected animated:(bool)animated sender:(id)sender
{
TGMediaSelectionChange *change = [[TGMediaSelectionChange alloc] init];
change->_item = item;
change->_item = (NSObject<TGMediaSelectableItem> *)item;
change->_selected = selected;
change->_animated = animated;
change->_sender = sender;

View File

@ -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);

View File

@ -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)];

View File

@ -45,7 +45,7 @@ typedef enum
@end
@interface TGMenuSheetController () <UIGestureRecognizerDelegate, UIPopoverPresentationControllerDelegate, UIPopoverControllerDelegate, UIViewControllerPreviewingDelegate>
@interface TGMenuSheetController () <UIGestureRecognizerDelegate, UIPopoverPresentationControllerDelegate, UIPopoverControllerDelegate>
{
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<LegacyComponentsContext> _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;
}

View File

@ -111,8 +111,9 @@
setupView(_topView);
}
if (iosMajorVersion() >= 11)
if (@available(iOS 11.0, *)) {
self.accessibilityIgnoresInvertColors = true;
}
}
return self;
}

View File

@ -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

View File

@ -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];
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -53,8 +53,9 @@
_key = key;
self.playerLayer.player = player;
if (iosMajorVersion() >= 11)
if (@available(iOS 11.0, *)) {
self.accessibilityIgnoresInvertColors = true;
}
}
return self;
}

View File

@ -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;

View File

@ -7,6 +7,8 @@
- (void)prepareForReuse
{
[self _recycleItemContentView];
[super prepareForReuse];
}
- (void)_recycleItemContentView

View File

@ -133,10 +133,11 @@ static id<TGNavigationBarMusicPlayerProvider> _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<TGNavigationBarMusicPlayerProvider> _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) {

View File

@ -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) {

View File

@ -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<SDisposable>(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];

View File

@ -40,33 +40,37 @@
+ (SSignal *)recognizeBarcodeInImage:(UIImage *)image
{
return [[[SSignal alloc] initWithGenerator:^id<SDisposable>(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<SDisposable>(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

View File

@ -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;

View File

@ -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);

View File

@ -169,4 +169,6 @@
}
}
@synthesize interactionBegan;
@end

View File

@ -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 {

View File

@ -228,4 +228,6 @@
}]];
}
@synthesize interactionBegan;
@end

View File

@ -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();

View File

@ -447,6 +447,7 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
}
- (void)setEnablePanHandling:(bool)enablePanHandling {
_enablePanHandling = enablePanHandling;
_panGestureRecognizer.enabled = enablePanHandling;
}

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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];

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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];

View File

@ -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
}
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -60,7 +60,7 @@ typedef enum
@end
@interface TGVideoMessageCaptureController () <TGVideoCameraPipelineDelegate, TGVideoMessageScrubberDataSource, TGVideoMessageScrubberDelegate>
@interface TGVideoMessageCaptureController () <TGVideoCameraPipelineDelegate, TGVideoMessageScrubberDataSource, TGVideoMessageScrubberDelegate, UIGestureRecognizerDelegate>
{
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)

View File

@ -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;

View File

@ -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;

View File

@ -375,12 +375,20 @@ static id<LegacyComponentsContext> _defaultContext = nil;
return self;
}
- (id)initWithCoder:(NSCoder *)coder {
return [self init];
}
- (void)_commonViewControllerInit:(id<LegacyComponentsContext>)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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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<LegacyComponentsContext> _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)
{

View File

@ -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

View File

@ -127,7 +127,9 @@ SHADER_STRING
return self;
}
- (void)setHighPassRadiusInPixels:(CGFloat)highPassRadiusInPixels {
_highPassRadiusInPixels = highPassRadiusInPixels;
self.highPassFilter.radiusInPixels = highPassRadiusInPixels;
}

Some files were not shown because too many files have changed in this diff Show More