Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
fnakstad committed Feb 19, 2016
2 parents c53b6a0 + abfec59 commit 279838d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 30 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: objective-c

before_install:
- brew update
#- brew install carthage
- if brew outdated | grep -qx xctool; then brew upgrade xctool; fi

script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
DD112158CF9886DE925FED5E /* Frameworks */,
A067DFAD5749963FA2D2ADED /* Pods */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
29D699DA1B70ABFC0021FA73 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -345,7 +347,7 @@
baseConfigurationReference = C4392341AC7391C01AD9F350 /* Pods-ImagePickerDemo.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -359,7 +361,7 @@
baseConfigurationReference = 6F9E1FF802198DC16F260795 /* Pods-ImagePickerDemo.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_IDENTITY = "";
INFOPLIST_FILE = ImagePickerDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
4 changes: 1 addition & 3 deletions Demo/ImagePickerDemo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
ImagePicker: 2a904341bbc47c96457de00558d2f8dd186eff7c

PODFILE CHECKSUM: ebbcd890a98cb01cb66183bea63d5e8e97f82923

COCOAPODS: 1.0.0.beta.2
COCOAPODS: 0.39.0
2 changes: 2 additions & 0 deletions ImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@
D5DC59AA1C201CC4003BD79B /* Source */,
D5DC598C1C201BE1003BD79B /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
D5DC598C1C201BE1003BD79B /* Products */ = {
isa = PBXGroup;
Expand Down
30 changes: 12 additions & 18 deletions Source/CameraView/CameraView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ class CameraView: UIViewController, CLLocationManagerDelegate {
}

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
setCorrectOrientationToPreviewLayer()
locationManager.startUpdatingLocation()
}

override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
locationManager.stopUpdatingLocation()
}

