Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #139 from vimeo/release/1.0.0
Browse files Browse the repository at this point in the history
Merging Release 1.0.0 branch
  • Loading branch information
mikew-personal authored May 30, 2017
2 parents 06f5dc9 + 8629bcd commit 8d357e7
Show file tree
Hide file tree
Showing 343 changed files with 27,894 additions and 1,747 deletions.
15 changes: 4 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ DerivedData
*.xcuserstate
.DS_STORE

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#

Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
Expand All @@ -38,7 +29,9 @@ Carthage/Build
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/test_output*

# Exclude fastlane xcode log
xcodebuild.log
xcodebuild.log

VimeoUpload-iOS-*.log
5 changes: 5 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
xcode_summary.ignored_files = 'Pods/*'
Dir.glob('build/reports/errors-*.json') do |result|
xcode_summary.report result
end
markdown "See build details on [CircleCI](#{ENV['CIRCLE_BUILD_URL']})"
22 changes: 11 additions & 11 deletions Examples/VimeoUpload+Demos/Cells/DemoCameraRollCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class DemoCameraRollCell: UICollectionViewCell, CameraRollAssetCell
@IBOutlet weak var fileSizeLabel: UILabel!
@IBOutlet weak var durationlabel: UILabel!

override var selected: Bool
override var isSelected: Bool
{
didSet
{
if selected == true
if isSelected == true
{
self.imageView.alpha = 0.5
}
Expand Down Expand Up @@ -78,33 +78,33 @@ class DemoCameraRollCell: UICollectionViewCell, CameraRollAssetCell

// MARK: CameraRollAssetCell Protocol

func setImage(image: UIImage)
func set(image: UIImage)
{
self.imageView.image = image
}

func setDuration(seconds seconds: Float64)
func setDuration(seconds: Float64)
{
var string: NSString = ""
var string = ""

if seconds > 0
{
string = String.stringFromDurationInSeconds(seconds) as String
string = String.stringFromDuration(inSeconds: seconds) as String
}

self.durationlabel?.text = string as String
self.durationlabel?.text = string
}

func setFileSize(bytes bytes: Float64)
func setFileSize(bytes: Float64)
{
var string: NSString = ""
var string = ""

if bytes > 0
{
string = NSString.stringFromFileSize(bytes: bytes)
string = NSString.stringFromFileSize(bytes: bytes) as String
}

self.fileSizeLabel.text = string as String
self.fileSizeLabel.text = string
}

func setInCloud()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
private var operation: MeQuotaOperation?
private var me: VIMUser? // We store this in a property instead of on the operation itself, so that we can refresh it independent of the operation [AH]
private var meOperation: MeOperation?
private var selectedIndexPath: NSIndexPath?
private var selectedIndexPath: IndexPath?

// MARK: Lifecycle

Expand All @@ -86,32 +86,32 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
self.setupAndStartOperation()
}

override func viewDidAppear(animated: Bool)
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)

if let indexPath = self.selectedIndexPath // Deselect the previously selected item upon return from video settings
{
self.collectionView.deselectItemAtIndexPath(indexPath, animated: true)
self.collectionView.deselectItem(at: indexPath, animated: true)
}
}

// MARK: Observers

private func addObservers()
{
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(UIApplicationDelegate.applicationWillEnterForeground(_:)), name: UIApplicationWillEnterForegroundNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(UIApplicationDelegate.applicationWillEnterForeground(_:)), name: Notification.Name.UIApplicationWillEnterForeground, object: nil)
}

private func removeObservers()
{
NSNotificationCenter.defaultCenter().removeObserver(self, name: UIApplicationWillEnterForegroundNotification, object: nil)
NotificationCenter.default.removeObserver(self, name: Notification.Name.UIApplicationWillEnterForeground, object: nil)
}

// Ensure that we refresh the me object on return from background
// In the event that a user modified their upload quota while the app was backgrounded [AH] 12/06/2015

