Skip to content

Commit

Permalink
Merge pull request #12 from jdiedrick/development
Browse files Browse the repository at this point in the history
Development to master!
  • Loading branch information
therewasaguy committed Aug 12, 2015
2 parents 7fe0ff3 + f3b9c40 commit 76e524c
Show file tree
Hide file tree
Showing 12 changed files with 902 additions and 62 deletions.
5 changes: 4 additions & 1 deletion ios/transients/Podfile
Expand Up @@ -5,7 +5,10 @@ platform :ios, '8.0'
use_frameworks!

target 'transients' do
pod 'Alamofire'
#pod 'Alamofire', '~> 1.2.3'
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
pod 'SwiftyJSON', '~> 2.2.0'
pod 'MotionKit'
end

target 'transientsTests' do
Expand Down
17 changes: 16 additions & 1 deletion ios/transients/Podfile.lock
@@ -1,10 +1,25 @@
PODS:
- Alamofire (1.2.3)
- MotionKit (0.8.1)
- SwiftyJSON (2.2.0)

DEPENDENCIES:
- Alamofire
- Alamofire (from `https://github.com/Alamofire/Alamofire.git`)
- MotionKit
- SwiftyJSON (~> 2.2.0)

EXTERNAL SOURCES:
Alamofire:
:git: https://github.com/Alamofire/Alamofire.git

CHECKOUT OPTIONS:
Alamofire:
:commit: 97c29c6c48c82344a8f4919b1b6517c7957af3a3
:git: https://github.com/Alamofire/Alamofire.git

SPEC CHECKSUMS:
Alamofire: 5550bf0b575ed1a4bf9be572f9463e1015cc169e
MotionKit: a88a7d7b5ed6652793a3744f6ca58227d8804236
SwiftyJSON: 0b3e6c07af17ff745e77e8e9984097b55c956e5c

COCOAPODS: 0.37.2
24 changes: 24 additions & 0 deletions ios/transients/transients.xcodeproj/project.pbxproj
Expand Up @@ -8,13 +8,19 @@

