Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Feb 11, 2021
1 parent fdbd3ce commit ad26786
Show file tree
Hide file tree
Showing 40 changed files with 5,255 additions and 5,537 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Linguist overrides for vendored code
submodules/AsyncDisplayKit/* linguist-vendored
submodules/ffmpeg/* linguist-vendored
submodules/HockeySDK-iOS/* linguist-vendored
submodules/libphonenumber/* linguist-vendored
submodules/libtgvoip/* linguist-vendored
submodules/lottie-ios/* linguist-vendored
submodules/Opus/* linguist-vendored
submodules/OpusBinding/* linguist-vendored
submodules/rlottie/rlottie/* linguist-vendored
submodules/sqlcipher/* linguist-vendored
submodules/Stripe/* linguist-vendored
submodules/ton/tonlib-src/* linguist-vendored
submodules/webp/include/* linguist-vendored
third-party/* linguist-vendored
Binary file modified Telegram/Telegram-iOS/Resources/Cop.tgs
Binary file not shown.
Binary file modified Telegram/Telegram-iOS/Resources/PoliceCar.tgs
Binary file not shown.
10 changes: 9 additions & 1 deletion Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -5838,6 +5838,7 @@ Sorry for the inconvenience.";
"InviteLink.PeopleJoined_many" = "%@ people joined";
"InviteLink.PeopleJoined_any" = "%@ people joined";
"InviteLink.CreatePrivateLinkHelp" = "Anyone who has Telegram installed will be able to join your group by following this link.";
"InviteLink.CreatePrivateLinkHelpChannel" = "Anyone who has Telegram installed will be able to join your channel by following this link.";
"InviteLink.Manage" = "Manage Invite Links";

"InviteLink.PeopleJoinedShortNoneExpired" = "no one joined";
Expand Down Expand Up @@ -5899,6 +5900,7 @@ Sorry for the inconvenience.";

"InviteLink.QRCode.Title" = "Invite by QR Code";
"InviteLink.QRCode.Info" = "Everyone on Telegram can scan this code to join your group.";
"InviteLink.QRCode.InfoChannel" = "Everyone on Telegram can scan this code to join your channel.";
"InviteLink.QRCode.Share" = "Share QR Code";

"InviteLink.InviteLink" = "Invite Link";
Expand Down Expand Up @@ -6021,6 +6023,9 @@ Sorry for the inconvenience.";
"Channel.AdminLog.DeletedInviteLink" = "%1$@ deleted invite link %2$@";
"Channel.AdminLog.RevokedInviteLink" = "%1$@ revoked invite link %2$@";
"Channel.AdminLog.EditedInviteLink" = "%1$@ edited invite link %2$@";
"Channel.AdminLog.CreatedInviteLink" = "%1$@ created invite link %2$@";

"Channel.AdminLog.JoinedViaInviteLink" = "%1$@ joined via invite link %2$@";

"GroupInfo.Permissions.BroadcastTitle" = "Broadcast Channel";
"GroupInfo.Permissions.BroadcastConvert" = "Convert Group to Channel";
Expand Down Expand Up @@ -6056,7 +6061,6 @@ Sorry for the inconvenience.";
"Report.Report" = "Report";
"Report.Succeed" = "Telegram moderators will study your report. Thank you!";


"Conversation.AutoremoveRemainingTime" = "auto-delete in %@";
"Conversation.AutoremoveRemainingDays_1" = "auto-delete in %@ day";
"Conversation.AutoremoveRemainingDays_any" = "auto-delete in %@ days";
Expand All @@ -6066,3 +6070,7 @@ Sorry for the inconvenience.";

"Conversation.AutoremoveChanged" = "Auto-Delete timer set to %@";

"PeerInfo.ReportProfilePhoto" = "Report Profile Photo";
"PeerInfo.ReportProfileVideo" = "Report Profile Video";

"Channel.AdminLog.CanInviteUsersViaLink" = "Invite Users via Link";
440 changes: 437 additions & 3 deletions Telegram/Watch/App/Base.lproj/Interface.storyboard

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions submodules/AnimatedStickerNode/Sources/FitzModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public func transformedWithFitzModifier(data: Data, fitzModifier: EmojiFitzModif
let replacementColors: [UIColor]
switch fitzModifier {
case .type12:
replacementColors = [0xca907a, 0xedc5a5, 0xf7e3c3, 0xfbefd6].map { UIColor(rgb: $0) }
replacementColors = [0xcb7b55, 0xf6b689, 0xffcda7, 0xffdfc5].map { UIColor(rgb: $0) }
case .type3:
replacementColors = [0xaa7c60, 0xc8a987, 0xddc89f, 0xe6d6b2].map { UIColor(rgb: $0) }
replacementColors = [0xa45a38, 0xdf986b, 0xedb183, 0xf4c3a0].map { UIColor(rgb: $0) }
case .type4:
replacementColors = [0x8c6148, 0xad8562, 0xc49e76, 0xd4b188].map { UIColor(rgb: $0) }
replacementColors = [0x703a17, 0xab673d, 0xc37f4e, 0xd89667].map { UIColor(rgb: $0) }
case .type5:
replacementColors = [0x6e3c2c, 0x925a34, 0xa16e46, 0xac7a52].map { UIColor(rgb: $0) }
replacementColors = [0x4a2409, 0x7d3e0e, 0x965529, 0xa96337].map { UIColor(rgb: $0) }
case .type6:
replacementColors = [0x291c12, 0x472a22, 0x573b30, 0x68493c].map { UIColor(rgb: $0) }
replacementColors = [0x200f0a, 0x412924, 0x593d37, 0x63453f].map { UIColor(rgb: $0) }
}

func colorToString(_ color: UIColor) -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
if let strongSelf = self {
// strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone)
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()

strongSelf.updateState { state in
Expand All @@ -859,7 +858,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
if let strongSelf = self {
// strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone)
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start()

strongSelf.updateState { state in
Expand Down
51 changes: 39 additions & 12 deletions submodules/DatePickerNode/Sources/DatePickerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,40 +307,46 @@ public final class DatePickerNode: ASDisplayNode {

public var valueUpdated: ((Date) -> Void)?

public var maximumDate: Date {
public var minimumDate: Date {
get {
return self.state.maxDate
return self.state.minDate
}
set {
guard newValue != self.maximumDate else {
guard newValue != self.minimumDate else {
return
}

let updatedState = State(minDate: self.state.minDate, maxDate: newValue, date: self.state.date, displayingMonthSelection: self.state.displayingMonthSelection, selectedMonth: self.state.selectedMonth)
let updatedState = State(minDate: newValue, maxDate: self.state.maxDate, date: self.state.date, displayingMonthSelection: self.state.displayingMonthSelection, selectedMonth: self.state.selectedMonth)
self.updateState(updatedState, animated: false)

self.pickerNode.minimumDate = newValue

if let size = self.validLayout {
let _ = self.updateLayout(size: size, transition: .immediate)
}
}
}
public var minimumDate: Date {

public var maximumDate: Date {
get {
return self.state.minDate
return self.state.maxDate
}
set {
guard newValue != self.minimumDate else {
guard newValue != self.maximumDate else {
return
}

let updatedState = State(minDate: newValue, maxDate: self.state.maxDate, date: self.state.date, displayingMonthSelection: self.state.displayingMonthSelection, selectedMonth: self.state.selectedMonth)
let updatedState = State(minDate: self.state.minDate, maxDate: newValue, date: self.state.date, displayingMonthSelection: self.state.displayingMonthSelection, selectedMonth: self.state.selectedMonth)
self.updateState(updatedState, animated: false)

self.pickerNode.maximumDate = newValue

if let size = self.validLayout {
let _ = self.updateLayout(size: size, transition: .immediate)
}
}
}

public var date: Date {
get {
return self.state.date
Expand Down Expand Up @@ -385,6 +391,8 @@ public final class DatePickerNode: ASDisplayNode {
self.pickerNode = MonthPickerNode(theme: theme, strings: strings, date: self.state.date, yearRange: yearRange(for: self.state), valueChanged: { date in
monthChangedImpl?(date)
})
self.pickerNode.minimumDate = self.state.minDate
self.pickerNode.maximumDate = self.state.maxDate

self.monthButtonNode = HighlightTrackingButtonNode()
self.monthTextNode = ImmediateTextNode()
Expand Down Expand Up @@ -768,8 +776,8 @@ private final class MonthPickerNode: ASDisplayNode, UIPickerViewDelegate, UIPick
}
}

var minDate: Date?
var maxDate: Date?
var minimumDate: Date?
var maximumDate: Date?

private let valueChanged: (Date) -> Void
private let pickerView: UIPickerView
Expand Down Expand Up @@ -847,7 +855,26 @@ private final class MonthPickerNode: ASDisplayNode, UIPickerViewDelegate, UIPick
let numberOfDays = calendar.range(of: .day, in: .month, for: tempDate)!.count
components.day = min(day, numberOfDays)

let date = calendar.date(from: components)!
var date = calendar.date(from: components)!

if let minimumDate = self.minimumDate, let maximumDate = self.maximumDate {
var changed = false
if date < minimumDate {
date = minimumDate
changed = true
}
if date > maximumDate {
date = maximumDate
changed = true
}
if changed {
let month = calendar.component(.month, from: date)
let year = calendar.component(.year, from: date)
self.pickerView.selectRow(month - 1, inComponent: 0, animated: true)
self.pickerView.selectRow(year - yearRange.startIndex, inComponent: 1, animated: true)
}
}

self.date = date

self.valueChanged(date)
Expand Down Expand Up @@ -924,7 +951,7 @@ private final class TimePickerNode: ASDisplayNode {
let minutes = Int32(calendar.component(.hour, from: self.date))
let string = stringForShortTimestamp(hours: hours, minutes: minutes, dateTimeFormat: self.dateTimeFormat).replacingOccurrences(of: " AM", with: "").replacingOccurrences(of: " PM", with: "")

self.textNode.attributedText = NSAttributedString(string: string, font: Font.with(size: 21.0, design: .monospace, weight: .regular, traits: []), textColor: self.theme.textColor)
self.textNode.attributedText = NSAttributedString(string: string, font: Font.with(size: 21.0, design: .regular, weight: .regular, traits: [.monospacedNumbers]), textColor: self.theme.textColor)
let textSize = self.textNode.updateLayout(size)
self.textNode.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((self.backgroundNode.frame.width - textSize.width) / 2.0), y: floorToScreenPixels((self.backgroundNode.frame.height - textSize.height) / 2.0)), size: textSize)

Expand Down
68 changes: 21 additions & 47 deletions submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,12 @@ private struct InviteLinkInviteTransaction {
private enum InviteLinkInviteEntryId: Hashable {
case header
case mainLink
case links(Int32)
case manage
}

private enum InviteLinkInviteEntry: Comparable, Identifiable {
case header(PresentationTheme, String, String)
case mainLink(PresentationTheme, ExportedInvitation)
case links(Int32, PresentationTheme, [ExportedInvitation])
case manage(PresentationTheme, String, Bool)

var stableId: InviteLinkInviteEntryId {
Expand All @@ -64,8 +62,6 @@ private enum InviteLinkInviteEntry: Comparable, Identifiable {
return .header
case .mainLink:
return .mainLink
case let .links(index, _, _):
return .links(index)
case .manage:
return .manage
}
Expand All @@ -85,12 +81,6 @@ private enum InviteLinkInviteEntry: Comparable, Identifiable {
} else {
return false
}
case let .links(lhsIndex, lhsTheme, lhsInvitations):
if case let .links(rhsIndex, rhsTheme, rhsInvitations) = rhs, lhsIndex == rhsIndex, lhsTheme === rhsTheme, lhsInvitations == rhsInvitations {
return true
} else {
return false
}
case let .manage(lhsTheme, lhsText, lhsStandalone):
if case let .manage(rhsTheme, rhsText, rhsStandalone) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsStandalone == rhsStandalone {
return true
Expand All @@ -106,28 +96,19 @@ private enum InviteLinkInviteEntry: Comparable, Identifiable {
switch rhs {
case .header:
return false
case .mainLink, .links, .manage:
case .mainLink, .manage:
return true
}
case .mainLink:
switch rhs {
case .header, .mainLink:
return false
case .links, .manage:
return true
}
case let .links(lhsIndex, _, _):
switch rhs {
case .header, .mainLink:
return false
case let .links(rhsIndex, _, _):
return lhsIndex < rhsIndex
case .manage:
return true
}
case .manage:
switch rhs {
case .header, .mainLink, .links:
case .header, .mainLink:
return false
case .manage:
return true
Expand All @@ -148,12 +129,6 @@ private enum InviteLinkInviteEntry: Comparable, Identifiable {
interaction.mainLinkContextAction(invite, node, nil)
}, viewAction: {
})
case let .links(_, _, invites):
return ItemListInviteLinkGridItem(presentationData: ItemListPresentationData(presentationData), invites: invites, count: 0, share: true, sectionId: 1, style: .plain, tapAction: { invite in
interaction.copyLink(invite)
}, contextAction: { invite, _ in
interaction.shareLink(invite)
})
case let .manage(theme, text, standalone):
return InviteLinkInviteManageItem(theme: theme, text: text, standalone: standalone, action: {
interaction.manageLinks()
Expand Down Expand Up @@ -372,8 +347,17 @@ public final class InviteLinkInviteController: ViewController {
f(.dismissWithoutContent)

if let invite = invite {
let controller = InviteLinkQRCodeController(context: context, invite: invite)
self?.controller?.present(controller, in: .window(.root))
let _ = (context.account.postbox.loadedPeerWithId(peerId)
|> deliverOnMainQueue).start(next: { [weak self] peer in
let isGroup: Bool
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
isGroup = false
} else {
isGroup = true
}
let controller = InviteLinkQRCodeController(context: context, invite: invite, isGroup: isGroup)
self?.controller?.present(controller, in: .window(.root))
})
}
})))

Expand All @@ -392,10 +376,6 @@ public final class InviteLinkInviteController: ViewController {
ActionSheetButtonItem(title: presentationData.strings.GroupInfo_InviteLink_RevokeLink, color: .destructive, action: {
dismissAction()

// revokePeerExportedInvitation(account: <#T##Account#>, peerId: <#T##PeerId#>, link: <#T##String#>)
// self?.revokeDisposable.set((revokePersistentPeerExportedInvitation(account: context.account, peerId: peerId) |> deliverOnMainQueue).start(completed: {
//
// }))
})
]),
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
Expand Down Expand Up @@ -430,7 +410,13 @@ public final class InviteLinkInviteController: ViewController {
if let strongSelf = self {
var entries: [InviteLinkInviteEntry] = []

entries.append(.header(presentationData.theme, presentationData.strings.InviteLink_InviteLink, presentationData.strings.InviteLink_CreatePrivateLinkHelp))
let helpText: String
if let peer = peerViewMainPeer(view) as? TelegramChannel, case .broadcast = peer.info {
helpText = presentationData.strings.InviteLink_CreatePrivateLinkHelpChannel
} else {
helpText = presentationData.strings.InviteLink_CreatePrivateLinkHelp
}
entries.append(.header(presentationData.theme, presentationData.strings.InviteLink_InviteLink, helpText))

let mainInvite: ExportedInvitation?
if let cachedData = view.cachedData as? CachedGroupData, let invite = cachedData.exportedInvitation {
Expand All @@ -444,19 +430,7 @@ public final class InviteLinkInviteController: ViewController {
entries.append(.mainLink(presentationData.theme, mainInvite))
}

let additionalInvites = invites.invitations.filter { $0.link != mainInvite?.link }
var index: Int32 = 0
for i in stride(from: 0, to: additionalInvites.endIndex, by: 2) {
var invitesPair: [ExportedInvitation] = []
invitesPair.append(additionalInvites[i])
if i + 1 < additionalInvites.count {
invitesPair.append(additionalInvites[i + 1])
}
entries.append(.links(index, presentationData.theme, invitesPair))
index += 1
}

entries.append(.manage(presentationData.theme, presentationData.strings.InviteLink_Manage, additionalInvites.isEmpty))
entries.append(.manage(presentationData.theme, presentationData.strings.InviteLink_Manage, true))

let previousEntries = previousEntries.swap(entries)

Expand Down
Loading

0 comments on commit ad26786

Please sign in to comment.