mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
API updates
This commit is contained in:
@@ -63,12 +63,6 @@ NSString *TGMentionBoldAttributeName = @"TGMentionBoldAttributeName";
|
||||
|
||||
- (void)commonInitialiser
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
[HPTextViewInternal addTextViewMethods];
|
||||
});
|
||||
|
||||
CGRect frame = self.frame;
|
||||
frame.origin = CGPointZero;
|
||||
_internalTextView = [[HPTextViewInternal alloc] initWithKeyCommandController:_keyCommandController];
|
||||
|
||||
@@ -29,15 +29,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)addTextViewMethods
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
InjectInstanceMethodFromAnotherClass([HPTextViewInternal class], [HPTextViewInternal class], @selector(textViewAdjustScrollRange:animated:), NSSelectorFromString(TGEncodeText(@"`tdspmmSbohfUpWjtjcmf;bojnbufe;", -1)));
|
||||
});
|
||||
}
|
||||
|
||||
- (void)setText:(NSString *)text
|
||||
{
|
||||
BOOL originalValue = self.scrollEnabled;
|
||||
@@ -64,25 +55,6 @@
|
||||
[super setScrollEnabled:isScrollable];
|
||||
}
|
||||
|
||||
- (void)textViewAdjustScrollRange:(NSRange)range animated:(BOOL)animated
|
||||
{
|
||||
static SEL selector = NULL;
|
||||
static void (*impl)(id, SEL, NSRange, BOOL) = NULL;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
Method method = class_getInstanceMethod([UITextView class], selector);
|
||||
if (method != NULL)
|
||||
impl = (void (*)(id, SEL, NSRange, BOOL))method_getImplementation(method);
|
||||
});
|
||||
|
||||
animated = false;
|
||||
|
||||
if (impl != NULL)
|
||||
impl(self, selector, range, animated);
|
||||
}
|
||||
|
||||
- (void)scrollRectToVisible:(CGRect)__unused rect animated:(BOOL)__unused animated
|
||||
{
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ void TGLegacyLog(NSString *format, ...);
|
||||
int iosMajorVersion();
|
||||
int iosMinorVersion();
|
||||
|
||||
NSString *TGEncodeText(NSString *string, int key);
|
||||
|
||||
void TGDispatchOnMainThread(dispatch_block_t block);
|
||||
void TGDispatchAfter(double delay, dispatch_queue_t queue, dispatch_block_t block);
|
||||
|
||||
|
||||
@@ -70,20 +70,6 @@ int iosMinorVersion()
|
||||
return version;
|
||||
}
|
||||
|
||||
NSString *TGEncodeText(NSString *string, int key)
|
||||
{
|
||||
NSMutableString *result = [[NSMutableString alloc] init];
|
||||
|
||||
for (int i = 0; i < (int)[string length]; i++)
|
||||
{
|
||||
unichar c = [string characterAtIndex:i];
|
||||
c += key;
|
||||
[result appendString:[NSString stringWithCharacters:&c length:1]];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int deviceMemorySize()
|
||||
{
|
||||
static int memorySize = 0;
|
||||
|
||||
@@ -215,209 +215,6 @@ void InjectInstanceMethodFromAnotherClass(Class toClass, Class fromClass, SEL fr
|
||||
window.alpha = alpha;
|
||||
}
|
||||
|
||||
+ (CGFloat)applicationStatusBarOffset
|
||||
{
|
||||
UIWindow *window = [[LegacyComponentsGlobals provider] applicationStatusBarWindow];
|
||||
return window.bounds.origin.y;
|
||||
}
|
||||
|
||||
+ (void)setApplicationStatusBarOffset:(CGFloat)offset {
|
||||
UIWindow *window = [[LegacyComponentsGlobals provider] applicationStatusBarWindow];
|
||||
CGRect bounds = window.bounds;
|
||||
bounds.origin = CGPointMake(0.0f, -offset);
|
||||
window.bounds = bounds;
|
||||
}
|
||||
|
||||
static UIView *findStatusBarView()
|
||||
{
|
||||
static Class viewClass = nil;
|
||||
static SEL selector = NULL;
|
||||
if (selector == NULL)
|
||||
{
|
||||
NSString *str1 = @"rs`str";
|
||||
NSString *str2 = @"A`qVhmcnv";
|
||||
|
||||
selector = NSSelectorFromString([[NSString alloc] initWithFormat:@"%@%@", TGEncodeText(str1, 1), TGEncodeText(str2, 1)]);
|
||||
|
||||
viewClass = NSClassFromString(TGEncodeText(@"VJTubuvtCbs", -1));
|
||||
}
|
||||
|
||||
UIWindow *window = [[LegacyComponentsGlobals provider] applicationStatusBarWindow];
|
||||
|
||||
for (UIView *subview in window.subviews)
|
||||
{
|
||||
if ([subview isKindOfClass:viewClass])
|
||||
{
|
||||
return subview;
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)animateApplicationStatusBarAppearance:(int)statusBarAnimation duration:(NSTimeInterval)duration completion:(void (^)())completion
|
||||
{
|
||||
[self animateApplicationStatusBarAppearance:statusBarAnimation delay:0.0 duration:duration completion:completion];
|
||||
}
|
||||
|
||||
+ (void)animateApplicationStatusBarAppearance:(int)statusBarAnimation delay:(NSTimeInterval)delay duration:(NSTimeInterval)duration completion:(void (^)())completion
|
||||
{
|
||||
UIView *view = findStatusBarView();
|
||||
|
||||
if (view != nil)
|
||||
{
|
||||
if ((statusBarAnimation & TGStatusBarAppearanceAnimationSlideDown) || (statusBarAnimation & TGStatusBarAppearanceAnimationSlideUp))
|
||||
{
|
||||
CGPoint startPosition = view.layer.position;
|
||||
CGPoint position = view.layer.position;
|
||||
|
||||
CGPoint normalPosition = CGPointMake(CGFloor(view.frame.size.width / 2), CGFloor(view.frame.size.height / 2));
|
||||
|
||||
CGFloat viewHeight = view.frame.size.height;
|
||||
|
||||
if (statusBarAnimation & TGStatusBarAppearanceAnimationSlideDown)
|
||||
{
|
||||
startPosition = CGPointMake(CGFloor(view.frame.size.width / 2), CGFloor(view.frame.size.height / 2) - viewHeight);
|
||||
position = CGPointMake(CGFloor(view.frame.size.width / 2), CGFloor(view.frame.size.height / 2));
|
||||
}
|
||||
else if (statusBarAnimation & TGStatusBarAppearanceAnimationSlideUp)
|
||||
{
|
||||
startPosition = CGPointMake(CGFloor(view.frame.size.width / 2), CGFloor(view.frame.size.height / 2));
|
||||
position = CGPointMake(CGFloor(view.frame.size.width / 2), CGFloor(view.frame.size.height / 2) - viewHeight);
|
||||
}
|
||||
|
||||
CABasicAnimation *animation = [[CABasicAnimation alloc] init];
|
||||
animation.duration = duration;
|
||||
animation.fromValue = [NSValue valueWithCGPoint:startPosition];
|
||||
animation.toValue = [NSValue valueWithCGPoint:position];
|
||||
animation.removedOnCompletion = true;
|
||||
animation.fillMode = kCAFillModeForwards;
|
||||
animation.beginTime = delay;
|
||||
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
|
||||
TGAnimationBlockDelegate *delegate = [[TGAnimationBlockDelegate alloc] initWithLayer:view.layer];
|
||||
delegate.completion = ^(BOOL finished)
|
||||
{
|
||||
if (finished)
|
||||
view.layer.position = normalPosition;
|
||||
if (completion)
|
||||
completion();
|
||||
};
|
||||
animation.delegate = delegate;
|
||||
[view.layer addAnimation:animation forKey:@"position"];
|
||||
|
||||
view.layer.position = position;
|
||||
}
|
||||
else if ((statusBarAnimation & TGStatusBarAppearanceAnimationFadeIn) || (statusBarAnimation & TGStatusBarAppearanceAnimationFadeOut))
|
||||
{
|
||||
float startOpacity = view.layer.opacity;
|
||||
float opacity = view.layer.opacity;
|
||||
|
||||
if (statusBarAnimation & TGStatusBarAppearanceAnimationFadeIn)
|
||||
{
|
||||
startOpacity = 0.0f;
|
||||
opacity = 1.0f;
|
||||
}
|
||||
else if (statusBarAnimation & TGStatusBarAppearanceAnimationFadeOut)
|
||||
{
|
||||
startOpacity = 1.0f;
|
||||
opacity = 0.0f;
|
||||
}
|
||||
|
||||
CABasicAnimation *animation = [[CABasicAnimation alloc] init];
|
||||
animation.duration = duration;
|
||||
animation.fromValue = @(startOpacity);
|
||||
animation.toValue = @(opacity);
|
||||
animation.removedOnCompletion = true;
|
||||
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
TGAnimationBlockDelegate *delegate = [[TGAnimationBlockDelegate alloc] initWithLayer:view.layer];
|
||||
delegate.completion = ^(__unused BOOL finished)
|
||||
{
|
||||
if (completion)
|
||||
completion();
|
||||
};
|
||||
animation.delegate = delegate;
|
||||
|
||||
[view.layer addAnimation:animation forKey:@"opacity"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (completion)
|
||||
completion();
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)animateApplicationStatusBarStyleTransitionWithDuration:(NSTimeInterval)duration
|
||||
{
|
||||
UIView *view = findStatusBarView();
|
||||
|
||||
if (view != nil)
|
||||
{
|
||||
UIView *snapshotView = [view snapshotViewAfterScreenUpdates:false];
|
||||
[view addSubview:snapshotView];
|
||||
|
||||
[UIView animateWithDuration:duration animations:^
|
||||
{
|
||||
snapshotView.alpha = 0.0f;
|
||||
} completion:^(__unused BOOL finished)
|
||||
{
|
||||
[snapshotView removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
+ (CGFloat)statusBarHeightForOrientation:(UIInterfaceOrientation)orientation
|
||||
{
|
||||
UIWindow *window = [[LegacyComponentsGlobals provider] applicationStatusBarWindow];
|
||||
|
||||
Class statusBarClass = NSClassFromString(TGEncodeText(@"VJTubuvtCbs", -1));
|
||||
|
||||
for (UIView *view in window.subviews)
|
||||
{
|
||||
if ([view isKindOfClass:statusBarClass])
|
||||
{
|
||||
SEL selector = NSSelectorFromString(TGEncodeText(@"dvssfouTuzmf", -1));
|
||||
NSMethodSignature *signature = [statusBarClass instanceMethodSignatureForSelector:selector];
|
||||
if (signature == nil)
|
||||
{
|
||||
TGLegacyLog(@"***** Method not found");
|
||||
return 20.0f;
|
||||
}
|
||||
|
||||
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:signature];
|
||||
[inv setSelector:selector];
|
||||
[inv setTarget:view];
|
||||
[inv invoke];
|
||||
|
||||
NSInteger result = 0;
|
||||
[inv getReturnValue:&result];
|
||||
|
||||
SEL selector2 = NSSelectorFromString(TGEncodeText(@"ifjhiuGpsTuzmf;psjfoubujpo;", -1));
|
||||
NSMethodSignature *signature2 = [statusBarClass methodSignatureForSelector:selector2];
|
||||
if (signature2 == nil)
|
||||
{
|
||||
TGLegacyLog(@"***** Method not found");
|
||||
return 20.0f;
|
||||
}
|
||||
NSInvocation *inv2 = [NSInvocation invocationWithMethodSignature:signature2];
|
||||
[inv2 setSelector:selector2];
|
||||
[inv2 setTarget:[view class]];
|
||||
[inv2 setArgument:&result atIndex:2];
|
||||
NSInteger argOrientation = orientation;
|
||||
[inv2 setArgument:&argOrientation atIndex:3];
|
||||
[inv2 invoke];
|
||||
|
||||
CGFloat result2 = 0;
|
||||
[inv2 getReturnValue:&result2];
|
||||
|
||||
return result2;
|
||||
}
|
||||
}
|
||||
|
||||
return 20.0f;
|
||||
}
|
||||
|
||||
+ (bool)isKeyboardVisible
|
||||
{
|
||||
return [self isKeyboardVisibleAlt];
|
||||
@@ -445,66 +242,9 @@ static bool keyboardHidden = true;
|
||||
return !keyboardHidden;
|
||||
}
|
||||
|
||||
+ (CGFloat)keyboardHeightForOrientation:(UIInterfaceOrientation)orientation
|
||||
+ (void)applyCurrentKeyboardAutocorrectionVariant:(UITextView *)textView
|
||||
{
|
||||
static NSInvocation *invocation = nil;
|
||||
static Class keyboardClass = NULL;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
keyboardClass = NSClassFromString(TGEncodeText(@"VJLfzcpbse", -1));
|
||||
|
||||
SEL selector = NSSelectorFromString(TGEncodeText(@"tj{fGpsJoufsgbdfPsjfoubujpo;", -1));
|
||||
NSMethodSignature *signature = [keyboardClass methodSignatureForSelector:selector];
|
||||
if (signature == nil)
|
||||
TGLegacyLog(@"***** Method not found");
|
||||
else
|
||||
{
|
||||
invocation = [NSInvocation invocationWithMethodSignature:signature];
|
||||
[invocation setSelector:selector];
|
||||
}
|
||||
});
|
||||
|
||||
if (invocation != nil)
|
||||
{
|
||||
[invocation setTarget:[keyboardClass class]];
|
||||
[invocation setArgument:&orientation atIndex:2];
|
||||
[invocation invoke];
|
||||
|
||||
CGSize result = CGSizeZero;
|
||||
[invocation getReturnValue:&result];
|
||||
|
||||
return MIN(result.width, result.height);
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
+ (void)applyCurrentKeyboardAutocorrectionVariant
|
||||
{
|
||||
static Class keyboardClass = NULL;
|
||||
static SEL currentInstanceSelector = NULL;
|
||||
static SEL applyVariantSelector = NULL;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
keyboardClass = NSClassFromString(TGEncodeText(@"VJLfzcpbse", -1));
|
||||
|
||||
currentInstanceSelector = NSSelectorFromString(TGEncodeText(@"bdujwfLfzcpbse", -1));
|
||||
applyVariantSelector = NSSelectorFromString(TGEncodeText(@"bddfquBvupdpssfdujpo", -1));
|
||||
});
|
||||
|
||||
if ([keyboardClass respondsToSelector:currentInstanceSelector])
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
id currentInstance = [keyboardClass performSelector:currentInstanceSelector];
|
||||
if ([currentInstance respondsToSelector:applyVariantSelector])
|
||||
[currentInstance performSelector:applyVariantSelector];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
[textView unmarkText];
|
||||
}
|
||||
|
||||
+ (UIWindow *)applicationKeyboardWindow
|
||||
@@ -518,32 +258,6 @@ static bool keyboardHidden = true;
|
||||
keyboardWindow.frame = CGRectOffset(keyboardWindow.bounds, 0.0f, offset);
|
||||
}
|
||||
|
||||
+ (UIView *)applicationKeyboardView
|
||||
{
|
||||
static Class keyboardViewClass = Nil;
|
||||
static Class keyboardViewContainerClass = Nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
keyboardViewClass = NSClassFromString(TGEncodeText(@"VJJoqvuTfuIptuWjfx", -1));
|
||||
keyboardViewContainerClass = NSClassFromString(TGEncodeText(@"VJJoqvuTfuDpoubjofsWjfx", -1));
|
||||
});
|
||||
|
||||
for (UIView *view in [self applicationKeyboardWindow].subviews)
|
||||
{
|
||||
if ([view isKindOfClass:keyboardViewContainerClass])
|
||||
{
|
||||
for (UIView *subview in view.subviews)
|
||||
{
|
||||
if ([subview isKindOfClass:keyboardViewClass])
|
||||
return subview;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void)setForceMovieAnimatedScaleMode:(bool)force
|
||||
{
|
||||
forceMovieAnimatedScaleMode = force;
|
||||
|
||||
@@ -1407,8 +1407,8 @@
|
||||
if (_searchController == nil)
|
||||
return;
|
||||
|
||||
UIView *backArrow = [self _findBackArrow:self.navigationBar];
|
||||
UIView *backButton = [self _findBackButton:self.navigationBar parentView:self.navigationBar];
|
||||
UIView *backArrow = nil;
|
||||
UIView *backButton = nil;
|
||||
|
||||
if ([viewController isKindOfClass:[TGPhotoEditorController class]])
|
||||
{
|
||||
@@ -1440,50 +1440,13 @@
|
||||
_searchSnapshotView = nil;
|
||||
_searchController.view.hidden = false;
|
||||
|
||||
UIView *backArrow = [self _findBackArrow:self.navigationBar];
|
||||
UIView *backButton = [self _findBackButton:self.navigationBar parentView:self.navigationBar];
|
||||
UIView *backArrow = nil;
|
||||
UIView *backButton = nil;
|
||||
backArrow.alpha = 1.0f;
|
||||
backButton.alpha = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIView *)_findBackArrow:(UIView *)view
|
||||
{
|
||||
Class backArrowClass = NSClassFromString(TGEncodeText(@"`VJObwjhbujpoCbsCbdlJoejdbupsWjfx", -1));
|
||||
|
||||
if ([view isKindOfClass:backArrowClass])
|
||||
return view;
|
||||
|
||||
for (UIView *subview in view.subviews)
|
||||
{
|
||||
UIView *result = [self _findBackArrow:subview];
|
||||
if (result != nil)
|
||||
return result;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIView *)_findBackButton:(UIView *)view parentView:(UIView *)parentView
|
||||
{
|
||||
Class backButtonClass = NSClassFromString(TGEncodeText(@"VJObwjhbujpoJufnCvuupoWjfx", -1));
|
||||
|
||||
if ([view isKindOfClass:backButtonClass])
|
||||
{
|
||||
if (view.center.x < parentView.frame.size.width / 2.0f)
|
||||
return view;
|
||||
}
|
||||
|
||||
for (UIView *subview in view.subviews)
|
||||
{
|
||||
UIView *result = [self _findBackButton:subview parentView:parentView];
|
||||
if (result != nil)
|
||||
return result;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
+ (TGMediaAssetType)assetTypeForIntent:(TGMediaAssetsControllerIntent)intent
|
||||
|
||||
@@ -252,7 +252,7 @@ static void setViewFrame(UIView *view, CGRect frame)
|
||||
}
|
||||
|
||||
if (_inputField.internalTextView.isFirstResponder)
|
||||
[TGHacks applyCurrentKeyboardAutocorrectionVariant];
|
||||
[TGHacks applyCurrentKeyboardAutocorrectionVariant:_inputField.internalTextView];
|
||||
|
||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString:_inputField.text == nil ? [[NSAttributedString alloc] initWithString:@""] : _inputField.attributedText];
|
||||
NSMutableString *usualString = [text.string mutableCopy];
|
||||
|
||||
@@ -352,40 +352,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setShowCallStatusBar:(bool)showCallStatusBar
|
||||
{
|
||||
if (_showCallStatusBar == showCallStatusBar)
|
||||
return;
|
||||
|
||||
_showCallStatusBar = showCallStatusBar;
|
||||
|
||||
int screenHeight = (int)TGScreenSize().height;
|
||||
CGFloat statusBarHeight = (screenHeight == 812 || screenHeight == 896) ? 0.0f : 20.0f;
|
||||
|
||||
_currentAdditionalStatusBarHeight = _showCallStatusBar ? statusBarHeight : 0.0f;
|
||||
[(TGNavigationBar *)self.navigationBar setVerticalOffset:_currentAdditionalStatusBarHeight];
|
||||
|
||||
[UIView animateWithDuration:0.25 animations:^
|
||||
{
|
||||
static SEL selector = NULL;
|
||||
static void (*impl)(id, SEL) = NULL;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
selector = NSSelectorFromString(TGEncodeText(@"`vqebufCbstGpsDvssfouJoufsgbdfPsjfoubujpo", -1));
|
||||
Method method = class_getInstanceMethod([UINavigationController class], selector);
|
||||
impl = (void (*)(id, SEL))method_getImplementation(method);
|
||||
});
|
||||
|
||||
if (impl != NULL)
|
||||
impl(self, selector);
|
||||
|
||||
[self updateStatusBarOnControllers];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
- (void)setupStatusBarOnControllers:(NSArray *)controllers
|
||||
{
|
||||
if ([[self navigationBar] isKindOfClass:[TGNavigationBar class]])
|
||||
@@ -416,11 +382,6 @@
|
||||
TGViewController *viewController = (TGViewController *)maybeController;
|
||||
[viewController setAdditionalStatusBarHeight:_currentAdditionalStatusBarHeight];
|
||||
[viewController setNeedsStatusBarAppearanceUpdate];
|
||||
|
||||
if ([viewController.presentedViewController isKindOfClass:[TGNavigationController class]] && viewController.presentedViewController.modalPresentationStyle != UIModalPresentationPopover)
|
||||
{
|
||||
[(TGNavigationController *)viewController.presentedViewController setShowCallStatusBar:_showCallStatusBar];
|
||||
}
|
||||
}
|
||||
else if ([maybeController isKindOfClass:[UITabBarController class]] && [maybeController conformsToProtocol:@protocol(TGNavigationControllerTabsController)])
|
||||
{
|
||||
@@ -438,54 +399,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
static UIView *findDimmingView(UIView *view)
|
||||
{
|
||||
static NSString *encodedString = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
encodedString = TGEncodeText(@"VJEjnnjohWjfx", -1);
|
||||
});
|
||||
|
||||
if ([NSStringFromClass(view.class) isEqualToString:encodedString])
|
||||
return view;
|
||||
|
||||
for (UIView *subview in view.subviews)
|
||||
{
|
||||
UIView *result = findDimmingView(subview);
|
||||
if (result != nil)
|
||||
return result;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
if (self.modalPresentationStyle == UIModalPresentationFormSheet)
|
||||
{
|
||||
UIView *dimmingView = findDimmingView(self.view.window);
|
||||
bool tapSetup = false;
|
||||
if (_dimmingTapRecognizer != nil)
|
||||
{
|
||||
for (UIGestureRecognizer *recognizer in dimmingView.gestureRecognizers)
|
||||
{
|
||||
if (recognizer == _dimmingTapRecognizer)
|
||||
{
|
||||
tapSetup = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tapSetup)
|
||||
{
|
||||
_dimmingTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dimmingViewTapped:)];
|
||||
[dimmingView addGestureRecognizer:_dimmingTapRecognizer];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dimmingViewTapped:(UITapGestureRecognizer *)recognizer
|
||||
@@ -931,74 +847,16 @@ TGNavigationController *findNavigationController()
|
||||
|
||||
- (void)updateInteractiveTransition:(CGFloat)percentComplete
|
||||
{
|
||||
TGNavigationController *navigationController = findNavigationController();
|
||||
if (navigationController != nil)
|
||||
{
|
||||
if (!navigationController.disableInteractiveKeyboardTransition && [TGHacks applicationKeyboardWindow] != nil && ![TGHacks applicationKeyboardWindow].hidden)
|
||||
{
|
||||
CGSize screenSize = [TGViewController screenSizeForInterfaceOrientation:navigationController.interfaceOrientation];
|
||||
CGFloat keyboardOffset = MAX(0.0f, percentComplete * screenSize.width);
|
||||
|
||||
UIView *keyboardView = [TGHacks applicationKeyboardView];
|
||||
CGRect keyboardViewFrame = keyboardView.frame;
|
||||
keyboardViewFrame.origin.x = keyboardOffset;
|
||||
|
||||
keyboardView.frame = keyboardViewFrame;
|
||||
}
|
||||
}
|
||||
|
||||
[super updateInteractiveTransition:percentComplete];
|
||||
}
|
||||
|
||||
- (void)finishInteractiveTransition
|
||||
{
|
||||
CGFloat value = self.percentComplete;
|
||||
UIView *keyboardView = [TGHacks applicationKeyboardView];
|
||||
CGRect keyboardViewFrame = keyboardView.frame;
|
||||
|
||||
[super finishInteractiveTransition];
|
||||
|
||||
TGNavigationController *navigationController = findNavigationController();
|
||||
if (navigationController != nil)
|
||||
{
|
||||
if (!navigationController.disableInteractiveKeyboardTransition)
|
||||
{
|
||||
keyboardView.frame = keyboardViewFrame;
|
||||
|
||||
CGSize screenSize = [TGViewController screenSizeForInterfaceOrientation:navigationController.interfaceOrientation];
|
||||
CGFloat keyboardOffset = 1.0f * screenSize.width;
|
||||
|
||||
keyboardViewFrame.origin.x = keyboardOffset;
|
||||
NSTimeInterval duration = (1.0 - value) * [navigationController myNominalTransitionAnimationDuration];
|
||||
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveLinear animations:^
|
||||
{
|
||||
keyboardView.frame = keyboardViewFrame;
|
||||
} completion:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelInteractiveTransition
|
||||
{
|
||||
CGFloat value = self.percentComplete;
|
||||
|
||||
TGNavigationController *navigationController = findNavigationController();
|
||||
if (navigationController != nil)
|
||||
{
|
||||
if (!navigationController.disableInteractiveKeyboardTransition && [TGHacks applicationKeyboardWindow] != nil && ![TGHacks applicationKeyboardWindow].hidden)
|
||||
{
|
||||
UIView *keyboardView = [TGHacks applicationKeyboardView];
|
||||
CGRect keyboardViewFrame = keyboardView.frame;
|
||||
keyboardViewFrame.origin.x = 0.0f;
|
||||
|
||||
NSTimeInterval duration = value * [navigationController myNominalTransitionAnimationDuration];
|
||||
[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveLinear animations:^
|
||||
{
|
||||
keyboardView.frame = keyboardViewFrame;
|
||||
} completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
[super cancelInteractiveTransition];
|
||||
}
|
||||
|
||||
|
||||
@@ -68,28 +68,7 @@
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
static NSArray *nonRotateableWindowClasses = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^
|
||||
{
|
||||
NSMutableArray *array = [[NSMutableArray alloc] init];
|
||||
Class alertClass = NSClassFromString(TGEncodeText(@"`VJBmfsuPwfsmbzXjoepx", -1));
|
||||
if (alertClass != nil)
|
||||
[array addObject:alertClass];
|
||||
|
||||
nonRotateableWindowClasses = array;
|
||||
});
|
||||
|
||||
for (UIWindow *window in [[LegacyComponentsGlobals provider] applicationWindows].reverseObjectEnumerator)
|
||||
{
|
||||
for (Class classInfo in nonRotateableWindowClasses)
|
||||
{
|
||||
if ([window isKindOfClass:classInfo])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
UIViewController *rootController = [[LegacyComponentsGlobals provider] applicationWindows].firstObject.rootViewController;
|
||||
|
||||
if (rootController.presentedViewController != nil)
|
||||
|
||||
@@ -695,7 +695,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
||||
{
|
||||
float additionalKeyboardHeight = [self _keyboardAdditionalDeltaHeightWhenRotatingFrom:_viewControllerRotatingFromOrientation toOrientation:toInterfaceOrientation];
|
||||
|
||||
CGFloat statusBarHeight = [TGHacks statusBarHeightForOrientation:toInterfaceOrientation];
|
||||
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
|
||||
[self _updateControllerInsetForOrientation:toInterfaceOrientation statusBarHeight:statusBarHeight keyboardHeight:[self _currentKeyboardHeight:toInterfaceOrientation] + additionalKeyboardHeight force:false notify:true];
|
||||
}
|
||||
|
||||
@@ -768,9 +768,6 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
||||
if ([self isViewLoaded] && !_viewControllerHasEverAppeared && ([self findFirstResponder:self.view] == nil && ![self willCaptureInputShortly]))
|
||||
return 0.0f;
|
||||
|
||||
if ([TGHacks isKeyboardVisible])
|
||||
return [TGHacks keyboardHeightForOrientation:orientation];
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -1264,7 +1261,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
||||
if (navigationBarHidden != self.navigationController.navigationBarHidden)
|
||||
{
|
||||
CGFloat barHeight = [self navigationBarHeightForInterfaceOrientation:self.interfaceOrientation];
|
||||
CGFloat statusBarHeight = [TGHacks statusBarHeightForOrientation:self.interfaceOrientation];
|
||||
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
|
||||
if ([self shouldIgnoreStatusBarInOrientation:self.interfaceOrientation])
|
||||
statusBarHeight = 0.0f;
|
||||
|
||||
@@ -1435,13 +1432,6 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
||||
if (TGIsPad() && iosMajorVersion() >= 7)
|
||||
viewControllerToPresent.preferredContentSize = [self.navigationController preferredContentSize];
|
||||
|
||||
if ([viewControllerToPresent isKindOfClass:[TGNavigationController class]])
|
||||
{
|
||||
TGNavigationController *navController = (TGNavigationController *)self.navigationController;
|
||||
if (navController.showCallStatusBar)
|
||||
[(TGNavigationController *)viewControllerToPresent setShowCallStatusBar:true];
|
||||
}
|
||||
|
||||
if (iosMajorVersion() >= 8 && self.presentedViewController != nil && [self.presentedViewController isKindOfClass:[UIAlertController class]])
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
|
||||
Reference in New Issue
Block a user