Skip to content

Commit 9d2094f

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 5c814c5 + 203047a commit 9d2094f

File tree

145 files changed

+34073
-2906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+34073
-2906
lines changed

Telegram/Tests/Sources/UITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class UITests: XCTestCase {
3131
}
3232

3333
func testSignUp() throws {
34-
deleteTestAccount(phone: "9996629999")
34+
deleteTestAccount(phone: "9996625296")
3535
app.launch()
3636

3737
// Welcome screen — tap Start Messaging

Tests/AnimationCacheTest/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ swift_library(
3131
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
3232
"//submodules/Display:Display",
3333
"//submodules/TelegramUI/Components/AnimationCache:AnimationCache",
34+
"//submodules/TelegramUI/Components/DCTAnimationCacheImpl:DCTAnimationCacheImpl",
3435
"//submodules/TelegramUI/Components/VideoAnimationCache:VideoAnimationCache",
3536
"//submodules/TelegramUI/Components/LottieAnimationCache:LottieAnimationCache",
3637
"//submodules/rlottie:RLottieBinding",

Tests/AnimationCacheTest/Sources/ViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import UIKit
33

44
import Display
55
import AnimationCache
6+
import DCTAnimationCacheImpl
67
import SwiftSignalKit
78
import VideoAnimationCache
89
import LottieAnimationCache
@@ -50,7 +51,7 @@ public final class ViewController: UIViewController {
5051
let basePath = NSTemporaryDirectory() + "/animation-cache"
5152
let _ = try? FileManager.default.removeItem(atPath: basePath)
5253
let _ = try? FileManager.default.createDirectory(at: URL(fileURLWithPath: basePath), withIntermediateDirectories: true)
53-
self.cache = AnimationCacheImpl(basePath: basePath, allocateTempFile: {
54+
self.cache = DCTAnimationCacheImpl(basePath: basePath, allocateTempFile: {
5455
return basePath + "/\(Int64.random(in: 0 ... Int64.max))"
5556
})
5657

build-system/Make/DeployBuild.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import hashlib
88
import base64
9+
import time
910
import requests
1011

1112
def sha256_file(path):
@@ -26,16 +27,55 @@ def init_build(host, token, files, channel):
2627
r.raise_for_status()
2728
return r.json()
2829

30+
class ProgressFileReader:
31+
def __init__(self, path, size):
32+
self._file = open(path, 'rb')
33+
self._size = size
34+
self._sent = 0
35+
self._start_time = time.time()
36+
self._last_print = self._start_time
37+
38+
def __len__(self):
39+
return self._size
40+
41+
def read(self, chunk_size=-1):
42+
if chunk_size == -1:
43+
chunk_size = self._size
44+
data = self._file.read(chunk_size)
45+
if not data:
46+
elapsed = time.time() - self._start_time
47+
speed = self._size / elapsed / 1024 / 1024 if elapsed > 0 else 0
48+
print(' 100% - all bytes sent in {:.1f}s ({:.2f} MB/s), waiting for server response...'.format(elapsed, speed))
49+
return data
50+
self._sent += len(data)
51+
now = time.time()
52+
if now - self._last_print >= 5:
53+
elapsed = now - self._start_time
54+
speed = self._sent / elapsed / 1024 / 1024 if elapsed > 0 else 0
55+
print(' {:.1f}% ({:.1f} / {:.1f} MB) {:.2f} MB/s'.format(
56+
self._sent * 100 / self._size, self._sent / 1024 / 1024, self._size / 1024 / 1024, speed))
57+
self._last_print = now
58+
return data
59+
60+
def close(self):
61+
self._file.close()
62+
2963
def upload_file(path, upload_info):
3064
url = upload_info.get('url')
3165
headers = dict(upload_info.get('headers', {}))
32-
66+
3367
size = os.path.getsize(path)
3468
headers['Content-Length'] = str(size)
3569

36-
print('Uploading', path)
37-
with open(path, 'rb') as f:
38-
r = requests.put(url, data=f, headers=headers, timeout=900)
70+
print('Uploading {} ({:.1f} MB)'.format(path, size / 1024 / 1024))
71+
start_time = time.time()
72+
73+
body = ProgressFileReader(path, size)
74+
try:
75+
r = requests.put(url, data=body, headers=headers, timeout=900)
76+
finally:
77+
body.close()
78+
print(' Server responded: {} ({:.1f}s total)'.format(r.status_code, time.time() - start_time))
3979
if r.status_code != 200:
4080
print('Upload failed', r.status_code)
4181
print(r.text[:500])

submodules/ChatListUI/Sources/ChatListController.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7177,9 +7177,6 @@ private final class ChatListLocationContext {
71777177
titleContent = NetworkStatusTitle(text: presentationData.strings.State_WaitingForNetwork, activity: true, hasProxy: false, connectsViaProxy: connectsViaProxy, isPasscodeSet: isRoot && isPasscodeSet, isManuallyLocked: isRoot && isManuallyLocked, peerStatus: peerStatus)
71787178
case let .connecting(proxy):
71797179
let text = presentationData.strings.State_Connecting
7180-
/*if let layout = strongSelf.validLayout, proxy != nil && layout.metrics.widthClass != .regular && layout.size.width > 320.0 {*/
7181-
//text = self.presentationData.strings.State_ConnectingToProxy
7182-
//}
71837180
if let proxy = proxy, proxy.hasConnectionIssues {
71847181
checkProxy = true
71857182
}

submodules/ChatListUI/Sources/Node/ChatListItem.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2722,7 +2722,8 @@ public class ChatListItemNode: ItemListRevealOptionsItemNode {
27222722

27232723
let messageString: NSAttributedString
27242724
if !messageText.isEmpty && entities.count > 0 {
2725-
messageString = foldLineBreaks(stringWithAppliedEntities(messageText, entities: entities, strings: item.presentationData.strings, dateTimeFormat: item.presentationData.dateTimeFormat, baseColor: theme.messageTextColor, linkColor: theme.messageTextColor, baseFont: textFont, linkFont: textFont, boldFont: textFont, italicFont: italicTextFont, boldItalicFont: textFont, fixedFont: textFont, blockQuoteFont: textFont, underlineLinks: false, message: message._asMessage()))
2725+
let appliedString = stringWithAppliedEntities(messageText, entities: entities, strings: item.presentationData.strings, dateTimeFormat: item.presentationData.dateTimeFormat, baseColor: theme.messageTextColor, linkColor: theme.messageTextColor, baseFont: textFont, linkFont: textFont, boldFont: textFont, italicFont: italicTextFont, boldItalicFont: textFont, fixedFont: textFont, blockQuoteFont: textFont, underlineLinks: false, message: message._asMessage())
2726+
messageString = foldLineBreaks(appliedString)
27262727
} else if spoilers != nil || customEmojiRanges != nil {
27272728
let mutableString = NSMutableAttributedString(string: messageText, font: textFont, textColor: theme.messageTextColor)
27282729
if let spoilers = spoilers {

submodules/ChatListUI/Sources/Node/ChatListItemStrings.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
287287
}
288288
if !processed {
289289
if !message.text.isEmpty {
290-
messageText = "📎 \(messageText)"
290+
if enableMediaEmoji {
291+
messageText = "📎 \(messageText)"
292+
}
291293
} else {
292294
if fileMedia.isAnimatedSticker {
293295
messageText = strings.Message_Sticker

submodules/Display/Source/TextNode.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,11 +1216,11 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
12161216
public static let all: RenderContentTypes = [.text, .emoji]
12171217
}
12181218

1219-
final class DrawingParameters: NSObject {
1219+
public final class DrawingParameters: NSObject {
12201220
let cachedLayout: TextNodeLayout?
12211221
let renderContentTypes: RenderContentTypes
12221222

1223-
init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) {
1223+
public init(cachedLayout: TextNodeLayout?, renderContentTypes: RenderContentTypes) {
12241224
self.cachedLayout = cachedLayout
12251225
self.renderContentTypes = renderContentTypes
12261226

@@ -1295,7 +1295,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
12951295
}
12961296
}
12971297

1298-
private static func calculateLayoutV2(
1298+
public static func calculateLayoutV2(
12991299
attributedString: NSAttributedString,
13001300
minimumNumberOfLines: Int,
13011301
maximumNumberOfLines: Int,
@@ -1685,7 +1685,7 @@ open class TextNode: ASDisplayNode, TextNodeProtocol {
16851685
)
16861686
}
16871687

1688-
static func calculateLayout(attributedString: NSAttributedString?, minimumNumberOfLines: Int, maximumNumberOfLines: Int, truncationType: CTLineTruncationType, backgroundColor: UIColor?, constrainedSize: CGSize, alignment: NSTextAlignment, verticalAlignment: TextVerticalAlignment, lineSpacingFactor: CGFloat, cutout: TextNodeCutout?, insets: UIEdgeInsets, lineColor: UIColor?, textShadowColor: UIColor?, textShadowBlur: CGFloat?, textStroke: (UIColor, CGFloat)?, displaySpoilers: Bool, displayEmbeddedItemsUnderSpoilers: Bool, customTruncationToken: NSAttributedString?) -> TextNodeLayout {
1688+
public static func calculateLayout(attributedString: NSAttributedString?, minimumNumberOfLines: Int, maximumNumberOfLines: Int, truncationType: CTLineTruncationType, backgroundColor: UIColor?, constrainedSize: CGSize, alignment: NSTextAlignment, verticalAlignment: TextVerticalAlignment, lineSpacingFactor: CGFloat, cutout: TextNodeCutout?, insets: UIEdgeInsets, lineColor: UIColor?, textShadowColor: UIColor?, textShadowBlur: CGFloat?, textStroke: (UIColor, CGFloat)?, displaySpoilers: Bool, displayEmbeddedItemsUnderSpoilers: Bool, customTruncationToken: NSAttributedString?) -> TextNodeLayout {
16891689
guard let attributedString else {
16901690
return TextNodeLayout(attributedString: attributedString, maximumNumberOfLines: maximumNumberOfLines, truncationType: truncationType, constrainedSize: constrainedSize, explicitAlignment: alignment, resolvedAlignment: alignment, verticalAlignment: verticalAlignment, lineSpacing: lineSpacingFactor, cutout: cutout, insets: insets, size: CGSize(), rawTextSize: CGSize(), truncated: false, firstLineOffset: 0.0, lines: [], blockQuotes: [], backgroundColor: backgroundColor, lineColor: lineColor, textShadowColor: textShadowColor, textShadowBlur: textShadowBlur, textStroke: textStroke, displaySpoilers: displaySpoilers)
16911691
}

submodules/MtProtoKit/Sources/MTApiEnvironment.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,11 @@ - (NSData * _Nonnull)serialize {
264264

265265
- (NSString * _Nonnull)serializeToString {
266266
NSData *data = [self serialize];
267-
if ([data respondsToSelector:@selector(base64EncodedDataWithOptions:)]) {
268-
return [[data base64EncodedStringWithOptions:kNilOptions] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"="]];
269-
} else {
270-
#pragma clang diagnostic push
271-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
272-
return [self.serialize base64Encoding];
273-
#pragma clang diagnostic pop
274-
}
267+
NSString *result = [data base64EncodedStringWithOptions:kNilOptions];
268+
result = [result stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
269+
result = [result stringByReplacingOccurrencesOfString:@"/" withString:@"_"];
270+
result = [result stringByReplacingOccurrencesOfString:@"=" withString:@""];
271+
return result;
275272
}
276273

277274
- (BOOL)isEqual:(id)object {

0 commit comments

Comments
 (0)