mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
API updates
This commit is contained in:
parent
e2e669e74b
commit
2a09dda7d9
@ -2,7 +2,7 @@ import Foundation
|
|||||||
import UIKitRuntimeUtils
|
import UIKitRuntimeUtils
|
||||||
|
|
||||||
public enum Keyboard {
|
public enum Keyboard {
|
||||||
public static func applyAutocorrection() {
|
public static func applyAutocorrection(textView: UITextView) {
|
||||||
applyKeyboardAutocorrection()
|
applyKeyboardAutocorrection(textView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,14 +117,6 @@ private func containedLayoutForWindowLayout(_ layout: WindowLayout, deviceMetric
|
|||||||
return ContainerViewLayout(size: layout.size, metrics: layout.metrics, deviceMetrics: deviceMetrics, intrinsicInsets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: layout.onScreenNavigationHeight ?? 0.0, right: 0.0), safeInsets: resolvedSafeInsets, additionalInsets: UIEdgeInsets(), statusBarHeight: resolvedStatusBarHeight, inputHeight: updatedInputHeight, inputHeightIsInteractivellyChanging: layout.upperKeyboardInputPositionBound != nil && layout.upperKeyboardInputPositionBound != layout.size.height && layout.inputHeight != nil, inVoiceOver: layout.inVoiceOver)
|
return ContainerViewLayout(size: layout.size, metrics: layout.metrics, deviceMetrics: deviceMetrics, intrinsicInsets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: layout.onScreenNavigationHeight ?? 0.0, right: 0.0), safeInsets: resolvedSafeInsets, additionalInsets: UIEdgeInsets(), statusBarHeight: resolvedStatusBarHeight, inputHeight: updatedInputHeight, inputHeightIsInteractivellyChanging: layout.upperKeyboardInputPositionBound != nil && layout.upperKeyboardInputPositionBound != layout.size.height && layout.inputHeight != nil, inVoiceOver: layout.inVoiceOver)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func encodeText(_ string: String, _ key: Int) -> String {
|
|
||||||
var result = ""
|
|
||||||
for c in string.unicodeScalars {
|
|
||||||
result.append(Character(UnicodeScalar(UInt32(Int(c.value) + key))!))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
public func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UIView, keyboardOnly: Bool = false) -> Bool {
|
public func doesViewTreeDisableInteractiveTransitionGestureRecognizer(_ view: UIView, keyboardOnly: Bool = false) -> Bool {
|
||||||
if view.disablesInteractiveTransitionGestureRecognizer && !keyboardOnly {
|
if view.disablesInteractiveTransitionGestureRecognizer && !keyboardOnly {
|
||||||
return true
|
return true
|
||||||
|
@ -46,8 +46,6 @@
|
|||||||
|
|
||||||
- (instancetype)initWithKeyCommandController:(TGKeyCommandController *)keyCommandController;
|
- (instancetype)initWithKeyCommandController:(TGKeyCommandController *)keyCommandController;
|
||||||
|
|
||||||
+ (void)addTextViewMethods;
|
|
||||||
|
|
||||||
- (void)textViewEnsureSelectionVisible;
|
- (void)textViewEnsureSelectionVisible;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -30,16 +30,9 @@ typedef enum {
|
|||||||
+ (void)setSecondaryAnimationDurationFactor:(float)factor;
|
+ (void)setSecondaryAnimationDurationFactor:(float)factor;
|
||||||
+ (void)setForceSystemCurve:(bool)forceSystemCurve;
|
+ (void)setForceSystemCurve:(bool)forceSystemCurve;
|
||||||
|
|
||||||
+ (CGFloat)applicationStatusBarOffset;
|
|
||||||
+ (void)setApplicationStatusBarOffset:(CGFloat)offset;
|
|
||||||
+ (void)animateApplicationStatusBarStyleTransitionWithDuration:(NSTimeInterval)duration;
|
|
||||||
+ (CGFloat)statusBarHeightForOrientation:(UIInterfaceOrientation)orientation;
|
|
||||||
|
|
||||||
+ (bool)isKeyboardVisible;
|
+ (bool)isKeyboardVisible;
|
||||||
+ (CGFloat)keyboardHeightForOrientation:(UIInterfaceOrientation)orientation;
|
+ (void)applyCurrentKeyboardAutocorrectionVariant:(UITextView *)textView;
|
||||||
+ (void)applyCurrentKeyboardAutocorrectionVariant;
|
|
||||||
+ (UIWindow *)applicationKeyboardWindow;
|
+ (UIWindow *)applicationKeyboardWindow;
|
||||||
+ (UIView *)applicationKeyboardView;
|
|
||||||
+ (void)setApplicationKeyboardOffset:(CGFloat)offset;
|
+ (void)setApplicationKeyboardOffset:(CGFloat)offset;
|
||||||
|
|
||||||
+ (void)forcePerformWithAnimation:(dispatch_block_t)block;
|
+ (void)forcePerformWithAnimation:(dispatch_block_t)block;
|
||||||
|
@ -63,12 +63,6 @@ NSString *TGMentionBoldAttributeName = @"TGMentionBoldAttributeName";
|
|||||||
|
|
||||||
- (void)commonInitialiser
|
- (void)commonInitialiser
|
||||||
{
|
{
|
||||||
static dispatch_once_t onceToken;
|
|
||||||
dispatch_once(&onceToken, ^
|
|
||||||
{
|
|
||||||
[HPTextViewInternal addTextViewMethods];
|
|
||||||
});
|
|
||||||
|
|
||||||
CGRect frame = self.frame;
|
CGRect frame = self.frame;
|
||||||
frame.origin = CGPointZero;
|
frame.origin = CGPointZero;
|
||||||
_internalTextView = [[HPTextViewInternal alloc] initWithKeyCommandController:_keyCommandController];
|
_internalTextView = [[HPTextViewInternal alloc] initWithKeyCommandController:_keyCommandController];
|
||||||
|
@ -29,15 +29,6 @@
|
|||||||
return self;
|
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
|
- (void)setText:(NSString *)text
|
||||||
{
|
{
|
||||||
BOOL originalValue = self.scrollEnabled;
|
BOOL originalValue = self.scrollEnabled;
|
||||||
@ -64,25 +55,6 @@
|
|||||||
[super setScrollEnabled:isScrollable];
|
[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
|
- (void)scrollRectToVisible:(CGRect)__unused rect animated:(BOOL)__unused animated
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ void TGLegacyLog(NSString *format, ...);
|
|||||||
int iosMajorVersion();
|
int iosMajorVersion();
|
||||||
int iosMinorVersion();
|
int iosMinorVersion();
|
||||||
|
|
||||||
NSString *TGEncodeText(NSString *string, int key);
|
|
||||||
|
|
||||||
void TGDispatchOnMainThread(dispatch_block_t block);
|
void TGDispatchOnMainThread(dispatch_block_t block);
|
||||||
void TGDispatchAfter(double delay, dispatch_queue_t queue, dispatch_block_t block);
|
void TGDispatchAfter(double delay, dispatch_queue_t queue, dispatch_block_t block);
|
||||||
|
|
||||||
|
@ -70,20 +70,6 @@ int iosMinorVersion()
|
|||||||
return version;
|
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()
|
int deviceMemorySize()
|
||||||
{
|
{
|
||||||
static int memorySize = 0;
|
static int memorySize = 0;
|
||||||
|
@ -215,209 +215,6 @@ void InjectInstanceMethodFromAnotherClass(Class toClass, Class fromClass, SEL fr
|
|||||||
window.alpha = alpha;
|
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
|
+ (bool)isKeyboardVisible
|
||||||
{
|
{
|
||||||
return [self isKeyboardVisibleAlt];
|
return [self isKeyboardVisibleAlt];
|
||||||
@ -445,66 +242,9 @@ static bool keyboardHidden = true;
|
|||||||
return !keyboardHidden;
|
return !keyboardHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (CGFloat)keyboardHeightForOrientation:(UIInterfaceOrientation)orientation
|
+ (void)applyCurrentKeyboardAutocorrectionVariant:(UITextView *)textView
|
||||||
{
|
{
|
||||||
static NSInvocation *invocation = nil;
|
[textView unmarkText];
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (UIWindow *)applicationKeyboardWindow
|
+ (UIWindow *)applicationKeyboardWindow
|
||||||
@ -518,32 +258,6 @@ static bool keyboardHidden = true;
|
|||||||
keyboardWindow.frame = CGRectOffset(keyboardWindow.bounds, 0.0f, offset);
|
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
|
+ (void)setForceMovieAnimatedScaleMode:(bool)force
|
||||||
{
|
{
|
||||||
forceMovieAnimatedScaleMode = force;
|
forceMovieAnimatedScaleMode = force;
|
||||||
|
@ -1407,8 +1407,8 @@
|
|||||||
if (_searchController == nil)
|
if (_searchController == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UIView *backArrow = [self _findBackArrow:self.navigationBar];
|
UIView *backArrow = nil;
|
||||||
UIView *backButton = [self _findBackButton:self.navigationBar parentView:self.navigationBar];
|
UIView *backButton = nil;
|
||||||
|
|
||||||
if ([viewController isKindOfClass:[TGPhotoEditorController class]])
|
if ([viewController isKindOfClass:[TGPhotoEditorController class]])
|
||||||
{
|
{
|
||||||
@ -1440,50 +1440,13 @@
|
|||||||
_searchSnapshotView = nil;
|
_searchSnapshotView = nil;
|
||||||
_searchController.view.hidden = false;
|
_searchController.view.hidden = false;
|
||||||
|
|
||||||
UIView *backArrow = [self _findBackArrow:self.navigationBar];
|
UIView *backArrow = nil;
|
||||||
UIView *backButton = [self _findBackButton:self.navigationBar parentView:self.navigationBar];
|
UIView *backButton = nil;
|
||||||
backArrow.alpha = 1.0f;
|
backArrow.alpha = 1.0f;
|
||||||
backButton.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 -
|
#pragma mark -
|
||||||
|
|
||||||
+ (TGMediaAssetType)assetTypeForIntent:(TGMediaAssetsControllerIntent)intent
|
+ (TGMediaAssetType)assetTypeForIntent:(TGMediaAssetsControllerIntent)intent
|
||||||
|
@ -252,7 +252,7 @@ static void setViewFrame(UIView *view, CGRect frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_inputField.internalTextView.isFirstResponder)
|
if (_inputField.internalTextView.isFirstResponder)
|
||||||
[TGHacks applyCurrentKeyboardAutocorrectionVariant];
|
[TGHacks applyCurrentKeyboardAutocorrectionVariant:_inputField.internalTextView];
|
||||||
|
|
||||||
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString:_inputField.text == nil ? [[NSAttributedString alloc] initWithString:@""] : _inputField.attributedText];
|
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString:_inputField.text == nil ? [[NSAttributedString alloc] initWithString:@""] : _inputField.attributedText];
|
||||||
NSMutableString *usualString = [text.string mutableCopy];
|
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
|
- (void)setupStatusBarOnControllers:(NSArray *)controllers
|
||||||
{
|
{
|
||||||
if ([[self navigationBar] isKindOfClass:[TGNavigationBar class]])
|
if ([[self navigationBar] isKindOfClass:[TGNavigationBar class]])
|
||||||
@ -416,11 +382,6 @@
|
|||||||
TGViewController *viewController = (TGViewController *)maybeController;
|
TGViewController *viewController = (TGViewController *)maybeController;
|
||||||
[viewController setAdditionalStatusBarHeight:_currentAdditionalStatusBarHeight];
|
[viewController setAdditionalStatusBarHeight:_currentAdditionalStatusBarHeight];
|
||||||
[viewController setNeedsStatusBarAppearanceUpdate];
|
[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)])
|
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
|
- (void)viewDidAppear:(BOOL)animated
|
||||||
{
|
{
|
||||||
[super viewDidAppear: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
|
- (void)dimmingViewTapped:(UITapGestureRecognizer *)recognizer
|
||||||
@ -931,74 +847,16 @@ TGNavigationController *findNavigationController()
|
|||||||
|
|
||||||
- (void)updateInteractiveTransition:(CGFloat)percentComplete
|
- (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];
|
[super updateInteractiveTransition:percentComplete];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)finishInteractiveTransition
|
- (void)finishInteractiveTransition
|
||||||
{
|
{
|
||||||
CGFloat value = self.percentComplete;
|
|
||||||
UIView *keyboardView = [TGHacks applicationKeyboardView];
|
|
||||||
CGRect keyboardViewFrame = keyboardView.frame;
|
|
||||||
|
|
||||||
[super finishInteractiveTransition];
|
[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
|
- (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];
|
[super cancelInteractiveTransition];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,27 +69,6 @@
|
|||||||
|
|
||||||
- (BOOL)shouldAutorotate
|
- (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;
|
UIViewController *rootController = [[LegacyComponentsGlobals provider] applicationWindows].firstObject.rootViewController;
|
||||||
|
|
||||||
if (rootController.presentedViewController != nil)
|
if (rootController.presentedViewController != nil)
|
||||||
|
@ -695,7 +695,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
|||||||
{
|
{
|
||||||
float additionalKeyboardHeight = [self _keyboardAdditionalDeltaHeightWhenRotatingFrom:_viewControllerRotatingFromOrientation toOrientation:toInterfaceOrientation];
|
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];
|
[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]))
|
if ([self isViewLoaded] && !_viewControllerHasEverAppeared && ([self findFirstResponder:self.view] == nil && ![self willCaptureInputShortly]))
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
if ([TGHacks isKeyboardVisible])
|
|
||||||
return [TGHacks keyboardHeightForOrientation:orientation];
|
|
||||||
|
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,7 +1261,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
|||||||
if (navigationBarHidden != self.navigationController.navigationBarHidden)
|
if (navigationBarHidden != self.navigationController.navigationBarHidden)
|
||||||
{
|
{
|
||||||
CGFloat barHeight = [self navigationBarHeightForInterfaceOrientation:self.interfaceOrientation];
|
CGFloat barHeight = [self navigationBarHeightForInterfaceOrientation:self.interfaceOrientation];
|
||||||
CGFloat statusBarHeight = [TGHacks statusBarHeightForOrientation:self.interfaceOrientation];
|
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
|
||||||
if ([self shouldIgnoreStatusBarInOrientation:self.interfaceOrientation])
|
if ([self shouldIgnoreStatusBarInOrientation:self.interfaceOrientation])
|
||||||
statusBarHeight = 0.0f;
|
statusBarHeight = 0.0f;
|
||||||
|
|
||||||
@ -1435,13 +1432,6 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
|||||||
if (TGIsPad() && iosMajorVersion() >= 7)
|
if (TGIsPad() && iosMajorVersion() >= 7)
|
||||||
viewControllerToPresent.preferredContentSize = [self.navigationController preferredContentSize];
|
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]])
|
if (iosMajorVersion() >= 8 && self.presentedViewController != nil && [self.presentedViewController isKindOfClass:[UIAlertController class]])
|
||||||
{
|
{
|
||||||
dispatch_async(dispatch_get_main_queue(), ^
|
dispatch_async(dispatch_get_main_queue(), ^
|
||||||
|
@ -67,25 +67,25 @@ private final class LegacyComponentsAccessCheckerImpl: NSObject, LegacyComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func encodeText(_ string: String, _ key: Int) -> String {
|
private func isKeyboardWindow(window: NSObject) -> Bool {
|
||||||
var result = ""
|
let typeName = NSStringFromClass(type(of: window))
|
||||||
for c in string.unicodeScalars {
|
|
||||||
result.append(Character(UnicodeScalar(UInt32(Int(c.value) + key))!))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
private let keyboardWindowClass: AnyClass? = {
|
|
||||||
if #available(iOS 9.0, *) {
|
if #available(iOS 9.0, *) {
|
||||||
return NSClassFromString(encodeText("VJSfnpufLfzcpbseXjoepx", -1))
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("RemoteKeyboardWindow") {
|
||||||
} else {
|
return true
|
||||||
return NSClassFromString(encodeText("VJUfyuFggfdutXjoepx", -1))
|
}
|
||||||
|
} else {
|
||||||
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("TextEffectsWindow") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
|
||||||
private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyComponentsGlobalsProvider {
|
private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyComponentsGlobalsProvider {
|
||||||
func log(_ string: String!) {
|
func log(_ string: String!) {
|
||||||
print(string)
|
if let string = string {
|
||||||
|
print("\(string)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func effectiveLocalization() -> TGLocalization! {
|
public func effectiveLocalization() -> TGLocalization! {
|
||||||
@ -101,12 +101,8 @@ private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyCompone
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func applicationKeyboardWindow() -> UIWindow! {
|
public func applicationKeyboardWindow() -> UIWindow! {
|
||||||
guard let keyboardWindowClass = keyboardWindowClass else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for window in legacyComponentsApplication?.windows ?? [] {
|
for window in legacyComponentsApplication?.windows ?? [] {
|
||||||
if window.isKind(of: keyboardWindowClass) {
|
if isKeyboardWindow(window: window) {
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,24 +45,35 @@ private let handleVoipNotifications = false
|
|||||||
|
|
||||||
private var testIsLaunched = false
|
private var testIsLaunched = false
|
||||||
|
|
||||||
private func encodeText(_ string: String, _ key: Int) -> String {
|
private func isKeyboardWindow(window: NSObject) -> Bool {
|
||||||
var result = ""
|
let typeName = NSStringFromClass(type(of: window))
|
||||||
for c in string.unicodeScalars {
|
|
||||||
result.append(Character(UnicodeScalar(UInt32(Int(c.value) + key))!))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
private let keyboardViewClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuIptuWjfx", -1))!
|
|
||||||
private let keyboardViewContainerClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuDpoubjofsWjfx", -1))!
|
|
||||||
|
|
||||||
private let keyboardWindowClass: AnyClass? = {
|
|
||||||
if #available(iOS 9.0, *) {
|
if #available(iOS 9.0, *) {
|
||||||
return NSClassFromString(encodeText("VJSfnpufLfzcpbseXjoepx", -1))
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("RemoteKeyboardWindow") {
|
||||||
} else {
|
return true
|
||||||
return NSClassFromString(encodeText("VJUfyuFggfdutXjoepx", -1))
|
}
|
||||||
|
} else {
|
||||||
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("TextEffectsWindow") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private func isKeyboardView(view: NSObject) -> Bool {
|
||||||
|
let typeName = NSStringFromClass(type(of: view))
|
||||||
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("InputSetHostView") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private func isKeyboardViewContainer(view: NSObject) -> Bool {
|
||||||
|
let typeName = NSStringFromClass(type(of: view))
|
||||||
|
if typeName.hasPrefix("UI") && typeName.hasSuffix("InputSetContainerView") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
|
|
||||||
private class ApplicationStatusBarHost: StatusBarHost {
|
private class ApplicationStatusBarHost: StatusBarHost {
|
||||||
private let application = UIApplication.shared
|
private let application = UIApplication.shared
|
||||||
@ -96,12 +107,8 @@ private class ApplicationStatusBarHost: StatusBarHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keyboardWindow: UIWindow? {
|
var keyboardWindow: UIWindow? {
|
||||||
guard let keyboardWindowClass = keyboardWindowClass else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for window in UIApplication.shared.windows {
|
for window in UIApplication.shared.windows {
|
||||||
if window.isKind(of: keyboardWindowClass) {
|
if isKeyboardWindow(window: window) {
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,14 +116,14 @@ private class ApplicationStatusBarHost: StatusBarHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var keyboardView: UIView? {
|
var keyboardView: UIView? {
|
||||||
guard let keyboardWindow = self.keyboardWindow, let keyboardViewContainerClass = keyboardViewContainerClass, let keyboardViewClass = keyboardViewClass else {
|
guard let keyboardWindow = self.keyboardWindow else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for view in keyboardWindow.subviews {
|
for view in keyboardWindow.subviews {
|
||||||
if view.isKind(of: keyboardViewContainerClass) {
|
if isKeyboardViewContainer(view: view) {
|
||||||
for subview in view.subviews {
|
for subview in view.subviews {
|
||||||
if subview.isKind(of: keyboardViewClass) {
|
if isKeyboardView(view: subview) {
|
||||||
return subview
|
return subview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2276,8 +2276,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
|
|
||||||
func sendCurrentMessage(silentPosting: Bool? = nil, scheduleTime: Int32? = nil, completion: @escaping () -> Void = {}) {
|
func sendCurrentMessage(silentPosting: Bool? = nil, scheduleTime: Int32? = nil, completion: @escaping () -> Void = {}) {
|
||||||
if let textInputPanelNode = self.inputPanelNode as? ChatTextInputPanelNode {
|
if let textInputPanelNode = self.inputPanelNode as? ChatTextInputPanelNode {
|
||||||
if textInputPanelNode.textInputNode?.isFirstResponder() ?? false {
|
if let textInputNode = textInputPanelNode.textInputNode, textInputNode.isFirstResponder() {
|
||||||
Keyboard.applyAutocorrection()
|
Keyboard.applyAutocorrection(textView: textInputNode.textView)
|
||||||
}
|
}
|
||||||
|
|
||||||
var effectivePresentationInterfaceState = self.chatPresentationInterfaceState
|
var effectivePresentationInterfaceState = self.chatPresentationInterfaceState
|
||||||
|
@ -6161,8 +6161,6 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
|
|
||||||
private var canOpenAvatarByDragging = false
|
private var canOpenAvatarByDragging = false
|
||||||
|
|
||||||
private let velocityKey: String = encodeText("`wfsujdbmWfmpdjuz", -1)
|
|
||||||
|
|
||||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||||
if self.ignoreScrolling {
|
if self.ignoreScrolling {
|
||||||
return
|
return
|
||||||
@ -6171,7 +6169,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
|||||||
if !self.state.isEditing {
|
if !self.state.isEditing {
|
||||||
if self.canAddVelocity {
|
if self.canAddVelocity {
|
||||||
self.previousVelocityM1 = self.previousVelocity
|
self.previousVelocityM1 = self.previousVelocity
|
||||||
if let value = (scrollView.value(forKey: self.velocityKey) as? NSNumber)?.doubleValue {
|
if let value = (scrollView.value(forKey: (["_", "verticalVelocity"] as [String]).joined()) as? NSNumber)?.doubleValue {
|
||||||
self.previousVelocity = CGFloat(value)
|
self.previousVelocity = CGFloat(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6985,14 +6983,6 @@ private final class PeerInfoNavigationTransitionNode: ASDisplayNode, CustomNavig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func encodeText(_ string: String, _ key: Int) -> String {
|
|
||||||
var result = ""
|
|
||||||
for c in string.unicodeScalars {
|
|
||||||
result.append(Character(UnicodeScalar(UInt32(Int(c.value) + key))!))
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
private final class ContextControllerContentSourceImpl: ContextControllerContentSource {
|
private final class ContextControllerContentSourceImpl: ContextControllerContentSource {
|
||||||
let controller: ViewController
|
let controller: ViewController
|
||||||
weak var sourceNode: ASDisplayNode?
|
weak var sourceNode: ASDisplayNode?
|
||||||
|
@ -84,38 +84,10 @@ CGFloat springAnimationValueAtImpl(CABasicAnimation * _Nonnull animation, CGFloa
|
|||||||
|
|
||||||
@interface CustomBlurEffect : UIBlurEffect
|
@interface CustomBlurEffect : UIBlurEffect
|
||||||
|
|
||||||
/*@property (nonatomic) double blurRadius;
|
|
||||||
@property (nonatomic) double colorBurnTintAlpha;
|
|
||||||
@property (nonatomic) double colorBurnTintLevel;
|
|
||||||
@property (nonatomic, retain) UIColor *colorTint;
|
|
||||||
@property (nonatomic) double colorTintAlpha;
|
|
||||||
@property (nonatomic) bool darkenWithSourceOver;
|
|
||||||
@property (nonatomic) double darkeningTintAlpha;
|
|
||||||
@property (nonatomic) double darkeningTintHue;
|
|
||||||
@property (nonatomic) double darkeningTintSaturation;
|
|
||||||
@property (nonatomic) double grayscaleTintAlpha;
|
|
||||||
@property (nonatomic) double grayscaleTintLevel;
|
|
||||||
@property (nonatomic) bool lightenGrayscaleWithSourceOver;
|
|
||||||
@property (nonatomic) double saturationDeltaFactor;
|
|
||||||
@property (nonatomic) double scale;
|
|
||||||
@property (nonatomic) double zoom;*/
|
|
||||||
|
|
||||||
+ (id)effectWithStyle:(long long)arg1;
|
+ (id)effectWithStyle:(long long)arg1;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static NSString *encodeText(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setField(CustomBlurEffect *object, NSString *name, double value) {
|
static void setField(CustomBlurEffect *object, NSString *name, double value) {
|
||||||
SEL selector = NSSelectorFromString(name);
|
SEL selector = NSSelectorFromString(name);
|
||||||
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
|
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
|
||||||
@ -145,7 +117,7 @@ static void setNilField(CustomBlurEffect *object, NSString *name) {
|
|||||||
[inv invoke];
|
[inv invoke];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBoolField(CustomBlurEffect *object, NSString *name, BOOL value) {
|
static void setBoolField(NSObject *object, NSString *name, BOOL value) {
|
||||||
SEL selector = NSSelectorFromString(name);
|
SEL selector = NSSelectorFromString(name);
|
||||||
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
|
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
|
||||||
if (signature == nil) {
|
if (signature == nil) {
|
||||||
@ -170,18 +142,17 @@ UIBlurEffect *makeCustomZoomBlurEffectImpl(bool isLight) {
|
|||||||
NSString *string = [@[@"_", @"UI", @"Custom", @"BlurEffect"] componentsJoinedByString:@""];
|
NSString *string = [@[@"_", @"UI", @"Custom", @"BlurEffect"] componentsJoinedByString:@""];
|
||||||
CustomBlurEffect *result = (CustomBlurEffect *)[NSClassFromString(string) effectWithStyle:0];
|
CustomBlurEffect *result = (CustomBlurEffect *)[NSClassFromString(string) effectWithStyle:0];
|
||||||
|
|
||||||
setField(result, encodeText(@"tfuCmvsSbejvt;", -1), 10.0);
|
setField(result, [@[@"set", @"BlurRadius", @":"] componentsJoinedByString:@""], 10.0);
|
||||||
//setField(result, encodeText(@"tfu[ppn;", -1), 0.015);
|
setNilField(result, [@[@"set", @"Color", @"Tint", @":"] componentsJoinedByString:@""]);
|
||||||
setNilField(result, encodeText(@"tfuDpmpsUjou;", -1));
|
setField(result, [@[@"set", @"Color", @"Tint", @"Alpha", @":"] componentsJoinedByString:@""], 0.0);
|
||||||
setField(result, encodeText(@"tfuDpmpsUjouBmqib;", -1), 0.0);
|
setField(result, [@[@"set", @"Darkening", @"Tint", @"Alpha", @":"] componentsJoinedByString:@""], 0.0);
|
||||||
setField(result, encodeText(@"tfuEbslfojohUjouBmqib;", -1), 0.0);
|
setField(result, [@[@"set", @"Grayscale", @"Tint", @"Alpha", @":"] componentsJoinedByString:@""], 0.0);
|
||||||
setField(result, encodeText(@"tfuHsbztdbmfUjouBmqib;", -1), 0.0);
|
setField(result, [@[@"set", @"Saturation", @"Delta", @"Factor", @":"] componentsJoinedByString:@""], 1.0);
|
||||||
setField(result, encodeText(@"tfuTbuvsbujpoEfmubGbdups;", -1), 1.0);
|
|
||||||
|
|
||||||
if ([UIScreen mainScreen].scale > 2.5f) {
|
if ([UIScreen mainScreen].scale > 2.5f) {
|
||||||
setField(result, encodeText(@"setScale:", 0), 0.3);
|
setField(result, @"setScale:", 0.3);
|
||||||
} else {
|
} else {
|
||||||
setField(result, encodeText(@"setScale:", 0), 0.5);
|
setField(result, @"setScale:", 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -191,7 +162,9 @@ UIBlurEffect *makeCustomZoomBlurEffectImpl(bool isLight) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void applySmoothRoundedCornersImpl(CALayer * _Nonnull layer) {
|
void applySmoothRoundedCornersImpl(CALayer * _Nonnull layer) {
|
||||||
if (@available(iOS 11.0, *)) {
|
if (@available(iOS 13.0, *)) {
|
||||||
setBoolField(layer, encodeText(@"tfuDpoujovpvtDpsofst;", -1), true);
|
layer.cornerCurve = kCACornerCurveContinuous;
|
||||||
|
} else {
|
||||||
|
setBoolField(layer, [@[@"set", @"Continuous", @"Corners", @":"] componentsJoinedByString:@""], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ typedef NS_OPTIONS(NSUInteger, UIResponderDisableAutomaticKeyboardHandling) {
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
void applyKeyboardAutocorrection();
|
void applyKeyboardAutocorrection(UITextView * _Nonnull textView);
|
||||||
|
|
||||||
@interface AboveStatusBarWindow : UIWindow
|
@interface AboveStatusBarWindow : UIWindow
|
||||||
|
|
||||||
|
@ -316,28 +316,8 @@ static NSString *TGEncodeText(NSString *string, int key)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyKeyboardAutocorrection() {
|
void applyKeyboardAutocorrection(UITextView * _Nonnull textView) {
|
||||||
static Class keyboardClass = NULL;
|
[textView unmarkText];
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface AboveStatusBarWindowController : UIViewController
|
@interface AboveStatusBarWindowController : UIViewController
|
||||||
|
Loading…
x
Reference in New Issue
Block a user