/* Begin PBXBuildFile section */
8689DFE0401127FC6435AADB /* Pods_transients.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A6BFBC4728ECC33093F2689 /* Pods_transients.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
8E01BA201B5DAFD400A1774F /* TZDriftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8E01BA1F1B5DAFD400A1774F /* TZDriftViewController.swift */; };
8E486BCB1B3E467E00CE41A4 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E486BCA1B3E467E00CE41A4 /* MapKit.framework */; };
8ED07CF61B38DAC100C1F950 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED07CF51B38DAC100C1F950 /* AppDelegate.swift */; };
8ED07CF91B38DAC100C1F950 /* transients.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 8ED07CF71B38DAC100C1F950 /* transients.xcdatamodeld */; };
8ED07CFB1B38DAC100C1F950 /* TZRecorderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED07CFA1B38DAC100C1F950 /* TZRecorderViewController.swift */; };
8ED07D001B38DAC100C1F950 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8ED07CFF1B38DAC100C1F950 /* Images.xcassets */; };
8ED07D031B38DAC100C1F950 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8ED07D011B38DAC100C1F950 /* LaunchScreen.xib */; };
8ED07D0F1B38DAC100C1F950 /* transientsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED07D0E1B38DAC100C1F950 /* transientsTests.swift */; };
8ED3F7E31B40D2C200E26D06 /* TZGeoSoundRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3F7E21B40D2C200E26D06 /* TZGeoSoundRecorder.swift */; };
8ED3F7E51B40D87700E26D06 /* TZGeoSoundPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3F7E41B40D87700E26D06 /* TZGeoSoundPlayer.swift */; };
8ED94E611B54C09E00D4A273 /* TZLocationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED94E601B54C09E00D4A273 /* TZLocationService.swift */; };
8EE840231B3C78EF0037EC64 /* TZMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EE840221B3C78EE0037EC64 /* TZMapViewController.swift */; };
E1C7C4221B71983F0099A025 /* TZSaveViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1C7C4211B71983F0099A025 /* TZSaveViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -29,6 +35,8 @@

/* Begin PBXFileReference section */
7A6BFBC4728ECC33093F2689 /* Pods_transients.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_transients.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8E01BA1F1B5DAFD400A1774F /* TZDriftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZDriftViewController.swift; sourceTree = "<group>"; };
8E486BCA1B3E467E00CE41A4 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
8ED07CF01B38DAC100C1F950 /* transients.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = transients.app; sourceTree = BUILT_PRODUCTS_DIR; };
8ED07CF41B38DAC100C1F950 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8ED07CF51B38DAC100C1F950 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -39,7 +47,11 @@
8ED07D081B38DAC100C1F950 /* transientsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = transientsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
8ED07D0D1B38DAC100C1F950 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8ED07D0E1B38DAC100C1F950 /* transientsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = transientsTests.swift; sourceTree = "<group>"; };
8ED3F7E21B40D2C200E26D06 /* TZGeoSoundRecorder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZGeoSoundRecorder.swift; sourceTree = "<group>"; };
8ED3F7E41B40D87700E26D06 /* TZGeoSoundPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZGeoSoundPlayer.swift; sourceTree = "<group>"; };
8ED94E601B54C09E00D4A273 /* TZLocationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZLocationService.swift; sourceTree = "<group>"; };
8EE840221B3C78EE0037EC64 /* TZMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZMapViewController.swift; sourceTree = "<group>"; };
E1C7C4211B71983F0099A025 /* TZSaveViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TZSaveViewController.swift; sourceTree = "<group>"; };
F1F1F2E4BE99EA7D0F555FA8 /* Pods-transients.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-transients.debug.xcconfig"; path = "Pods/Target Support Files/Pods-transients/Pods-transients.debug.xcconfig"; sourceTree = "<group>"; };
F22EA1881006184062FB1506 /* Pods-transients.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-transients.release.xcconfig"; path = "Pods/Target Support Files/Pods-transients/Pods-transients.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -49,6 +61,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8E486BCB1B3E467E00CE41A4 /* MapKit.framework in Frameworks */,
8689DFE0401127FC6435AADB /* Pods_transients.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -66,6 +79,7 @@
2CB6CB170D55CA1433A0A071 /* Frameworks */ = {
isa = PBXGroup;
children = (
8E486BCA1B3E467E00CE41A4 /* MapKit.framework */,
7A6BFBC4728ECC33093F2689 /* Pods_transients.framework */,
);
name = Frameworks;
Expand Down Expand Up @@ -95,8 +109,13 @@
isa = PBXGroup;
children = (
8ED07CF51B38DAC100C1F950 /* AppDelegate.swift */,
E1C7C4211B71983F0099A025 /* TZSaveViewController.swift */,
8ED07CFA1B38DAC100C1F950 /* TZRecorderViewController.swift */,
8ED3F7E41B40D87700E26D06 /* TZGeoSoundPlayer.swift */,
8ED3F7E21B40D2C200E26D06 /* TZGeoSoundRecorder.swift */,
8EE840221B3C78EE0037EC64 /* TZMapViewController.swift */,
8E01BA1F1B5DAFD400A1774F /* TZDriftViewController.swift */,
8ED94E601B54C09E00D4A273 /* TZLocationService.swift */,
8ED07CFF1B38DAC100C1F950 /* Images.xcassets */,
8ED07D011B38DAC100C1F950 /* LaunchScreen.xib */,
8ED07CF71B38DAC100C1F950 /* transients.xcdatamodeld */,
Expand Down Expand Up @@ -289,10 +308,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8ED94E611B54C09E00D4A273 /* TZLocationService.swift in Sources */,
8E01BA201B5DAFD400A1774F /* TZDriftViewController.swift in Sources */,
8ED07CFB1B38DAC100C1F950 /* TZRecorderViewController.swift in Sources */,
8ED3F7E31B40D2C200E26D06 /* TZGeoSoundRecorder.swift in Sources */,
8ED07CF91B38DAC100C1F950 /* transients.xcdatamodeld in Sources */,
8ED07CF61B38DAC100C1F950 /* AppDelegate.swift in Sources */,
8ED3F7E51B40D87700E26D06 /* TZGeoSoundPlayer.swift in Sources */,
8EE840231B3C78EF0037EC64 /* TZMapViewController.swift in Sources */,
E1C7C4221B71983F0099A025 /* TZSaveViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 8 additions & 2 deletions ios/transients/transients/AppDelegate.swift
Expand Up @@ -14,14 +14,16 @@ import CoreData
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

var tabBarController: UITabBarController?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)


if let window = window{
let tabBarController = UITabBarController()

var tabBarController = UITabBarController()
let rvc = TZRecorderViewController(nibName: nil, bundle: nil)
let mvc = TZMapViewController(nibName: nil, bundle: nil)
let controllers = [rvc, mvc]
Expand All @@ -33,6 +35,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
rvc.tabBarItem = UITabBarItem(title: "Record", image: nil, tag: 1)
mvc.tabBarItem = UITabBarItem(title: "Map", image: nil, tag: 2)

//these two lines are used to custom make tzdriftviewcontroller load first for testing
// let rootViewController : UIViewController = TZDriftViewController()
// window.rootViewController = rootViewController

window.makeKeyAndVisible()
}

Expand Down
7 changes: 7 additions & 0 deletions ios/transients/transients/Info.plist
Expand Up @@ -20,8 +20,12 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>heyo</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand All @@ -31,6 +35,9 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
93 changes: 93 additions & 0 deletions ios/transients/transients/TZDriftViewController.swift
@@ -0,0 +1,93 @@
//
// TZDriftViewController.swift
// transients
//
// Created by Johann Diedrick on 7/20/15.
// Copyright (c) 2015 Johann Diedrick. All rights reserved.
//

import Foundation
import MotionKit


class TZDriftViewController: UIViewController{

var file_path:NSURL?

let motionKit = MotionKit()

let threshold = 0.5
let interval = 0.1
let magnitude = 5

override func viewDidLoad(){
view.backgroundColor = UIColor.orangeColor()


LocationService.sharedInstance.startUpdatingLocation()
LocationService.sharedInstance.startUpdatingHeading()


var motionValues = NSMutableArray()



motionKit.getAccelerometerValues(interval: self.interval) {(x, y, z) -> () in

// println("X: \(x) Y: \(y) Z \(z)")
var slowedDown = false


if(x < -self.threshold){ //we're moving!

//println("we're moving")
motionValues.addObject(x)
//println(motionValues)
var lastValue = motionValues.lastObject as! Float64

if(motionValues.count > 3){
var penultimateValue = motionValues.objectAtIndex(motionValues.count - 2) as! Float64
// println("last value: \(lastValue) | penultimateValue: \(penultimateValue)")
if slowedDown == false{
if (lastValue > penultimateValue){

var throwDistance = abs(penultimateValue) - self.threshold
println("we're slowing down: max value above threshold: \(throwDistance)")

slowedDown = true
motionValues.removeAllObjects()

self.calculateNewPosition(throwDistance)
}
}
}
}

//reset slowedDown check
slowedDown = false

}
}

func calculateNewPosition(throwDistance : Double){
var distance = 3.0*throwDistance //first calculate magnitude (distance); might wanna use a map function?
var currentLat = LocationService.sharedInstance.currentLocation!.coordinate.latitude
var currentLng = LocationService.sharedInstance.currentLocation!.coordinate.longitude
var heading = LocationService.sharedInstance.currentHeading!.magneticHeading
var latDisplacement = distance*cos(self.DegreesToRadians(heading))
var lngDisplacement = distance*sin(self.DegreesToRadians(heading))
var newLat = currentLat + latDisplacement
var newLng = currentLng + lngDisplacement

println("Distance: \(distance) | Current Lat: \(currentLat) | Current Lng: \(currentLng) | Heading: \(heading) | latDisp: \(latDisplacement) | lngDisp: \(lngDisplacement) | New Lat: \(newLat) | New Lng: \(newLng) ")


}



func DegreesToRadians (value:Double) -> Double {
return value * M_PI / 180.0
}

}
26 changes: 26 additions & 0 deletions ios/transients/transients/TZGeoSoundPlayer.swift
@@ -0,0 +1,26 @@
//
// TZGeoSoundPlayer.swift
// transients
//
// Created by Johann Diedrick on 6/28/15.
// Copyright (c) 2015 Johann Diedrick. All rights reserved.
//

import Foundation
import AVFoundation

class TZGeoSoundPlayer : AVAudioPlayer{

func startPlayingAudio(){
if self.playing == false{
self.play()
}
}

func stopPlayingAudio(){
if self.playing == true{
self.stop()
}
}

}
27 changes: 27 additions & 0 deletions ios/transients/transients/TZGeoSoundRecorder.swift
@@ -0,0 +1,27 @@
//
// TZGeoSoundRecorder.swift
// transients
//
// Created by Johann Diedrick on 6/28/15.
// Copyright (c) 2015 Johann Diedrick. All rights reserved.
//

import Foundation
import AVFoundation

class TZGeoSoundRecorder : AVAudioRecorder{

func startRecordingAudio(){
if self.recording == false{
self.record()
}
}

func stopRecordingAudio(){
println("\(self.currentTime)")
if self.recording == true{
self.stop()
}
}

}

0 comments on commit 76e524c

Please sign in to comment.