Support sharing/saving videos and gifvs from gallery

See #450
This commit is contained in:
Shadowfacts 2024-03-20 12:00:57 -04:00
parent 072bb0daf0
commit 1cf3ce48ce
6 changed files with 16 additions and 16 deletions

View File

@ -195,7 +195,7 @@
D6934F3A2BA8F3D7002B1C8D /* FallbackGalleryContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F392BA8F3D7002B1C8D /* FallbackGalleryContentViewController.swift */; };
D6934F3C2BAA0F80002B1C8D /* VideoGalleryContentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F3B2BAA0F80002B1C8D /* VideoGalleryContentViewController.swift */; };
D6934F3E2BAA19D5002B1C8D /* ImageActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F3D2BAA19D5002B1C8D /* ImageActivityItemSource.swift */; };
D6934F402BAA19EC002B1C8D /* GifvActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F3F2BAA19EC002B1C8D /* GifvActivityItemSource.swift */; };
D6934F402BAA19EC002B1C8D /* VideoActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6934F3F2BAA19EC002B1C8D /* VideoActivityItemSource.swift */; };
D693A72825CF282E003A14E2 /* TrendingHashtagsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */; };
D693A72F25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */; };
D693A73025CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */; };
@ -596,7 +596,7 @@
D6934F392BA8F3D7002B1C8D /* FallbackGalleryContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FallbackGalleryContentViewController.swift; sourceTree = "<group>"; };
D6934F3B2BAA0F80002B1C8D /* VideoGalleryContentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoGalleryContentViewController.swift; sourceTree = "<group>"; };
D6934F3D2BAA19D5002B1C8D /* ImageActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageActivityItemSource.swift; sourceTree = "<group>"; };
D6934F3F2BAA19EC002B1C8D /* GifvActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GifvActivityItemSource.swift; sourceTree = "<group>"; };
D6934F3F2BAA19EC002B1C8D /* VideoActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoActivityItemSource.swift; sourceTree = "<group>"; };
D693A72725CF282E003A14E2 /* TrendingHashtagsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingHashtagsViewController.swift; sourceTree = "<group>"; };
D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeaturedProfileCollectionViewCell.swift; sourceTree = "<group>"; };
D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FeaturedProfileCollectionViewCell.xib; sourceTree = "<group>"; };
@ -1348,7 +1348,7 @@
D681E4D6246E32290053414F /* StatusActivityItemSource.swift */,
D681E4D8246E346E0053414F /* AccountActivityItemSource.swift */,
D6934F3D2BAA19D5002B1C8D /* ImageActivityItemSource.swift */,
D6934F3F2BAA19EC002B1C8D /* GifvActivityItemSource.swift */,
D6934F3F2BAA19EC002B1C8D /* VideoActivityItemSource.swift */,
D6AEBB3D2321638100E5038B /* UIActivity+Types.swift */,
D6AEBB422321685E00E5038B /* OpenInSafariActivity.swift */,
D6CA8CDD296387310050C433 /* SaveToPhotosActivity.swift */,
@ -2211,7 +2211,7 @@
D6E426B325337C7000C02E1C /* CustomEmojiImageView.swift in Sources */,
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,
D61F75B3293BD89C00C0B37F /* UpdateFilterService.swift in Sources */,
D6934F402BAA19EC002B1C8D /* GifvActivityItemSource.swift in Sources */,
D6934F402BAA19EC002B1C8D /* VideoActivityItemSource.swift in Sources */,
D6C3F5172991C1A00009FCFF /* View+AppListStyle.swift in Sources */,
D65B4B6A297777D900DABDFB /* StatusNotFoundView.swift in Sources */,
D6412B0924B0291E00F5412E /* MyProfileViewController.swift in Sources */,

View File

@ -1,5 +1,5 @@
//
// GifvActivityItemSource.swift
// VideoActivityItemSource.swift
// Tusker
//
// Created by Shadowfacts on 3/19/24.
@ -10,7 +10,7 @@ import UIKit
import UniformTypeIdentifiers
import AVFoundation
class GifvActivityItemSource: NSObject, UIActivityItemSource {
class VideoActivityItemSource: NSObject, UIActivityItemSource {
let asset: AVAsset
let url: URL

View File

@ -11,13 +11,15 @@ import GalleryVC
import Combine
class GifvGalleryContentViewController: UIViewController, GalleryContentViewController {
let controller: GifvController
private let controller: GifvController
private let url: URL
let caption: String?
private var presentationSizeCancellable: AnyCancellable?
init(controller: GifvController, caption: String?) {
init(controller: GifvController, url: URL, caption: String?) {
self.controller = controller
self.url = url
self.caption = caption
super.init(nibName: nil, bundle: nil)
@ -64,8 +66,7 @@ class GifvGalleryContentViewController: UIViewController, GalleryContentViewCont
}
var activityItemsForSharing: [Any] {
// TODO: share gifv
[]
[VideoActivityItemSource(asset: controller.item.asset, url: url)]
}
}

View File

@ -71,7 +71,7 @@ class StatusAttachmentsGalleryDataSource: GalleryDataSource {
} else {
GifvController(asset: AVAsset(url: attachment.url))
}
return GifvGalleryContentViewController(controller: controller, caption: attachment.description)
return GifvGalleryContentViewController(controller: controller, url: attachment.url, caption: attachment.description)
case .video:
return VideoGalleryContentViewController(url: attachment.url, caption: attachment.description)
case .audio:

View File

@ -92,8 +92,7 @@ class VideoGalleryContentViewController: UIViewController, GalleryContentViewCon
}
var activityItemsForSharing: [Any] {
// TODO: share videos
[]
[VideoActivityItemSource(asset: item.asset, url: url)]
}
}

View File

@ -448,7 +448,7 @@ extension AttachmentView: UIContextMenuInteractionDelegate {
return ImageGalleryContentViewController(url: self.attachment.url, caption: nil, originalData: nil, image: image, gifController: self.gifController)
} else if self.attachment.kind == .gifv,
let gifvView {
return GifvGalleryContentViewController(controller: gifvView.controller, caption: nil)
return GifvGalleryContentViewController(controller: gifvView.controller, url: self.attachment.url, caption: nil)
} else if self.attachment.kind == .video || self.attachment.kind == .audio {
let vc = VideoGalleryContentViewController(url: self.attachment.url, caption: nil)
vc.player.isMuted = true
@ -478,8 +478,8 @@ extension AttachmentView: UIContextMenuInteractionDelegate {
itemSource = ImageActivityItemSource(data: data, url: url, image: image)
itemData = Task { data }
}
} else if self.attachment.kind == .gifv {
itemSource = GifvActivityItemSource(asset: AVAsset(url: self.attachment.url), url: self.attachment.url)
} else if self.attachment.kind == .gifv || self.attachment.kind == .video {
itemSource = VideoActivityItemSource(asset: AVAsset(url: self.attachment.url), url: self.attachment.url)
itemData = Task {
try? await URLSession.shared.data(from: self.attachment.url).0
}