From 97c0dbebb9c066cc4e87862345ddefb01f9836c5 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 25 Aug 2020 21:06:42 +0300 Subject: [PATCH 01/12] Improve country selection search --- submodules/CountrySelectionUI/BUCK | 1 + submodules/CountrySelectionUI/BUILD | 1 + ...onSequenceCountrySelectionController.swift | 1 + ...quenceCountrySelectionControllerNode.swift | 85 ++++++++++++++++--- .../Sources/ShareController.swift | 80 ++++++++++++----- 5 files changed, 134 insertions(+), 34 deletions(-) diff --git a/submodules/CountrySelectionUI/BUCK b/submodules/CountrySelectionUI/BUCK index 03763af9f3..06b334d255 100644 --- a/submodules/CountrySelectionUI/BUCK +++ b/submodules/CountrySelectionUI/BUCK @@ -9,6 +9,7 @@ static_library( "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit#shared", "//submodules/AsyncDisplayKit:AsyncDisplayKit#shared", "//submodules/Display:Display#shared", + "//submodules/Postbox:Postbox#shared", "//submodules/TelegramCore:TelegramCore#shared", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/TelegramStringFormatting:TelegramStringFormatting", diff --git a/submodules/CountrySelectionUI/BUILD b/submodules/CountrySelectionUI/BUILD index 368cd0b914..b5284ea80d 100644 --- a/submodules/CountrySelectionUI/BUILD +++ b/submodules/CountrySelectionUI/BUILD @@ -10,6 +10,7 @@ swift_library( "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/AsyncDisplayKit:AsyncDisplayKit", "//submodules/Display:Display", + "//submodules/Postbox:Postbox", "//submodules/TelegramCore:TelegramCore", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/TelegramStringFormatting:TelegramStringFormatting", diff --git a/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionController.swift b/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionController.swift index 66c79dbfa7..653cf32759 100644 --- a/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionController.swift +++ b/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionController.swift @@ -236,6 +236,7 @@ public final class AuthorizationSequenceCountrySelectionController: ViewControll } public static func lookupPatternByNumber(_ number: String, preferredCountries: [String: String]) -> String? { + let number = removePlus(number) if let (_, code) = lookupCountryIdByNumber(number, preferredCountries: preferredCountries), !code.patterns.isEmpty { var prefixes: [String: String] = [:] for pattern in code.patterns { diff --git a/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionControllerNode.swift b/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionControllerNode.swift index f7d22cf3aa..82b9b60a54 100644 --- a/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionControllerNode.swift +++ b/submodules/CountrySelectionUI/Sources/AuthorizationSequenceCountrySelectionControllerNode.swift @@ -2,6 +2,7 @@ import Foundation import UIKit import AsyncDisplayKit import Display +import Postbox import TelegramCore import SyncCore import TelegramPresentationData @@ -73,6 +74,75 @@ func localizedCountryNamesAndCodes(strings: PresentationStrings) -> [((String, S return result } +private func stringTokens(_ string: String) -> [ValueBoxKey] { + let nsString = string.replacingOccurrences(of: ".", with: "").folding(options: .diacriticInsensitive, locale: .current).lowercased() as NSString + + let flag = UInt(kCFStringTokenizerUnitWord) + let tokenizer = CFStringTokenizerCreate(kCFAllocatorDefault, nsString, CFRangeMake(0, nsString.length), flag, CFLocaleCopyCurrent()) + var tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer) + var tokens: [ValueBoxKey] = [] + + var addedTokens = Set() + while tokenType != [] { + let currentTokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer) + + if currentTokenRange.location >= 0 && currentTokenRange.length != 0 { + let token = ValueBoxKey(length: currentTokenRange.length * 2) + nsString.getCharacters(token.memory.assumingMemoryBound(to: unichar.self), range: NSMakeRange(currentTokenRange.location, currentTokenRange.length)) + if !addedTokens.contains(token) { + tokens.append(token) + addedTokens.insert(token) + } + } + tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer) + } + + return tokens +} + +private func matchStringTokens(_ tokens: [ValueBoxKey], with other: [ValueBoxKey]) -> Bool { + if other.isEmpty { + return false + } else if other.count == 1 { + let otherToken = other[0] + for token in tokens { + if otherToken.isPrefix(to: token) { + return true + } + } + } else { + for otherToken in other { + var found = false + for token in tokens { + if otherToken.isPrefix(to: token) { + found = true + break + } + } + if !found { + return false + } + } + return true + } + return false +} + +private func searchCountries(items: [((String, String), String, Int)], query: String) -> [((String, String), String, Int)] { + let queryTokens = stringTokens(query.lowercased()) + + var result: [((String, String), String, Int)] = [] + for item in items { + let string = "\(item.0) \(item.1)" + let tokens = stringTokens(string) + if matchStringTokens(tokens, with: queryTokens) { + result.append(item) + } + } + + return result +} + final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, UITableViewDelegate, UITableViewDataSource { let itemSelected: (((String, String), String, Int)) -> Void @@ -88,6 +158,7 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, private let sectionTitles: [String] private var searchResults: [((String, String), String, Int)] = [] + private let countryNamesAndCodes: [((String, String), String, Int)] init(theme: PresentationTheme, strings: PresentationStrings, displayCodes: Bool, itemSelected: @escaping (((String, String), String, Int)) -> Void) { self.theme = theme @@ -107,6 +178,7 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, } let countryNamesAndCodes = localizedCountryNamesAndCodes(strings: strings) + self.countryNamesAndCodes = countryNamesAndCodes var sections: [(String, [((String, String), String, Int)])] = [] for (names, id, code) in countryNamesAndCodes.sorted(by: { lhs, rhs in @@ -176,18 +248,7 @@ final class AuthorizationSequenceCountrySelectionControllerNode: ASDisplayNode, self.searchTableView.reloadData() self.searchTableView.isHidden = true } else { - let normalizedQuery = query.lowercased().trimmingCharacters(in: .whitespacesAndNewlines) - - var results: [((String, String), String, Int)] = [] - for (_, items) in self.sections { - for item in items { - if item.0.0.lowercased().hasPrefix(normalizedQuery) || item.0.1.lowercased().hasPrefix(normalizedQuery) { - results.append(item) - } - } - } - - self.searchResults = results + self.searchResults = searchCountries(items: self.countryNamesAndCodes, query: query) self.searchTableView.isHidden = false self.searchTableView.reloadData() } diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index 78e8de6d3f..173abe52b1 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -593,27 +593,6 @@ public final class ShareController: ViewController { } self.controllerNode.shareExternal = { [weak self] in if let strongSelf = self { -// if case let .messages(messages) = strongSelf.subject, let message = messages.first, let peer = message.peers[message.id.peerId] { -// let renderer = MessageStoryRenderer(context: strongSelf.currentContext, messages: messages) -// -// let layout = ContainerViewLayout(size: CGSize(width: 414.0, height: 896.0), metrics: LayoutMetrics(widthClass: .compact, heightClass: .compact), deviceMetrics: .iPhoneX, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: 0.0, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false) -// renderer.update(layout: layout) { image in -// if let data = image?.pngData() { -// let pasteboardItems: [[String: Any]] = [["com.instagram.sharedSticker.backgroundImage": data, -// "com.instagram.sharedSticker.contentURL": "https://t.me/\(peer.addressName ?? "")/\(message.id.id)"]] -// if #available(iOS 10.0, *) { -// UIPasteboard.general.setItems(pasteboardItems, options: [.expirationDate: Date().addingTimeInterval(5 * 60)]) -// } else { -//// UIPasteboard.general.setItems(pasteboardItems) -// } -// strongSelf.sharedContext.applicationBindings.openUrl("instagram-stories://share") -// } -// } -// -// return .complete() -// } - - var collectableItems: [CollectableExternalShareItem] = [] switch strongSelf.subject { case let .url(text): @@ -695,7 +674,25 @@ public final class ShareController: ViewController { activityItems.append(url) } } - let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil) + + var activities: [UIActivity]? + if false, #available(iOS 10.0, *), strongSelf.sharedContext.applicationBindings.canOpenUrl("instagram-stories://"), case let .messages(messages) = strongSelf.subject, let message = messages.first, let peer = message.peers[message.id.peerId] { + let shareToInstagram = ShareToInstagramActivity(action: { sharedItems in + let renderer = MessageStoryRenderer(context: strongSelf.currentContext, messages: messages) + + let layout = ContainerViewLayout(size: CGSize(width: 414.0, height: 896.0), metrics: LayoutMetrics(widthClass: .compact, heightClass: .compact), deviceMetrics: .iPhoneX, intrinsicInsets: UIEdgeInsets(), safeInsets: UIEdgeInsets(), statusBarHeight: 0.0, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false) + renderer.update(layout: layout) { image in + if let data = image?.pngData() { + let pasteboardItems: [[String: Any]] = [["com.instagram.sharedSticker.backgroundImage": data, + "com.instagram.sharedSticker.contentURL": "https://t.me/\(peer.addressName ?? "")/\(message.id.id)"]] + UIPasteboard.general.setItems(pasteboardItems, options: [.expirationDate: Date().addingTimeInterval(5 * 60)]) + strongSelf.sharedContext.applicationBindings.openUrl("instagram-stories://share") + } + } + }) + activities = [shareToInstagram] + } + let activityController = UIActivityViewController(activityItems: activityItems, applicationActivities: activities) if let window = strongSelf.view.window, let rootViewController = window.rootViewController { activityController.popoverPresentationController?.sourceView = window @@ -1015,3 +1012,42 @@ final class MessageStoryRenderer { dateHeaderNode.updateLayout(size: self.containerNode.frame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right) } } + +private class ShareToInstagramActivity: UIActivity { + private var activityItems = [Any]() + private var action: ([Any]) -> Void + + init(action: @escaping ([Any]) -> Void) { + self.action = action + super.init() + } + + override var activityTitle: String? { + return "Share to Instagram Stories" + } + + override var activityImage: UIImage? { + return nil + } + + override var activityType: UIActivity.ActivityType? { + return UIActivity.ActivityType(rawValue: "org.telegram.Telegram.ShareToInstagram") + } + + override class var activityCategory: UIActivity.Category { + return .action + } + + override func canPerform(withActivityItems activityItems: [Any]) -> Bool { + return true + } + + override func prepare(withActivityItems activityItems: [Any]) { + self.activityItems = activityItems + } + + override func perform() { + self.action(self.activityItems) + activityDidFinish(true) + } +} From c6b82593736d8630758b5778e4fadfce71ffac9a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 25 Aug 2020 21:22:43 +0300 Subject: [PATCH 02/12] Fix stats availability flag --- submodules/TelegramCore/Sources/UpdateCachedPeerData.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TelegramCore/Sources/UpdateCachedPeerData.swift b/submodules/TelegramCore/Sources/UpdateCachedPeerData.swift index f61217fabb..493276fbae 100644 --- a/submodules/TelegramCore/Sources/UpdateCachedPeerData.swift +++ b/submodules/TelegramCore/Sources/UpdateCachedPeerData.swift @@ -355,7 +355,7 @@ func fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPeerId: PeerI if (flags & (1 << 10)) == 0 { channelFlags.insert(.preHistoryEnabled) } - if (flags & (1 << 12)) != 0 { + if (flags & (1 << 20)) != 0 { channelFlags.insert(.canViewStats) } if (flags & (1 << 7)) != 0 { From 80e93b6a303a4eefc6471eeb736ca1773a8008ca Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 25 Aug 2020 23:53:43 +0300 Subject: [PATCH 03/12] Fix avatar loading crash --- .../Sources/TGPhotoEditorController.m | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m index 6a5e18795e..5093a30128 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoEditorController.m +++ b/submodules/LegacyComponents/Sources/TGPhotoEditorController.m @@ -162,13 +162,21 @@ _initialAdjustments = adjustments; _screenImage = screenImage; + CGSize originalSize = _item.originalSize; + if ([self presentedForAvatarCreation]) { + CGFloat maxSide = [GPUImageContext maximumTextureSizeForThisDevice]; + if (MAX(_item.originalSize.width, _item.originalSize.height) > maxSide) { + originalSize = TGScaleToFit(_item.originalSize, CGSizeMake(maxSide, maxSide)); + } + } + _queue = [[SQueue alloc] init]; - _photoEditor = [[PGPhotoEditor alloc] initWithOriginalSize:_item.originalSize adjustments:adjustments forVideo:item.isVideo enableStickers:(intent & TGPhotoEditorControllerSignupAvatarIntent) == 0]; + _photoEditor = [[PGPhotoEditor alloc] initWithOriginalSize:originalSize adjustments:adjustments forVideo:item.isVideo enableStickers:(intent & TGPhotoEditorControllerSignupAvatarIntent) == 0]; if ([self presentedForAvatarCreation]) { _photoEditor.cropOnLast = true; - CGFloat shortSide = MIN(_item.originalSize.width, _item.originalSize.height); - _photoEditor.cropRect = CGRectMake((_item.originalSize.width - shortSide) / 2, (_item.originalSize.height - shortSide) / 2, shortSide, shortSide); + CGFloat shortSide = MIN(originalSize.width, originalSize.height); + _photoEditor.cropRect = CGRectMake((originalSize.width - shortSide) / 2, (originalSize.height - shortSide) / 2, shortSide, shortSide); } if ([adjustments isKindOfClass:[TGVideoEditAdjustments class]]) @@ -354,7 +362,7 @@ [_scrubberView addSubview:_dotMarkerView]; _dotMarkerView.center = CGPointMake(30.0, -20.0); - _dotImageView = [[TGMediaPickerGalleryVideoScrubberThumbnailView alloc] initWithImage:nil originalSize:_item.originalSize cropRect:CGRectZero cropOrientation:UIImageOrientationUp cropMirrored:false]; + _dotImageView = [[TGMediaPickerGalleryVideoScrubberThumbnailView alloc] initWithImage:nil originalSize:_photoEditor.originalSize cropRect:CGRectZero cropOrientation:UIImageOrientationUp cropMirrored:false]; _dotImageView.frame = CGRectMake(0.0, 0.0, 160.0, 160.0); _dotImageView.userInteractionEnabled = true; @@ -505,7 +513,13 @@ }] map:^UIImage *(UIImage *image) { if (avatar) { - return image; + CGFloat maxSide = [GPUImageContext maximumTextureSizeForThisDevice]; + if (MAX(image.size.width, image.size.height) > maxSide) { + CGSize fittedSize = TGScaleToFit(image.size, CGSizeMake(maxSide, maxSide)); + return TGScaleImageToPixelSize(image, fittedSize); + } else { + return image; + } } else { return TGPhotoEditorCrop(image, nil, photoEditor.cropOrientation, photoEditor.cropRotation, photoEditor.cropRect, photoEditor.cropMirrored, TGPhotoEditorScreenImageMaxSize(), photoEditor.originalSize, true); } From 0549a2cba877d4addc673dfe19fbf84486b63e2a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 26 Aug 2020 00:11:52 +0300 Subject: [PATCH 04/12] Make phone code input field wider --- .../ChangePhoneNumberControllerNode.swift | 16 ++++++++-------- ...izationSequencePhoneEntryControllerNode.swift | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift b/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift index f2662535ab..174f26a1e8 100644 --- a/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift +++ b/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift @@ -10,7 +10,7 @@ import PhoneInputNode import CountrySelectionUI private func generateCountryButtonBackground(color: UIColor, strokeColor: UIColor) -> UIImage? { - return generateImage(CGSize(width: 45.0, height: 44.0 + 6.0), rotatedContext: { size, context in + return generateImage(CGSize(width: 59, height: 44.0 + 6.0), rotatedContext: { size, context in let arrowSize: CGFloat = 6.0 let lineWidth = UIScreenPixel @@ -37,11 +37,11 @@ private func generateCountryButtonBackground(color: UIColor, strokeColor: UIColo context.move(to: CGPoint(x: 0.0, y: lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width, y: lineWidth / 2.0)) context.strokePath() - })?.stretchableImage(withLeftCapWidth: 46, topCapHeight: 1) + })?.stretchableImage(withLeftCapWidth: 58, topCapHeight: 1) } private func generateCountryButtonHighlightedBackground(color: UIColor) -> UIImage? { - return generateImage(CGSize(width: 45.0, height: 44.0 + 6.0), rotatedContext: { size, context in + return generateImage(CGSize(width: 59.0, height: 44.0 + 6.0), rotatedContext: { size, context in let arrowSize: CGFloat = 6.0 context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(color.cgColor) @@ -52,11 +52,11 @@ private func generateCountryButtonHighlightedBackground(color: UIColor) -> UIIma context.addLine(to: CGPoint(x: size.width - 1.0 - arrowSize - arrowSize, y: size.height - arrowSize)) context.closePath() context.fillPath() - })?.stretchableImage(withLeftCapWidth: 46, topCapHeight: 2) + })?.stretchableImage(withLeftCapWidth: 58, topCapHeight: 2) } private func generatePhoneInputBackground(color: UIColor, strokeColor: UIColor) -> UIImage? { - return generateImage(CGSize(width: 60.0, height: 44.0), rotatedContext: { size, context in + return generateImage(CGSize(width: 82.0, height: 44.0), rotatedContext: { size, context in let lineWidth = UIScreenPixel context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(color.cgColor) @@ -69,7 +69,7 @@ private func generatePhoneInputBackground(color: UIColor, strokeColor: UIColor) context.move(to: CGPoint(x: size.width - 2.0 + lineWidth / 2.0, y: size.height - lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width - 2.0 + lineWidth / 2.0, y: 0.0)) context.strokePath() - })?.stretchableImage(withLeftCapWidth: 61, topCapHeight: 2) + })?.stretchableImage(withLeftCapWidth: 81, topCapHeight: 2) } final class ChangePhoneNumberControllerNode: ASDisplayNode { @@ -261,8 +261,8 @@ final class ChangePhoneNumberControllerNode: ASDisplayNode { transition.updateFrame(node: self.countryButton, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationHeight), size: CGSize(width: layout.size.width, height: 44.0 + 6.0))) transition.updateFrame(node: self.phoneBackground, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationHeight + 44.0), size: CGSize(width: layout.size.width, height: 44.0))) - let countryCodeFrame = CGRect(origin: CGPoint(x: 9.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: 45.0, height: 44.0)) - let numberFrame = CGRect(origin: CGPoint(x: 70.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: layout.size.width - 70.0 - 8.0, height: 44.0)) + let countryCodeFrame = CGRect(origin: CGPoint(x: 9.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: 67.0, height: 44.0)) + let numberFrame = CGRect(origin: CGPoint(x: 92.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: layout.size.width - 70.0 - 8.0, height: 44.0)) let placeholderFrame = numberFrame.offsetBy(dx: -1.0, dy: 8.0) let phoneInputFrame = countryCodeFrame.union(numberFrame) diff --git a/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift b/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift index a6dda75351..35829cf051 100644 --- a/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift +++ b/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift @@ -27,7 +27,7 @@ private final class PhoneAndCountryNode: ASDisplayNode { init(strings: PresentationStrings, theme: PresentationTheme) { self.strings = strings - let countryButtonBackground = generateImage(CGSize(width: 61.0, height: 67.0), rotatedContext: { size, context in + let countryButtonBackground = generateImage(CGSize(width: 68.0, height: 67.0), rotatedContext: { size, context in let arrowSize: CGFloat = 10.0 let lineWidth = UIScreenPixel context.clear(CGRect(origin: CGPoint(), size: size)) @@ -43,9 +43,9 @@ private final class PhoneAndCountryNode: ASDisplayNode { context.addLine(to: CGPoint(x: size.width - 1.0 - arrowSize - arrowSize, y: size.height - arrowSize - lineWidth / 2.0)) context.addLine(to: CGPoint(x: 15.0, y: size.height - arrowSize - lineWidth / 2.0)) context.strokePath() - })?.stretchableImage(withLeftCapWidth: 61, topCapHeight: 1) + })?.stretchableImage(withLeftCapWidth: 67, topCapHeight: 1) - let countryButtonHighlightedBackground = generateImage(CGSize(width: 60.0, height: 67.0), rotatedContext: { size, context in + let countryButtonHighlightedBackground = generateImage(CGSize(width: 68.0, height: 67.0), rotatedContext: { size, context in let arrowSize: CGFloat = 10.0 context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(theme.list.itemHighlightedBackgroundColor.cgColor) @@ -56,9 +56,9 @@ private final class PhoneAndCountryNode: ASDisplayNode { context.addLine(to: CGPoint(x: size.width - 1.0 - arrowSize - arrowSize, y: size.height - arrowSize)) context.closePath() context.fillPath() - })?.stretchableImage(withLeftCapWidth: 61, topCapHeight: 2) + })?.stretchableImage(withLeftCapWidth: 67, topCapHeight: 2) - let phoneInputBackground = generateImage(CGSize(width: 85.0, height: 57.0), rotatedContext: { size, context in + let phoneInputBackground = generateImage(CGSize(width: 96.0, height: 57.0), rotatedContext: { size, context in let lineWidth = UIScreenPixel context.clear(CGRect(origin: CGPoint(), size: size)) context.setStrokeColor(theme.list.itemPlainSeparatorColor.cgColor) @@ -69,7 +69,7 @@ private final class PhoneAndCountryNode: ASDisplayNode { context.move(to: CGPoint(x: size.width - 2.0 + lineWidth / 2.0, y: size.height - lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width - 2.0 + lineWidth / 2.0, y: 0.0)) context.strokePath() - })?.stretchableImage(withLeftCapWidth: 84, topCapHeight: 2) + })?.stretchableImage(withLeftCapWidth: 95, topCapHeight: 2) self.countryButton = ASButtonNode() self.countryButton.displaysAsynchronously = false @@ -190,8 +190,8 @@ private final class PhoneAndCountryNode: ASDisplayNode { self.countryButton.frame = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 67.0)) self.phoneBackground.frame = CGRect(origin: CGPoint(x: 0.0, y: size.height - 57.0), size: CGSize(width: size.width, height: 57.0)) - let countryCodeFrame = CGRect(origin: CGPoint(x: 18.0, y: size.height - 57.0), size: CGSize(width: 60.0, height: 57.0)) - let numberFrame = CGRect(origin: CGPoint(x: 96.0, y: size.height - 57.0), size: CGSize(width: size.width - 96.0 - 8.0, height: 57.0)) + let countryCodeFrame = CGRect(origin: CGPoint(x: 18.0, y: size.height - 57.0), size: CGSize(width: 71.0, height: 57.0)) + let numberFrame = CGRect(origin: CGPoint(x: 107.0, y: size.height - 57.0), size: CGSize(width: size.width - 96.0 - 8.0, height: 57.0)) let placeholderFrame = numberFrame.offsetBy(dx: -1.0, dy: 16.0) let phoneInputFrame = countryCodeFrame.union(numberFrame) From 8bb519216bab1459203ac2e75bc826bbefb456dc Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 26 Aug 2020 00:18:46 +0300 Subject: [PATCH 05/12] Tweak phone input fields layout more --- .../Sources/ChangePhoneNumberControllerNode.swift | 12 ++++++------ ...thorizationSequencePhoneEntryControllerNode.swift | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift b/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift index 174f26a1e8..80f22d8b4b 100644 --- a/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift +++ b/submodules/SettingsUI/Sources/ChangePhoneNumberControllerNode.swift @@ -10,7 +10,7 @@ import PhoneInputNode import CountrySelectionUI private func generateCountryButtonBackground(color: UIColor, strokeColor: UIColor) -> UIImage? { - return generateImage(CGSize(width: 59, height: 44.0 + 6.0), rotatedContext: { size, context in + return generateImage(CGSize(width: 56, height: 44.0 + 6.0), rotatedContext: { size, context in let arrowSize: CGFloat = 6.0 let lineWidth = UIScreenPixel @@ -37,11 +37,11 @@ private func generateCountryButtonBackground(color: UIColor, strokeColor: UIColo context.move(to: CGPoint(x: 0.0, y: lineWidth / 2.0)) context.addLine(to: CGPoint(x: size.width, y: lineWidth / 2.0)) context.strokePath() - })?.stretchableImage(withLeftCapWidth: 58, topCapHeight: 1) + })?.stretchableImage(withLeftCapWidth: 55, topCapHeight: 1) } private func generateCountryButtonHighlightedBackground(color: UIColor) -> UIImage? { - return generateImage(CGSize(width: 59.0, height: 44.0 + 6.0), rotatedContext: { size, context in + return generateImage(CGSize(width: 56.0, height: 44.0 + 6.0), rotatedContext: { size, context in let arrowSize: CGFloat = 6.0 context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(color.cgColor) @@ -52,7 +52,7 @@ private func generateCountryButtonHighlightedBackground(color: UIColor) -> UIIma context.addLine(to: CGPoint(x: size.width - 1.0 - arrowSize - arrowSize, y: size.height - arrowSize)) context.closePath() context.fillPath() - })?.stretchableImage(withLeftCapWidth: 58, topCapHeight: 2) + })?.stretchableImage(withLeftCapWidth: 55, topCapHeight: 2) } private func generatePhoneInputBackground(color: UIColor, strokeColor: UIColor) -> UIImage? { @@ -261,9 +261,9 @@ final class ChangePhoneNumberControllerNode: ASDisplayNode { transition.updateFrame(node: self.countryButton, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationHeight), size: CGSize(width: layout.size.width, height: 44.0 + 6.0))) transition.updateFrame(node: self.phoneBackground, frame: CGRect(origin: CGPoint(x: 0.0, y: navigationHeight + 44.0), size: CGSize(width: layout.size.width, height: 44.0))) - let countryCodeFrame = CGRect(origin: CGPoint(x: 9.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: 67.0, height: 44.0)) + let countryCodeFrame = CGRect(origin: CGPoint(x: 11.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: 67.0, height: 44.0)) let numberFrame = CGRect(origin: CGPoint(x: 92.0, y: navigationHeight + 44.0 + 1.0), size: CGSize(width: layout.size.width - 70.0 - 8.0, height: 44.0)) - let placeholderFrame = numberFrame.offsetBy(dx: -1.0, dy: 8.0) + let placeholderFrame = numberFrame.offsetBy(dx: 0.0, dy: 8.0) let phoneInputFrame = countryCodeFrame.union(numberFrame) diff --git a/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift b/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift index 35829cf051..d6320febd5 100644 --- a/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift +++ b/submodules/TelegramUI/Sources/AuthorizationSequencePhoneEntryControllerNode.swift @@ -192,7 +192,7 @@ private final class PhoneAndCountryNode: ASDisplayNode { let countryCodeFrame = CGRect(origin: CGPoint(x: 18.0, y: size.height - 57.0), size: CGSize(width: 71.0, height: 57.0)) let numberFrame = CGRect(origin: CGPoint(x: 107.0, y: size.height - 57.0), size: CGSize(width: size.width - 96.0 - 8.0, height: 57.0)) - let placeholderFrame = numberFrame.offsetBy(dx: -1.0, dy: 16.0) + let placeholderFrame = numberFrame.offsetBy(dx: 0.0, dy: 16.0) let phoneInputFrame = countryCodeFrame.union(numberFrame) From d8b8793f9c7718d9cb74948881aeac41f9e955dd Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 26 Aug 2020 00:39:14 +0300 Subject: [PATCH 06/12] Fix message action callback progress updates --- .../TelegramUI/Sources/ChatController.swift | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index ca5c2dd380..7f473217a4 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -844,14 +844,44 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } + let updateProgress = { [weak self] in + Queue.mainQueue().async { + if let strongSelf = self { + strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { + return $0.updatedTitlePanelContext { + if let index = $0.firstIndex(where: { + switch $0 { + case .requestInProgress: + return true + default: + return false + } + }) { + var updatedContexts = $0 + updatedContexts.remove(at: index) + return updatedContexts + } + return $0 + } + }) + } + } + } + let account = strongSelf.context.account if requiresPassword { - strongSelf.messageActionCallbackDisposable.set((requestMessageActionCallbackPasswordCheck(account: account, messageId: messageId, isGame: isGame, data: data) - |> deliverOnMainQueue).start(error: { error in + strongSelf.messageActionCallbackDisposable.set(((requestMessageActionCallbackPasswordCheck(account: account, messageId: messageId, isGame: isGame, data: data) + |> afterDisposed { + updateProgress() + }) + |> deliverOnMainQueue).start(error: { error in let controller = ownershipTransferController(context: context, initialError: error, present: { c, a in strongSelf.present(c, in: .window(.root), with: a) }, commit: { password in - return requestMessageActionCallback(account: account, messageId: messageId, isGame: isGame, password: password, data: data) + return requestMessageActionCallback(account: account, messageId: messageId, isGame: isGame, password: password, data: data) + |> afterDisposed { + updateProgress() + } }, completion: { result in proceedWithResult(result) }) @@ -860,27 +890,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { strongSelf.messageActionCallbackDisposable.set(((requestMessageActionCallback(account: account, messageId: messageId, isGame: isGame, password: nil, data: data) |> afterDisposed { - Queue.mainQueue().async { - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { - return $0.updatedTitlePanelContext { - if let index = $0.firstIndex(where: { - switch $0 { - case .requestInProgress: - return true - default: - return false - } - }) { - var updatedContexts = $0 - updatedContexts.remove(at: index) - return updatedContexts - } - return $0 - } - }) - } - } + updateProgress() }) |> deliverOnMainQueue).start(next: { result in proceedWithResult(result) From 732f0e6bea34fbfc45703639596b04c1e0d598e3 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 12:47:58 +0100 Subject: [PATCH 07/12] Merge --- build-system/bazel-rules/apple_support | 2 +- build-system/bazel-rules/rules_apple | 2 +- build-system/bazel-rules/rules_swift | 2 +- build-system/tulsi | 2 +- third-party/libvpx/libvpx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build-system/bazel-rules/apple_support b/build-system/bazel-rules/apple_support index 501b4afb27..b8755bd288 160000 --- a/build-system/bazel-rules/apple_support +++ b/build-system/bazel-rules/apple_support @@ -1 +1 @@ -Subproject commit 501b4afb27745c4813a88ffa28acd901408014e4 +Subproject commit b8755bd2884d6bf651827c30e00bd0ea318e41a2 diff --git a/build-system/bazel-rules/rules_apple b/build-system/bazel-rules/rules_apple index 748e7e2b1e..d6f9a87d70 160000 --- a/build-system/bazel-rules/rules_apple +++ b/build-system/bazel-rules/rules_apple @@ -1 +1 @@ -Subproject commit 748e7e2b1ee5e8976ba873394cbd5e32b61818c7 +Subproject commit d6f9a87d70781e92b95b9344c7d21d921ccc3ae2 diff --git a/build-system/bazel-rules/rules_swift b/build-system/bazel-rules/rules_swift index 6408d85da7..44e8c29afe 160000 --- a/build-system/bazel-rules/rules_swift +++ b/build-system/bazel-rules/rules_swift @@ -1 +1 @@ -Subproject commit 6408d85da799ec2af053c4e2883dce3ce6d30f08 +Subproject commit 44e8c29afe3baa7f5fc434f4a7e83f7ac786644e diff --git a/build-system/tulsi b/build-system/tulsi index ee185c4c20..e890fb6c88 160000 --- a/build-system/tulsi +++ b/build-system/tulsi @@ -1 +1 @@ -Subproject commit ee185c4c20ea4384bc3cbf8ccd8705c904154abb +Subproject commit e890fb6c88846454c4f69abd8d265a302c0e80e4 diff --git a/third-party/libvpx/libvpx b/third-party/libvpx/libvpx index c413c8f18e..2d20a42ab6 160000 --- a/third-party/libvpx/libvpx +++ b/third-party/libvpx/libvpx @@ -1 +1 @@ -Subproject commit c413c8f18eb1932b100850505031980e27160d5f +Subproject commit 2d20a42ab60f8fed37612361f2ea776d0bc7ca1a From 1ef233719ca4b5618af70f81b909adf5d5a2a9dc Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 13:31:38 +0100 Subject: [PATCH 08/12] Fix log path [nocache] --- .../Sources/ChatInterfaceStateContextMenus.swift | 7 ++++++- submodules/TelegramVoip/Sources/OngoingCallContext.swift | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 2466374495..3ca84785e2 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -414,7 +414,12 @@ func contextMenuForChatPresentationIntefaceState(chatPresentationInterfaceState: let logsPath = callLogsPath(account: context.account) let logPath = logsPath + "/" + logName let start = logName.index(logName.startIndex, offsetBy: "\(id)".count + 1) - let end = logName.index(logName.endIndex, offsetBy: -4 - 5) + let end: String.Index + if logName.hasSuffix(".log.json") { + end = logName.index(logName.endIndex, offsetBy: -4 - 5) + } else { + end = logName.index(logName.endIndex, offsetBy: -4) + } let accessHash = logName[start.. String? { for url in enumerator { if let url = url as? URL { if url.lastPathComponent.hasPrefix(namePrefix) { + if url.lastPathComponent.hasSuffix(".log.json") { + continue + } return url.lastPathComponent } } From 3a9a131c8568832813c8378d1e3a4c7bfe74b7ec Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 14:50:24 +0100 Subject: [PATCH 09/12] Update submodule --- submodules/rlottie/rlottie | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/rlottie/rlottie b/submodules/rlottie/rlottie index 970fa3ae9f..af8d9313db 160000 --- a/submodules/rlottie/rlottie +++ b/submodules/rlottie/rlottie @@ -1 +1 @@ -Subproject commit 970fa3ae9f2f567ca260981e2f4304d6abfd88b7 +Subproject commit af8d9313db00e216d5d1572369477e741fc4d461 From fe20ce67b359c999b6a1509109077d3c703f3061 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 16:17:07 +0100 Subject: [PATCH 10/12] Trigger rebuild --- Random.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Random.txt b/Random.txt index ddf1b87341..74e882fd4a 100644 --- a/Random.txt +++ b/Random.txt @@ -1 +1 @@ -NC8Ilqd9zpOXIij3OOYFUJxDucj8mEwygMYgxbeBpE0= ++ENS8aythHtLSRDHjunJjPNy+iEawfdaaYB4Q5g9PP8= From 275e5c1a2e78303d3996350b5ea686d6425a2466 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 16:26:41 +0100 Subject: [PATCH 11/12] Trigger rebuild [nocache] --- Random.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Random.txt b/Random.txt index 74e882fd4a..ca2dee0413 100644 --- a/Random.txt +++ b/Random.txt @@ -1 +1 @@ -+ENS8aythHtLSRDHjunJjPNy+iEawfdaaYB4Q5g9PP8= +8tRwQybvfoDddhSIfdMSOMv4FZd9LSHiWmObmx6d7rE= From fe440aad4489f4ce19aaba95f6bdcf2e6b2f4f80 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 27 Aug 2020 17:18:10 +0100 Subject: [PATCH 12/12] Fix progressive photo sizes [nocache] --- submodules/PhotoResources/Sources/PhotoResources.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/submodules/PhotoResources/Sources/PhotoResources.swift b/submodules/PhotoResources/Sources/PhotoResources.swift index b8e3aa46fd..4980951cd6 100644 --- a/submodules/PhotoResources/Sources/PhotoResources.swift +++ b/submodules/PhotoResources/Sources/PhotoResources.swift @@ -32,9 +32,9 @@ public func largestRepresentationForPhoto(_ photo: TelegramMediaImage) -> Telegr private let progressiveRangeMap: [(Int, [Int])] = [ (100, [0]), - (400, [2]), - (600, [4, 5]), - (Int(Int32.max), [4, 5, 8, 9]) + (400, [1]), + (600, [2, 3]), + (Int(Int32.max), [2, 3, 4]) ] public func representationFetchRangeForDisplayAtSize(representation: TelegramMediaImageRepresentation, dimension: Int) -> Range? { @@ -52,7 +52,7 @@ public func representationFetchRangeForDisplayAtSize(representation: TelegramMed } public func chatMessagePhotoDatas(postbox: Postbox, photoReference: ImageMediaReference, fullRepresentationSize: CGSize = CGSize(width: 1280.0, height: 1280.0), autoFetchFullSize: Bool = false, tryAdditionalRepresentations: Bool = false, synchronousLoad: Bool = false, useMiniThumbnailIfAvailable: Bool = false) -> Signal, NoError> { - if let progressiveRepresentation = progressiveImageRepresentation(photoReference.media.representations), progressiveRepresentation.progressiveSizes.count == 10 { + if let progressiveRepresentation = progressiveImageRepresentation(photoReference.media.representations), progressiveRepresentation.progressiveSizes.count == 5 { enum SizeSource { case miniThumbnail(data: Data) case image(size: Int)