mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
0220c4ca14
@ -1260,40 +1260,26 @@ open class TextNode: ASDisplayNode {
|
||||
var effectiveLineRange = brokenLineRange
|
||||
var additionalTrailingLine: (CTLine, Double)?
|
||||
|
||||
if lineRange.length == 0 || (CTLineGetTypographicBounds(originalLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(originalLine) + truncationTokenWidth) < Double(lineConstrainedSize.width) {
|
||||
var measureFitWidth = CTLineGetTypographicBounds(originalLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(originalLine)
|
||||
if customTruncationToken != nil {
|
||||
measureFitWidth += truncationTokenWidth
|
||||
}
|
||||
|
||||
if lineRange.length == 0 || measureFitWidth < Double(lineConstrainedSize.width) {
|
||||
if didClipLinebreak {
|
||||
coreTextLine = originalLine
|
||||
if lineRange.length == 0 {
|
||||
coreTextLine = CTLineCreateWithAttributedString(NSAttributedString())
|
||||
} else {
|
||||
coreTextLine = originalLine
|
||||
}
|
||||
additionalTrailingLine = (truncationToken, truncationTokenWidth)
|
||||
|
||||
/*let mergedLine = NSMutableAttributedString()
|
||||
mergedLine.append(attributedString.attributedSubstring(from: NSRange(location: lineRange.location, length: lineRange.length)))
|
||||
mergedLine.append(truncatedTokenString)
|
||||
|
||||
coreTextLine = CTLineCreateWithAttributedString(mergedLine)
|
||||
|
||||
let runs = (CTLineGetGlyphRuns(coreTextLine) as [AnyObject]) as! [CTRun]
|
||||
for run in runs {
|
||||
let runAttributes: NSDictionary = CTRunGetAttributes(run)
|
||||
if let _ = runAttributes["CTForegroundColorFromContext"] {
|
||||
brokenLineRange.length = CTRunGetStringRange(run).location - brokenLineRange.location
|
||||
break
|
||||
}
|
||||
}
|
||||
if brokenLineRange.location + brokenLineRange.length > lineRange.location + lineRange.length {
|
||||
brokenLineRange.location = lineRange.location
|
||||
brokenLineRange.length = lineRange.length
|
||||
}
|
||||
if brokenLineRange.location + brokenLineRange.length > attributedString.length {
|
||||
brokenLineRange.length = attributedString.length - brokenLineRange.location
|
||||
}
|
||||
effectiveLineRange = brokenLineRange*/
|
||||
|
||||
truncated = true
|
||||
} else {
|
||||
coreTextLine = originalLine
|
||||
}
|
||||
} else {
|
||||
coreTextLine = CTLineCreateTruncatedLine(originalLine, Double(lineConstrainedSize.width), truncationType, truncationToken) ?? truncationToken
|
||||
coreTextLine = CTLineCreateTruncatedLine(originalLine, max(1.0, Double(lineConstrainedSize.width) - truncationTokenWidth), truncationType, truncationToken) ?? truncationToken
|
||||
let runs = (CTLineGetGlyphRuns(coreTextLine) as [AnyObject]) as! [CTRun]
|
||||
for run in runs {
|
||||
let runAttributes: NSDictionary = CTRunGetAttributes(run)
|
||||
|
@ -1022,7 +1022,6 @@ private final class MediaPlayerContext {
|
||||
if isPaused && self.fadeTimer != nil {
|
||||
playbackStatus = .paused
|
||||
} else if reportRate.isZero {
|
||||
//playbackStatus = .buffering(initial: false, whilePlaying: true)
|
||||
playbackStatus = .playing
|
||||
statusTimestamp = 0.0
|
||||
} else {
|
||||
|
@ -82,6 +82,8 @@ final class StoryItemContentComponent: Component {
|
||||
private var currentProgressTimerValue: Double = 0.0
|
||||
private var videoProgressDisposable: Disposable?
|
||||
|
||||
private var ignoreBufferingTimestamp: Double = 0.0
|
||||
|
||||
private var markedAsSeen: Bool = false
|
||||
private var contentLoaded: Bool = false
|
||||
|
||||
@ -252,6 +254,7 @@ final class StoryItemContentComponent: Component {
|
||||
|
||||
override func leaveAmbientMode() {
|
||||
if let videoNode = self.videoNode {
|
||||
self.ignoreBufferingTimestamp = CFAbsoluteTimeGetCurrent()
|
||||
videoNode.setSoundEnabled(true)
|
||||
videoNode.continueWithOverridingAmbientMode(isAmbient: false)
|
||||
}
|
||||
@ -259,6 +262,7 @@ final class StoryItemContentComponent: Component {
|
||||
|
||||
override func enterAmbientMode(ambient: Bool) {
|
||||
if let videoNode = self.videoNode {
|
||||
self.ignoreBufferingTimestamp = CFAbsoluteTimeGetCurrent()
|
||||
if ambient {
|
||||
videoNode.continueWithOverridingAmbientMode(isAmbient: true)
|
||||
} else {
|
||||
@ -369,6 +373,16 @@ final class StoryItemContentComponent: Component {
|
||||
isBuffering = true
|
||||
}
|
||||
|
||||
if isBuffering {
|
||||
if CFAbsoluteTimeGetCurrent() - self.ignoreBufferingTimestamp < 0.3 {
|
||||
isBuffering = false
|
||||
} else {
|
||||
self.ignoreBufferingTimestamp = 0.0
|
||||
}
|
||||
} else {
|
||||
self.ignoreBufferingTimestamp = 0.0
|
||||
}
|
||||
|
||||
if case .buffering(true, _, _, _) = videoPlaybackStatus.status {
|
||||
timestampAndDuration = (nil, effectiveDuration)
|
||||
} else if effectiveDuration > 0.0 {
|
||||
|
@ -3886,7 +3886,7 @@ public final class StoryItemSetContainerComponent: Component {
|
||||
self.requestSave()
|
||||
})))
|
||||
|
||||
if component.slice.item.storyItem.isPublic && (component.slice.peer.addressName != nil || !component.slice.peer._asPeer().usernames.isEmpty) && component.slice.item.storyItem.expirationTimestamp > Int32(Date().timeIntervalSince1970) {
|
||||
if component.slice.item.storyItem.isPublic && (component.slice.peer.addressName != nil || !component.slice.peer._asPeer().usernames.isEmpty) && (component.slice.item.storyItem.expirationTimestamp > Int32(Date().timeIntervalSince1970) || component.slice.item.storyItem.isPinned) {
|
||||
items.append(.action(ContextMenuActionItem(text: component.strings.Story_Context_CopyLink, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Link"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak self] _, a in
|
||||
|
Loading…
x
Reference in New Issue
Block a user