Merge commit '025a21fc495734b6556e260d3990f69a8da9fb08'

This commit is contained in:
Ali 2020-11-29 22:03:57 +04:00
commit 705ad11e0c
10 changed files with 4359 additions and 4249 deletions

View File

@ -2278,6 +2278,19 @@ Unused sets are archived when you add more.";
"Call.Minutes_any" = "%@ minutes";
"Call.Minutes_many" = "%@ minutes";
"Call.Minutes_0" = "%@ minutes";
"Call.Hours_1" = "%@ hour";
"Call.Hours_2" = "%@ hours";
"Call.Hours_3_10" = "%@ hours";
"Call.Hours_any" = "%@ hours";
"Call.Hours_many" = "%@ hours";
"Call.Hours_0" = "%@ hours";
"Call.Days_1" = "%@ day";
"Call.Days_2" = "%@ days";
"Call.Days_3_10" = "%@ days";
"Call.Days_any" = "%@ days";
"Call.Days_many" = "%@ days";
"Call.Days_0" = "%@ days";
"Call.ShortSeconds_1" = "%@ sec";
"Call.ShortSeconds_2" = "%@ sec";
@ -5936,20 +5949,27 @@ Sorry for the inconvenience.";
"VoiceChat.PanelJoin" = "Join";
"VoiceChat.Title" = "Voice Chat";
"Message.VoiceChat.Started" = "Voice chat started";
"Message.VoiceChat.Ended" = "Voice chat ended";
"VoiceChat.StatusMembersSpeaking_0" = "%@ members speaking";
"VoiceChat.StatusMembersSpeaking_1" = "1 member speaking";
"VoiceChat.StatusMembersSpeaking_2" = "2 members speaking";
"VoiceChat.StatusMembersSpeaking_3_10" = "%@ members speaking";
"VoiceChat.StatusMembersSpeaking_many" = "%@ members speaking";
"VoiceChat.StatusMembersSpeaking_any" = "%@ members speaking";
"VoiceChat.UserInvited" = "You invited **%@** to the voice chat";
"PeerInfo.CreateVoiceChat" = "Create Voice Chat";
"Notification.VoiceChatInvitation" = "%1$@ invited %2$@ to the voice chat";
"Notification.VoiceChatInvitationByYou" = "You invited %1$@ to the voice chat";
"Notification.VoiceChatInvitationForYou" = "%1$@ invited you to the voice chat";
"Notification.VoiceChatStarted" = "Voice chat started";
"Notification.VoiceChatEnded" = "Voice chat ended (%@)";
"VoiceChat.Panel.TapToJoin" = "Tap to join";
"VoiceChat.Panel.Members_0" = "%@ members";
"VoiceChat.Panel.Members_1" = "%@ member";
"VoiceChat.Panel.Members_2" = "%@ members";
"VoiceChat.Panel.Members_3_10" = "%@ members";
"VoiceChat.Panel.Members_many" = "%@ members";
"VoiceChat.Panel.Members_any" = "%@ members";
"VoiceChat.Panel.MembersSpeaking_0" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_1" = "%@ member speaking";
"VoiceChat.Panel.MembersSpeaking_2" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_3_10" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_many" = "%@ members speaking";
"VoiceChat.Panel.MembersSpeaking_any" = "%@ members speaking";
"ChannelInfo.CreateVoiceChat" = "Create Voice Chat";

View File

