diff --git a/GetHip/CurrentlyPlayingViewController.swift b/GetHip/CurrentlyPlayingViewController.swift
index 1f77e4d..61a47f7 100644
--- a/GetHip/CurrentlyPlayingViewController.swift
+++ b/GetHip/CurrentlyPlayingViewController.swift
@@ -11,7 +11,7 @@ import MediaPlayer
import AVFoundation
import MultipeerConnectivity
-class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDelegate{
+class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDelegate, UICollectionViewDataSource, UICollectionViewDelegate{
//persistant data
var party: PartyServiceManager!
var usr: [UserParseData] = []
@@ -21,19 +21,97 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
var playing = true
var timer = NSTimer()
var nextHost: String!
+ @IBOutlet var segmentControl: UISegmentedControl!
- //controller data
+ @IBAction func switchViews(segCtrl: UISegmentedControl){
+
+ if(segCtrl.selectedSegmentIndex == 0){
+ //hide all in party view elements
+ self.friendsInParty.hidden = true
+ self.leaveOrEnd.hidden = true
+ self.leaveOrEnd.enabled = false
+ self.addMore.hidden = true
+ self.addMore.enabled == true
+
+
+ //show all relevent current playing ui components
+ self.songImg.hidden = false
+ self.titleLabel.hidden = false
+ self.artistAndAlbumLabel.hidden = false
+ self.minLabel.hidden = false
+ self.maxLabel.hidden = false
+ self.progressBar.hidden = false
+
+ if(self.party.role == PeerType.Host_Creator || self.party.role == PeerType.Guest_Creator){
+
+ self.volCtrl.hidden == false
+ self.volCtrl.enabled = true
+
+ }
+
+ }
+
+ if(segCtrl.selectedSegmentIndex == 1){
+ //show all in party view elements
+ self.friendsInParty.hidden = false
+ self.leaveOrEnd.hidden = false
+ self.leaveOrEnd.enabled = true
+
+
+ if(self.party.role == PeerType.Host_Creator || self.party.role == PeerType.Guest_Creator){
+
+ self.addMore.hidden = false
+ self.addMore.enabled == true
+ }
+
+
+ //hide all relevent current playing ui components
+ self.songImg.hidden = true
+ self.titleLabel.hidden = true
+ self.artistAndAlbumLabel.hidden = true
+ self.minLabel.hidden = true
+ self.maxLabel.hidden = true
+ self.progressBar.hidden = true
+
+ self.volCtrl.hidden == true
+ self.volCtrl.enabled = false
+ }
+
+ }
+
+ //controller data for currently playing segment
@IBOutlet var songImg: UIImageView!
@IBOutlet var titleLabel: UILabel!
@IBOutlet var artistAndAlbumLabel: UILabel!
@IBOutlet var minLabel: UILabel!
@IBOutlet var maxLabel: UILabel!
@IBOutlet var progressBar: UIProgressView!
-
- //Host buttons
+ /*Host Buttons*/
@IBOutlet var volCtrl: UISlider!
@IBOutlet var ppfButton: UIButton!
+ //controller data for in party view
+ @IBOutlet var friendsInParty: UICollectionView!
+ @IBOutlet var leaveOrEnd: UIButton!
+ /*Host Buttons*/
+ @IBOutlet var addMore: UIButton!
+
+
+
+ //Action Methods for In Party View
+
+ //Only visible for host
+ @IBAction func inviteMore(sender: UIButton!){
+
+ }
+
+ //Alternates to either end a party or leave a party depending on host or guest role
+ @IBAction func endOrLeaveParty(sender: UIButton){
+
+ }
+
+
+ //Action Methods for Currently Playing View
@IBAction func volChng(sender: UISlider){
self.audioPlayer.volume = sender.value
}
@@ -63,10 +141,6 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
}
-
- //Guest buttons
-
-
override func viewDidLoad() {
@@ -74,9 +148,24 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
// Do any additional setup after loading the view.
+
+ //set up for in party view
+ self.friendsInParty.dataSource = self
+ self.friendsInParty.delegate = self
+ self.friendsInParty.hidden = true
+ self.leaveOrEnd.hidden = true
+ self.leaveOrEnd.enabled = false
+
+
+ //Set up for CurrentlyPlayingView
self.progressBar.setProgress(0, animated: true)
+ self.volCtrl.hidden = true
+ self.volCtrl.enabled = false
if(self.party.role == PeerType.Host_Creator || self.party.role == PeerType.Guest_Creator){
+ self.volCtrl.hidden = false
+ self.volCtrl.enabled = true
+
self.audioPlayer = AVPlayer(URL: self.party.currentSong.valueForProperty(MPMediaItemPropertyAssetURL) as! NSURL)
self.songImg.image = self.party.currentSong.valueForProperty(MPMediaItemPropertyArtwork).imageWithSize(songImg.frame.size)
@@ -100,6 +189,8 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "songDidEnd:", name: "AVPlayerItemDidPlayToEndTimeNotification", object: nil)
}else if (self.party.role == PeerType.Guest_Invited || self.party.role == PeerType.Host_Invited){
+ self.volCtrl.hidden = true
+ self.volCtrl.enabled = false
self.songImg.image = self.party.currentSongIMG
self.titleLabel.text = (self.party.currentSongTitle)
@@ -113,6 +204,11 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
+ }
+
+ override func viewDidAppear(animated: Bool) {
+ //make this part check which view to display later
+
}
func songDidEnd(notification: NSNotification){
@@ -229,6 +325,43 @@ class CurrentlyPlayingViewController: UIViewController, PartyServiceManagerDeleg
}
+//collection view methods
+extension CurrentlyPlayingViewController {
+
+ func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
+
+ var cell: InvitedCollectionViewCell!
+
+
+ let friend = self.party.invitedFriends[indexPath.row]
+ cell = self.friendsInParty.dequeueReusableCellWithReuseIdentifier("InvitedCollectionCell", forIndexPath: indexPath) as! InvitedCollectionViewCell
+
+ if friend.profileImg == nil {
+ cell.friendImage.backgroundColor = UIColor.grayColor()
+ }
+ else{
+ cell.friendImage.image = friend.profileImg.image!
+ }
+
+ //rounds uiimage and configures UIImageView
+ cell.friendImage.layer.cornerRadius = cell.friendImage.frame.size.width/2
+ cell.friendImage.clipsToBounds = true
+
+
+
+ return cell
+
+ }
+
+ func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+
+ return self.party.invitedFriends.count
+
+
+ }
+
+}
+
extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
func foundPeer() {
@@ -266,23 +399,35 @@ extension CurrentlyPlayingViewController: PartyServiceManagerDelegate {
}else if(instruction == "want_to_be_host"){
- let alert = UIAlertController(title: "Hosting Request", message: "Would you like to be the next host for the party and pick a song?", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "Accept", style: .Default, handler:{
- (action: UIAlertAction!) -> Void in
+ if objc_getClass("UIAlertController") != nil {
- self.party.currentHost = self.party.myPeerID.displayName
- alert.dismissViewControllerAnimated(true, completion: nil)
+ let alert = UIAlertController(title: "Hosting Request", message: "Would you like to be the next host for the party and pick a song?", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "Accept", style: .Default, handler:{
+ (action: UIAlertAction!) -> Void in
+
+ self.party.currentHost = self.party.myPeerID.displayName
+ alert.dismissViewControllerAnimated(true, completion: nil)
+
+ }))
- }))
-
- alert.addAction(UIAlertAction(title: "Decline", style: .Default, handler:{
- (action: UIAlertAction!) -> Void in
- var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "does_not_accept"]
- self.party.sendInstruction(dictionary, toPeer: fromPeer)
- alert.dismissViewControllerAnimated(true, completion: nil)
- }))
-
- self.presentViewController(alert, animated: true, completion: nil)
+
+ alert.addAction(UIAlertAction(title: "Decline", style: .Default, handler:{
+ (action: UIAlertAction!) -> Void in
+ var dictionary: [String: AnyObject] = ["sender": self.party.myPeerID, "instruction": "does_not_accept"]
+ self.party.sendInstruction(dictionary, toPeer: fromPeer)
+ alert.dismissViewControllerAnimated(true, completion: nil)
+ }))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Password Changed"
+ alert.message = "Your password has been updated."
+ alert.addButtonWithTitle("Yes")
+ alert.addButtonWithTitle("No")
+ alert.show()
+ }
}else if(instruction == "start_picking_a_song"){
if(self.party.role == PeerType.Host_Invited){
diff --git a/GetHip/FriendRequestViewController.swift b/GetHip/FriendRequestViewController.swift
index de37461..cb767b6 100644
--- a/GetHip/FriendRequestViewController.swift
+++ b/GetHip/FriendRequestViewController.swift
@@ -53,10 +53,23 @@ class FriendRequestViewController: UIViewController{
(succeeded, error) -> Void in
if(succeeded){
- var alert = UIAlertController(title: "Request Sent!", message: "Your friend request was sent successfully!", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+
+ var alert = UIAlertController(title: "Request Sent!", message: "Your friend request was sent successfully!", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Request Sent!"
+ alert.message = "Your friend request was sent successfully!"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
println(friendRequest.objectId!)
var params = NSMutableDictionary()
@@ -151,9 +164,25 @@ extension FriendRequestViewController: UITextFieldDelegate{
if(self.searchedEmail == (self.tabBarController as! HomeTabController).userData[0].email){
- let alert = UIAlertController(title: "That's You!", message: "Sorry, you can't send a request to yourself.", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+
+
+ //for ios 7 and lower compatibility
+ if objc_getClass("UIAlertController") != nil {
+
+
+ let alert = UIAlertController(title: "That's You!", message: "Sorry, you can't send a request to yourself.", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "That's You!"
+ alert.message = "Sorry, you can't send a request to yourself."
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+
}
else if(inFriendsList == false){
@@ -199,19 +228,47 @@ extension FriendRequestViewController: UITextFieldDelegate{
})
}else{
- let alert = UIAlertController(title: "Request Already Made", message: "You have already sent a friend request to this user.", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
- }
+
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ let alert = UIAlertController(title: "Request Already Made!", message: "You have already sent a friend request to this user.", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Request Already Made!"
+ alert.message = "You have already sent a friend request to this user."
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+ }
})
})
}else{
- let alert = UIAlertController(title: "Already Friends", message: "You are already friends with this user!", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ let alert = UIAlertController(title: "Already Friends!", message: "You are already friends with this user!", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
self.presentViewController(alert, animated: true, completion: nil)
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Already Friends!"
+ alert.message = "You are already friends with this user!"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+
}
diff --git a/GetHip/HomeScreenViewController.swift b/GetHip/HomeScreenViewController.swift
index 7079e8e..aa290aa 100644
--- a/GetHip/HomeScreenViewController.swift
+++ b/GetHip/HomeScreenViewController.swift
@@ -139,6 +139,11 @@ class HomeScreenViewController: UIViewController, PartyServiceManagerDelegate {
//initialize host role
self.partyData.setRole(PeerType(rawValue: 0)!)
+ //remove fake peers that would appear in list if a peer that is found disconnects before entering invite screen
+
+
+
+
vc.setData(self.userData, frndData: self.friendData, party: self.partyData, request: self.requestData)
diff --git a/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo.png b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo.png
new file mode 100644
index 0000000..135f9b6
Binary files /dev/null and b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo.png differ
diff --git a/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo@2x.png b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo@2x.png
new file mode 100644
index 0000000..7f04335
Binary files /dev/null and b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Background photo@2x.png differ
diff --git a/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Contents.json b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Contents.json
new file mode 100644
index 0000000..1e863f0
--- /dev/null
+++ b/GetHip/Images-3.xcassets/Background/BackgroundPhoto.imageset/Contents.json
@@ -0,0 +1,22 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "scale" : "1x",
+ "filename" : "Background photo.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "2x",
+ "filename" : "Background photo@2x.png"
+ },
+ {
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
\ No newline at end of file
diff --git a/GetHip/Info.plist b/GetHip/Info.plist
index 70b8d19..794755d 100644
--- a/GetHip/Info.plist
+++ b/GetHip/Info.plist
@@ -35,7 +35,7 @@
CFBundleVersion
- 3
+ 4
FacebookAppID
1166375230058840
FacebookDisplayName
diff --git a/GetHip/InvitedToPartyViewController.swift b/GetHip/InvitedToPartyViewController.swift
index 81bdac7..9954075 100644
--- a/GetHip/InvitedToPartyViewController.swift
+++ b/GetHip/InvitedToPartyViewController.swift
@@ -23,13 +23,21 @@ class InvitedToPartyViewController: UIViewController , PartyServiceManagerDelega
@IBAction func declineInvite(sender: UIButton){
self.inviteHandle(false, self.partyData.session)
+ self.shouldEndInvite = true
self.dismissViewControllerAnimated(true, completion: nil)
}
@IBAction func acceptInvite(sender: UIButton){
self.partyData.currentHost = self.fromPeer.displayName
self.inviteHandle(true, self.partyData.session)
+ self.shouldEndInvite = true
self.performSegueWithIdentifier("JoiningPartySegue", sender: self)
+ /*self.dismissViewControllerAnimated(true, completion: {
+ () -> Void in
+
+
+ })*/
+
}
override func viewDidLoad() {
diff --git a/GetHip/JoiningPartyViewController.swift b/GetHip/JoiningPartyViewController.swift
index 89cc751..7eaaa3b 100644
--- a/GetHip/JoiningPartyViewController.swift
+++ b/GetHip/JoiningPartyViewController.swift
@@ -105,11 +105,19 @@ extension JoiningPartyViewController: PartyServiceManagerDelegate {
if (instruction == "start_party"){
- println("mark 4")
+ println("mark 4: start party")
+ //var microDelay = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: Selector("doIt"), userInfo: nil, repeats: false)
self.performSegueWithIdentifier("EnteringPartySegue", sender: self)
+ println("micro-triggered")
+
}
}
+ func doIt(){
+ self.performSegueWithIdentifier("EnteringPartySegue", sender: self)
+ println("triggered")
+ }
+
}
diff --git a/GetHip/LoadingPartyViewController.swift b/GetHip/LoadingPartyViewController.swift
index 1ea471a..e67c250 100644
--- a/GetHip/LoadingPartyViewController.swift
+++ b/GetHip/LoadingPartyViewController.swift
@@ -91,6 +91,7 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource,
var dictionary: [String: String] = ["sender": self.party.myPeerID.displayName, "instruction": "start_party"]
for peer in self.party.session.connectedPeers as! [MCPeerID] {
+ println("start_party_from_host")
self.party.sendInstruction(dictionary, toPeer: peer )
}
@@ -100,7 +101,7 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource,
func attemptToStart(){
-
+ /*
for peer in self.party.session.connectedPeers as! [MCPeerID] {
if self.arePeersReady[peer.displayName] == false{
@@ -108,7 +109,7 @@ class LoadingPartyViewController: UIViewController, UICollectionViewDataSource,
self.party.sendInstruction(dictionary, toPeer: peer)
}
}
-
+ */
var delTimer = NSTimer.scheduledTimerWithTimeInterval(5, target: self, selector: Selector("startParty"), userInfo: nil, repeats: false)
diff --git a/GetHip/LoginController.swift b/GetHip/LoginController.swift
index f09257e..78e49b8 100644
--- a/GetHip/LoginController.swift
+++ b/GetHip/LoginController.swift
@@ -41,25 +41,71 @@ class LoginController: UIViewController, PFLogInViewControllerDelegate, UITextFi
self.presentViewController(tabBarController, animated: true, completion: nil)
}else{
- var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ //for ios 7 and lower compatibility
- self.presentViewController(alert, animated: true, completion: nil)
+ if objc_getClass("UIAlertController") != nil {
+ var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Invalid Login"
+ alert.message = "Invalid email or password"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
}
})
}else{
- var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Invalid Login"
+ alert.message = "Invalid email or password"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+
}
})
})
}else{
- var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
- /*
+
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ var alert = UIAlertController(title: "Invalid Login", message: "Invalid email or password", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Invalid Login"
+ alert.message = "Invalid email or password"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+
+
+ /*
PFUser.logInWithUsernameInBackground(userEmailField.text!, password: password.text!, block: {
(user, error) -> Void in
diff --git a/GetHip/Main.storyboard b/GetHip/Main.storyboard
index 789fbb8..bc91854 100644
--- a/GetHip/Main.storyboard
+++ b/GetHip/Main.storyboard
@@ -522,17 +522,17 @@
-
+
-
+
-
-
@@ -1098,10 +1100,10 @@
-
+
-
+
@@ -1115,7 +1117,7 @@
-
+
@@ -1660,12 +1662,12 @@
-
+
-
+
@@ -1781,14 +1783,14 @@
-
+
-
+
@@ -1846,7 +1848,7 @@
-
+
@@ -1859,7 +1861,7 @@
-
+
@@ -1868,8 +1870,18 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1880,12 +1892,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1893,6 +1965,7 @@
+
@@ -1900,9 +1973,10 @@
-
+
+
@@ -1910,16 +1984,20 @@
-
+
+
+
+
+
@@ -1943,7 +2021,7 @@
-
+
@@ -2086,10 +2164,10 @@
-
+
-
+
@@ -2105,7 +2183,7 @@
-
+
@@ -2113,7 +2191,7 @@
-
+
@@ -2160,10 +2238,10 @@
-
+
-
+
@@ -2179,7 +2257,7 @@
-
+
@@ -2187,7 +2265,7 @@
-
+
@@ -2235,7 +2313,7 @@
-
+
@@ -2293,7 +2371,7 @@
-
+
@@ -2327,6 +2405,7 @@
+
@@ -2351,10 +2430,10 @@
+
-
-
-
-
+
+
+
diff --git a/GetHip/PartyServiceManager.swift b/GetHip/PartyServiceManager.swift
index f6aad83..a38c3ee 100644
--- a/GetHip/PartyServiceManager.swift
+++ b/GetHip/PartyServiceManager.swift
@@ -161,6 +161,7 @@ class PartyServiceManager: NSObject, AnyObject {
if (instruction == "are_you_ready"){
var ready = true
+ println("guest is ready")
for peer in dataDictionary["connectedPeers"] as! [MCPeerID] {
if (self.connectedPeersDictionary[peer.displayName] == nil) && (peer != self.myPeerID) {
ready = false
@@ -256,7 +257,7 @@ class PartyServiceManager: NSObject, AnyObject {
//Host Methods
func initializeSession(){
- self.session = MCSession(peer: self.myPeerID, securityIdentity: nil, encryptionPreference: MCEncryptionPreference.Required)
+ self.session = MCSession(peer: self.myPeerID)//, securityIdentity: nil, encryptionPreference: MCEncryptionPreference.Required)
self.session.delegate = self
println("Initialized Peer-To-Peer Connection")
}
@@ -305,9 +306,29 @@ extension PartyServiceManager: MCNearbyServiceBrowserDelegate{
if(!isPeerFound(peerID)){
if(peerID.displayName != self.myPeerID.displayName) {
NSLog("%@", "foundPeer: \(peerID)")
- self.foundPeers.append(peerID)
- self.delegate?.foundPeer()
- //self.serviceBrowser.invitePeer(peerID, toSession: self.session, withContext: nil, timeout: NSTimeInterval(60.00))
+
+ /*
+ //compare hash values of the 2 peer ids
+ if(UInt32(self.myPeerID.hash) > UInt32(peerID.hash)){
+
+ }
+ /*
+ */
+ if(isPeerFound(peerID)){
+ for(index, aPeer) in enumerate(foundPeers) {
+ if aPeer.displayName == peerID.displayName{
+ foundPeers[index] = peerID
+ break
+ }
+ }
+ }else{
+*/
+ self.foundPeers.append(peerID)
+ //disconnectedPeersDictionary[peerID.displayName]
+ self.delegate?.foundPeer()
+ //self.serviceBrowser.invitePeer(peerID, toSession: self.session, withContext: nil, timeout: NSTimeInterval(60.00))
+ /*
+ }*/
}
@@ -324,6 +345,8 @@ extension PartyServiceManager: MCNearbyServiceBrowserDelegate{
for(index, aPeer) in enumerate(foundPeers) {
if aPeer == peerID{
foundPeers.removeAtIndex(index)
+ //disconnectedPeersDictionary[peerID.displayName] = peerID
+ self.invitableCount--
break
}
}
@@ -371,8 +394,8 @@ extension PartyServiceManager: MCSessionDelegate{
}
func session(session: MCSession!, didReceiveData data: NSData!, fromPeer peerID: MCPeerID!) {
- NSLog("%@", "didRecieveData: \(data)")
-
+ //NSLog("%@", "didRecieveData: \(data)")
+ println("recieved data")
let dictionary: [String: AnyObject] = ["data": data, "fromPeer": peerID]
self.delegate?.didRecieveInstruction(dictionary)
@@ -399,6 +422,12 @@ extension PartyServiceManager: MCSessionDelegate{
NSLog("%@", "didStartReceivingResourceWithName: \(resourceName) from peer: \(peerID)")
}
+ func session(session: MCSession!, didReceiveCertificate certificate: [AnyObject]!, fromPeer peerID: MCPeerID!, certificateHandler: ((Bool) -> Void)!) {
+ if(certificateHandler != nil){
+ certificateHandler(true)
+ }
+ }
+
}
diff --git a/GetHip/SettingsDetailViewWrapper.swift b/GetHip/SettingsDetailViewWrapper.swift
index 6a09488..8b9714a 100644
--- a/GetHip/SettingsDetailViewWrapper.swift
+++ b/GetHip/SettingsDetailViewWrapper.swift
@@ -199,10 +199,23 @@ class ResetPassDetailViewController: UIViewController {
obj.save()
- let alert = UIAlertController(title: "Password Changed", message: "Your password has been updated", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
- }
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+
+ let alert = UIAlertController(title: "Password Changed", message: "Your password has been updated.", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Password Changed"
+ alert.message = "Your password has been updated."
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+ }
@@ -210,9 +223,23 @@ class ResetPassDetailViewController: UIViewController {
} else {
- let alert = UIAlertController(title: "Incorrect Password", message: "The password you gave as your current password was incorrect. Please enter the correct password.", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+
+ let alert = UIAlertController(title: "Incorrect Password", message: "The password you gave as your current password was incorrect. Please enter the correct password.", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Incorrect Password"
+ alert.message = "The password you gave as your current password was incorrect. Please enter the correct password."
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
+
}
}
}
@@ -234,7 +261,7 @@ class ResetPassDetailViewController: UIViewController {
}
}
-class ProfileDetailViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
+class ProfileDetailViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate {
var profileImg: UIImageView!
private var picker = UIImagePickerController()
@@ -244,32 +271,46 @@ class ProfileDetailViewController: UIViewController, UINavigationControllerDeleg
@IBAction func changePhoto(sender: UIButton) {
- let captureMenu = UIAlertController(title: nil, message:nil, preferredStyle: .ActionSheet)
- let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
- (alert: UIAlertAction!) -> Void in
- })
+ //for ios 7 and lower compatibility
- let cameraAction = UIAlertAction(title: "Take a New Pic", style: .Default, handler: {
- (alert: UIAlertAction!) -> Void in
- self.picker.allowsEditing = false
- self.picker.sourceType = UIImagePickerControllerSourceType.Camera
- self.picker.cameraCaptureMode = .Photo
- self.presentViewController(self.picker, animated: true, completion: nil)
+ if objc_getClass("UIAlertController") != nil {
- })
+ let captureMenu = UIAlertController(title: nil, message:nil, preferredStyle: .ActionSheet)
+
+ let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
+ (alert: UIAlertAction!) -> Void in
+ })
+
+ let cameraAction = UIAlertAction(title: "Take a New Pic", style: .Default, handler: {
+ (alert: UIAlertAction!) -> Void in
+ self.picker.allowsEditing = false
+ self.picker.sourceType = UIImagePickerControllerSourceType.Camera
+ self.picker.cameraCaptureMode = .Photo
+ self.presentViewController(self.picker, animated: true, completion: nil)
+
+ })
+
+ let galleryAction = UIAlertAction(title: "Select a Profile Pic", style: .Default, handler: {
+ (alert: UIAlertAction!) -> Void in
+ self.picker.allowsEditing = false
+ self.picker.sourceType = .PhotoLibrary
+ self.presentViewController(self.picker, animated: true, completion: nil)
+ })
+
+ captureMenu.addAction(galleryAction)
+ captureMenu.addAction(cameraAction)
+ captureMenu.addAction(cancelAction)
+ self.presentViewController(captureMenu, animated: true, completion: nil)
+
+
+ }else{
+ let actionSheet = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: nil, destructiveButtonTitle: "Cancel", otherButtonTitles: "Take a New Pic")
+ actionSheet.addButtonWithTitle("Select a Profile Pic")
+
+ actionSheet.showInView(self.view)
+ }
- let galleryAction = UIAlertAction(title: "Select a Profile Pic", style: .Default, handler: {
- (alert: UIAlertAction!) -> Void in
- self.picker.allowsEditing = false
- self.picker.sourceType = .PhotoLibrary
- self.presentViewController(self.picker, animated: true, completion: nil)
- })
-
- captureMenu.addAction(galleryAction)
- captureMenu.addAction(cameraAction)
- captureMenu.addAction(cancelAction)
- self.presentViewController(captureMenu, animated: true, completion: nil)
}
@@ -350,3 +391,27 @@ extension ProfileDetailViewController: UIImagePickerControllerDelegate{
dismissViewControllerAnimated(true, completion: nil)
}
}
+
+extension ProfileDetailViewController: UIActionSheetDelegate {
+ func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
+
+ switch buttonIndex {
+
+ case 0:
+ break;
+ case 1:
+ self.picker.allowsEditing = false
+ self.picker.sourceType = UIImagePickerControllerSourceType.Camera
+ self.picker.cameraCaptureMode = .Photo
+ self.presentViewController(self.picker, animated: true, completion: nil)
+ case 2:
+ self.picker.allowsEditing = false
+ self.picker.sourceType = .PhotoLibrary
+ self.presentViewController(self.picker, animated: true, completion: nil)
+ break;
+ default:
+ break;
+
+ }
+ }
+}
diff --git a/GetHip/SignInController.swift b/GetHip/SignInController.swift
index c3927bd..e3e2659 100644
--- a/GetHip/SignInController.swift
+++ b/GetHip/SignInController.swift
@@ -27,13 +27,27 @@ class SignInController: UIViewController, UINavigationControllerDelegate, UIImag
|| self.passField.hasText() == false
|| self.profilePic.image == nil){
- let alert = UIAlertController(title: "Invalid Registration", message: "We're missing some information from you, before we can start the party!", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ let alert = UIAlertController(title: "Invalid Registration", message: "We're missing some information from you, before we can start the party!", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Invalid Registration"
+ alert.message = "We're missing some information from you, before we can start the party!"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
}else{
- if /*(!(contains(self.userField.text!, "@") ||*/ contains(self.nameField.text!, "@"){
+ if /*(!(contains(self.userField.text!, "@") ||*/ !contains(self.nameField.text!, "@"){
let predicate: NSPredicate = NSPredicate(format: "(email = %@)", argumentArray: [self.emailField.text!])
var userQuery: PFQuery = PFQuery(className: "_User", predicate: predicate)
@@ -43,10 +57,23 @@ class SignInController: UIViewController, UINavigationControllerDelegate, UIImag
(object, error) -> Void in
if(object != nil && error == nil){
- let alert = UIAlertController(title: "User Info Taken", message: "Sorry this information is already registered to another user. Please try again.", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
- self.presentViewController(alert, animated: true, completion: nil)
+ //for ios 7 and lower compatibility
+
+ if objc_getClass("UIAlertController") != nil {
+ let alert = UIAlertController(title: "User Info Taken", message: "Sorry this information is already registered to another user. Please try again.", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "User Info Taken"
+ alert.message = "Sorry this information is already registered to another user. Please try again."
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
+
}else{
var user = PFUser()
var img:PFFile = PFFile(data: UIImageJPEGRepresentation(self.profilePic.image, 1.0))!
@@ -78,10 +105,22 @@ class SignInController: UIViewController, UINavigationControllerDelegate, UIImag
}else{
- let alert = UIAlertController(title: "Illegal Characters", message: "The username or email you entered contains illegal characters such as: '@'", preferredStyle: .Alert)
- alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+ //for ios 7 and lower compatibility
- self.presentViewController(alert, animated: true, completion: nil)
+ if objc_getClass("UIAlertController") != nil {
+ let alert = UIAlertController(title: "Illegal Characters", message: "The display name you entered contains illegal characters such as: '@'", preferredStyle: .Alert)
+ alert.addAction(UIAlertAction(title: "OK", style: .Default, handler:{(action: UIAlertAction!) in alert.dismissViewControllerAnimated(true, completion: nil)}))
+
+ self.presentViewController(alert, animated: true, completion: nil)
+
+
+ }else{
+ let alert = UIAlertView()
+ alert.title = "Illegal Characters"
+ alert.message = "The display name you entered contains illegal characters such as: '@'"
+ alert.addButtonWithTitle("OK")
+ alert.show()
+ }
}
}
diff --git a/GetHip/TestInviteFriendsController.swift b/GetHip/TestInviteFriendsController.swift
index 0e52553..074f05c 100644
--- a/GetHip/TestInviteFriendsController.swift
+++ b/GetHip/TestInviteFriendsController.swift
@@ -142,6 +142,7 @@ class TestInviteFriendsController: UIViewController, UITableViewDelegate, UITabl
//iterate through the currently found peers and display only friends who are available
var friend: FriendData!
+ //need to rethink this logic
for i in 0..