diff --git a/submodules/AvatarNode/Sources/AvatarNode.swift b/submodules/AvatarNode/Sources/AvatarNode.swift index 246a19f26e..00fccc23c8 100644 --- a/submodules/AvatarNode/Sources/AvatarNode.swift +++ b/submodules/AvatarNode/Sources/AvatarNode.swift @@ -985,9 +985,18 @@ public final class AvatarBadgeView: UIImageView { context.setFillColor(UIColor(white: 0.0, alpha: 0.05).cgColor) context.fillEllipse(in: CGRect(origin: CGPoint(), size: size))*/ - let string = NSAttributedString(string: parameters.text, font: Font.bold(floor(parameters.size.height * 0.48)), textColor: .white) - let stringBounds = string.boundingRect(with: CGSize(width: 100.0, height: 100.0), options: .usesLineFragmentOrigin, context: nil) - string.draw(at: CGPoint(x: stringBounds.minX + floorToScreenPixels((size.width - stringBounds.width) / 2.0), y: stringBounds.minY + floorToScreenPixels((size.height - stringBounds.height) / 2.0))) + var fontSize: CGFloat = floor(parameters.size.height * 0.48) + while true { + let string = NSAttributedString(string: parameters.text, font: Font.bold(fontSize), textColor: .white) + let stringBounds = string.boundingRect(with: CGSize(width: 100.0, height: 100.0), options: .usesLineFragmentOrigin, context: nil) + + if stringBounds.width <= size.width - 5.0 * 2.0 || fontSize <= 2.0 { + string.draw(at: CGPoint(x: stringBounds.minX + floorToScreenPixels((size.width - stringBounds.width) / 2.0), y: stringBounds.minY + floorToScreenPixels((size.height - stringBounds.height) / 2.0))) + break + } else { + fontSize -= 1.0 + } + } let lineWidth: CGFloat = 1.5 let lineInset: CGFloat = 2.0 diff --git a/submodules/SettingsUI/Sources/Privacy and Security/GlobalAutoremoveScreen.swift b/submodules/SettingsUI/Sources/Privacy and Security/GlobalAutoremoveScreen.swift index e8ae528236..27c3b92a6b 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/GlobalAutoremoveScreen.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/GlobalAutoremoveScreen.swift @@ -226,6 +226,7 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32, var state = state state.updatedValue = timeout if timeout != 0 { + state.additionalValues.removeAll() state.additionalValues.insert(timeout) } return state @@ -321,6 +322,9 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32, if user.botInfo == nil { canManage = true } + if user.id.isRepliesOrSavedMessages(accountPeerId: context.account.peerId) { + return false + } } else if case .secretChat = peer { canManage = true } else if case let .legacyGroup(group) = peer { @@ -354,8 +358,23 @@ public func globalAutoremoveScreen(context: AccountContext, initialValue: Int32, } else { selectionController?.displayProgress = true let _ = (context.engine.peers.setChatMessageAutoremoveTimeouts(peerIds: peerIds, timeout: value) - |> deliverOnMainQueue).start(completed: { + |> deliverOnMainQueue).start(completed: { selectionController?.dismiss() + + let isOn: Bool = true + //TODO:localize + let text = "You applied the \(timeIntervalString(strings: presentationData.strings, value: value)) self-destruct timer to \(peerIds.count) \(peerIds.count == 1 ? "chat" : "chats")." + + var animateAsReplacement = false + if let window = getController?()?.window { + window.forEachController { other in + if let other = other as? UndoOverlayController { + animateAsReplacement = true + other.dismiss() + } + } + } + presentControllerImpl?(UndoOverlayController(presentationData: presentationData, content: .autoDelete(isOn: isOn, title: nil, text: text), elevatedLayout: false, animateInAsReplacement: animateAsReplacement, action: { _ in return false }), nil) }) } }) diff --git a/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/AutoremoveIconOff.svg b/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/AutoremoveIconOff.svg deleted file mode 100644 index 2a5f77534c..0000000000 --- a/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/AutoremoveIconOff.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Contents.json index cc433a9fa8..eb2f2c51d0 100644 --- a/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Contents.json +++ b/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "AutoremoveIconOff.svg", + "filename" : "Frame 4.svg", "idiom" : "universal" } ], diff --git a/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Frame 4.svg b/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Frame 4.svg new file mode 100644 index 0000000000..342e8db698 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Chat List/StatusIconAutoremoveOff.imageset/Frame 4.svg @@ -0,0 +1,4 @@ + + + + diff --git a/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift index e099103a24..0dd4d00fd4 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift @@ -208,7 +208,7 @@ class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode { if let (currentOffset, currentImage, currentRects) = cachedMaskBackgroundImage, currentRects == labelRects { backgroundMaskImage = (currentOffset, currentImage) } else { - backgroundMaskImage = LinkHighlightingNode.generateImage(color: .black, inset: 0.0, innerRadius: 10.0, outerRadius: 10.0, rects: labelRects, useModernPathCalculation: false) + backgroundMaskImage = LinkHighlightingNode.generateImage(color: .black, inset: 0.0, innerRadius: 10.0, outerRadius: 10.0, rects: labelRects, useModernPathCalculation: true) backgroundMaskUpdated = true } @@ -449,6 +449,7 @@ class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode { } else { let serviceColor = serviceMessageColorComponents(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) linkHighlightingNode = LinkHighlightingNode(color: serviceColor.linkHighlight) + linkHighlightingNode.useModernPathCalculation = true linkHighlightingNode.inset = 2.5 self.linkHighlightingNode = linkHighlightingNode self.insertSubnode(linkHighlightingNode, belowSubnode: self.labelNode.textNode) diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 51dd0ff546..755b518892 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -169,8 +169,10 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode { let previousItem = self.item self.item = item + let (updatedImage, text, _, _, _) = AccessoryItemIconButtonNode.imageAndInsets(item: item, theme: self.theme, strings: self.strings) + if let image = self.iconImageNode.image { - self.iconImageNode.image = AccessoryItemIconButtonNode.imageAndInsets(item: item, theme: self.theme, strings: self.strings).0 + self.iconImageNode.image = updatedImage let bottomInset: CGFloat = 0.0 let imageFrame = CGRect(origin: CGPoint(x: floor((size.width - image.size.width) / 2.0), y: floor((size.height - image.size.height) / 2.0) - bottomInset), size: image.size) @@ -307,6 +309,12 @@ private final class AccessoryItemIconButtonNode: HighlightTrackingButtonNode { } } } + + if let text = text { + self.setAttributedTitle(NSAttributedString(string: text, font: accessoryButtonFont, textColor: self.theme.chat.inputPanel.inputControlColor), for: .normal) + } else { + self.setAttributedTitle(NSAttributedString(), for: .normal) + } } var buttonWidth: CGFloat {