From e2fc5ace75a635724688ad09b5e77f1b13af3f7c Mon Sep 17 00:00:00 2001 From: Peter Date: Sat, 15 Sep 2018 00:39:38 +0300 Subject: [PATCH] no message --- .../AutodownloadMediaCategoryController.swift | 36 +++++++++---------- .../FFMpegMediaFrameSourceContext.swift | 8 ++--- TelegramUI/ItemListPeerItem.swift | 35 ++++++++++++------ .../SecureIdDocumentFormControllerNode.swift | 2 +- TelegramUI/SinglePhoneInputNode.swift | 2 +- TelegramUI/StorageUsageController.swift | 26 +++++++++----- 6 files changed, 67 insertions(+), 42 deletions(-) diff --git a/TelegramUI/AutodownloadMediaCategoryController.swift b/TelegramUI/AutodownloadMediaCategoryController.swift index d27eaca023..d1e1de39f3 100644 --- a/TelegramUI/AutodownloadMediaCategoryController.swift +++ b/TelegramUI/AutodownloadMediaCategoryController.swift @@ -315,26 +315,26 @@ private func autodownloadMediaCategoryControllerEntries(presentationData: Presen size = settings.peers.contacts.videoMessage.sizeLimit } - entries.append(.cellularHeader(presentationData.theme, "CELLULAR")) - entries.append(.cellularContacts(presentationData.theme, "Contacts", cellular.contacts)) - entries.append(.cellularOtherPrivate(presentationData.theme, "Other Private", cellular.otherPrivate)) - entries.append(.cellularGroups(presentationData.theme, "Groups", cellular.groups)) - entries.append(.cellularChannels(presentationData.theme, "Channels", cellular.channels)) + entries.append(.cellularHeader(presentationData.theme, presentationData.strings.AutoDownloadSettings_Cellular)) + entries.append(.cellularContacts(presentationData.theme, presentationData.strings.AutoDownloadSettings_Contacts, cellular.contacts)) + entries.append(.cellularOtherPrivate(presentationData.theme, presentationData.strings.AutoDownloadSettings_PrivateChats, cellular.otherPrivate)) + entries.append(.cellularGroups(presentationData.theme, presentationData.strings.AutoDownloadSettings_GroupChats, cellular.groups)) + entries.append(.cellularChannels(presentationData.theme, presentationData.strings.AutoDownloadSettings_Channels, cellular.channels)) - entries.append(.wifiHeader(presentationData.theme, "WI-FI")) - entries.append(.wifiContacts(presentationData.theme, "Contacts", wifi.contacts)) - entries.append(.wifiOtherPrivate(presentationData.theme, "Other Private", wifi.otherPrivate)) - entries.append(.wifiGroups(presentationData.theme, "Groups", wifi.groups)) - entries.append(.wifiChannels(presentationData.theme, "Channels", wifi.channels)) + entries.append(.wifiHeader(presentationData.theme, presentationData.strings.AutoDownloadSettings_WiFi)) + entries.append(.wifiContacts(presentationData.theme, presentationData.strings.AutoDownloadSettings_Contacts, wifi.contacts)) + entries.append(.wifiOtherPrivate(presentationData.theme, presentationData.strings.AutoDownloadSettings_PrivateChats, wifi.otherPrivate)) + entries.append(.wifiGroups(presentationData.theme, presentationData.strings.AutoDownloadSettings_GroupChats, wifi.groups)) + entries.append(.wifiChannels(presentationData.theme, presentationData.strings.AutoDownloadSettings_Channels, wifi.channels)) switch category { case .file, .video: - entries.append(.sizeHeader(presentationData.theme, "LIMIT BY SIZE")) + entries.append(.sizeHeader(presentationData.theme, presentationData.strings.AutoDownloadSettings_LimitBySize)) let text: String if size == Int32.max { - text = "unlimited" + text = presentationData.strings.AutoDownloadSettings_Unlimited } else { - text = "up to \(dataSizeString(Int(size)))" + text = presentationData.strings.AutoDownloadSettings_UpTo(dataSizeString(Int(size))).0 } entries.append(.sizeItem(presentationData.theme, text, size)) default: @@ -553,15 +553,15 @@ func autodownloadMediaCategoryController(account: Account, category: AutomaticDo let title: String switch category { case .photo: - title = "Photos" + title = presentationData.strings.AutoDownloadSettings_PhotosTitle case .video: - title = "Videos" + title = presentationData.strings.AutoDownloadSettings_VideosTitle case .file: - title = "Files" + title = presentationData.strings.AutoDownloadSettings_DocumentsTitle case .voiceMessage: - title = "Voice Messages" + title = presentationData.strings.AutoDownloadSettings_VoiceMessagesTitle case .videoMessage: - title = "Video Messages" + title = presentationData.strings.AutoDownloadSettings_VideoMessagesTitle } let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(title), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false) diff --git a/TelegramUI/FFMpegMediaFrameSourceContext.swift b/TelegramUI/FFMpegMediaFrameSourceContext.swift index 3a4a06c520..4aa187236a 100644 --- a/TelegramUI/FFMpegMediaFrameSourceContext.swift +++ b/TelegramUI/FFMpegMediaFrameSourceContext.swift @@ -171,10 +171,10 @@ private func seekCallback(userData: UnsafeMutableRawPointer?, offset: Int64, whe context.requestedCompleteFetch = false } else { if streamable { - context.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, range: context.readingOffset ..< resourceSize, statsCategory: statsCategory).start()) + context.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, range: context.readingOffset ..< resourceSize, statsCategory: statsCategory, preferBackgroundReferenceRevalidation: streamable).start()) } else if !context.requestedCompleteFetch && context.fetchAutomatically { context.requestedCompleteFetch = true - context.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, statsCategory: statsCategory).start()) + context.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, statsCategory: statsCategory, preferBackgroundReferenceRevalidation: streamable).start()) } } } @@ -235,10 +235,10 @@ final class FFMpegMediaFrameSourceContext: NSObject { let resourceSize: Int = resourceReference.resource.size ?? Int(Int32.max - 1) if streamable { - self.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, range: 0 ..< resourceSize, statsCategory: self.statsCategory ?? .generic).start()) + self.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, range: 0 ..< resourceSize, statsCategory: self.statsCategory ?? .generic, preferBackgroundReferenceRevalidation: streamable).start()) } else if !self.requestedCompleteFetch && self.fetchAutomatically { self.requestedCompleteFetch = true - self.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, statsCategory: self.statsCategory ?? .generic).start()) + self.fetchedDataDisposable.set(fetchedMediaResource(postbox: postbox, reference: resourceReference, statsCategory: self.statsCategory ?? .generic, preferBackgroundReferenceRevalidation: streamable).start()) } var avFormatContextRef = avformat_alloc_context() diff --git a/TelegramUI/ItemListPeerItem.swift b/TelegramUI/ItemListPeerItem.swift index e3c527bcfc..baf6b55c39 100644 --- a/TelegramUI/ItemListPeerItem.swift +++ b/TelegramUI/ItemListPeerItem.swift @@ -38,6 +38,11 @@ enum ItemListPeerItemAliasHandling { case threatSelfAsSaved } +enum ItemListPeerItemNameColor { + case primary + case secret +} + enum ItemListPeerItemRevealOptionType { case neutral case warning @@ -60,6 +65,7 @@ final class ItemListPeerItem: ListViewItem, ItemListItem { let account: Account let peer: Peer let aliasHandling: ItemListPeerItemAliasHandling + let nameColor: ItemListPeerItemNameColor let presence: PeerPresence? let text: ItemListPeerItemText let label: ItemListPeerItemLabel @@ -73,12 +79,13 @@ final class ItemListPeerItem: ListViewItem, ItemListItem { let removePeer: (PeerId) -> Void let toggleUpdated: ((Bool) -> Void)? - init(theme: PresentationTheme, strings: PresentationStrings, account: Account, peer: Peer, aliasHandling: ItemListPeerItemAliasHandling = .standard, presence: PeerPresence?, text: ItemListPeerItemText, label: ItemListPeerItemLabel, editing: ItemListPeerItemEditing, revealOptions: ItemListPeerItemRevealOptions? = nil, switchValue: ItemListPeerItemSwitch?, enabled: Bool, sectionId: ItemListSectionId, action: (() -> Void)?, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, removePeer: @escaping (PeerId) -> Void, toggleUpdated: ((Bool) -> Void)? = nil) { + init(theme: PresentationTheme, strings: PresentationStrings, account: Account, peer: Peer, aliasHandling: ItemListPeerItemAliasHandling = .standard, nameColor: ItemListPeerItemNameColor = .primary, presence: PeerPresence?, text: ItemListPeerItemText, label: ItemListPeerItemLabel, editing: ItemListPeerItemEditing, revealOptions: ItemListPeerItemRevealOptions? = nil, switchValue: ItemListPeerItemSwitch?, enabled: Bool, sectionId: ItemListSectionId, action: (() -> Void)?, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, removePeer: @escaping (PeerId) -> Void, toggleUpdated: ((Bool) -> Void)? = nil) { self.theme = theme self.strings = strings self.account = account self.peer = peer self.aliasHandling = aliasHandling + self.nameColor = nameColor self.presence = presence self.text = text self.label = label @@ -304,26 +311,34 @@ class ItemListPeerItemNode: ItemListRevealOptionsItemNode { currentCheckNode = nil } + let titleColor: UIColor + switch item.nameColor { + case .primary: + titleColor = item.theme.list.itemPrimaryTextColor + case .secret: + titleColor = item.theme.chatList.secretTitleColor + } + if item.peer.id == item.account.peerId, case .threatSelfAsSaved = item.aliasHandling { - titleAttributedString = NSAttributedString(string: item.strings.DialogList_SavedMessages, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor) + titleAttributedString = NSAttributedString(string: item.strings.DialogList_SavedMessages, font: titleBoldFont, textColor: titleColor) } else if let user = item.peer as? TelegramUser { if let firstName = user.firstName, let lastName = user.lastName, !firstName.isEmpty, !lastName.isEmpty { let string = NSMutableAttributedString() - string.append(NSAttributedString(string: firstName, font: titleFont, textColor: item.theme.list.itemPrimaryTextColor)) - string.append(NSAttributedString(string: " ", font: titleFont, textColor: item.theme.list.itemPrimaryTextColor)) - string.append(NSAttributedString(string: lastName, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor)) + string.append(NSAttributedString(string: firstName, font: titleFont, textColor: titleColor)) + string.append(NSAttributedString(string: " ", font: titleFont, textColor: titleColor)) + string.append(NSAttributedString(string: lastName, font: titleBoldFont, textColor: titleColor)) titleAttributedString = string } else if let firstName = user.firstName, !firstName.isEmpty { - titleAttributedString = NSAttributedString(string: firstName, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor) + titleAttributedString = NSAttributedString(string: firstName, font: titleBoldFont, textColor: titleColor) } else if let lastName = user.lastName, !lastName.isEmpty { - titleAttributedString = NSAttributedString(string: lastName, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor) + titleAttributedString = NSAttributedString(string: lastName, font: titleBoldFont, textColor: titleColor) } else { - titleAttributedString = NSAttributedString(string: "Deleted User", font: titleBoldFont, textColor: item.theme.list.itemDisabledTextColor) + titleAttributedString = NSAttributedString(string: item.strings.User_DeletedAccount, font: titleBoldFont, textColor: titleColor) } } else if let group = item.peer as? TelegramGroup { - titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor) + titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: titleColor) } else if let channel = item.peer as? TelegramChannel { - titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.theme.list.itemPrimaryTextColor) + titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: titleColor) } switch item.text { diff --git a/TelegramUI/SecureIdDocumentFormControllerNode.swift b/TelegramUI/SecureIdDocumentFormControllerNode.swift index 188d270bb7..ec9196822c 100644 --- a/TelegramUI/SecureIdDocumentFormControllerNode.swift +++ b/TelegramUI/SecureIdDocumentFormControllerNode.swift @@ -2614,7 +2614,7 @@ final class SecureIdDocumentFormControllerNode: FormControllerNode