func applicationWillEnterForeground(notification: NSNotification)
func applicationWillEnterForeground(_ notification: Notification)
{
if self.meOperation != nil
{
Expand All @@ -121,7 +121,7 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
let operation = MeOperation(sessionManager: self.sessionManager)
operation.completionBlock = { [weak self] () -> Void in

dispatch_async(dispatch_get_main_queue(), { [weak self] () -> Void in
DispatchQueue.main.async(execute: { [weak self] () -> Void in

guard let strongSelf = self else
{
Expand All @@ -130,7 +130,7 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource

strongSelf.meOperation = nil

if operation.cancelled == true
if operation.isCancelled == true
{
return
}
Expand All @@ -157,24 +157,24 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
let options = PHFetchOptions()
options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]

let fetchResult = PHAsset.fetchAssetsWithMediaType(.Video, options: options)

fetchResult.enumerateObjectsUsingBlock{ (object: AnyObject?, count: Int, stop: UnsafeMutablePointer<ObjCBool>) in
let fetchResult = PHAsset.fetchAssets(with: .video, options: options)

fetchResult.enumerateObjects({ (object: AnyObject?, count: Int, stop: UnsafeMutablePointer<ObjCBool>) in

if let phAsset = object as? PHAsset
{
let vimPHAsset = VIMPHAsset(phAsset: phAsset)
assets.append(vimPHAsset)
}
}
})

return assets
}

private func setupCollectionView()
{
let nib = UINib(nibName: DemoCameraRollCell.NibName, bundle: nil)
self.collectionView.registerNib(nib, forCellWithReuseIdentifier: DemoCameraRollCell.CellIdentifier)
self.collectionView.register(nib, forCellWithReuseIdentifier: DemoCameraRollCell.CellIdentifier)

let layout = self.collectionView.collectionViewLayout as? UICollectionViewFlowLayout
layout?.minimumInteritemSpacing = BaseCameraRollViewController.CollectionViewSpacing
Expand All @@ -186,14 +186,14 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
let operation = MeQuotaOperation(sessionManager: self.sessionManager, me: self.me)
operation.completionBlock = { [weak self] () -> Void in

dispatch_async(dispatch_get_main_queue(), { [weak self] () -> Void in
DispatchQueue.main.async(execute: { [weak self] () -> Void in

guard let strongSelf = self else
{
return
}

if operation.cancelled == true
if operation.isCancelled == true
{
return
}
Expand All @@ -204,7 +204,7 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
{
if let indexPath = strongSelf.selectedIndexPath
{
strongSelf.presentErrorAlert(indexPath, error: error)
strongSelf.presentErrorAlert(at: indexPath, error: error)
}
// else: do nothing, the error will be communicated at the time of cell selection
}
Expand All @@ -225,14 +225,14 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource

// MARK: UICollectionViewDataSource

func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return self.assets.count
}

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(DemoCameraRollCell.CellIdentifier, forIndexPath: indexPath) as! DemoCameraRollCell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DemoCameraRollCell.CellIdentifier, for: indexPath) as! DemoCameraRollCell

let cameraRollAsset = self.assets[indexPath.item]

Expand All @@ -242,39 +242,39 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
return cell
}

func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath)
func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath)
{
let cameraRollAsset = self.assets[indexPath.item]

self.cameraRollAssetHelper?.cancelRequests(cameraRollAsset)
self.cameraRollAssetHelper?.cancelRequests(with: cameraRollAsset)
}

// MARK: UICollectionViewFlowLayoutDelegate

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
{
let dimension = (collectionView.bounds.size.width - BaseCameraRollViewController.CollectionViewSpacing) / 2

return CGSizeMake(dimension, dimension)
return CGSize(width: dimension, height: dimension)
}

// MARK: UICollectionViewDelegate

func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath)
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
self.didSelectIndexPath(indexPath)
self.didSelect(indexPath: indexPath)
}

// MARK: Private API

private func didSelectIndexPath(indexPath: NSIndexPath)
private func didSelect(indexPath: IndexPath)
{
let cameraRollAsset = self.assets[indexPath.item]

// Check if an error occurred when attempting to retrieve the asset
if let error = cameraRollAsset.error
{
self.presentAssetErrorAlert(indexPath, error: error)
self.presentAssetErrorAlert(at: indexPath, error: error)

return
}
Expand All @@ -283,14 +283,14 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource

if let error = self.operation?.error
{
self.presentErrorAlert(indexPath, error: error)
self.presentErrorAlert(at: indexPath, error: error)
}
else
{
if AFNetworkReachabilityManager.sharedManager().reachable == false
if AFNetworkReachabilityManager.shared().isReachable == false
{
let error = NSError(domain: NSURLErrorDomain, code: NSURLErrorNotConnectedToInternet, userInfo: [NSLocalizedDescriptionKey: "The internet connection appears to be offline."])
self.presentErrorAlert(indexPath, error: error)
self.presentErrorAlert(at: indexPath, error: error)

return
}
Expand All @@ -308,54 +308,54 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource

// MARK: UI Presentation

private func presentAssetErrorAlert(indexPath: NSIndexPath, error: NSError)
private func presentAssetErrorAlert(at indexPath: IndexPath, error: NSError)
{
let alert = UIAlertController(title: "Asset Error", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: { [weak self] (action) -> Void in
self?.collectionView.reloadItemsAtIndexPaths([indexPath]) // Let the user manually reselect the cell since reload is async
let alert = UIAlertController(title: "Asset Error", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: { [weak self] (action) -> Void in
self?.collectionView.reloadItems(at: [indexPath]) // Let the user manually reselect the cell since reload is async
}))

self.presentViewController(alert, animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
}

private func presentErrorAlert(indexPath: NSIndexPath, error: NSError)
private func presentErrorAlert(at indexPath: IndexPath, error: NSError)
{
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: { [weak self] (action) -> Void in
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler: { [weak self] (action) -> Void in

guard let strongSelf = self else
{
return
}

strongSelf.selectedIndexPath = nil
strongSelf.collectionView.deselectItemAtIndexPath(indexPath, animated: true)
strongSelf.collectionView.deselectItem(at: indexPath, animated: true)
strongSelf.setupAndStartOperation()
}))

alert.addAction(UIAlertAction(title: "Try Again", style: UIAlertActionStyle.Default, handler: { [weak self] (action) -> Void in
alert.addAction(UIAlertAction(title: "Try Again", style: UIAlertActionStyle.default, handler: { [weak self] (action) -> Void in

guard let strongSelf = self else
{
return
}

strongSelf.setupAndStartOperation()
strongSelf.didSelectIndexPath(indexPath)
strongSelf.didSelect(indexPath: indexPath)
}))

self.presentViewController(alert, animated: true, completion: nil)
self.present(alert, animated: true, completion: nil)
}

private func finish(cameraRollAsset cameraRollAsset: VIMPHAsset)
private func finish(cameraRollAsset: VIMPHAsset)
{
let me = self.me!

// Reset the operation so we're prepared to retry upon cancellation from video settings [AH] 12/06/2015
self.setupAndStartOperation()

let result = UploadUserAndCameraRollAsset(user: me, cameraRollAsset: cameraRollAsset)
self.didFinishWithResult(result)
self.didFinish(with: result)
}

// MARK: Overrides
Expand All @@ -365,7 +365,7 @@ class BaseCameraRollViewController: UIViewController, UICollectionViewDataSource
self.title = "Camera Roll"
}

func didFinishWithResult(result: UploadUserAndCameraRollAsset)
func didFinish(with result: UploadUserAndCameraRollAsset)
{
assertionFailure("Subclasses must override")
}
Expand Down
Loading

0 comments on commit 8d357e7

Please sign in to comment.