@@ -0,0 +1,141 @@
//
// FBLoginController.m
// FartWatch
//
// Created by Jake Saferstein on 2/27/15.
// Copyright (c) 2015 Jake Saferstein. All rights reserved.
//

#import "FBLoginController.h"

@interface FBLoginController ()

@end

@implementation FBLoginController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

self.view.backgroundColor = [UIColor blueColor];

if([PFFacebookUtils isLinkedWithUser: [PFUser currentUser]] && [PFUser currentUser]) {
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error)
{
NSArray* friendObjects= [result objectForKey:@"data"];
NSMutableArray* friendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
for (NSDictionary* friendObject in friendObjects) {
[friendIds addObject:[friendObject objectForKey:@"id"]];
}

// Construct a PFUser query that will find friends whose facebook ids
// are contained in the current user's friend list.
PFQuery *friendQuery = [PFUser query];
[friendQuery whereKey:@"fbId" containedIn:friendIds];

//PFUsers Array
NSArray *friendUsers = [friendQuery findObjects];


[((FriendsListViewController *)[self.navigationController viewControllers][1]) setFriends:friendUsers];

[self.navigationController popViewControllerAnimated:YES];
}
}];
}

else
{



UIButton* login = [UIButton buttonWithType:UIButtonTypeRoundedRect];
login.frame = CGRectMake(self.view.frame.size.width/2 - 50, self.view.frame.size.height/2 - 50, 100, 100);

login.backgroundColor = [UIColor redColor];

[self.view addSubview:login];

[login addTarget:self action:@selector(loginPressed) forControlEvents:UIControlEventTouchUpInside];
}
}


-(void)loginPressed
{

NSArray* permissions = @[ @"public_profile", @"user_friends", ];

[PFFacebookUtils logInWithPermissions:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
} else {
NSLog(@"User logged in through Facebook!");
}

PFInstallation* instll = [PFInstallation currentInstallation];
instll[@"user"] = [PFUser currentUser];
[instll saveInBackground];


[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@"%@", result);
user[@"fbId"] = result[@"id"];
user[@"firstname"] = result[@"first_name"];
user[@"lastname"] = result[@"last_name"];
user[@"name"] = result[@"name"];
user[@"gender"] = result[@"gender"];
[user saveInBackground];

[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error)
{
NSArray* friendObjects= [result objectForKey:@"data"];
NSMutableArray* friendIds = [NSMutableArray arrayWithCapacity:friendObjects.count];
for (NSDictionary* friendObject in friendObjects) {
[friendIds addObject:[friendObject objectForKey:@"id"]];
}

// Construct a PFUser query that will find friends whose facebook ids
// are contained in the current user's friend list.
PFQuery *friendQuery = [PFUser query];
[friendQuery whereKey:@"fbId" containedIn:friendIds];

//PFUsers Array
NSArray *friendUsers = [friendQuery findObjects];

((FriendsListViewController *)self.presentingViewController).friends = friendUsers;

[self.presentingViewController dismissViewControllerAnimated:YES completion:^{
NSLog(@"Going back");
}];
}
}];
}
}];
}];


}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
@@ -0,0 +1,16 @@
//
// FriendTableViewCell.h
// FartWatch
//
// Created by Jake Saferstein on 2/26/15.
// Copyright (c) 2015 Jake Saferstein. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Parse/Parse.h>

@interface FriendTableViewCell : UITableViewCell

@property (nonatomic) PFUser* user;

@end
@@ -0,0 +1,35 @@
//
// FriendTableViewCell.m
// FartWatch
//
// Created by Jake Saferstein on 2/26/15.
// Copyright (c) 2015 Jake Saferstein. All rights reserved.
//

#import "FriendTableViewCell.h"

@implementation FriendTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{

}
return self;
}

-(void)setUser:(PFUser *)user
{
_user = user;

self.textLabel.text = user[@"name"];
NSData* imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://graph.facebook.com/%@/picture", user[@"fbId"]]]];
self.imageView.image = [UIImage imageWithData:imgData];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}

@end
@@ -0,0 +1,26 @@
//
// FriendsListViewController.h
//
//
// Created by Jake Saferstein on 2/26/15.
//
//

