mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix keyboard
This commit is contained in:
parent
ba3d2a2430
commit
d27fb1fdce
@ -2574,8 +2574,6 @@
|
|||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
stopOnEveryThreadSanitizerIssue = "YES"
|
|
||||||
stopOnEveryMainThreadCheckerIssue = "YES"
|
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable
|
<BuildableProductRunnable
|
||||||
|
@ -50,8 +50,7 @@ private func fetchRawData(prefix: String) -> Signal<Data, FetchError> {
|
|||||||
public func cloudDataAdditionalAddressSource(phoneNumber: Signal<String?, NoError>) -> Signal<MTBackupDatacenterData, NoError> {
|
public func cloudDataAdditionalAddressSource(phoneNumber: Signal<String?, NoError>) -> Signal<MTBackupDatacenterData, NoError> {
|
||||||
return phoneNumber
|
return phoneNumber
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> mapToSignal { _ -> Signal<MTBackupDatacenterData, NoError> in
|
|> mapToSignal { phoneNumber -> Signal<MTBackupDatacenterData, NoError> in
|
||||||
let phoneNumber: String? = "7950"
|
|
||||||
var prefix = ""
|
var prefix = ""
|
||||||
if let phoneNumber = phoneNumber, phoneNumber.count >= 1 {
|
if let phoneNumber = phoneNumber, phoneNumber.count >= 1 {
|
||||||
prefix = String(phoneNumber[phoneNumber.startIndex ..< phoneNumber.index(after: phoneNumber.startIndex)])
|
prefix = String(phoneNumber[phoneNumber.startIndex ..< phoneNumber.index(after: phoneNumber.startIndex)])
|
||||||
|
@ -83,7 +83,7 @@ private final class AuthorizationSequenceCountrySelectionNavigationContentNode:
|
|||||||
self.addSubnode(self.searchBar)
|
self.addSubnode(self.searchBar)
|
||||||
|
|
||||||
self.searchBar.cancel = { [weak self] in
|
self.searchBar.cancel = { [weak self] in
|
||||||
self?.searchBar.deactivate(clear: false)
|
//self?.searchBar.deactivate(clear: false)
|
||||||
self?.cancel()
|
self?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +159,8 @@ public final class AuthorizationSequenceCountrySelectionController: ViewControll
|
|||||||
|
|
||||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: theme), strings: NavigationBarStrings(presentationStrings: strings)))
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: theme), strings: NavigationBarStrings(presentationStrings: strings)))
|
||||||
|
|
||||||
|
self.navigationPresentation = .modal
|
||||||
|
|
||||||
self.statusBar.statusBarStyle = theme.rootController.statusBarStyle.style
|
self.statusBar.statusBarStyle = theme.rootController.statusBarStyle.style
|
||||||
|
|
||||||
let navigationContentNode = AuthorizationSequenceCountrySelectionNavigationContentNode(theme: theme, strings: strings, cancel: { [weak self] in
|
let navigationContentNode = AuthorizationSequenceCountrySelectionNavigationContentNode(theme: theme, strings: strings, cancel: { [weak self] in
|
||||||
@ -191,7 +193,6 @@ public final class AuthorizationSequenceCountrySelectionController: ViewControll
|
|||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
|
|
||||||
self.controllerNode.animateIn()
|
|
||||||
self.navigationContentNode?.activate()
|
self.navigationContentNode?.activate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode,
|
|||||||
}
|
}
|
||||||
self.sections = sections
|
self.sections = sections
|
||||||
var sectionTitles = sections.map { $0.0 }
|
var sectionTitles = sections.map { $0.0 }
|
||||||
sectionTitles.insert(UITableView.indexSearch, at: 0)
|
|
||||||
self.sectionTitles = sectionTitles
|
self.sectionTitles = sectionTitles
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
@ -25,6 +25,7 @@ open class ActionSheetController: ViewController, PresentableController, Standal
|
|||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = .Ignore
|
||||||
self.blocksBackgroundWhenInOverlay = true
|
self.blocksBackgroundWhenInOverlay = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,11 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
topController.viewWillDisappear(true)
|
topController.viewWillDisappear(true)
|
||||||
let topNode = topController.displayNode
|
let topNode = topController.displayNode
|
||||||
bottomController.containerLayoutUpdated(layout.withUpdatedInputHeight(nil), transition: .immediate)
|
var bottomControllerLayout = layout
|
||||||
|
if bottomController.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
|
bottomControllerLayout = bottomControllerLayout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
|
bottomController.containerLayoutUpdated(bottomControllerLayout, transition: .immediate)
|
||||||
bottomController.viewWillAppear(true)
|
bottomController.viewWillAppear(true)
|
||||||
let bottomNode = bottomController.displayNode
|
let bottomNode = bottomController.displayNode
|
||||||
|
|
||||||
@ -274,7 +278,11 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
} else {
|
} else {
|
||||||
transitionType = .pop
|
transitionType = .pop
|
||||||
}
|
}
|
||||||
self.state.pending = PendingChild(value: self.makeChild(layout: layout.withUpdatedInputHeight(nil), value: last), transitionType: transitionType, transition: transition, update: { [weak self] pendingChild in
|
var updatedLayout = layout
|
||||||
|
if last.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
|
self.state.pending = PendingChild(value: self.makeChild(layout: updatedLayout, value: last), transitionType: transitionType, transition: transition, update: { [weak self] pendingChild in
|
||||||
self?.pendingChildIsReady(pendingChild)
|
self?.pendingChildIsReady(pendingChild)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -289,7 +297,11 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
self.state.pending = nil
|
self.state.pending = nil
|
||||||
let previous = self.state.top
|
let previous = self.state.top
|
||||||
self.state.top = pending.value
|
self.state.top = pending.value
|
||||||
self.topTransition(from: previous, to: pending.value, transitionType: pending.transitionType, layout: layout.withUpdatedInputHeight(nil), transition: pending.transition)
|
var updatedLayout = layout
|
||||||
|
if pending.value.value.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
|
self.topTransition(from: previous, to: pending.value, transitionType: pending.transitionType, layout: updatedLayout, transition: pending.transition)
|
||||||
statusBarTransition = pending.transition
|
statusBarTransition = pending.transition
|
||||||
if !self.isReady {
|
if !self.isReady {
|
||||||
self.isReady = true
|
self.isReady = true
|
||||||
@ -307,7 +319,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
var updatedStatusBarStyle = self.statusBarStyle
|
var updatedStatusBarStyle = self.statusBarStyle
|
||||||
if let top = self.state.top {
|
if let top = self.state.top {
|
||||||
var updatedLayout = layout
|
var updatedLayout = layout
|
||||||
if let topTransition = self.state.transition {
|
if let topTransition = self.state.transition, top.value.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
}
|
}
|
||||||
self.applyLayout(layout: updatedLayout, to: top, isMaster: true, transition: transition)
|
self.applyLayout(layout: updatedLayout, to: top, isMaster: true, transition: transition)
|
||||||
@ -408,7 +420,10 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func makeChild(layout: ContainerViewLayout, value: ViewController) -> Child {
|
private func makeChild(layout: ContainerViewLayout, value: ViewController) -> Child {
|
||||||
let updatedLayout = layout.withUpdatedInputHeight(nil)
|
var updatedLayout = layout
|
||||||
|
if value.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
|
}
|
||||||
value.containerLayoutUpdated(updatedLayout, transition: .immediate)
|
value.containerLayoutUpdated(updatedLayout, transition: .immediate)
|
||||||
return Child(value: value, layout: updatedLayout)
|
return Child(value: value, layout: updatedLayout)
|
||||||
}
|
}
|
||||||
@ -430,7 +445,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if updatedLayout.inputHeight != nil {
|
if updatedLayout.inputHeight != nil {
|
||||||
if !self.canHaveKeyboardFocus {
|
if !self.canHaveKeyboardFocus && child.value.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,7 +454,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
shouldSyncKeyboard = true
|
shouldSyncKeyboard = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if updatedLayout.inputHeight != nil {
|
if updatedLayout.inputHeight != nil && child.value.view.disableAutomaticKeyboardHandling.isEmpty {
|
||||||
if !self.canHaveKeyboardFocus || self.ignoreInputHeight {
|
if !self.canHaveKeyboardFocus || self.ignoreInputHeight {
|
||||||
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
updatedLayout = updatedLayout.withUpdatedInputHeight(nil)
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1078,7 @@ open class NavigationController: UINavigationController, ContainableController,
|
|||||||
}
|
}
|
||||||
if let layout = self.validLayout {
|
if let layout = self.validLayout {
|
||||||
self.containerLayoutUpdated(layout, transition: transition)
|
self.containerLayoutUpdated(layout, transition: transition)
|
||||||
inCallStatusBar.updateState(statusBar: nil, withSafeInsets: false, inCallText: forceInCallStatusBarText, animated: false)
|
inCallStatusBar.updateState(statusBar: nil, withSafeInsets: !layout.safeInsets.top.isZero, inCallText: forceInCallStatusBarText, animated: false)
|
||||||
}
|
}
|
||||||
} else if let inCallStatusBar = self.inCallStatusBar {
|
} else if let inCallStatusBar = self.inCallStatusBar {
|
||||||
self.inCallStatusBar = nil
|
self.inCallStatusBar = nil
|
||||||
|
@ -52,8 +52,6 @@ final class InstantPageReferenceController: ViewController {
|
|||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -31,6 +31,8 @@ public final class JoinLinkPreviewController: ViewController {
|
|||||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = .Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder aDecoder: NSCoder) {
|
required public init(coder aDecoder: NSCoder) {
|
||||||
@ -76,8 +78,6 @@ public final class JoinLinkPreviewController: ViewController {
|
|||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -30,6 +30,8 @@ public final class LanguageLinkPreviewController: ViewController {
|
|||||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = .Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init(coder aDecoder: NSCoder) {
|
required public init(coder aDecoder: NSCoder) {
|
||||||
@ -85,8 +87,6 @@ public final class LanguageLinkPreviewController: ViewController {
|
|||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -739,7 +739,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
|
|
||||||
[UIView animateWithDuration:0.3f animations:^
|
[UIView animateWithDuration:0.3f animations:^
|
||||||
{
|
{
|
||||||
[_context setApplicationStatusBarAlpha:1.0f];
|
//[_context setApplicationStatusBarAlpha:1.0f];
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1816,7 +1816,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
|
|
||||||
[UIView animateWithDuration:0.3f animations:^
|
[UIView animateWithDuration:0.3f animations:^
|
||||||
{
|
{
|
||||||
[_context setApplicationStatusBarAlpha:1.0f];
|
//[_context setApplicationStatusBarAlpha:1.0f];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self setInterfaceHidden:true animated:true];
|
[self setInterfaceHidden:true animated:true];
|
||||||
@ -1892,7 +1892,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
{
|
{
|
||||||
_finishedWithResult = true;
|
_finishedWithResult = true;
|
||||||
|
|
||||||
[_context setApplicationStatusBarAlpha:1.0f];
|
//[_context setApplicationStatusBarAlpha:1.0f];
|
||||||
|
|
||||||
self.view.hidden = true;
|
self.view.hidden = true;
|
||||||
|
|
||||||
|
@ -71,19 +71,23 @@ static NSData *base64_decode(NSString *str) {
|
|||||||
|
|
||||||
+ (MTSignal *)fetchBackupIpsResolveGoogle:(bool)isTesting phoneNumber:(NSString *)phoneNumber currentContext:(MTContext *)currentContext addressOverride:(NSString *)addressOverride {
|
+ (MTSignal *)fetchBackupIpsResolveGoogle:(bool)isTesting phoneNumber:(NSString *)phoneNumber currentContext:(MTContext *)currentContext addressOverride:(NSString *)addressOverride {
|
||||||
NSArray *hosts = @[
|
NSArray *hosts = @[
|
||||||
@"google.com",
|
@[@"dns.google.com", @""],
|
||||||
@"www.google.com",
|
@[@"www.google.com", @"dns.google.com"],
|
||||||
@"google.ru"
|
|
||||||
];
|
];
|
||||||
NSDictionary *headers = @{@"Host": @"dns.google.com"};
|
|
||||||
|
|
||||||
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
||||||
for (NSString *host in hosts) {
|
for (NSArray *hostAndHostname in hosts) {
|
||||||
|
NSString *host = hostAndHostname[0];
|
||||||
|
NSString *hostName = hostAndHostname[1];
|
||||||
|
NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
|
||||||
|
if ([hostName length] != 0) {
|
||||||
|
headers[@"Host"] = hostName;
|
||||||
|
}
|
||||||
NSString *apvHost = @"apv3.stel.com";
|
NSString *apvHost = @"apv3.stel.com";
|
||||||
if (addressOverride != nil) {
|
if (addressOverride != nil) {
|
||||||
apvHost = addressOverride;
|
apvHost = addressOverride;
|
||||||
}
|
}
|
||||||
MTSignal *signal = [[[MTHttpRequestOperation dataForHttpUrl:[NSURL URLWithString:[NSString stringWithFormat:@"https://%@/resolve?name=%@&type=16", host, isTesting ? @"tapv3.stel.com" : apvHost]] headers:headers] mapToSignal:^MTSignal *(NSData *data) {
|
MTSignal *signal = [[[MTHttpRequestOperation dataForHttpUrl:[NSURL URLWithString:[NSString stringWithFormat:@"https://%@/resolve?name=%@&type=16&random_padding=%@", host, isTesting ? @"tapv3.stel.com" : apvHost, makeRandomPadding()]] headers:headers] mapToSignal:^MTSignal *(NSData *data) {
|
||||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||||
if ([dict respondsToSelector:@selector(objectForKey:)]) {
|
if ([dict respondsToSelector:@selector(objectForKey:)]) {
|
||||||
NSArray *answer = dict[@"Answer"];
|
NSArray *answer = dict[@"Answer"];
|
||||||
@ -132,6 +136,90 @@ static NSData *base64_decode(NSString *str) {
|
|||||||
return [[MTSignal mergeSignals:signals] take:1];
|
return [[MTSignal mergeSignals:signals] take:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSString *makeRandomPadding() {
|
||||||
|
char validCharacters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
|
int maxIndex = sizeof(validCharacters) - 1;
|
||||||
|
|
||||||
|
int minPadding = 13;
|
||||||
|
int maxPadding = 128;
|
||||||
|
int padding = minPadding + arc4random_uniform(maxPadding - minPadding);
|
||||||
|
NSMutableData *result = [[NSMutableData alloc] initWithLength:padding];
|
||||||
|
for (NSUInteger i = 0; i < result.length; i++) {
|
||||||
|
int index = arc4random_uniform(maxIndex);
|
||||||
|
assert(index >= 0 && index < maxIndex);
|
||||||
|
((uint8_t *)(result.mutableBytes))[i] = validCharacters[index];
|
||||||
|
}
|
||||||
|
NSString *string = [[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding];
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (MTSignal *)fetchBackupIpsResolveCloudflare:(bool)isTesting phoneNumber:(NSString *)phoneNumber currentContext:(MTContext *)currentContext addressOverride:(NSString *)addressOverride {
|
||||||
|
NSArray *hosts = @[
|
||||||
|
@[@"mozilla.cloudflare-dns.com", @""],
|
||||||
|
];
|
||||||
|
|
||||||
|
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
||||||
|
for (NSArray *hostAndHostname in hosts) {
|
||||||
|
NSString *host = hostAndHostname[0];
|
||||||
|
NSString *hostName = hostAndHostname[1];
|
||||||
|
NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
|
||||||
|
headers[@"accept"] = @"application/dns-json";
|
||||||
|
if ([hostName length] != 0) {
|
||||||
|
headers[@"Host"] = hostName;
|
||||||
|
}
|
||||||
|
NSString *apvHost = @"apv3.stel.com";
|
||||||
|
if (addressOverride != nil) {
|
||||||
|
apvHost = addressOverride;
|
||||||
|
}
|
||||||
|
MTSignal *signal = [[[MTHttpRequestOperation dataForHttpUrl:[NSURL URLWithString:[NSString stringWithFormat:@"https://%@/dns-query?name=%@&type=16&random_padding=%@", host, isTesting ? @"tapv3.stel.com" : apvHost, makeRandomPadding()]] headers:headers] mapToSignal:^MTSignal *(NSData *data) {
|
||||||
|
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||||
|
if ([dict respondsToSelector:@selector(objectForKey:)]) {
|
||||||
|
NSArray *answer = dict[@"Answer"];
|
||||||
|
NSMutableArray *strings = [[NSMutableArray alloc] init];
|
||||||
|
if ([answer respondsToSelector:@selector(objectAtIndex:)]) {
|
||||||
|
for (NSDictionary *value in answer) {
|
||||||
|
if ([value respondsToSelector:@selector(objectForKey:)]) {
|
||||||
|
NSString *part = value[@"data"];
|
||||||
|
if ([part respondsToSelector:@selector(characterAtIndex:)]) {
|
||||||
|
[strings addObject:part];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[strings sortUsingComparator:^NSComparisonResult(NSString *lhs, NSString *rhs) {
|
||||||
|
if (lhs.length > rhs.length) {
|
||||||
|
return NSOrderedAscending;
|
||||||
|
} else {
|
||||||
|
return NSOrderedDescending;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
NSString *finalString = @"";
|
||||||
|
for (NSString *string in strings) {
|
||||||
|
finalString = [finalString stringByAppendingString:[string stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"="]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
NSData *result = base64_decode(finalString);
|
||||||
|
NSMutableData *finalData = [[NSMutableData alloc] initWithData:result];
|
||||||
|
[finalData setLength:256];
|
||||||
|
MTBackupDatacenterData *datacenterData = MTIPDataDecode(finalData, phoneNumber);
|
||||||
|
if (datacenterData != nil && [self checkIpData:datacenterData timestamp:(int32_t)[currentContext globalTime] source:@"resolveCloudflare"]) {
|
||||||
|
return [MTSignal single:datacenterData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [MTSignal complete];
|
||||||
|
}] catch:^MTSignal *(__unused id error) {
|
||||||
|
return [MTSignal complete];
|
||||||
|
}];
|
||||||
|
if (signals.count != 0) {
|
||||||
|
signal = [signal delay:signals.count onQueue:[[MTQueue alloc] init]];
|
||||||
|
}
|
||||||
|
[signals addObject:signal];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [[MTSignal mergeSignals:signals] take:1];
|
||||||
|
}
|
||||||
|
|
||||||
+ (MTSignal *)fetchConfigFromAddress:(MTBackupDatacenterAddress *)address currentContext:(MTContext *)currentContext {
|
+ (MTSignal *)fetchConfigFromAddress:(MTBackupDatacenterAddress *)address currentContext:(MTContext *)currentContext {
|
||||||
MTApiEnvironment *apiEnvironment = [currentContext.apiEnvironment copy];
|
MTApiEnvironment *apiEnvironment = [currentContext.apiEnvironment copy];
|
||||||
|
|
||||||
@ -209,12 +297,23 @@ static NSData *base64_decode(NSString *str) {
|
|||||||
|
|
||||||
+ (MTSignal * _Nonnull)fetchBackupIps:(bool)isTestingEnvironment currentContext:(MTContext * _Nonnull)currentContext additionalSource:(MTSignal * _Nullable)additionalSource phoneNumber:(NSString * _Nullable)phoneNumber {
|
+ (MTSignal * _Nonnull)fetchBackupIps:(bool)isTestingEnvironment currentContext:(MTContext * _Nonnull)currentContext additionalSource:(MTSignal * _Nullable)additionalSource phoneNumber:(NSString * _Nullable)phoneNumber {
|
||||||
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
||||||
[signals addObject:[self fetchBackupIpsResolveGoogle:isTestingEnvironment phoneNumber:phoneNumber currentContext:currentContext addressOverride:currentContext.apiEnvironment.accessHostOverride]];
|
//[signals addObject:[self fetchBackupIpsResolveGoogle:isTestingEnvironment phoneNumber:phoneNumber currentContext:currentContext addressOverride:currentContext.apiEnvironment.accessHostOverride]];
|
||||||
|
//[signals addObject:[self fetchBackupIpsResolveCloudflare:isTestingEnvironment phoneNumber:phoneNumber currentContext:currentContext addressOverride:currentContext.apiEnvironment.accessHostOverride]];
|
||||||
if (additionalSource != nil) {
|
if (additionalSource != nil) {
|
||||||
/*#if DEBUG
|
/*#if DEBUG
|
||||||
[signals removeAllObjects];
|
[signals removeAllObjects];
|
||||||
#endif*/
|
#endif*/
|
||||||
[signals addObject:additionalSource];
|
[signals addObject:[additionalSource mapToSignal:^MTSignal *(MTBackupDatacenterData *datacenterData) {
|
||||||
|
if (![datacenterData isKindOfClass:[MTBackupDatacenterData class]]) {
|
||||||
|
return [MTSignal complete];
|
||||||
|
}
|
||||||
|
MTBackupDatacenterData *datacenterData = MTIPDataDecode(finalData, phoneNumber);
|
||||||
|
if (datacenterData != nil && [self checkIpData:datacenterData timestamp:(int32_t)[currentContext globalTime] source:@"resolveExternal"]) {
|
||||||
|
return [MTSignal single:datacenterData];
|
||||||
|
} else {
|
||||||
|
return [MTSignal complete];
|
||||||
|
}
|
||||||
|
}]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [[[MTSignal mergeSignals:signals] take:1] mapToSignal:^MTSignal *(MTBackupDatacenterData *data) {
|
return [[[MTSignal mergeSignals:signals] take:1] mapToSignal:^MTSignal *(MTBackupDatacenterData *data) {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
[subscriber putCompletion];
|
[subscriber putCompletion];
|
||||||
} failure:^(__unused NSOperation *operation, __unused NSError *error)
|
} failure:^(__unused NSOperation *operation, __unused NSError *error)
|
||||||
{
|
{
|
||||||
[subscriber putError:nil];
|
[subscriber putError:error];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[operation start];
|
[operation start];
|
||||||
|
@ -447,7 +447,7 @@ func editSettingsController(context: AccountContext, currentName: ItemListAvatar
|
|||||||
(controller?.navigationController as? NavigationController)?.pushViewController(value)
|
(controller?.navigationController as? NavigationController)?.pushViewController(value)
|
||||||
}
|
}
|
||||||
presentControllerImpl = { [weak controller] value, arguments in
|
presentControllerImpl = { [weak controller] value, arguments in
|
||||||
controller?.present(value, in: .window(.root), with: arguments ?? ViewControllerPresentationArguments(presentationAnimation: .modalSheet))
|
controller?.present(value, in: .window(.root), with: arguments)
|
||||||
}
|
}
|
||||||
dismissImpl = { [weak controller] in
|
dismissImpl = { [weak controller] in
|
||||||
let _ = (controller?.navigationController as? NavigationController)?.popViewController(animated: true)
|
let _ = (controller?.navigationController as? NavigationController)?.popViewController(animated: true)
|
||||||
|
@ -203,6 +203,11 @@ public final class ShareController: ViewController {
|
|||||||
return self.displayNode as! ShareControllerNode
|
return self.displayNode as! ShareControllerNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let _ready = Promise<Bool>()
|
||||||
|
override public var ready: Promise<Bool> {
|
||||||
|
return self._ready
|
||||||
|
}
|
||||||
|
|
||||||
private var animatedIn = false
|
private var animatedIn = false
|
||||||
|
|
||||||
private let sharedContext: SharedAccountContext
|
private let sharedContext: SharedAccountContext
|
||||||
@ -242,6 +247,8 @@ public final class ShareController: ViewController {
|
|||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = .Ignore
|
||||||
|
|
||||||
switch subject {
|
switch subject {
|
||||||
case let .url(text):
|
case let .url(text):
|
||||||
self.defaultAction = ShareControllerAction(title: self.presentationData.strings.ShareMenu_CopyShareLink, action: { [weak self] in
|
self.defaultAction = ShareControllerAction(title: self.presentationData.strings.ShareMenu_CopyShareLink, action: { [weak self] in
|
||||||
@ -567,7 +574,7 @@ public final class ShareController: ViewController {
|
|||||||
return .preparing
|
return .preparing
|
||||||
case let .done(items):
|
case let .done(items):
|
||||||
if let strongSelf = self, !items.isEmpty {
|
if let strongSelf = self, !items.isEmpty {
|
||||||
strongSelf.ready.set(.single(true))
|
strongSelf._ready.set(.single(true))
|
||||||
var activityItems: [Any] = []
|
var activityItems: [Any] = []
|
||||||
for item in items {
|
for item in items {
|
||||||
switch item {
|
switch item {
|
||||||
@ -632,13 +639,11 @@ public final class ShareController: ViewController {
|
|||||||
strongSelf.controllerNode.updatePeers(account: strongSelf.currentAccount, switchableAccounts: strongSelf.switchableAccounts, peers: next.0, accountPeer: next.1, defaultAction: strongSelf.defaultAction)
|
strongSelf.controllerNode.updatePeers(account: strongSelf.currentAccount, switchableAccounts: strongSelf.switchableAccounts, peers: next.0, accountPeer: next.1, defaultAction: strongSelf.defaultAction)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
self.ready.set(self.controllerNode.ready.get())
|
self._ready.set(self.controllerNode.ready.get())
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -500,7 +500,7 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary
|
|||||||
context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber))
|
context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber))
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil)
|
let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, additionalSource: wrappedAdditionalSource, phoneNumber: phoneNumber).start(next: nil)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil))!
|
let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil))!
|
||||||
|
@ -70,6 +70,8 @@ final class AuthorizationSequenceCodeEntryController: ViewController {
|
|||||||
self.displayNode = AuthorizationSequenceCodeEntryControllerNode(strings: self.strings, theme: self.theme)
|
self.displayNode = AuthorizationSequenceCodeEntryControllerNode(strings: self.strings, theme: self.theme)
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
|
self.controllerNode.view.disableAutomaticKeyboardHandling = [.forward, .backward]
|
||||||
|
|
||||||
self.controllerNode.loginWithCode = { [weak self] code in
|
self.controllerNode.loginWithCode = { [weak self] code in
|
||||||
self?.continueWithCode(code)
|
self?.continueWithCode(code)
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,8 @@ final class AuthorizationSequencePasswordEntryController: ViewController {
|
|||||||
self.displayNode = AuthorizationSequencePasswordEntryControllerNode(strings: self.strings, theme: self.theme)
|
self.displayNode = AuthorizationSequencePasswordEntryControllerNode(strings: self.strings, theme: self.theme)
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
|
self.controllerNode.view.disableAutomaticKeyboardHandling = [.forward, .backward]
|
||||||
|
|
||||||
self.controllerNode.loginWithCode = { [weak self] _ in
|
self.controllerNode.loginWithCode = { [weak self] _ in
|
||||||
self?.nextPressed()
|
self?.nextPressed()
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,9 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
|
|||||||
self.controllerNode.codeAndNumber = (code, name, number)
|
self.controllerNode.codeAndNumber = (code, name, number)
|
||||||
}
|
}
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
|
self.controllerNode.view.disableAutomaticKeyboardHandling = [.forward, .backward]
|
||||||
|
|
||||||
self.controllerNode.selectCountryCode = { [weak self] in
|
self.controllerNode.selectCountryCode = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme)
|
let controller = AuthorizationSequenceCountrySelectionController(strings: strongSelf.strings, theme: strongSelf.theme)
|
||||||
@ -118,8 +121,7 @@ final class AuthorizationSequencePhoneEntryController: ViewController {
|
|||||||
controller.dismissed = {
|
controller.dismissed = {
|
||||||
self?.controllerNode.activateInput()
|
self?.controllerNode.activateInput()
|
||||||
}
|
}
|
||||||
strongSelf.controllerNode.view.endEditing(true)
|
strongSelf.push(controller)
|
||||||
strongSelf.present(controller, in: .window(.root))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.controllerNode.checkPhone = { [weak self] in
|
self.controllerNode.checkPhone = { [weak self] in
|
||||||
|
@ -93,6 +93,8 @@ final class AuthorizationSequenceSignUpController: ViewController {
|
|||||||
})
|
})
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
|
self.controllerNode.view.disableAutomaticKeyboardHandling = [.forward, .backward]
|
||||||
|
|
||||||
self.controllerNode.signUpWithName = { [weak self] _, _ in
|
self.controllerNode.signUpWithName = { [weak self] _, _ in
|
||||||
self?.nextPressed()
|
self?.nextPressed()
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ final class ChatScheduleTimeController: ViewController {
|
|||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
|
self.statusBar.statusBarStyle = .Ignore
|
||||||
|
|
||||||
self.blocksBackgroundWhenInOverlay = true
|
self.blocksBackgroundWhenInOverlay = true
|
||||||
|
|
||||||
self.presentationDataDisposable = (context.sharedContext.presentationData
|
self.presentationDataDisposable = (context.sharedContext.presentationData
|
||||||
@ -74,8 +76,6 @@ final class ChatScheduleTimeController: ViewController {
|
|||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -79,8 +79,6 @@ final class OverlayAudioPlayerControllerImpl: ViewController, OverlayAudioPlayer
|
|||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
super.loadView()
|
super.loadView()
|
||||||
|
|
||||||
self.statusBar.removeFromSupernode()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func viewDidAppear(_ animated: Bool) {
|
override public func viewDidAppear(_ animated: Bool) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user