Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,14 @@ end
version_key: "APP_SHORT_VERSION"
)

if values[:BETA_APP_ICON]
commit = last_git_commit
short_hash = commit[:abbreviated_commit_hash] # short sha of commit
sh "brew install librsvg"
sh "sed -e \"s/\#version#/" + version + "/\" -e \"s/\#githash#/" + short_hash + "/\" badge.svg > badge_tmp.svg"
sh "rsvg-convert badge_tmp.svg > badge.png"
add_badge(custom: "fastlane/badge.png")
end
#if values[:BETA_APP_ICON]
# commit = last_git_commit
# short_hash = commit[:abbreviated_commit_hash] # short sha of commit
# sh "brew install librsvg"
# sh "sed -e \"s/\#version#/" + version + "/\" -e \"s/\#githash#/" + short_hash + "/\" badge.svg > badge_tmp.svg"
# sh "rsvg-convert badge_tmp.svg > badge.png"
# add_badge(custom: "fastlane/badge.png")
#end
Comment on lines +616 to +623
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be uncommented

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I commented that out because it failed and prevented Bitrise builds a few weeks ago (IIRC). When putting it back in, please check whether IPAs are still being built.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed with the latest master merged inside


#Create the build
gym(
Expand Down
4 changes: 4 additions & 0 deletions ownCloud/Media Uploads/MediaUploadOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ class MediaUploadOperation : Operation {
if userDefaults.preferRawPhotos {
preferredResourceTypes.append(.alternatePhoto)
}

if userDefaults.preferOriginalVideos {
preferredResourceTypes.append(.video)
}
}

if let result = asset.upload(with: core,
Expand Down
85 changes: 16 additions & 69 deletions ownCloud/Media Uploads/PhotoKit Extensions/PHAsset+Upload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,69 +335,21 @@ extension PHAsset {
}
}

/**
Method for exporting video assets
- parameter resources: array of PHAssetResource objects belonging to PHAsset
- parameter fileName: name for the exported asset including file extension
- parameter utisToConvert: list of file UTIs for media formats which shall be converted to MP4 format
- parameter completionHandler: called when the file is written to disk or if an error occurs
*/
func exportVideo(resources:[PHAssetResource], fileName:String, utisToConvert:[String] = [], completionHandler: @escaping (_ url:URL?, _ error:Error?) -> Void) {

var resourceToExport:PHAssetResource?

// For edited video pick the edited version
resourceToExport = resources.filter({$0.type == .fullSizeVideo}).first

// If edited video is not avaialable, pick the original
if resourceToExport == nil {
resourceToExport = resources.filter({$0.type == .video}).first
}

// No resource found?
guard let resource = resourceToExport else {
completionHandler(nil, NSError(ocError: .internal))
return
}

// Allow to request resource underlying data from network (iCloud in this case)
let requestOptions = PHAssetResourceRequestOptions()
requestOptions.isNetworkAccessAllowed = true

// Prepare export URL and remove path extension which will depend on output format

// Check if conversion is required?
if utisToConvert.contains(resource.uniformTypeIdentifier) {
exportVideo(fileName: fileName, utisToConvert: utisToConvert) { (url, error) in
completionHandler(url, error)
}
} else {
var exportURL = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent(fileName).deletingPathExtension()
// Append correct file extension to export URL
exportURL = exportURL.appendingPathExtension(resource.fileExtension)

// Write the file to disc
PHAssetResourceManager.default().writeData(for: resource, toFile: exportURL, options: requestOptions) { (error) in
completionHandler(exportURL, error)
}
}
}

/**
Method for exporting video assets
- parameter fileName: name for the exported asset including file extension
- parameter utisToConvert: list of file UTIs for media formats which shall be converted to MP4 format
- parameter completionHandler: called when the file is written to disk or if an error occurs
*/
func exportVideo(fileName:String, utisToConvert:[String] = [], completionHandler: @escaping (_ url:URL?, _ error:Error?) -> Void) {
func exportVideo(fileName:String, utisToConvert:[String] = [], preferOriginal:Bool = false, completionHandler: @escaping (_ url:URL?, _ error:Error?) -> Void) {

var outError: Error?
var exportURL = URL(fileURLWithPath:NSTemporaryDirectory()).appendingPathComponent(fileName)

let videoRequestOptions = PHVideoRequestOptions()
videoRequestOptions.isNetworkAccessAllowed = true
// Take care that in case of edited video, the edited content is used
videoRequestOptions.version = .current
videoRequestOptions.version = preferOriginal ? .original : .current
videoRequestOptions.deliveryMode = .highQualityFormat

// Request AVAssetExport session (can be also done with requestAVAsset() in conjunction with AVAssetWriter for more fine-grained control)
Expand Down Expand Up @@ -439,39 +391,34 @@ extension PHAsset {
*/
func export(fileName:String, utisToConvert:[String] = [], preferredResourceTypes:[PHAssetResourceType] = [], completion:@escaping (_ url:URL?, _ error:Error?) -> Void) {
let assetResources = PHAssetResource.assetResources(for: self)
if assetResources.count > 0 {
// We have actual data on the device and we can export it directly
if self.mediaType == .image {

// We have actual data on the device and we can export it directly
if self.mediaType == .image {
if assetResources.count > 0 {
exportPhoto(resources: assetResources,
fileName: fileName,
utisToConvert: utisToConvert,
preferredResourceTypes: preferredResourceTypes,
completionHandler: { (url, error) in
completion(url, error)
})
} else if self.mediaType == .video {
exportVideo(resources: assetResources, fileName: fileName, utisToConvert: utisToConvert) { (url, error) in
completion(url, error)
}
} else {
completion(nil, NSError(ocError: .internal))
}
} else {
// It could be that we don't have any asset resources locally e.g. since we have to deal with an asset from a cloud album
if self.mediaType == .image {
exportPhoto(fileName: fileName,
utisToConvert: utisToConvert,
completionHandler: { (url, error) in
completion(url, error)
})
} else if self.mediaType == .video {
exportVideo(fileName: fileName,
utisToConvert: utisToConvert) { (url, error) in
completion(url, error)
}
} else {
completion(nil, NSError(ocError: .internal))
}

} else if self.mediaType == .video {
let preferOriginal = preferredResourceTypes.contains(.video)
exportVideo(fileName: fileName,
utisToConvert: utisToConvert,
preferOriginal: preferOriginal) { (url, error) in
completion(url, error)
}
} else {
completion(nil, NSError(ocError: .internal))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -832,4 +832,4 @@
"Extended upload settings" = "Extended upload settings";
"Prefer unedited photos" = "Prefer unedited photos";
"Prefer RAW photos" = "Prefer RAW photos";

"Prefer original videos" = "Prefer original videos";
43 changes: 30 additions & 13 deletions ownCloud/Settings/ProPhotoUploadSettingsSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,39 @@ extension AVCaptureDevice {
}

extension UserDefaults {
enum ProPhotoUploadSettingsKeys : String {
enum ProMediaUploadSettingsKeys : String {
case PreferOriginals = "pro-photo-upload-prefer-originals"
case PreferRAW = "pro-photo-upload-prefer-raw"
case PreferOriginalVideos = "pro-video-upload-prefer-originals"
}

public var preferOriginalPhotos: Bool {
set {
self.set(newValue, forKey: ProPhotoUploadSettingsKeys.PreferOriginals.rawValue)
self.set(newValue, forKey: ProMediaUploadSettingsKeys.PreferOriginals.rawValue)
}

get {
return self.bool(forKey: ProPhotoUploadSettingsKeys.PreferOriginals.rawValue)
return self.bool(forKey: ProMediaUploadSettingsKeys.PreferOriginals.rawValue)
}
}

public var preferRawPhotos: Bool {
set {
self.set(newValue, forKey: ProPhotoUploadSettingsKeys.PreferRAW.rawValue)
self.set(newValue, forKey: ProMediaUploadSettingsKeys.PreferRAW.rawValue)
}

get {
return self.bool(forKey: ProPhotoUploadSettingsKeys.PreferRAW.rawValue)
return self.bool(forKey: ProMediaUploadSettingsKeys.PreferRAW.rawValue)
}
}

public var preferOriginalVideos: Bool {
set {
self.set(newValue, forKey: ProMediaUploadSettingsKeys.PreferOriginalVideos.rawValue)
}

get {
return self.bool(forKey: ProMediaUploadSettingsKeys.PreferOriginalVideos.rawValue)
}
}
}
Expand All @@ -98,14 +109,20 @@ class ProPhotoUploadSettingsSection: SettingsSection {

self.add(row: preferOriginalsRow)

if AVCaptureDevice.rawCameraDeviceAvailable() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the if clause? Raw camera support is not available on every device.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the if clause? Raw camera support is not available on every device.

What about raw files stored on devices without the latest camera? I created the file in iPhone 12 Pro Max, but did my upload testing with the iPhone 8 test device.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good point. I missed that option!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hosy that was exactly the intension to allow users upload RAW photos from their iCloud synced photo library shot on more capable device.

let preferRawRow = StaticTableViewRow(switchWithAction: { (_, sender) in
if let enableSwitch = sender as? UISwitch {
userDefaults.preferRawPhotos = enableSwitch.isOn
}
}, title: "Prefer RAW photos".localized, value: self.userDefaults.preferRawPhotos, identifier: "prefer-raw")
let preferRawRow = StaticTableViewRow(switchWithAction: { (_, sender) in
if let enableSwitch = sender as? UISwitch {
userDefaults.preferRawPhotos = enableSwitch.isOn
}
}, title: "Prefer RAW photos".localized, value: self.userDefaults.preferRawPhotos, identifier: "prefer-raw")

self.add(row: preferRawRow)
}
self.add(row: preferRawRow)

let preferOriginalVideosRow = StaticTableViewRow(switchWithAction: { (_, sender) in
if let enableSwitch = sender as? UISwitch {
userDefaults.preferOriginalVideos = enableSwitch.isOn
}
}, title: "Prefer original videos".localized, value: self.userDefaults.preferOriginalVideos, identifier: "prefer-original-videos")

self.add(row: preferOriginalVideosRow)
}
}