@ -230,9 +230,9 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
if previousData?.groupCall !== data.groupCall {
let membersText: String
if data.participantCount == 0 {
membersText = self.strings.PeopleNearby_NoMembers
membersText = self.strings.VoiceChat_Panel_TapToJoin
} else {
membersText = self.strings.Conversation_StatusMembers(Int32(data.participantCount))
membersText = self.strings.VoiceChat_Panel_Members(Int32(data.participantCount))
}
self.avatarsContent = self.avatarsContext.update(peers: data.topParticipants.map { $0.peer }, animated: false)
@ -252,13 +252,13 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
let membersText: String
let membersTextIsActive: Bool
if summaryState.numberOfActiveSpeakers != 0 {
membersText = strongSelf.strings.VoiceChat_StatusMembersSpeaking(Int32(summaryState.numberOfActiveSpeakers))
membersText = strongSelf.strings.VoiceChat_Panel_MembersSpeaking(Int32(summaryState.numberOfActiveSpeakers))
membersTextIsActive = true
} else {
if summaryState.participantCount == 0 {
membersText = strongSelf.strings.PeopleNearby_NoMembers
membersText = strongSelf.strings.VoiceChat_Panel_TapToJoin
} else {
membersText = strongSelf.strings.Conversation_StatusMembers(Int32(summaryState.participantCount))
membersText = strongSelf.strings.VoiceChat_Panel_Members(Int32(summaryState.participantCount))
}
membersTextIsActive = false
}
@ -284,13 +284,13 @@ public final class GroupCallNavigationAccessoryPanel: ASDisplayNode {
let membersText: String
let membersTextIsActive: Bool
if data.numberOfActiveSpeakers != 0 {
membersText = self.strings.VoiceChat_StatusMembersSpeaking(Int32(data.numberOfActiveSpeakers))
membersText = self.strings.VoiceChat_Panel_MembersSpeaking(Int32(data.numberOfActiveSpeakers))
membersTextIsActive = true
} else {
if data.participantCount == 0 {
membersText = self.strings.PeopleNearby_NoMembers
membersText = self.strings.VoiceChat_Panel_TapToJoin
} else {
membersText = self.strings.Conversation_StatusMembers(Int32(data.participantCount))
membersText = self.strings.VoiceChat_Panel_Members(Int32(data.participantCount))
}
membersTextIsActive = false
}

View File

@ -694,7 +694,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
self?._canBeRemoved.set(.single(true))
}))
}
} else if case .requesting = self.internalState {
} else if case .requesting = self.internalState {
self.callContext?.stop()
self.callContext = nil
self.requestDisposable.set(nil)

View File

@ -88,7 +88,11 @@ public func unmuteIntervalString(strings: PresentationStrings, value: Int32) ->
public func callDurationString(strings: PresentationStrings, value: Int32) -> String {
if value < 60 {
return strings.Call_Seconds(max(1, value))
} else {
} else if value < 60 * 60 {
return strings.Call_Minutes(max(1, value / 60))
} else if value < 60 * 60 * 24 {
return strings.Call_Hours(max(1, value / (60 * 60)))
} else {
return strings.Call_Days(max(1, value / (60 * 60 * 24)))
}
}

View File

@ -407,9 +407,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
case let .groupPhoneCall(_, _, duration):
let titleString: String
if let duration = duration {
titleString = strings.Message_VoiceChat_Ended
titleString = strings.Notification_VoiceChatEnded(callDurationString(strings: strings, value: duration)).0
} else {
titleString = strings.Message_VoiceChat_Started
titleString = strings.Notification_VoiceChatStarted
}
attributedString = NSAttributedString(string: titleString, font: titleFont, textColor: primaryTextColor)
case let .customText(text, entities):

View File

@ -496,6 +496,40 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
break
}
}
case let .groupPhoneCall(callId, accessHash, duration):
let peerId = message.id.peerId
if duration == nil {
let callResult = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peerId, initialCall: CachedChannelData.ActiveCall(id: callId, accessHash: accessHash), endCurrentIfAny: false, sourcePanel: nil)
if let callResult = callResult, case let .alreadyInProgress(currentPeerId) = callResult {
if currentPeerId == peerId {
strongSelf.context.sharedContext.navigateToCurrentCall(sourcePanel: nil)
} else {
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
let _ = (strongSelf.context.account.postbox.transaction { transaction -> (Peer?, Peer?) in
return (transaction.getPeer(peerId), currentPeerId.flatMap(transaction.getPeer))
}
|> deliverOnMainQueue).start(next: { [weak self] peer, current in
guard let strongSelf = self else {
return
}
guard let peer = peer else {
return
}
if let current = current {
strongSelf.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_CallInProgressMessage(current.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
if let strongSelf = self {
let _ = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peerId, initialCall: CachedChannelData.ActiveCall(id: callId, accessHash: accessHash), endCurrentIfAny: true, sourcePanel: nil)
}
})]), in: .window(.root))
} else {
strongSelf.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_ExternalCallInProgressMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
})]), in: .window(.root))
}
})
}
}
}
break
default:
break
}

View File