#import <UIKit/UIKit.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <Parse/Parse.h>
#import "FriendTableViewCell.h"

@interface FriendsListViewController : UITableViewController

@property(nonatomic) NSMutableArray* revenge;
@property(nonatomic) NSMutableArray* recent;
@property(nonatomic) NSArray* friends;

@property (nonatomic) BOOL shouldntUseThis;


-(void)setFriends:(NSArray *)friends;


@end
@@ -0,0 +1,159 @@
//
// FriendsListViewController.m
//
//
// Created by Jake Saferstein on 2/26/15.
//
//

#import "FriendsListViewController.h"
#import "FBLoginController.h"

@interface FriendsListViewController ()

@end

@implementation FriendsListViewController

-(id)initWithStyle:(UITableViewStyle)style
{
if((self = [super initWithStyle:style]))
{
_friends = [NSMutableArray array];
_recent = [NSMutableArray array];
_revenge = [NSMutableArray array];
self.tableView.dataSource = self;
self.tableView.delegate = self;
_shouldntUseThis = NO;
}
return self;
}

-(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
[super dismissViewControllerAnimated:flag completion:completion];
[self.tableView reloadData];
}

-(void)setFriends:(NSArray *)friends
{
_friends = friends;
[self.tableView reloadData];
_shouldntUseThis = YES;
}

- (void)viewDidLoad {
[super viewDidLoad];




// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}


-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:YES];
if(!_shouldntUseThis)
{
[self.navigationController pushViewController: [[FBLoginController alloc] init] animated:YES];
}
else{
//Normal viewDidAppear
}
}



- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PFUser* toSend = _friends[indexPath.row];

PFQuery *qry = [PFInstallation query];
[qry whereKey:@"user" equalTo:toSend];
//Brendan is the best!

PFPush *push = [[PFPush alloc] init];

[push setQuery:qry];
NSDictionary *data = @{
@"alert" : @"FART BOMBED",
@"sound" : @"fart1.caf",
};
[push setData:data];
[push sendPushInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
NSLog(@"push error %@", error);
}];

[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// switch (section) {
// case 0:
// return _revenge.count;
// break;
// case 1:
// return _recent.count;
// break;
// case 2:
// return _friends.count;
// default:
// return 0;
// break;
// }

return _friends.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"friend"];

if(!cell)
{
cell = [[FriendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"friend"];
}

PFUser* temp;
NSArray* arr;
//
// switch (indexPath.section) {
// case 0:
// arr = _revenge;
// break;
// case 1:
// arr = _recent;
// break;
// case 2:
// arr = _friends;
// break;
// }
//
arr = _friends;


temp = arr[indexPath.row];

[((FriendTableViewCell *)cell) setUser:temp];
return cell;
}

@end
@@ -1,33 +1,39 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appicon58.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appicon87.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appicon80.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appicon120.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appicon120-1.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appicon.png",
"scale" : "3x"
}
],
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -24,7 +24,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<string>Fart Bomber</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
@@ -17,6 +17,7 @@
@property (nonatomic) UIButton* camBtn;
@property (nonatomic) UIImagePickerController* picker;
@property (nonatomic) UIActionSheet* actnSht;
@property (nonatomic) UIButton* fbBtn;



@@ -10,6 +10,9 @@
#import <Pop/POP.h>
#include <math.h>
#import "AppDelegate.h"
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import "FriendsListViewController.h"



#define HEIGHT (self.view.frame.size.height - 54)
@@ -40,34 +43,37 @@ -(id)initWithImg: (UIImage *) img andNum: (int) num{
_camBtn = [UIButton buttonWithType:UIButtonTypeSystem];
_camBtn.tintColor = [UIColor blackColor];

_fbBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
_fbBtn.backgroundColor = [UIColor blueColor];

_cushionImg = img;
_cushNum = num;

NSString* fart1 = [[NSBundle mainBundle] pathForResource:@"fart1" ofType:@"wav"];
NSString* fart1 = [[NSBundle mainBundle] pathForResource:@"fart1" ofType:@"caf"];
NSURL* fart1URL = [NSURL fileURLWithPath:fart1];
_plyr1 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart1URL error:nil];

