diff --git a/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@2x.png b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@2x.png new file mode 100644 index 0000000000..da6c6dd833 Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@2x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@3x.png b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@3x.png new file mode 100644 index 0000000000..4f7340561c Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Calls@3x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Contents.json b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Contents.json new file mode 100644 index 0000000000..4019ae2782 --- /dev/null +++ b/Images.xcassets/Chat List/Tabs/IconCallsHW.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Calls@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Calls@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@2x.png b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@2x.png new file mode 100644 index 0000000000..f33b703348 Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@2x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@3x.png b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@3x.png new file mode 100644 index 0000000000..c6253384f1 Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Chats@3x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Contents.json b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Contents.json new file mode 100644 index 0000000000..fcc01c2388 --- /dev/null +++ b/Images.xcassets/Chat List/Tabs/IconChatsHW.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Chats@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Chats@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@2x.png b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@2x.png new file mode 100644 index 0000000000..eccfc5f4f9 Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@2x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@3x.png b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@3x.png new file mode 100644 index 0000000000..296dc60b8d Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contacts@3x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contents.json b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contents.json new file mode 100644 index 0000000000..2554b4ce50 --- /dev/null +++ b/Images.xcassets/Chat List/Tabs/IconContactsHW.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Contacts@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Contacts@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Contents.json b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Contents.json new file mode 100644 index 0000000000..9a15c71190 --- /dev/null +++ b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "Settings@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Settings@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@2x.png b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@2x.png new file mode 100644 index 0000000000..f1e7a1f97b Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@2x.png differ diff --git a/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@3x.png b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@3x.png new file mode 100644 index 0000000000..72fbd22988 Binary files /dev/null and b/Images.xcassets/Chat List/Tabs/IconSettingsHW.imageset/Settings@3x.png differ diff --git a/TelegramUI/CallListController.swift b/TelegramUI/CallListController.swift index 20f53136e4..ef7d3048e1 100644 --- a/TelegramUI/CallListController.swift +++ b/TelegramUI/CallListController.swift @@ -48,10 +48,17 @@ public final class CallListController: ViewController { if case .tab = self.mode { self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCallIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.callPressed)) - + + let icon: UIImage? + if (useSpecialTabBarIcons()) { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconCallsHW") + } else { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconCalls") + } + self.tabBarItem.title = self.presentationData.strings.Calls_TabTitle - self.tabBarItem.image = UIImage(bundleImageName: "Chat List/Tabs/IconCalls") - self.tabBarItem.selectedImage = UIImage(bundleImageName: "Chat List/Tabs/IconCalls") + self.tabBarItem.image = icon + self.tabBarItem.selectedImage = icon } self.segmentedTitleView.indexUpdated = { [weak self] index in diff --git a/TelegramUI/ChatListController.swift b/TelegramUI/ChatListController.swift index 0e8a2fc305..854d06dd63 100644 --- a/TelegramUI/ChatListController.swift +++ b/TelegramUI/ChatListController.swift @@ -4,27 +4,34 @@ import SwiftSignalKit import Display import TelegramCore -private let tabImageNone = UIImage(bundleImageName: "Chat List/Tabs/IconChats")?.precomposed() -private let tabImageUp = tabImageNone.flatMap({ image in - return generateImage(image.size, contextGenerator: { size, context in - context.clear(CGRect(origin: CGPoint(), size: size)) - context.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size)) - context.setBlendMode(.copy) - context.setFillColor(UIColor.clear.cgColor) - context.translateBy(x: 0.0, y: 7.0) - let _ = try? drawSvgPath(context, path: "M14.6557321,9.04533883 C14.9642504,8.81236784 15.4032142,8.87361104 15.6361852,9.18212936 C15.8691562,9.49064768 15.807913,9.9296115 15.4993947,10.1625825 L11.612306,13.0978342 C11.3601561,13.2882398 11.0117095,13.2861239 10.7618904,13.0926701 L6.97141581,10.1574184 C6.66574952,9.92071787 6.60984175,9.48104267 6.84654232,9.17537638 C7.08324289,8.86971009 7.5229181,8.81380232 7.82858438,9.05050289 L11.1958257,11.658013 L14.6557321,9.04533883 Z ") - }) -}) -private let tabImageUnread = tabImageNone.flatMap({ image in - return generateImage(image.size, contextGenerator: { size, context in - context.clear(CGRect(origin: CGPoint(), size: size)) - context.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size)) - context.setBlendMode(.copy) - context.setFillColor(UIColor.clear.cgColor) - context.translateBy(x: 0.0, y: 7.0) - let _ = try? drawSvgPath(context, path: "M14.6557321,12.0977948 L11.1958257,9.48512064 L7.82858438,12.0926307 C7.5229181,12.3293313 7.08324289,12.2734235 6.84654232,11.9677572 C6.60984175,11.662091 6.66574952,11.2224158 6.97141581,10.9857152 L10.7618904,8.05046348 C11.0117095,7.85700968 11.3601561,7.85489378 11.612306,8.04529942 L15.4993947,10.9805511 C15.807913,11.2135221 15.8691562,11.6524859 15.6361852,11.9610043 C15.4032142,12.2695226 14.9642504,12.3307658 14.6557321,12.0977948 Z ") - }) -}) +//private let tabImageNone = UIImage(bundleImageName: "Chat List/Tabs/IconChats")?.precomposed() +//private let tabImageUp = tabImageNone.flatMap({ image in +// return generateImage(image.size, contextGenerator: { size, context in +// context.clear(CGRect(origin: CGPoint(), size: size)) +// context.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size)) +// context.setBlendMode(.copy) +// context.setFillColor(UIColor.clear.cgColor) +// context.translateBy(x: 0.0, y: 7.0) +// let _ = try? drawSvgPath(context, path: "M14.6557321,9.04533883 C14.9642504,8.81236784 15.4032142,8.87361104 15.6361852,9.18212936 C15.8691562,9.49064768 15.807913,9.9296115 15.4993947,10.1625825 L11.612306,13.0978342 C11.3601561,13.2882398 11.0117095,13.2861239 10.7618904,13.0926701 L6.97141581,10.1574184 C6.66574952,9.92071787 6.60984175,9.48104267 6.84654232,9.17537638 C7.08324289,8.86971009 7.5229181,8.81380232 7.82858438,9.05050289 L11.1958257,11.658013 L14.6557321,9.04533883 Z ") +// }) +//}) +//private let tabImageUnread = tabImageNone.flatMap({ image in +// return generateImage(image.size, contextGenerator: { size, context in +// context.clear(CGRect(origin: CGPoint(), size: size)) +// context.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size)) +// context.setBlendMode(.copy) +// context.setFillColor(UIColor.clear.cgColor) +// context.translateBy(x: 0.0, y: 7.0) +// let _ = try? drawSvgPath(context, path: "M14.6557321,12.0977948 L11.1958257,9.48512064 L7.82858438,12.0926307 C7.5229181,12.3293313 7.08324289,12.2734235 6.84654232,11.9677572 C6.60984175,11.662091 6.66574952,11.2224158 6.97141581,10.9857152 L10.7618904,8.05046348 C11.0117095,7.85700968 11.3601561,7.85489378 11.612306,8.04529942 L15.4993947,10.9805511 C15.807913,11.2135221 15.8691562,11.6524859 15.6361852,11.9610043 C15.4032142,12.2695226 14.9642504,12.3307658 14.6557321,12.0977948 Z ") +// }) +//}) + +public func useSpecialTabBarIcons() -> Bool { + let calendar = Calendar(identifier: .gregorian) + let now = calendar.dateComponents([.year, .month, .day], from: Date()) + let target = calendar.dateComponents([.year, .month, .day], from: Date(timeIntervalSince1970: 1540987200)) + return now.day == target.day && now.month == target.month && now.year == target.year +} public class ChatListController: TelegramController, KeyShortcutResponder, UIViewControllerPreviewingDelegate { private var validLayout: ContainerViewLayout? @@ -78,8 +85,16 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie self.titleView.title = NetworkStatusTitle(text: self.presentationData.strings.DialogList_Title, activity: false, hasProxy: false, connectsViaProxy: false, isPasscodeSet: false, isManuallyLocked: false) self.navigationItem.titleView = self.titleView self.tabBarItem.title = self.presentationData.strings.DialogList_Title - self.tabBarItem.image = tabImageNone - self.tabBarItem.selectedImage = tabImageNone + + let icon: UIImage? + if (useSpecialTabBarIcons()) { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconChatsHW") + } else { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconChats") + } + + self.tabBarItem.image = icon + self.tabBarItem.selectedImage = icon self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Edit, style: .plain, target: self, action: #selector(self.editPressed)) self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationComposeIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.composePressed)) diff --git a/TelegramUI/ChatMessageInstantVideoItemNode.swift b/TelegramUI/ChatMessageInstantVideoItemNode.swift index 8e32926fa0..3347cb0f43 100644 --- a/TelegramUI/ChatMessageInstantVideoItemNode.swift +++ b/TelegramUI/ChatMessageInstantVideoItemNode.swift @@ -121,7 +121,14 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView { let displaySize = CGSize(width: 212.0, height: 212.0) - let (videoLayout, videoApply) = makeVideoLayout(ChatMessageBubbleContentItem(account: item.account, controllerInteraction: item.controllerInteraction, message: item.message, read: item.read, presentationData: item.presentationData, associatedData: item.associatedData), params.width - params.leftInset - params.rightInset - avatarInset, displaySize, .free, true) + var automaticDownload = true + for media in item.message.media { + if let file = media as? TelegramMediaFile { + automaticDownload = shouldDownloadMediaAutomatically(settings: item.controllerInteraction.automaticMediaDownloadSettings, peerType: item.associatedData.automaticDownloadPeerType, networkType: item.associatedData.automaticDownloadNetworkType, media: file) + } + } + + let (videoLayout, videoApply) = makeVideoLayout(ChatMessageBubbleContentItem(account: item.account, controllerInteraction: item.controllerInteraction, message: item.message, read: item.read, presentationData: item.presentationData, associatedData: item.associatedData), params.width - params.leftInset - params.rightInset - avatarInset, displaySize, .free, automaticDownload) let videoFrame = CGRect(origin: CGPoint(x: (incoming ? (params.leftInset + layoutConstants.bubble.edgeInset + avatarInset + layoutConstants.bubble.contentInsets.left) : (params.width - params.rightInset - videoLayout.contentSize.width - layoutConstants.bubble.edgeInset - layoutConstants.bubble.contentInsets.left)), y: 0.0), size: videoLayout.contentSize) diff --git a/TelegramUI/ContactsController.swift b/TelegramUI/ContactsController.swift index a0f0c490f4..cad551de3a 100644 --- a/TelegramUI/ContactsController.swift +++ b/TelegramUI/ContactsController.swift @@ -34,8 +34,16 @@ public class ContactsController: ViewController { self.title = self.presentationData.strings.Contacts_Title self.tabBarItem.title = self.presentationData.strings.Contacts_Title - self.tabBarItem.image = UIImage(bundleImageName: "Chat List/Tabs/IconContacts") - self.tabBarItem.selectedImage = UIImage(bundleImageName: "Chat List/Tabs/IconContacts") + + let icon: UIImage? + if (useSpecialTabBarIcons()) { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconContactsHW") + } else { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconContacts") + } + + self.tabBarItem.image = icon + self.tabBarItem.selectedImage = icon self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil) self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationAddIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.addPressed)) diff --git a/TelegramUI/EditSettingsController.swift b/TelegramUI/EditSettingsController.swift index 90466cecfb..3b803bd987 100644 --- a/TelegramUI/EditSettingsController.swift +++ b/TelegramUI/EditSettingsController.swift @@ -344,7 +344,7 @@ func editSettingsController(account: Account, currentName: ItemListAvatarAndName } var updateBioSignal: Signal = .complete() if let updateBio = updateBio { - updateBioSignal = updateAbout(account: account, about: updateBio.isEmpty ? nil : updateBio) + updateBioSignal = updateAbout(account: account, about: updateBio) |> `catch` { _ -> Signal in return .complete() } @@ -385,9 +385,7 @@ func editSettingsController(account: Account, currentName: ItemListAvatarAndName actionsDisposable.dispose() } - let controller = ItemListController(account: account, state: signal, tabBarItem: (account.applicationContext as! TelegramApplicationContext).presentationData |> map { presentationData in - return ItemListControllerTabBarItem(title: presentationData.strings.EditProfile_Title, image: PresentationResourcesRootController.tabSettingsIcon(presentationData.theme), selectedImage: PresentationResourcesRootController.tabSettingsSelectedIcon(presentationData.theme)) - }) + let controller = ItemListController(account: account, state: signal, tabBarItem: nil) pushControllerImpl = { [weak controller] value in (controller?.navigationController as? NavigationController)?.pushViewController(value) } diff --git a/TelegramUI/NotificationExceptions.swift b/TelegramUI/NotificationExceptions.swift index 00573fb257..5a81c62d07 100644 --- a/TelegramUI/NotificationExceptions.swift +++ b/TelegramUI/NotificationExceptions.swift @@ -200,6 +200,13 @@ public enum NotificationExceptionMode : Equatable { } } + var isEmpty: Bool { + switch self { + case let .users(value), let .groups(value): + return value.isEmpty + } + } + case users([PeerId : NotificationExceptionWrapper]) case groups([PeerId : NotificationExceptionWrapper]) @@ -439,6 +446,12 @@ public func notificationExceptionsController(account: Account, mode: Notificatio }) presentControllerImpl?(controller, ViewControllerPresentationArguments(presentationAnimation: .modalSheet)) actionSheet?.dismissAnimated() + }), + ActionSheetButtonItem(title: presentationData.strings.Notifications_ExceptionsResetToDefaults, color: .destructive, action: { [weak actionSheet] in + + updatePeerNotificationInterval(peerId, nil) + updatePeerSound(peerId, .default) + actionSheet?.dismissAnimated() }) ]), ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, action: { [weak actionSheet] in @@ -505,6 +518,15 @@ public func notificationExceptionsController(account: Account, mode: Notificatio actionSheet?.dismissAnimated() })) + if settings.muteState != .default || settings.messageSound != .default { + items.append(ActionSheetButtonItem(title: presentationData.strings.Notifications_ExceptionsResetToDefaults, color: .destructive, action: { [weak actionSheet] in + + updatePeerNotificationInterval(peerId, nil) + updatePeerSound(peerId, .default) + actionSheet?.dismissAnimated() + })) + } + actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [ ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, color: .accent, action: { [weak actionSheet] in actionSheet?.dismissAnimated() @@ -544,7 +566,7 @@ public func notificationExceptionsController(account: Account, mode: Notificatio let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.Notifications_ExceptionsTitle), leftNavigationButton: nil, rightNavigationButton: nil, backNavigationButton: nil) - let listState = ItemListNodeState(entries: notificationsExceptionEntries(presentationData: presentationData, peers: peers, state: state), style: .plain, searchItem: nil) + let listState = ItemListNodeState(entries: notificationsExceptionEntries(presentationData: presentationData, peers: peers, state: state), style: .blocks, searchItem: nil) return (controllerState, (listState, arguments)) } @@ -771,8 +793,6 @@ private final class NotificationExceptionsControllerNode: ASDisplayNode { } }) - - self.readyValue.set(contentNode.ready) } diff --git a/TelegramUI/NotificationsAndSounds.swift b/TelegramUI/NotificationsAndSounds.swift index 9bf1194acd..403385eba6 100644 --- a/TelegramUI/NotificationsAndSounds.swift +++ b/TelegramUI/NotificationsAndSounds.swift @@ -423,14 +423,19 @@ private func notificationsAndSoundsEntries(globalSettings: GlobalNotificationSet entries.append(.messageAlerts(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, globalSettings.privateChats.enabled)) entries.append(.messagePreviews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, globalSettings.privateChats.displayPreviews)) entries.append(.messageSound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(globalSettings.privateChats.sound)), filteredGlobalSound(globalSettings.privateChats.sound))) - //entries.append(.userExceptions(presentationData.theme, presentationData.strings, presentationData.strings.Notifications_MessageNotificationsExceptions, exceptions.0)) + if !exceptions.0.isEmpty { + // entries.append(.userExceptions(presentationData.theme, presentationData.strings, presentationData.strings.Notifications_MessageNotificationsExceptions, exceptions.0)) + } entries.append(.messageNotice(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsHelp)) entries.append(.groupHeader(presentationData.theme, presentationData.strings.Notifications_GroupNotifications)) entries.append(.groupAlerts(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsAlert, globalSettings.groupChats.enabled)) entries.append(.groupPreviews(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsPreview, globalSettings.groupChats.displayPreviews)) entries.append(.groupSound(presentationData.theme, presentationData.strings.Notifications_MessageNotificationsSound, localizedPeerNotificationSoundString(strings: presentationData.strings, sound: filteredGlobalSound(globalSettings.groupChats.sound)), filteredGlobalSound(globalSettings.groupChats.sound))) - entries.append(.groupExceptions(presentationData.theme, presentationData.strings, presentationData.strings.Notifications_MessageNotificationsExceptions, exceptions.1)) + if !exceptions.1.isEmpty { + // entries.append(.groupExceptions(presentationData.theme, presentationData.strings, presentationData.strings.Notifications_MessageNotificationsExceptions, exceptions.1)) + } + entries.append(.groupNotice(presentationData.theme, presentationData.strings.Notifications_GroupNotificationsHelp)) entries.append(.inAppHeader(presentationData.theme, presentationData.strings.Notifications_InAppNotifications)) @@ -584,7 +589,8 @@ public func notificationsAndSoundsController(account: Account) -> ViewController var groups: [PeerId : NotificationExceptionWrapper] = [:] for (key, value) in allSettings { - if let value = value as? TelegramPeerNotificationSettings { + let peer = transaction.getPeer(key) + if let value = value as? TelegramPeerNotificationSettings, let peer = peer, !peer.displayTitle.isEmpty, peer.id != account.peerId { switch value.muteState { case .default: switch value.messageSound { diff --git a/TelegramUI/PhotoResources.swift b/TelegramUI/PhotoResources.swift index bcc18993d6..b4b7aaeb86 100644 --- a/TelegramUI/PhotoResources.swift +++ b/TelegramUI/PhotoResources.swift @@ -837,6 +837,11 @@ public func chatMessageVideoThumbnail(account: Account, fileReference: FileMedia fittedSize.height = arguments.boundingSize.height } + if arguments.intrinsicInsets != UIEdgeInsets.zero { + fittedSize.width -= arguments.intrinsicInsets.left + arguments.intrinsicInsets.right + fittedSize.height -= arguments.intrinsicInsets.top + arguments.intrinsicInsets.bottom + } + let fittedRect = CGRect(origin: CGPoint(x: drawingRect.origin.x + (drawingRect.size.width - fittedSize.width) / 2.0, y: drawingRect.origin.y + (drawingRect.size.height - fittedSize.height) / 2.0), size: fittedSize) var fullSizeImage: CGImage? diff --git a/TelegramUI/PresentationResourcesRootController.swift b/TelegramUI/PresentationResourcesRootController.swift index a8d8e30045..f4d269f508 100644 --- a/TelegramUI/PresentationResourcesRootController.swift +++ b/TelegramUI/PresentationResourcesRootController.swift @@ -34,43 +34,7 @@ struct PresentationResourcesRootController { generateIndefiniteActivityIndicatorImage(color: theme.rootController.navigationBar.accentTextColor) }) } - - static func tabContactsIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabContactsIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconContacts"), color: theme.rootController.tabBar.iconColor) - }) - } - - static func tabContactsSelectedIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabContactsSelectedIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconContacts"), color: theme.rootController.tabBar.selectedIconColor) - }) - } - - static func tabChatsIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabChatsIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconChats"), color: theme.rootController.tabBar.iconColor) - }) - } - - static func tabChatsSelectedIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabChatsSelectedIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconChats"), color: theme.rootController.tabBar.selectedIconColor) - }) - } - - static func tabSettingsIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabSettingsIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconSettings"), color: theme.rootController.tabBar.iconColor) - }) - } - - static func tabSettingsSelectedIcon(_ theme: PresentationTheme) -> UIImage? { - return theme.image(PresentationResourceKey.rootTabSettingsSelectedIcon.rawValue, { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat List/Tabs/IconSettings"), color: theme.rootController.tabBar.selectedIconColor) - }) - } - + static func navigationComposeIcon(_ theme: PresentationTheme) -> UIImage? { return theme.image(PresentationResourceKey.navigationComposeIcon.rawValue, { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat List/ComposeIcon"), color: theme.rootController.navigationBar.accentTextColor) diff --git a/TelegramUI/PresentationStrings.swift b/TelegramUI/PresentationStrings.swift index 70312084cd..7821ff82d6 100644 --- a/TelegramUI/PresentationStrings.swift +++ b/TelegramUI/PresentationStrings.swift @@ -1537,6 +1537,7 @@ public final class PresentationStrings { } public let Conversation_ClearPrivateHistory: String public let Conversation_ContextMenuShare: String + public let Notifications_ExceptionsResetToDefaults: String public let Notifications_ExceptionsNone: String private let _Time_MonthOfYear_m6: String private let _Time_MonthOfYear_m6_r: [(Int, NSRange)] @@ -6588,6 +6589,7 @@ public final class PresentationStrings { self._LOCKED_MESSAGE_r = extractArgumentRanges(self._LOCKED_MESSAGE) self.Conversation_ClearPrivateHistory = getValue(dict, "Conversation.ClearPrivateHistory") self.Conversation_ContextMenuShare = getValue(dict, "Conversation.ContextMenuShare") + self.Notifications_ExceptionsResetToDefaults = getValue(dict, "Notifications.ExceptionsResetToDefaults") self.Notifications_ExceptionsNone = getValue(dict, "Notifications.ExceptionsNone") self._Time_MonthOfYear_m6 = getValue(dict, "Time.MonthOfYear_m6") self._Time_MonthOfYear_m6_r = extractArgumentRanges(self._Time_MonthOfYear_m6) diff --git a/TelegramUI/SettingsController.swift b/TelegramUI/SettingsController.swift index 4cc17f524a..3a646f3cb7 100644 --- a/TelegramUI/SettingsController.swift +++ b/TelegramUI/SettingsController.swift @@ -714,8 +714,15 @@ public func settingsController(account: Account, accountManager: AccountManager) actionsDisposable.dispose() } + let icon: UIImage? + if (useSpecialTabBarIcons()) { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconSettingsHW") + } else { + icon = UIImage(bundleImageName: "Chat List/Tabs/IconSettings") + } + let controller = ItemListController(account: account, state: signal, tabBarItem: (account.applicationContext as! TelegramApplicationContext).presentationData |> map { presentationData in - return ItemListControllerTabBarItem(title: presentationData.strings.Settings_Title, image: PresentationResourcesRootController.tabSettingsIcon(presentationData.theme), selectedImage: PresentationResourcesRootController.tabSettingsSelectedIcon(presentationData.theme)) + return ItemListControllerTabBarItem(title: presentationData.strings.Settings_Title, image: icon, selectedImage: icon) }) pushControllerImpl = { [weak controller] value in (controller?.navigationController as? NavigationController)?.replaceAllButRootController(value, animated: true) diff --git a/TelegramUI/StorageUsageController.swift b/TelegramUI/StorageUsageController.swift index 5142210d44..d2308a2488 100644 --- a/TelegramUI/StorageUsageController.swift +++ b/TelegramUI/StorageUsageController.swift @@ -373,7 +373,7 @@ func storageUsageController(account: Account) -> ViewController { if otherSize.1 != 0 { totalSize += otherSize.1 let index = itemIndex - items.append(ActionSheetCheckboxItem(title: presentationData.strings.Localization_LanguageOther, label: dataSizeString(Int(otherSize.1)), value: true, action: { value in + items.append(ActionSheetCheckboxItem(title: presentationData.strings.Localization_LanguageOther, label: dataSizeString(otherSize.1), value: true, action: { value in toggleCheck(nil, index) })) itemIndex += 1 @@ -524,17 +524,14 @@ func storageUsageController(account: Account) -> ViewController { items.append(ActionSheetButtonItem(title: presentationData.strings.Cache_Clear("\(dataSizeString(totalSize))").0, action: { if let statsPromise = statsPromise { let clearCategories = sizeIndex.keys.filter({ sizeIndex[$0]!.0 }) - //var clearSize: Int64 = 0 - var clearMediaIds = Set() var media = stats.media if var categories = media[peerId] { for category in clearCategories { if let contents = categories[category] { - for (mediaId, size) in contents { + for (mediaId, _) in contents { clearMediaIds.insert(mediaId) - //clearSize += size } } categories.removeValue(forKey: category) diff --git a/TelegramUI/WatchManager.swift b/TelegramUI/WatchManager.swift index 4267029d30..e568573369 100644 --- a/TelegramUI/WatchManager.swift +++ b/TelegramUI/WatchManager.swift @@ -3,15 +3,29 @@ import SwiftSignalKit import Postbox import TelegramCore +public struct WatchRunningTasks: Equatable { + public let running: Bool + public let version: Int32 + + public init(running: Bool, version: Int32) { + self.running = running + self.version = version + } + + public static func ==(lhs: WatchRunningTasks, rhs: WatchRunningTasks) -> Bool { + return lhs.running == rhs.running && lhs.version == rhs.version + } +} + public final class WatchManagerArguments { public let appInstalled: Signal public let navigateToMessageRequested: Signal - public let runningRequests: Signal + public let runningTasks: Signal - public init(appInstalled: Signal, navigateToMessageRequested: Signal, runningRequests: Signal) { + public init(appInstalled: Signal, navigateToMessageRequested: Signal, runningTasks: Signal) { self.appInstalled = appInstalled self.navigateToMessageRequested = navigateToMessageRequested - self.runningRequests = runningRequests + self.runningTasks = runningTasks } } @@ -30,7 +44,7 @@ public final class WatchManager { return self.arguments?.navigateToMessageRequested ?? .never() } - public var runningRequests: Signal { - return self.arguments?.runningRequests ?? .single(false) + public var runningTasks: Signal { + return self.arguments?.runningTasks ?? .single(nil) } } diff --git a/TelegramUI/WatchSettingsController.swift b/TelegramUI/WatchSettingsController.swift index 1321a40234..385619f3ff 100644 --- a/TelegramUI/WatchSettingsController.swift +++ b/TelegramUI/WatchSettingsController.swift @@ -85,7 +85,7 @@ private enum WatchSettingsControllerEntry: ItemListNodeEntry { private func watchSettingsControllerEntries(presentationData: PresentationData, customPresets: [String : String]) -> [WatchSettingsControllerEntry] { var entries: [WatchSettingsControllerEntry] = [] - let defaultSuggestions : [(Int32, String, String)] = [ + let defaultSuggestions: [(Int32, String, String)] = [ (0, "OK", presentationData.strings.Watch_Suggestion_OK), (1, "Thanks", presentationData.strings.Watch_Suggestion_Thanks), (2, "WhatsUp", presentationData.strings.Watch_Suggestion_WhatsUp),