@ -2968,7 +2968,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
} else if let channel = peer as? TelegramChannel {
if case .group = channel.info, !channel.flags.contains(.hasVoiceChat) {
if channel.flags.contains(.isCreator) || channel.hasPermission(.manageCalls) {
items.append(ActionSheetButtonItem(title: presentationData.strings.PeerInfo_CreateVoiceChat, color: .accent, action: { [weak self] in
items.append(ActionSheetButtonItem(title: presentationData.strings.ChannelInfo_CreateVoiceChat, color: .accent, action: { [weak self] in
dismissAction()
self?.requestCall(isVideo: false)
}))
@ -3181,39 +3181,73 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
if let activeCall = cachedChannelData.activeCall {
let _ = self.context.sharedContext.callManager?.joinGroupCall(context: self.context, peerId: peer.id, initialCall: activeCall, endCurrentIfAny: false, sourcePanel: nil)
} else {
var dismissStatus: (() -> Void)?
let statusController = OverlayStatusController(theme: self.presentationData.theme, type: .loading(cancelled: {
dismissStatus?()
}))
dismissStatus = { [weak self, weak statusController] in
self?.activeActionDisposable.set(nil)
statusController?.dismiss()
} else if let callManager = self.context.sharedContext.callManager {
let startCall: (Bool) -> Void = { [weak self] endCurrentIfAny in
guard let strongSelf = self else {
return
}
var dismissStatus: (() -> Void)?
let statusController = OverlayStatusController(theme: strongSelf.presentationData.theme, type: .loading(cancelled: {
dismissStatus?()
}))
dismissStatus = { [weak self, weak statusController] in
self?.activeActionDisposable.set(nil)
statusController?.dismiss()
}
strongSelf.controller?.present(statusController, in: .window(.root))
strongSelf.activeActionDisposable.set((createGroupCall(account: strongSelf.context.account, peerId: peer.id)
|> deliverOnMainQueue).start(next: { [weak self] info in
guard let strongSelf = self else {
return
}
let _ = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peer.id, initialCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash), endCurrentIfAny: endCurrentIfAny, sourcePanel: nil)
}, error: { [weak self] _ in
dismissStatus?()
guard let strongSelf = self else {
return
}
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
}, completed: { [weak self] in
dismissStatus?()
guard let strongSelf = self else {
return
}
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
}))
}
self.controller?.present(statusController, in: .window(.root))
self.activeActionDisposable.set((createGroupCall(account: self.context.account, peerId: peer.id)
|> deliverOnMainQueue).start(next: { [weak self] info in
let _ = (callManager.currentGroupCallSignal
|> take(1)
|> deliverOnMainQueue).start(next: { [weak self] activeCall in
guard let strongSelf = self else {
return
}
let _ = strongSelf.context.sharedContext.callManager?.joinGroupCall(context: strongSelf.context, peerId: peer.id, initialCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash), endCurrentIfAny: false, sourcePanel: nil)
}, error: { [weak self] _ in
dismissStatus?()
guard let strongSelf = self else {
return
if let activeCall = activeCall {
let currentPeerId = activeCall.peerId
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
let _ = (strongSelf.context.account.postbox.transaction { transaction -> (Peer?, Peer?) in
return (transaction.getPeer(peer.id), transaction.getPeer(currentPeerId))
} |> deliverOnMainQueue).start(next: { [weak self] peer, current in
if let peer = peer {
if let strongSelf = self, let current = current {
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_CallInProgressMessage(current.compactDisplayTitle, peer.compactDisplayTitle).0, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
startCall(true)
})]), in: .window(.root))
} else {
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_CallInProgressTitle, text: presentationData.strings.Call_ExternalCallInProgressMessage, actions: [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {
})]), in: .window(.root))
}
}
})
} else {
startCall(false)
}
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
}, completed: { [weak self] in
dismissStatus?()
guard let strongSelf = self else {
return
}
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
}))
})
}
return
}

View File

@ -123,7 +123,7 @@ private final class ShimmerEffectForegroundNode: ASDisplayNode {
}
}
private let decodingMap: [String] = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-", ","]
private let decodingMap: [String] = ["A", "A", "C", "A", "A", "A", "A", "H", "A", "A", "A", "L", "M", "A", "A", "A", "Q", "A", "S", "T", "A", "V", "A", "A", "A", "Z", "a", "a", "c", "a", "a", "a", "a", "h", "a", "a", "a", "l", "m", "a", "a", "a", "q", "a", "s", "t", "a", "v", "a", ".", "a", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "-", ","]
private func decodeStickerThumbnailData(_ data: Data) -> String {
var string = "M"
data.forEach { byte in