NSString* fart2 = [[NSBundle mainBundle] pathForResource:@"fart2" ofType:@"wav"];
NSString* fart2 = [[NSBundle mainBundle] pathForResource:@"fart2" ofType:@"caf"];
NSURL* fart2URL = [NSURL fileURLWithPath:fart2];
_plyr2 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart2URL error:nil];

NSString* fart3 = [[NSBundle mainBundle] pathForResource:@"fart3" ofType:@"wav"];
NSString* fart3 = [[NSBundle mainBundle] pathForResource:@"fart3" ofType:@"caf"];
NSURL* fart3URL = [NSURL fileURLWithPath:fart3];
_plyr3 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart3URL error:nil];

NSString* fart4 = [[NSBundle mainBundle] pathForResource:@"fart4" ofType:@"wav"];
NSString* fart4 = [[NSBundle mainBundle] pathForResource:@"fart4" ofType:@"caf"];
NSURL* fart4URL = [NSURL fileURLWithPath:fart4];
_plyr4 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart4URL error:nil];

NSString* fart5 = [[NSBundle mainBundle] pathForResource:@"fart5" ofType:@"wav"];
NSString* fart5 = [[NSBundle mainBundle] pathForResource:@"fart5" ofType:@"caf"];
NSURL* fart5URL = [NSURL fileURLWithPath:fart5];
_plyr5 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart5URL error:nil];

NSString* fart6 = [[NSBundle mainBundle] pathForResource:@"fart6" ofType:@"wav"];
NSString* fart6 = [[NSBundle mainBundle] pathForResource:@"fart6" ofType:@"caf"];
NSURL* fart6URL = [NSURL fileURLWithPath:fart6];
_plyr6 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart6URL error:nil];

NSString* fart7 = [[NSBundle mainBundle] pathForResource:@"fart7" ofType:@"wav"];
NSString* fart7 = [[NSBundle mainBundle] pathForResource:@"fart7" ofType:@"caf"];
NSURL* fart7URL = [NSURL fileURLWithPath:fart7];
_plyr7 = [[AVAudioPlayer alloc] initWithContentsOfURL:fart7URL error:nil];
}
@@ -87,19 +93,23 @@ - (void)viewDidLoad {
_camBtn.frame = CGRectMake(WIDTH*15/16 - HEIGHT/8, 54 + HEIGHT*13/16, HEIGHT/8, HEIGHT/8);
[_camBtn setImage:[UIImage imageNamed:@"camera44.png"] forState:UIControlStateNormal];
[_camBtn setImage:[UIImage imageNamed:@"camera44.png"] forState:UIControlStateSelected];



[_camBtn addTarget:self action:@selector(camPressed) forControlEvents:UIControlEventTouchUpInside];

// UIImage* temp = [self mergeTwoImages: [UIImage imageNamed:@"testImg.png"]: _cushionImg];
_fbBtn.frame = CGRectMake(WIDTH*1/16, 54 + HEIGHT*13/16, HEIGHT/8, HEIGHT/8);
[_fbBtn addTarget:self action:@selector(fbPressed) forControlEvents:UIControlEventTouchUpInside];

_blendVw.image = _cushionImg;

[self.view addSubview:_camBtn];
[self.view addSubview:_fbBtn];
[self.view addSubview:_blendVw];

}

-(void)fbPressed
{
FriendsListViewController* toPush = [[FriendsListViewController alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController: toPush animated:YES];
}

-(void)camPressed
{
@@ -108,9 +118,6 @@ -(void)camPressed
[_actnSht showInView:self.view];
}




-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
_picker = [[UIImagePickerController alloc] init];
BIN +58.6 KB FinIcons/appicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +16.1 KB FinIcons/appicon80.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +18.5 KB FinIcons/appicon87.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +417 KB FinIcons/cushion7.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +39.7 KB Sounds/fart1.caf
Binary file not shown.
BIN +58.4 KB Sounds/fart2.caf
Binary file not shown.
BIN +32.2 KB Sounds/fart3.caf
Binary file not shown.
BIN +39.8 KB Sounds/fart4.caf
Binary file not shown.
BIN +18.1 KB Sounds/fart5.caf
Binary file not shown.
BIN +9.94 KB Sounds/fart6.caf
Binary file not shown.
BIN +46.8 KB Sounds/fart7.caf
Binary file not shown.