diff --git a/Telegram-iOS/en.lproj/Localizable.strings b/Telegram-iOS/en.lproj/Localizable.strings index 9dd93aa449..2d7372d412 100644 --- a/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram-iOS/en.lproj/Localizable.strings @@ -5268,13 +5268,13 @@ Any member of this group will be able to see messages in the channel."; "PollResults.Title" = "Poll Results"; "PollResults.Collapse" = "COLLAPSE"; -"PollResults.ShowMore_1" = "Show %@ More Person"; -"PollResults.ShowMore_any" = "Show %@ More People"; +"PollResults.ShowMore_1" = "Show %@ More"; +"PollResults.ShowMore_any" = "Show %@ More"; "Conversation.StopQuiz" = "Stop Quiz"; "Conversation.StopQuizConfirmationTitle" = "If you stop this quiz now, nobody will be able to submit answers. This action cannot be undone."; "Conversation.StopQuizConfirmation" = "Stop Quiz"; "Forward.ErrorDisabledForChat" = "Sorry, you can't forward messages to this chat."; -"Forward.ErrorPublicPollDisabledInChannels" = "Sorry, you can't forward public poll to the channel."; -"Forward.ErrorPublicQuizDisabledInChannels" = "Sorry, you can't forward public quiz to the channel."; +"Forward.ErrorPublicPollDisabledInChannels" = "Sorry, public polls can’t be forwarded to channels."; +"Forward.ErrorPublicQuizDisabledInChannels" = "Sorry, public polls can’t be forwarded to channels."; diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index 0aa47ea55a..18f61800f6 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -416,7 +416,7 @@ public final class AvatarNode: ASDisplayNode { if peerId.namespace == -1 { colorIndex = -1 } else { - colorIndex = abs(Int(clamping: accountPeerId.id &+ peerId.id)) + colorIndex = abs(Int(clamping: peerId.id)) } } else { colorIndex = -1 @@ -582,6 +582,8 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) + context.resetClip() + context.setBlendMode(.normal) let string = letters.count == 0 ? "" : (letters[0] + (letters.count == 1 ? "" : letters[1])) @@ -597,7 +599,9 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont context.scaleBy(x: 1.0, y: -1.0) context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0) + let textPosition = context.textPosition context.translateBy(x: lineOrigin.x, y: lineOrigin.y) CTLineDraw(line, context) context.translateBy(x: -lineOrigin.x, y: -lineOrigin.y) + context.textPosition = textPosition } diff --git a/submodules/DirectionalPanGesture/Sources/DirectionalPanGestureRecognizer.swift b/submodules/DirectionalPanGesture/Sources/DirectionalPanGestureRecognizer.swift index 74ec8d23ca..ce7a0fc69b 100644 --- a/submodules/DirectionalPanGesture/Sources/DirectionalPanGestureRecognizer.swift +++ b/submodules/DirectionalPanGesture/Sources/DirectionalPanGestureRecognizer.swift @@ -5,6 +5,8 @@ public class DirectionalPanGestureRecognizer: UIPanGestureRecognizer { private var validatedGesture = false private var firstLocation: CGPoint = CGPoint() + public var shouldBegin: ((CGPoint) -> Bool)? + override public init(target: Any?, action: Selector?) { super.init(target: target, action: action) @@ -21,7 +23,13 @@ public class DirectionalPanGestureRecognizer: UIPanGestureRecognizer { super.touchesBegan(touches, with: event) let touch = touches.first! - self.firstLocation = touch.location(in: self.view) + let point = touch.location(in: self.view) + if let shouldBegin = self.shouldBegin, !shouldBegin(point) { + self.state = .failed + return + } + + self.firstLocation = point if let target = self.view?.hitTest(self.firstLocation, with: event) { if target == self.view { diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift index ea41559ece..f55097b4a2 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift @@ -296,7 +296,13 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, editMediaO })! itemViews.append(locationItem) - if (peer is TelegramGroup || peer is TelegramChannel) && canSendMessagesToPeer(peer) && canSendPolls { + var peerSupportsPolls = false + if peer is TelegramGroup || peer is TelegramChannel { + peerSupportsPolls = true + } else if let user = peer as? TelegramUser, let _ = user.botInfo { + peerSupportsPolls = true + } + if peerSupportsPolls && canSendMessagesToPeer(peer) && canSendPolls { let pollItem = TGMenuSheetButtonItemView(title: presentationData.strings.AttachmentMenu_Poll, type: TGMenuSheetButtonTypeDefault, fontSize: fontSize, action: { [weak controller] in controller?.dismiss(animated: true) openPoll() diff --git a/submodules/TelegramCore/Sources/Polls.swift b/submodules/TelegramCore/Sources/Polls.swift index 81d99f3cf4..57ec6751b9 100644 --- a/submodules/TelegramCore/Sources/Polls.swift +++ b/submodules/TelegramCore/Sources/Polls.swift @@ -229,7 +229,7 @@ private final class PollResultsOptionContext { } |> mapToSignal { inputPeer -> Signal<([RenderedPeer], Int, String?), NoError> in if let inputPeer = inputPeer { - let signal = account.network.request(Api.functions.messages.getPollVotes(flags: 1 << 0, peer: inputPeer, id: messageId.id, option: Buffer(data: opaqueIdentifier), offset: nextOffset, limit: nextOffset == nil ? 10 : 50)) + let signal = account.network.request(Api.functions.messages.getPollVotes(flags: 1 << 0, peer: inputPeer, id: messageId.id, option: Buffer(data: opaqueIdentifier), offset: nextOffset, limit: nextOffset == nil ? 15 : 50)) |> map(Optional.init) |> `catch` { _ -> Signal in return .single(nil) diff --git a/submodules/TelegramUI/TelegramUI/ChatMessagePollBubbleContentNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessagePollBubbleContentNode.swift index f6ede984b1..945a5f7427 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessagePollBubbleContentNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessagePollBubbleContentNode.swift @@ -1351,7 +1351,7 @@ class ChatMessagePollBubbleContentNode: ChatMessageBubbleContentNode { if optionNode.frame.contains(point), case .tap = gesture { if optionNode.isUserInteractionEnabled { return .ignore - } else if let result = optionNode.currentResult, let item = self.item, let option = optionNode.option { + } else if let result = optionNode.currentResult, let item = self.item, let poll = self.poll, case .public = poll.publicity, let option = optionNode.option { if !isEstimating { item.controllerInteraction.openMessagePollResults(item.message.id, option.opaqueIdentifier) return .ignore @@ -1543,6 +1543,7 @@ private final class MergedAvatarsNode: ASDisplayNode { case let .letters(peerId, letters): context.translateBy(x: currentX, y: 0.0) drawPeerAvatarLetters(context: context, size: CGSize(width: mergedImageSize, height: mergedImageSize), font: avatarFont, letters: letters, peerId: peerId) + context.translateBy(x: -currentX, y: 0.0) case let .image(reference): if let image = parameters.images[parameters.peers[i].peerId] { context.translateBy(x: imageRect.midX, y: imageRect.midY) diff --git a/submodules/TelegramUI/TelegramUI/OverlayPlayerControllerNode.swift b/submodules/TelegramUI/TelegramUI/OverlayPlayerControllerNode.swift index fb21839166..339f1da827 100644 --- a/submodules/TelegramUI/TelegramUI/OverlayPlayerControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/OverlayPlayerControllerNode.swift @@ -259,7 +259,18 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu panRecognizer.delegate = self panRecognizer.delaysTouchesBegan = false panRecognizer.cancelsTouchesInView = true - //self.view.addGestureRecognizer(panRecognizer) + panRecognizer.shouldBegin = { [weak self] point in + guard let strongSelf = self else { + return false + } + if strongSelf.controlsNode.bounds.contains(strongSelf.view.convert(point, to: strongSelf.controlsNode.view)) { + if strongSelf.controlsNode.frame.maxY <= strongSelf.historyNode.frame.minY { + return true + } + } + return false + } + self.view.addGestureRecognizer(panRecognizer) } func updatePresentationData(_ presentationData: PresentationData) { @@ -325,7 +336,9 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu if self.controlsNode.bounds.contains(self.view.convert(point, to: self.controlsNode.view)) { let controlsHitTest = self.controlsNode.view.hitTest(self.view.convert(point, to: self.controlsNode.view), with: event) if controlsHitTest == nil { - return self.historyNode.view + if self.controlsNode.frame.maxY > self.historyNode.frame.minY { + return self.historyNode.view + } } } diff --git a/submodules/TelegramUI/TelegramUI/PollResultsController.swift b/submodules/TelegramUI/TelegramUI/PollResultsController.swift index 3036a9833d..55c3729a44 100644 --- a/submodules/TelegramUI/TelegramUI/PollResultsController.swift +++ b/submodules/TelegramUI/TelegramUI/PollResultsController.swift @@ -322,13 +322,17 @@ public func pollResultsController(context: AccountContext, messageId: MessageId, var initialScrollToItem: ListViewScrollToItem? if let focusOnOptionWithOpaqueIdentifier = focusOnOptionWithOpaqueIdentifier, previousWasEmptyValue == nil { + var isFirstOption = true loop: for i in 0 ..< entries.count { switch entries[i] { case let .optionPeer(optionPeer): if optionPeer.opaqueIdentifier == focusOnOptionWithOpaqueIdentifier { - initialScrollToItem = ListViewScrollToItem(index: i, position: .top(0.0), animated: false, curve: .Default(duration: nil), directionHint: .Down) + if !isFirstOption { + initialScrollToItem = ListViewScrollToItem(index: i, position: .top(0.0), animated: false, curve: .Default(duration: nil), directionHint: .Down) + } break loop } + isFirstOption = false default: break }