Fixed video layer crash on iOS 8.x

This commit is contained in:
Peter Iakovlev 2018-12-25 17:58:09 +04:00
parent 0ba4de1457
commit 8d38a8db0c
9 changed files with 74 additions and 18 deletions

View File

@ -1270,13 +1270,15 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
}
var hasBots: Bool = false
if let cachedGroupData = peerView.cachedData as? CachedGroupData {
if !cachedGroupData.botInfos.isEmpty {
hasBots = true
}
} else if let cachedChannelData = peerView.cachedData as? CachedChannelData {
if !cachedChannelData.botInfos.isEmpty {
hasBots = true
if let peer = peerView.peers[peerView.peerId] {
if let cachedGroupData = peerView.cachedData as? CachedGroupData {
if !cachedGroupData.botInfos.isEmpty {
hasBots = true
}
} else if let cachedChannelData = peerView.cachedData as? CachedChannelData, let channel = peer as? TelegramChannel, case .group = channel.info {
if !cachedChannelData.botInfos.isEmpty {
hasBots = true
}
}
}

View File

@ -590,9 +590,15 @@ private func canPerformEditingActions(limits: LimitsConfiguration, accountPeerId
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
if message.timestamp + limits.maxMessageEditingInterval > timestamp {
return true
} else {
return false
}
if let peer = message.peers[message.id.peerId] as? TelegramChannel {
if peer.hasAdminRights(.canPinMessages) {
return true
}
}
return false
}
func chatAvailableMessageActions(postbox: Postbox, accountPeerId: PeerId, messageIds: Set<MessageId>) -> Signal<ChatAvailableMessageActions, NoError> {
@ -682,8 +688,14 @@ func chatAvailableMessageActions(postbox: Postbox, accountPeerId: PeerId, messag
for media in message.media {
if let _ = media as? TelegramMediaImage {
hasMediaToReport = true
} else if let file = media as? TelegramMediaFile, file.isVideo {
} else if let _ = media as? TelegramMediaFile {
hasMediaToReport = true
} else if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content {
if let _ = content.image {
hasMediaToReport = true
} else if let _ = content.file {
hasMediaToReport = true
}
}
}
if hasMediaToReport {

View File

@ -1219,7 +1219,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
@objc func editableTextNodeDidChangeSelection(_ editableTextNode: ASEditableTextNode, fromSelectedRange: NSRange, toSelectedRange: NSRange, dueToEditing: Bool) {
if !dueToEditing && !updatingInputState {
if !dueToEditing && !self.updatingInputState {
let inputTextState = self.inputTextState
self.interfaceInteraction?.updateTextInputStateAndMode({ _, inputMode in return (inputTextState, inputMode) })
}
@ -1307,6 +1307,34 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
@objc func editableTextNode(_ editableTextNode: ASEditableTextNode, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
self.updateActivity()
var cleanText = text
let removeSequences: [String] = ["\u{202d}", "\u{202c}"]
for sequence in removeSequences {
inner: while true {
if let range = cleanText.range(of: sequence) {
cleanText.removeSubrange(range)
} else {
break inner
}
}
}
if cleanText != text {
let string = NSMutableAttributedString(attributedString: editableTextNode.attributedText ?? NSAttributedString())
var textColor: UIColor = .black
var accentTextColor: UIColor = .blue
var baseFontSize: CGFloat = 17.0
if let presentationInterfaceState = self.presentationInterfaceState {
textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
accentTextColor = presentationInterfaceState.theme.chat.inputPanel.panelControlAccentColor
baseFontSize = max(17.0, presentationInterfaceState.fontSize.baseDisplaySize)
}
let cleanReplacementString = textAttributedStringForStateText(NSAttributedString(string: cleanText), fontSize: baseFontSize, textColor: textColor, accentTextColor: accentTextColor)
string.replaceCharacters(in: range, with: cleanReplacementString)
self.textInputNode?.attributedText = string
self.textInputNode?.selectedRange = NSMakeRange(range.lowerBound + cleanReplacementString.length, 0)
self.updateTextNodeText(animated: true)
return false
}
return true
}

View File

@ -4,9 +4,14 @@ import AsyncDisplayKit
import SwiftSignalKit
import AVFoundation
private final class MediaPlayerNodeLayerNullAction: NSNull {
@objc override func run(forKey event: String, object anObject: Any, arguments dict: [AnyHashable : Any]?) {
}
}
private final class MediaPlayerNodeLayer: AVSampleBufferDisplayLayer {
override func action(forKey event: String) -> CAAction? {
return NSNull()
return MediaPlayerNodeLayerNullAction()
}
}

View File

@ -50,7 +50,7 @@ public func navigateToChatController(navigationController: NavigationController,
resolvedKeepStack = false
}
if resolvedKeepStack {
navigationController.pushViewController(controller, completion: completion)
navigationController.pushViewController(controller, animated: animated, completion: completion)
} else {
navigationController.replaceAllButRootController(controller, animated: animated, completion: completion)
}

View File

@ -57,7 +57,7 @@ final class NetworkStatusTitleView: UIView, NavigationBarTitleView, NavigationBa
var theme: PresentationTheme {
didSet {
self.titleNode.attributedText = NSAttributedString(string: self.title.text, font: Font.medium(17.0), textColor: self.theme.rootController.navigationBar.primaryTextColor)
self.titleNode.attributedText = NSAttributedString(string: self.title.text, font: Font.bold(17.0), textColor: self.theme.rootController.navigationBar.primaryTextColor)
if self.isPasscodeSet {
self.lockView.setIsLocked(self.isManuallyLocked, theme: self.theme, animated: false)

View File

@ -34,7 +34,7 @@ func peerReportOptionsController(account: Account, subject: PeerReportSubject, p
var items: [ActionSheetItem] = []
for option in options {
let title: String
var color: ActionSheetButtonColor = .accent
let color: ActionSheetButtonColor = .accent
switch option {
case .spam:
title = presentationData.strings.ReportPeer_ReasonSpam
@ -44,7 +44,6 @@ func peerReportOptionsController(account: Account, subject: PeerReportSubject, p
title = presentationData.strings.ReportPeer_ReasonPornography
case .childAbuse:
title = presentationData.strings.ReportPeer_ReasonChildAbuse
color = .destructive
case .copyright:
title = presentationData.strings.ReportPeer_ReasonCopyright
case .other:

View File

@ -3,9 +3,14 @@ import UIKit
import AVFoundation
import SwiftSignalKit
private final class SampleBufferLayerImplNullAction: NSNull {
@objc override func run(forKey event: String, object anObject: Any, arguments dict: [AnyHashable : Any]?) {
}
}
private final class SampleBufferLayerImpl: AVSampleBufferDisplayLayer {
override func action(forKey event: String) -> CAAction? {
return NSNull()
return SampleBufferLayerImplNullAction()
}
deinit {

View File

@ -4,6 +4,11 @@ import TelegramCore
import Postbox
import SwiftSignalKit
private final class SoftwareVideoThumbnailLayerNullAction: NSNull {
@objc override func run(forKey event: String, object anObject: Any, arguments dict: [AnyHashable : Any]?) {
}
}
final class SoftwareVideoThumbnailLayer: CALayer {
var disposable: Disposable?
@ -49,6 +54,6 @@ final class SoftwareVideoThumbnailLayer: CALayer {
}
override func action(forKey event: String) -> CAAction? {
return NSNull()
return SoftwareVideoThumbnailLayerNullAction()
}
}