Expand Down Expand Up @@ -253,24 +256,20 @@ class CameraView: UIViewController, CLLocationManagerDelegate {

let queue = dispatch_queue_create("session queue", DISPATCH_QUEUE_SERIAL)

guard let stillImageOutput = self.stillImageOutput else { return }

if let videoOrientation = previewLayer?.connection.videoOrientation {
stillImageOutput?.connectionWithMediaType(AVMediaTypeVideo).videoOrientation = videoOrientation
stillImageOutput.connectionWithMediaType(AVMediaTypeVideo).videoOrientation = videoOrientation
}

guard let stillImageOutput = self.stillImageOutput else { return }

dispatch_async(queue, { [unowned self] in
stillImageOutput.captureStillImageAsynchronouslyFromConnection(stillImageOutput.connectionWithMediaType(AVMediaTypeVideo),
completionHandler: { (buffer, error) -> Void in
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(buffer)

guard let imageFromData = UIImage(data: imageData) else { return }
let image = self.cropImage(imageFromData)
let orientation = self.pictureOrientation()
guard let imageCG = image.CGImage else { return }

PHPhotoLibrary.sharedPhotoLibrary().performChanges({
let request = PHAssetChangeRequest.creationRequestForAssetFromImage(UIImage(CGImage: imageCG, scale: 1.0, orientation: orientation))
let request = PHAssetChangeRequest.creationRequestForAssetFromImage(imageFromData)
request.location = self.latestLocation
}, completionHandler: { success, error in
self.delegate?.imageToLibrary()
Expand All @@ -279,14 +278,6 @@ class CameraView: UIViewController, CLLocationManagerDelegate {
})
}

func cropImage(image: UIImage) -> UIImage {
guard let imageReference = CGImageCreateWithImageInRect(image.CGImage,
CGRect(x: 0, y: 0, width: image.size.height - 285, height: image.size.width)) else { return UIImage() }
let normalizedImage = UIImage(CGImage: imageReference, scale: 1, orientation: .Right)

return normalizedImage
}

func pictureOrientation() -> UIImageOrientation {
switch UIDevice.currentDevice().orientation {
case .LandscapeLeft:
Expand Down Expand Up @@ -421,12 +412,15 @@ class CameraView: UIViewController, CLLocationManagerDelegate {
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

previewLayer?.frame.size = size
setCorrectOrientationToPreviewLayer()
}

func setCorrectOrientationToPreviewLayer() {
guard let previewLayer = self.previewLayer,
connection = previewLayer.connection
else { return }

previewLayer.frame.size = size

switch UIDevice.currentDevice().orientation {
case .Portrait:
connection.videoOrientation = .Portrait
Expand Down
4 changes: 4 additions & 0 deletions Source/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public struct Configuration {
// MARK: Dimensions

public static var cellSpacing: CGFloat = 2

// MARK: Custom behaviour

public static var collapseCollectionViewWhileShot: Bool = true
}
1 change: 1 addition & 0 deletions Source/ImageGallery/ImageGalleryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public class ImageGalleryView: UIView {
collectionView.delegate = self

topSeparator.frame = CGRect(x: 0, y: 0, width: totalWidth, height: Dimensions.galleryBarHeight)
topSeparator.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin]
indicator.frame = CGRect(x: (totalWidth - Dimensions.indicatorWidth) / 2, y: (topSeparator.frame.height - Dimensions.indicatorHeight) / 2,
width: Dimensions.indicatorWidth, height: Dimensions.indicatorHeight)
collectionView.frame = CGRect(x: 0, y: topSeparator.frame.height, width: totalWidth, height: collectionFrame - topSeparator.frame.height)
Expand Down
36 changes: 30 additions & 6 deletions Source/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public class ImagePickerController: UIViewController {
view.frame = CGRect(x: 0, y: 0, width: 1, height: 1)

return view
}()
}()

var volume = AVAudioSession.sharedInstance().outputVolume

public weak var delegate: ImagePickerDelegate?
public var stack = ImageStack()
public var imageLimit = 0
let totalSize = UIScreen.mainScreen().bounds.size
var totalSize: CGSize { return UIScreen.mainScreen().bounds.size }
var initialFrame: CGRect?
var initialContentOffset: CGPoint?
var numberOfCells: Int?
Expand Down Expand Up @@ -134,7 +134,7 @@ public class ImagePickerController: UIViewController {
super.viewWillDisappear(animated)
UIApplication.sharedApplication().setStatusBarHidden(statusBarHidden, withAnimation: .Fade)
}

public override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
}
Expand All @@ -158,7 +158,7 @@ public class ImagePickerController: UIViewController {
object: nil)

NSNotificationCenter.defaultCenter().addObserver(self,
selector: "adjustButtonTitle:",
selector: "didReloadAssets:",
name: ImageStack.Notifications.stackDidReload,
object: nil)

Expand All @@ -168,12 +168,18 @@ public class ImagePickerController: UIViewController {
object: nil)
}

func didReloadAssets(notification: NSNotification) {
adjustButtonTitle(notification)
galleryView.collectionView.reloadData()
galleryView.collectionView.setContentOffset(CGPointZero, animated: false)
}

func volumeChanged(notification: NSNotification) {
guard let slider = volumeView.subviews.filter({ $0 is UISlider }).first as? UISlider,
let userInfo = notification.userInfo,
let changeReason = userInfo["AVSystemController_AudioVolumeChangeReasonNotificationParameter"] as? String
where changeReason == "ExplicitVolumeChange" else { return }

slider.setValue(volume, animated: false)
cameraController.takePicture()
}
Expand All @@ -188,6 +194,18 @@ public class ImagePickerController: UIViewController {

// MARK: - Helpers

public override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

let galleryHeight: CGFloat = UIScreen.mainScreen().nativeBounds.height == 960
? ImageGalleryView.Dimensions.galleryBarHeight
: GestureConstants.minimumHeight

let y = totalSize.height - bottomContainer.frame.height - galleryHeight
galleryView.frame = CGRect(x: 0, y: y,
width: totalSize.width, height: galleryHeight)
}

public override func prefersStatusBarHidden() -> Bool {
return true
}
Expand Down Expand Up @@ -257,9 +275,15 @@ extension ImagePickerController: BottomContainerViewDelegate {

bottomContainer.pickerButton.enabled = false
bottomContainer.stackView.startLoader()
collapseGalleryView { [unowned self] in
let action: Void -> Void = { [unowned self] in
self.cameraController.takePicture()
}

if Configuration.collapseCollectionViewWhileShot {
collapseGalleryView(action)
} else {
action()
}
}

func doneButtonDidPress() {
Expand Down

0 comments on commit 279838d

Please sign in to comment.