mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Improvements
This commit is contained in:
parent
1946dffa2d
commit
d01eeb93a9
@ -7079,9 +7079,9 @@ Sorry for the inconvenience.";
|
|||||||
|
|
||||||
"AuthSessions.View.LocationInfo" = "This location estimate is based on the IP address and may not always be accurate.";
|
"AuthSessions.View.LocationInfo" = "This location estimate is based on the IP address and may not always be accurate.";
|
||||||
|
|
||||||
"AuthSessions.View.AcceptSecretChatsTitle" = "Incoming Secret Chats";
|
"AuthSessions.View.AcceptTitle" = "Accept on This Device";
|
||||||
"AuthSessions.View.AcceptSecretChats" = "Accept on This Device";
|
"AuthSessions.View.AcceptSecretChats" = "New Secret Chats";
|
||||||
"AuthSessions.View.AcceptSecretChatsInfo" = "You can disable the acception of incoming secret chats on this device.";
|
"AuthSessions.View.AcceptIncomingCalls" = "Incoming Calls";
|
||||||
|
|
||||||
"Conversation.SendMesageAs" = "Send Message As...";
|
"Conversation.SendMesageAs" = "Send Message As...";
|
||||||
"Conversation.InviteRequestAdminGroup" = "%1$@ is an admin of %2$@, a group you requested to join.";
|
"Conversation.InviteRequestAdminGroup" = "%1$@ is an admin of %2$@, a group you requested to join.";
|
||||||
|
@ -703,6 +703,8 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont
|
|||||||
}, openSession: { session in
|
}, openSession: { session in
|
||||||
let controller = RecentSessionScreen(context: context, subject: .session(session), updateAcceptSecretChats: { value in
|
let controller = RecentSessionScreen(context: context, subject: .session(session), updateAcceptSecretChats: { value in
|
||||||
updateSessionDisposable.set(activeSessionsContext.updateSessionAcceptsSecretChats(session, accepts: value).start())
|
updateSessionDisposable.set(activeSessionsContext.updateSessionAcceptsSecretChats(session, accepts: value).start())
|
||||||
|
}, updateAcceptIncomingCalls: { value in
|
||||||
|
updateSessionDisposable.set(activeSessionsContext.updateSessionAcceptsIncomingCalls(session, accepts: value).start())
|
||||||
}, remove: { completion in
|
}, remove: { completion in
|
||||||
removeSessionImpl(session.hash, {
|
removeSessionImpl(session.hash, {
|
||||||
completion()
|
completion()
|
||||||
@ -710,7 +712,7 @@ public func recentSessionsController(context: AccountContext, activeSessionsCont
|
|||||||
})
|
})
|
||||||
presentControllerImpl?(controller, nil)
|
presentControllerImpl?(controller, nil)
|
||||||
}, openWebSession: { session, peer in
|
}, openWebSession: { session, peer in
|
||||||
let controller = RecentSessionScreen(context: context, subject: .website(session, peer), updateAcceptSecretChats: { _ in }, remove: { completion in
|
let controller = RecentSessionScreen(context: context, subject: .website(session, peer), updateAcceptSecretChats: { _ in }, updateAcceptIncomingCalls: { _ in }, remove: { completion in
|
||||||
removeWebSessionImpl(session.hash)
|
removeWebSessionImpl(session.hash)
|
||||||
completion()
|
completion()
|
||||||
})
|
})
|
||||||
|
@ -56,6 +56,7 @@ final class RecentSessionScreen: ViewController {
|
|||||||
private let subject: RecentSessionScreen.Subject
|
private let subject: RecentSessionScreen.Subject
|
||||||
private let remove: (@escaping () -> Void) -> Void
|
private let remove: (@escaping () -> Void) -> Void
|
||||||
private let updateAcceptSecretChats: (Bool) -> Void
|
private let updateAcceptSecretChats: (Bool) -> Void
|
||||||
|
private let updateAcceptIncomingCalls: (Bool) -> Void
|
||||||
|
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
@ -70,12 +71,13 @@ final class RecentSessionScreen: ViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init(context: AccountContext, subject: RecentSessionScreen.Subject, updateAcceptSecretChats: @escaping (Bool) -> Void, remove: @escaping (@escaping () -> Void) -> Void) {
|
init(context: AccountContext, subject: RecentSessionScreen.Subject, updateAcceptSecretChats: @escaping (Bool) -> Void, updateAcceptIncomingCalls: @escaping (Bool) -> Void, remove: @escaping (@escaping () -> Void) -> Void) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
self.remove = remove
|
self.remove = remove
|
||||||
self.updateAcceptSecretChats = updateAcceptSecretChats
|
self.updateAcceptSecretChats = updateAcceptSecretChats
|
||||||
|
self.updateAcceptIncomingCalls = updateAcceptIncomingCalls
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: nil)
|
super.init(navigationBarPresentationData: nil)
|
||||||
|
|
||||||
@ -119,6 +121,9 @@ final class RecentSessionScreen: ViewController {
|
|||||||
self.controllerNode.updateAcceptSecretChats = { [weak self] value in
|
self.controllerNode.updateAcceptSecretChats = { [weak self] value in
|
||||||
self?.updateAcceptSecretChats(value)
|
self?.updateAcceptSecretChats(value)
|
||||||
}
|
}
|
||||||
|
self.controllerNode.updateAcceptIncomingCalls = { [weak self] value in
|
||||||
|
self?.updateAcceptIncomingCalls(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public func loadView() {
|
override public func loadView() {
|
||||||
@ -178,11 +183,13 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
private let locationValueNode: ImmediateTextNode
|
private let locationValueNode: ImmediateTextNode
|
||||||
private let locationInfoNode: ImmediateTextNode
|
private let locationInfoNode: ImmediateTextNode
|
||||||
|
|
||||||
private let secretChatsBackgroundNode: ASDisplayNode
|
private let acceptBackgroundNode: ASDisplayNode
|
||||||
private let secretChatsHeaderNode: ImmediateTextNode
|
private let acceptHeaderNode: ImmediateTextNode
|
||||||
private let secretChatsTitleNode: ImmediateTextNode
|
private let secretChatsTitleNode: ImmediateTextNode
|
||||||
private let secretChatsSwitchNode: SwitchNode
|
private let secretChatsSwitchNode: SwitchNode
|
||||||
private let secretChatsInfoNode: ImmediateTextNode
|
private let incomingCallsTitleNode: ImmediateTextNode
|
||||||
|
private let incomingCallsSwitchNode: SwitchNode
|
||||||
|
private let acceptSeparatorNode: ASDisplayNode
|
||||||
|
|
||||||
private let cancelButton: HighlightableButtonNode
|
private let cancelButton: HighlightableButtonNode
|
||||||
private let terminateButton: SolidRoundedButtonNode
|
private let terminateButton: SolidRoundedButtonNode
|
||||||
@ -193,6 +200,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
var remove: (() -> Void)?
|
var remove: (() -> Void)?
|
||||||
var dismiss: (() -> Void)?
|
var dismiss: (() -> Void)?
|
||||||
var updateAcceptSecretChats: ((Bool) -> Void)?
|
var updateAcceptSecretChats: ((Bool) -> Void)?
|
||||||
|
var updateAcceptIncomingCalls: ((Bool) -> Void)?
|
||||||
|
|
||||||
init(context: AccountContext, presentationData: PresentationData, controller: RecentSessionScreen, subject: RecentSessionScreen.Subject) {
|
init(context: AccountContext, presentationData: PresentationData, controller: RecentSessionScreen, subject: RecentSessionScreen.Subject) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -249,10 +257,11 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
self.locationValueNode = ImmediateTextNode()
|
self.locationValueNode = ImmediateTextNode()
|
||||||
self.locationInfoNode = ImmediateTextNode()
|
self.locationInfoNode = ImmediateTextNode()
|
||||||
|
|
||||||
self.secretChatsHeaderNode = ImmediateTextNode()
|
self.acceptHeaderNode = ImmediateTextNode()
|
||||||
self.secretChatsTitleNode = ImmediateTextNode()
|
self.secretChatsTitleNode = ImmediateTextNode()
|
||||||
self.secretChatsSwitchNode = SwitchNode()
|
self.secretChatsSwitchNode = SwitchNode()
|
||||||
self.secretChatsInfoNode = ImmediateTextNode()
|
self.incomingCallsTitleNode = ImmediateTextNode()
|
||||||
|
self.incomingCallsSwitchNode = SwitchNode()
|
||||||
|
|
||||||
self.cancelButton = HighlightableButtonNode()
|
self.cancelButton = HighlightableButtonNode()
|
||||||
self.cancelButton.setImage(closeButtonImage(theme: self.presentationData.theme), for: .normal)
|
self.cancelButton.setImage(closeButtonImage(theme: self.presentationData.theme), for: .normal)
|
||||||
@ -330,6 +339,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats)
|
self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats)
|
||||||
|
self.incomingCallsSwitchNode.isOn = session.flags.contains(.acceptsIncomingCalls)
|
||||||
|
|
||||||
if !session.flags.contains(.passwordPending) && ![2040, 2496].contains(session.apiId) {
|
if !session.flags.contains(.passwordPending) && ![2040, 2496].contains(session.apiId) {
|
||||||
hasSecretChats = true
|
hasSecretChats = true
|
||||||
@ -391,15 +401,17 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor)
|
self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor)
|
||||||
self.locationInfoNode.maximumNumberOfLines = 3
|
self.locationInfoNode.maximumNumberOfLines = 3
|
||||||
|
|
||||||
self.secretChatsBackgroundNode = ASDisplayNode()
|
self.acceptBackgroundNode = ASDisplayNode()
|
||||||
self.secretChatsBackgroundNode.clipsToBounds = true
|
self.acceptBackgroundNode.clipsToBounds = true
|
||||||
self.secretChatsBackgroundNode.cornerRadius = 11
|
self.acceptBackgroundNode.cornerRadius = 11
|
||||||
self.secretChatsBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
self.acceptBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
|
|
||||||
self.secretChatsHeaderNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChatsTitle.uppercased(), font: Font.regular(17.0), textColor: textColor)
|
self.acceptHeaderNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptTitle.uppercased(), font: Font.regular(17.0), textColor: textColor)
|
||||||
self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChats, font: Font.regular(17.0), textColor: textColor)
|
self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChats, font: Font.regular(17.0), textColor: textColor)
|
||||||
self.secretChatsInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChatsInfo, font: Font.regular(17.0), textColor: secondaryTextColor)
|
self.incomingCallsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptIncomingCalls, font: Font.regular(17.0), textColor: textColor)
|
||||||
self.secretChatsInfoNode.maximumNumberOfLines = 3
|
|
||||||
|
self.acceptSeparatorNode = ASDisplayNode()
|
||||||
|
self.acceptSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -442,18 +454,27 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
self.animationNode.flatMap { self.contentContainerNode.addSubnode($0) }
|
self.animationNode.flatMap { self.contentContainerNode.addSubnode($0) }
|
||||||
self.avatarNode.flatMap { self.contentContainerNode.addSubnode($0) }
|
self.avatarNode.flatMap { self.contentContainerNode.addSubnode($0) }
|
||||||
|
|
||||||
|
self.contentContainerNode.addSubnode(self.acceptBackgroundNode)
|
||||||
|
self.contentContainerNode.addSubnode(self.acceptHeaderNode)
|
||||||
if hasSecretChats {
|
if hasSecretChats {
|
||||||
self.contentContainerNode.addSubnode(self.secretChatsBackgroundNode)
|
|
||||||
self.contentContainerNode.addSubnode(self.secretChatsHeaderNode)
|
|
||||||
self.contentContainerNode.addSubnode(self.secretChatsTitleNode)
|
self.contentContainerNode.addSubnode(self.secretChatsTitleNode)
|
||||||
self.contentContainerNode.addSubnode(self.secretChatsSwitchNode)
|
self.contentContainerNode.addSubnode(self.secretChatsSwitchNode)
|
||||||
self.contentContainerNode.addSubnode(self.secretChatsInfoNode)
|
|
||||||
|
|
||||||
self.secretChatsSwitchNode.valueUpdated = { [weak self] value in
|
self.secretChatsSwitchNode.valueUpdated = { [weak self] value in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.updateAcceptSecretChats?(value)
|
strongSelf.updateAcceptSecretChats?(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.contentContainerNode.addSubnode(self.acceptSeparatorNode)
|
||||||
|
}
|
||||||
|
self.contentContainerNode.addSubnode(self.incomingCallsTitleNode)
|
||||||
|
self.contentContainerNode.addSubnode(self.incomingCallsSwitchNode)
|
||||||
|
|
||||||
|
self.incomingCallsSwitchNode.valueUpdated = { [weak self] value in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.updateAcceptIncomingCalls?(value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
|
self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
|
||||||
@ -556,6 +577,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
self.fieldBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
self.fieldBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
self.firstSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
self.firstSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
self.secondSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
self.secondSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
|
self.acceptSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
|
||||||
|
|
||||||
self.deviceTitleNode.attributedText = NSAttributedString(string: self.deviceTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.deviceTitleNode.attributedText = NSAttributedString(string: self.deviceTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
self.locationTitleNode.attributedText = NSAttributedString(string: self.locationTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.locationTitleNode.attributedText = NSAttributedString(string: self.locationTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
@ -566,10 +588,10 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
self.ipValueNode.attributedText = NSAttributedString(string: self.ipValueNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
self.ipValueNode.attributedText = NSAttributedString(string: self.ipValueNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
||||||
self.locationInfoNode.attributedText = NSAttributedString(string: self.locationInfoNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
self.locationInfoNode.attributedText = NSAttributedString(string: self.locationInfoNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
||||||
|
|
||||||
self.secretChatsHeaderNode.attributedText = NSAttributedString(string: self.secretChatsHeaderNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
self.acceptHeaderNode.attributedText = NSAttributedString(string: self.acceptHeaderNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
||||||
self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.secretChatsTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.secretChatsTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
self.secretChatsInfoNode.attributedText = NSAttributedString(string: self.secretChatsInfoNode.attributedText?.string ?? "", font: Font.regular(13.0), textColor: self.presentationData.theme.list.itemSecondaryTextColor)
|
self.incomingCallsTitleNode.attributedText = NSAttributedString(string: self.incomingCallsTitleNode.attributedText?.string ?? "", font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor)
|
||||||
self.secretChatsBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
self.acceptBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
|
||||||
|
|
||||||
if previousTheme !== presentationData.theme, let (layout, navigationBarHeight) = self.containerLayout {
|
if previousTheme !== presentationData.theme, let (layout, navigationBarHeight) = self.containerLayout {
|
||||||
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||||
@ -749,33 +771,48 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
|
|
||||||
var contentHeight = locationInfoTextFrame.maxY + bottomInset + 64.0
|
var contentHeight = locationInfoTextFrame.maxY + bottomInset + 64.0
|
||||||
|
|
||||||
if let _ = self.secretChatsBackgroundNode.supernode {
|
var secretFrame = CGRect(x: inset, y: locationInfoTextFrame.maxY + 59.0, width: width - inset * 2.0, height: fieldItemHeight)
|
||||||
let secretFrame = CGRect(x: inset, y: locationInfoTextFrame.maxY + 59.0, width: width - inset * 2.0, height: fieldItemHeight)
|
if let _ = self.secretChatsTitleNode.supernode {
|
||||||
transition.updateFrame(node: self.secretChatsBackgroundNode, frame: secretFrame)
|
secretFrame.size.height += fieldItemHeight
|
||||||
|
}
|
||||||
let secretChatsHeaderTextSize = self.secretChatsHeaderNode.updateLayout(CGSize(width: secretFrame.width - inset * 2.0 - locationTitleTextSize.width - 10.0, height: fieldItemHeight))
|
transition.updateFrame(node: self.acceptBackgroundNode, frame: secretFrame)
|
||||||
let secretChatsHeaderTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY - secretChatsHeaderTextSize.height - 6.0), size: secretChatsHeaderTextSize)
|
|
||||||
transition.updateFrame(node: self.secretChatsHeaderNode, frame: secretChatsHeaderTextFrame)
|
let secretChatsHeaderTextSize = self.acceptHeaderNode.updateLayout(CGSize(width: secretFrame.width - inset * 2.0 - locationTitleTextSize.width - 10.0, height: fieldItemHeight))
|
||||||
|
let secretChatsHeaderTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY - secretChatsHeaderTextSize.height - 6.0), size: secretChatsHeaderTextSize)
|
||||||
|
transition.updateFrame(node: self.acceptHeaderNode, frame: secretChatsHeaderTextFrame)
|
||||||
|
|
||||||
|
if let _ = self.secretChatsTitleNode.supernode {
|
||||||
let secretChatsTitleTextSize = self.secretChatsTitleNode.updateLayout(CGSize(width: width - inset * 4.0 - 80.0, height: fieldItemHeight))
|
let secretChatsTitleTextSize = self.secretChatsTitleNode.updateLayout(CGSize(width: width - inset * 4.0 - 80.0, height: fieldItemHeight))
|
||||||
let secretChatsTitleTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - secretChatsTitleTextSize.height) / 2.0)), size: secretChatsTitleTextSize)
|
let secretChatsTitleTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - secretChatsTitleTextSize.height) / 2.0)), size: secretChatsTitleTextSize)
|
||||||
transition.updateFrame(node: self.secretChatsTitleNode, frame: secretChatsTitleTextFrame)
|
transition.updateFrame(node: self.secretChatsTitleNode, frame: secretChatsTitleTextFrame)
|
||||||
|
|
||||||
let secretChatsInfoTextSize = self.secretChatsInfoNode.updateLayout(CGSize(width: secretFrame.width - inset * 2.0, height: fieldItemHeight))
|
|
||||||
let secretChatsInfoTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.maxY + 6.0), size: secretChatsInfoTextSize)
|
|
||||||
transition.updateFrame(node: self.secretChatsInfoNode, frame: secretChatsInfoTextFrame)
|
|
||||||
|
|
||||||
if let switchView = self.secretChatsSwitchNode.view as? UISwitch {
|
if let switchView = self.secretChatsSwitchNode.view as? UISwitch {
|
||||||
if self.secretChatsSwitchNode.bounds.size.width.isZero {
|
if self.secretChatsSwitchNode.bounds.size.width.isZero {
|
||||||
switchView.sizeToFit()
|
switchView.sizeToFit()
|
||||||
}
|
}
|
||||||
let switchSize = switchView.bounds.size
|
let switchSize = switchView.bounds.size
|
||||||
|
|
||||||
self.secretChatsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
|
self.secretChatsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
contentHeight += secretChatsInfoTextFrame.maxY - locationInfoTextFrame.maxY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let incomingCallsTitleTextSize = self.incomingCallsTitleNode.updateLayout(CGSize(width: width - inset * 4.0 - 80.0, height: fieldItemHeight))
|
||||||
|
let incomingCallsTitleTextFrame = CGRect(origin: CGPoint(x: secretFrame.minX + inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - incomingCallsTitleTextSize.height) / 2.0)), size: incomingCallsTitleTextSize)
|
||||||
|
transition.updateFrame(node: self.incomingCallsTitleNode, frame: incomingCallsTitleTextFrame)
|
||||||
|
|
||||||
|
transition.updateFrame(node: self.acceptSeparatorNode, frame: CGRect(x: secretFrame.minX + inset, y: secretFrame.minY + fieldItemHeight, width: fieldFrame.width - inset, height: UIScreenPixel))
|
||||||
|
|
||||||
|
if let switchView = self.incomingCallsSwitchNode.view as? UISwitch {
|
||||||
|
if self.incomingCallsSwitchNode.bounds.size.width.isZero {
|
||||||
|
switchView.sizeToFit()
|
||||||
|
}
|
||||||
|
let switchSize = switchView.bounds.size
|
||||||
|
|
||||||
|
self.incomingCallsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
contentHeight += secretFrame.maxY - locationInfoTextFrame.maxY
|
||||||
|
contentHeight += 40.0
|
||||||
|
|
||||||
let isCurrent: Bool
|
let isCurrent: Bool
|
||||||
if case let .session(session) = self.subject, session.isCurrent {
|
if case let .session(session) = self.subject, session.isCurrent {
|
||||||
@ -803,7 +840,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
|
|||||||
transition.updateFrame(node: self.contentBackgroundNode, frame: CGRect(origin: CGPoint(), size: backgroundFrame.size))
|
transition.updateFrame(node: self.contentBackgroundNode, frame: CGRect(origin: CGPoint(), size: backgroundFrame.size))
|
||||||
|
|
||||||
let doneButtonHeight = self.terminateButton.updateLayout(width: width - inset * 2.0, transition: transition)
|
let doneButtonHeight = self.terminateButton.updateLayout(width: width - inset * 2.0, transition: transition)
|
||||||
transition.updateFrame(node: self.terminateButton, frame: CGRect(x: inset, y: contentHeight - doneButtonHeight - insets.bottom - 6.0, width: width, height: doneButtonHeight))
|
transition.updateFrame(node: self.terminateButton, frame: CGRect(x: inset, y: contentHeight - doneButtonHeight - 40.0 - insets.bottom - 6.0, width: width, height: doneButtonHeight))
|
||||||
|
|
||||||
transition.updateFrame(node: self.contentContainerNode, frame: contentContainerFrame)
|
transition.updateFrame(node: self.contentContainerNode, frame: contentContainerFrame)
|
||||||
transition.updateFrame(node: self.topContentContainerNode, frame: contentContainerFrame)
|
transition.updateFrame(node: self.topContentContainerNode, frame: contentContainerFrame)
|
||||||
|
@ -144,6 +144,29 @@ private final class ActiveSessionsContextImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateSessionAcceptsIncomingCalls(_ session: RecentAccountSession, accepts: Bool) -> Signal<Never, UpdateSessionError> {
|
||||||
|
let updatedSession = session.withUpdatedAcceptsIncomingCalls(accepts)
|
||||||
|
|
||||||
|
var mergedSessions = self._state.sessions
|
||||||
|
for i in 0 ..< mergedSessions.count {
|
||||||
|
if mergedSessions[i].hash == updatedSession.hash {
|
||||||
|
mergedSessions.remove(at: i)
|
||||||
|
mergedSessions.insert(updatedSession, at: i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self._state = ActiveSessionsContextState(isLoadingMore: self._state.isLoadingMore, sessions: mergedSessions, ttlDays: self._state.ttlDays)
|
||||||
|
|
||||||
|
return updateAccountSessionAcceptsIncomingCalls(account: self.account, hash: session.hash, accepts: accepts)
|
||||||
|
|> deliverOnMainQueue
|
||||||
|
|> mapToSignal { [weak self] _ -> Signal<Never, UpdateSessionError> in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf._state = ActiveSessionsContextState(isLoadingMore: strongSelf._state.isLoadingMore, sessions: mergedSessions, ttlDays: strongSelf._state.ttlDays)
|
||||||
|
}
|
||||||
|
return .complete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func updateAuthorizationTTL(days: Int32) -> Signal<Never, UpadteAuthorizationTTLError> {
|
func updateAuthorizationTTL(days: Int32) -> Signal<Never, UpadteAuthorizationTTLError> {
|
||||||
self._state = ActiveSessionsContextState(isLoadingMore: self._state.isLoadingMore, sessions: self._state.sessions, ttlDays: days)
|
self._state = ActiveSessionsContextState(isLoadingMore: self._state.isLoadingMore, sessions: self._state.sessions, ttlDays: days)
|
||||||
|
|
||||||
@ -233,6 +256,20 @@ public final class ActiveSessionsContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func updateSessionAcceptsIncomingCalls(_ session: RecentAccountSession, accepts: Bool) -> Signal<Never, UpdateSessionError> {
|
||||||
|
return Signal { subscriber in
|
||||||
|
let disposable = MetaDisposable()
|
||||||
|
self.impl.with { impl in
|
||||||
|
disposable.set(impl.updateSessionAcceptsIncomingCalls(session, accepts: accepts).start(error: { error in
|
||||||
|
subscriber.putError(error)
|
||||||
|
}, completed: {
|
||||||
|
subscriber.putCompletion()
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
return disposable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func updateAuthorizationTTL(days: Int32) -> Signal<Never, UpadteAuthorizationTTLError> {
|
public func updateAuthorizationTTL(days: Int32) -> Signal<Never, UpadteAuthorizationTTLError> {
|
||||||
let days = max(1, min(365, days))
|
let days = max(1, min(365, days))
|
||||||
return Signal { subscriber in
|
return Signal { subscriber in
|
||||||
|
@ -15,6 +15,7 @@ public struct AccountSessionFlags: OptionSet {
|
|||||||
public static let isOfficial = AccountSessionFlags(rawValue: (1 << 1))
|
public static let isOfficial = AccountSessionFlags(rawValue: (1 << 1))
|
||||||
public static let passwordPending = AccountSessionFlags(rawValue: (1 << 2))
|
public static let passwordPending = AccountSessionFlags(rawValue: (1 << 2))
|
||||||
public static let acceptsSecretChats = AccountSessionFlags(rawValue: (1 << 3))
|
public static let acceptsSecretChats = AccountSessionFlags(rawValue: (1 << 3))
|
||||||
|
public static let acceptsIncomingCalls = AccountSessionFlags(rawValue: (1 << 4))
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct RecentAccountSession: Equatable {
|
public struct RecentAccountSession: Equatable {
|
||||||
@ -88,6 +89,16 @@ public struct RecentAccountSession: Equatable {
|
|||||||
}
|
}
|
||||||
return RecentAccountSession(hash: self.hash, deviceModel: self.deviceModel, platform: self.platform, systemVersion: self.systemVersion, apiId: self.apiId, appName: self.appName, appVersion: self.appVersion, creationDate: self.creationDate, activityDate: self.activityDate, ip: self.ip, country: self.country, region: self.region, flags: flags)
|
return RecentAccountSession(hash: self.hash, deviceModel: self.deviceModel, platform: self.platform, systemVersion: self.systemVersion, apiId: self.apiId, appName: self.appName, appVersion: self.appVersion, creationDate: self.creationDate, activityDate: self.activityDate, ip: self.ip, country: self.country, region: self.region, flags: flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func withUpdatedAcceptsIncomingCalls(_ accepts: Bool) -> RecentAccountSession {
|
||||||
|
var flags = self.flags
|
||||||
|
if accepts {
|
||||||
|
flags.insert(.acceptsIncomingCalls)
|
||||||
|
} else {
|
||||||
|
flags.remove(.acceptsIncomingCalls)
|
||||||
|
}
|
||||||
|
return RecentAccountSession(hash: self.hash, deviceModel: self.deviceModel, platform: self.platform, systemVersion: self.systemVersion, apiId: self.apiId, appName: self.appName, appVersion: self.appVersion, creationDate: self.creationDate, activityDate: self.activityDate, ip: self.ip, country: self.country, region: self.region, flags: flags)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension RecentAccountSession {
|
extension RecentAccountSession {
|
||||||
@ -104,6 +115,9 @@ extension RecentAccountSession {
|
|||||||
if (flags & (1 << 3)) == 0 {
|
if (flags & (1 << 3)) == 0 {
|
||||||
accountSessionFlags.insert(.acceptsSecretChats)
|
accountSessionFlags.insert(.acceptsSecretChats)
|
||||||
}
|
}
|
||||||
|
if (flags & (1 << 4)) == 0 {
|
||||||
|
accountSessionFlags.insert(.acceptsIncomingCalls)
|
||||||
|
}
|
||||||
self.init(hash: hash, deviceModel: deviceModel, platform: platform, systemVersion: systemVersion, apiId: apiId, appName: appName, appVersion: appVersion, creationDate: dateCreated, activityDate: dateActive, ip: ip, country: country, region: region, flags: accountSessionFlags)
|
self.init(hash: hash, deviceModel: deviceModel, platform: platform, systemVersion: systemVersion, apiId: apiId, appName: appName, appVersion: appVersion, creationDate: dateCreated, activityDate: dateActive, ip: ip, country: country, region: region, flags: accountSessionFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,3 +78,13 @@ func updateAccountSessionAcceptsSecretChats(account: Account, hash: Int64, accep
|
|||||||
return .single(Void())
|
return .single(Void())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateAccountSessionAcceptsIncomingCalls(account: Account, hash: Int64, accepts: Bool) -> Signal<Void, UpdateSessionError> {
|
||||||
|
return account.network.request(Api.functions.account.changeAuthorizationSettings(flags: 1 << 1, hash: hash, encryptedRequestsDisabled: nil, callRequestsDisabled: accepts ? .boolFalse : .boolTrue))
|
||||||
|
|> mapError { error -> UpdateSessionError in
|
||||||
|
return .generic
|
||||||
|
}
|
||||||
|
|> mapToSignal { _ -> Signal<Void, UpdateSessionError> in
|
||||||
|
return .single(Void())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -8395,7 +8395,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
self.checksTooltipDisposable.set((getServerProvidedSuggestions(account: self.context.account)
|
self.checksTooltipDisposable.set((getServerProvidedSuggestions(account: self.context.account)
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] values in
|
|> deliverOnMainQueue).start(next: { [weak self] values in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self, strongSelf.chatLocation.peerId != strongSelf.context.account.peerId else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !values.contains(.newcomerTicks) {
|
if !values.contains(.newcomerTicks) {
|
||||||
@ -13570,7 +13570,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
tooltipController.dismissed = { [weak self, weak tooltipController] _ in
|
tooltipController.dismissed = { [weak self, weak tooltipController] _ in
|
||||||
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.checksTooltipController === tooltipController {
|
if let strongSelf = self, let tooltipController = tooltipController, strongSelf.checksTooltipController === tooltipController {
|
||||||
strongSelf.checksTooltipController = nil
|
strongSelf.checksTooltipController = nil
|
||||||
// ApplicationSpecificNotice.setVolumeButtonToUnmute(accountManager: strongSelf.context.sharedContext.accountManager)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
self.present(tooltipController, in: .window(.root), with: TooltipControllerPresentationArguments(sourceNodeAndRect: { [weak self] in
|
||||||
|
@ -322,7 +322,7 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
|||||||
self.closeButton.displaysAsynchronously = false
|
self.closeButton.displaysAsynchronously = false
|
||||||
|
|
||||||
self.textNode = ImmediateTextNode()
|
self.textNode = ImmediateTextNode()
|
||||||
self.textNode.maximumNumberOfLines = 2
|
self.textNode.maximumNumberOfLines = 3
|
||||||
self.textNode.textAlignment = .center
|
self.textNode.textAlignment = .center
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user