Skip to content

Commit

Permalink
you can now send messages to FB and 4sq when you tweet; reorganized t…
Browse files Browse the repository at this point in the history
…he abstract/base class heirarchy; some small designy things

git-svn-id: http://literalshore.com/svn/kickball/trunk@722 73bdbd85-dd75-0410-9d14-8527f93b1508
  • Loading branch information
shawn committed May 5, 2010
1 parent c7ce050 commit c43b2d5
Show file tree
Hide file tree
Showing 34 changed files with 1,711 additions and 454 deletions.
4 changes: 2 additions & 2 deletions Classes/AbstractFacebookViewController.h
Expand Up @@ -8,10 +8,10 @@

#import <UIKit/UIKit.h>
#import "FBConnect/FBConnect.h"
#import "KBFoursquareViewController.h"
#import "KBTwitterViewController.h"


@interface AbstractFacebookViewController : KBFoursquareViewController <FBDialogDelegate, FBSessionDelegate, FBRequestDelegate> {
@interface AbstractFacebookViewController : KBTwitterViewController <FBDialogDelegate, FBSessionDelegate, FBRequestDelegate> {
FBSession* _session;
}

Expand Down
9 changes: 8 additions & 1 deletion Classes/AbstractFacebookViewController.m
Expand Up @@ -33,8 +33,15 @@ - (void)viewDidLoad {
_session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
}
NSLog(@"FB session: %@", _session);
headerNibName = HEADER_NIB_FOURSQUARE;
//headerNibName = HEADER_NIB_FOURSQUARE;
[super viewDidLoad];

if (!self.hideHeader) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:HEADER_NIB_FOURSQUARE owner:self options:nil];
FoursquareHeaderView *headerView = [nibViews objectAtIndex:0];
[self.view addSubview:headerView];
}

[_session resume];

// this is a hack. the abstract facebook vc has to inherit from the 4sq vc, which f's everything up
Expand Down
4 changes: 4 additions & 0 deletions Classes/FoursquareAPI/FSVenue.h
Expand Up @@ -35,6 +35,9 @@
NSString * addressWithCrossstreet;
FSCategory *primaryCategory;
NSInteger distanceFromUser;

CLLocationCoordinate2D location;
CLLocation *fullLocation;
}

@property (nonatomic, retain) NSString * name;
Expand All @@ -61,5 +64,6 @@
@property (nonatomic, retain) NSString * addressWithCrossstreet;
@property (nonatomic, retain) FSCategory *primaryCategory;
@property (nonatomic, readonly) CLLocationCoordinate2D location;
@property (nonatomic, readonly) CLLocation *fullLocation;

@end
9 changes: 9 additions & 0 deletions Classes/FoursquareAPI/FSVenue.m
Expand Up @@ -47,6 +47,15 @@ - (CLLocationCoordinate2D) location
return loc;
}

- (CLLocation*) fullLocation {
CLLocation *loc = nil;
if (geolat && geolong)
{
loc = [[[CLLocation alloc] initWithLatitude:[geolat doubleValue] longitude:[geolong doubleValue]] autorelease];
}
return loc;
}

- (void) encodeWithCoder: (NSCoder *)coder {
[coder encodeObject: name forKey:@"name"];
[coder encodeObject: geolat forKey:@"geolat"];
Expand Down
1 change: 1 addition & 0 deletions Classes/KBBaseViewController.h
Expand Up @@ -16,6 +16,7 @@
#import "Utilities.h"
#import "EGORefreshTableHeaderView.h"
#import "FooterTabView.h"
#import "FoursquareHeaderView.h"

#define HEADER_NIB_TWITTER @"TwitterHeaderView"
#define HEADER_NIB_FOURSQUARE @"FoursquareHeaderView"
Expand Down
11 changes: 5 additions & 6 deletions Classes/KBBaseViewController.m
Expand Up @@ -18,7 +18,6 @@
#import "KBWebViewController.h"
#import "KBShoutViewController.h"
#import "ASIFormDataRequest.h"
#import "FoursquareHeaderView.h"

#define PROGRESS_BAR_TIMER_LENGTH 30.0

Expand Down Expand Up @@ -53,11 +52,11 @@ - (void) viewDidLoad {
[appDelegate.pushNotificationUserId addObserver:self forKeyPath:@"pushUserId" options:0 context:nil];

// v1.1
if (!self.hideHeader && headerNibName) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:headerNibName owner:self options:nil];
FoursquareHeaderView *headerView = [nibViews objectAtIndex:0];
[self.view addSubview:headerView];
}
// if (!self.hideHeader && headerNibName) {
// NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:headerNibName owner:self options:nil];
// FoursquareHeaderView *headerView = [nibViews objectAtIndex:0];
// [self.view addSubview:headerView];
// }
if (!self.hideFooter) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"FooterTabView" owner:self options:nil];
footerTabView = [nibViews objectAtIndex:0];
Expand Down
2 changes: 0 additions & 2 deletions Classes/KBCheckinModalViewController.h
Expand Up @@ -25,11 +25,9 @@
IBOutlet UIButton *checkinButton;
IBOutlet UITextField *checkinTextField;

XAuthTwitterEngine *twitterEngine;
BOOL isReadyToClose;
}

@property (nonatomic, retain) XAuthTwitterEngine *twitterEngine;
@property (nonatomic, retain) NSString *venueId;

- (IBAction) shout;
Expand Down
1 change: 0 additions & 1 deletion Classes/KBCheckinModalViewController.m
Expand Up @@ -21,7 +21,6 @@
@implementation KBCheckinModalViewController

@synthesize venueId;
@synthesize twitterEngine;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
Expand Down
4 changes: 2 additions & 2 deletions Classes/KBCreateTweetViewController.h
Expand Up @@ -7,10 +7,10 @@
//

#import <UIKit/UIKit.h>
#import "KBTwitterViewController.h"
#import "AbstractFacebookViewController.h"


@interface KBCreateTweetViewController : KBTwitterViewController <UITextViewDelegate, MGTwitterEngineDelegate> {
@interface KBCreateTweetViewController : AbstractFacebookViewController <UITextViewDelegate, MGTwitterEngineDelegate> {
IBOutlet UITextView *tweetTextView;
IBOutlet UILabel *characterCountLabel;
IBOutlet UIButton *sendTweet;
Expand Down
30 changes: 30 additions & 0 deletions Classes/KBCreateTweetViewController.m
Expand Up @@ -8,6 +8,8 @@

#import "KBCreateTweetViewController.h"
#import "KBLocationManager.h"
#import "FoursquareAPI.h"


@implementation KBCreateTweetViewController

Expand Down Expand Up @@ -52,6 +54,34 @@ - (void) submitTweet {
[twitterEngine sendUpdate:tweetTextView.text];
}
}

if (isFacebookOn) {
NSLog(@"facebook is on and the status will be updated (hopefully)");
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:tweetTextView.text, @"status", nil];
[[FBRequest requestWithDelegate:self] call:@"facebook.status.set" params:params dataParam:nil];
}

if (isFoursquareOn) {
[[FoursquareAPI sharedInstance] doCheckinAtVenueWithId:nil
andShout:tweetTextView.text
offGrid:NO
toTwitter:NO
toFacebook:NO
withTarget:self
andAction:@selector(shoutResponseReceived:withResponseString:)];
}

}

- (void)shoutResponseReceived:(NSURL *)inURL withResponseString:(NSString *)inString {

}

- (void)request:(FBRequest*)request didLoad:(id)result {
if ([request.method isEqualToString:@"facebook.status.set"]) {
NSDictionary* info = result;
NSLog(@"facebook status updated: %@", info);
}
}

- (void) cancelCreate {
Expand Down
8 changes: 7 additions & 1 deletion Classes/KBFoursquareViewController.m
Expand Up @@ -20,11 +20,17 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

- (void)viewDidLoad {

headerNibName = HEADER_NIB_FOURSQUARE;
///headerNibName = HEADER_NIB_FOURSQUARE;
footerType = KBFooterTypeFoursquare;

[super viewDidLoad];

if (!self.hideHeader) {
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:HEADER_NIB_FOURSQUARE owner:self options:nil];
FoursquareHeaderView *headerView = [nibViews objectAtIndex:0];
[self.view addSubview:headerView];
}

CGRect frame = homeBackView.frame;
frame.origin = CGPointMake(0, 0);
homeBackView.frame = frame;
Expand Down
2 changes: 2 additions & 0 deletions Classes/KBLocationManager.h
Expand Up @@ -38,4 +38,6 @@
- (BOOL) locationServicesEnabled;
+ (void) stopAllUpdates:(NSString *)state;

- (CLLocationDistance) distanceFromCoordinate:(CLLocation*)coordinate;

@end
5 changes: 5 additions & 0 deletions Classes/KBLocationManager.m
Expand Up @@ -89,6 +89,11 @@ -(void)dealloc {
[super dealloc];
}

- (CLLocationDistance) distanceFromCoordinate:(CLLocation*)coordinate {
CLLocation *currentLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
return [currentLocation getDistanceFrom:coordinate];
}

- (void) stopAllUpdates:(NSString *)state {
[self stopUpdates];
}
Expand Down
3 changes: 0 additions & 3 deletions Classes/KBShoutViewController.h
Expand Up @@ -28,12 +28,9 @@
IBOutlet UIButton *foursquareButton;
IBOutlet UIButton *checkinButton;
IBOutlet UITextField *shoutTextField;

XAuthTwitterEngine *twitterEngine;
BOOL isReadyToClose;
}

@property (nonatomic, retain) XAuthTwitterEngine *twitterEngine;
@property (nonatomic, retain) NSString *venueId;
@property (nonatomic) BOOL isCheckin;

Expand Down
1 change: 0 additions & 1 deletion Classes/KBShoutViewController.m
Expand Up @@ -22,7 +22,6 @@ @implementation KBShoutViewController

@synthesize venueId;
@synthesize isCheckin;
@synthesize twitterEngine;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
Expand Down
10 changes: 3 additions & 7 deletions Classes/KBTweetListViewController.xib
Expand Up @@ -12,8 +12,6 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="16"/>
<integer value="8"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -39,7 +37,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="286422906">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -69,12 +67,11 @@
</object>
</object>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
<reference key="IBUIBackgroundColor" ref="206962023"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUITableViewCell" id="157955609">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -117,7 +114,6 @@
</object>
</object>
<string key="NSFrameSize">{320, 44}</string>
<reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MSAxIDEAA</bytes>
Expand Down Expand Up @@ -378,11 +374,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>centerHeaderButton</string>
<string>directMessageButton</string>
<string>mentionsButton</string>
<string>searchButton</string>
<string>timelineButton</string>
<string>twitterCenterHeaderButton</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down
6 changes: 2 additions & 4 deletions Classes/KBTwitterSearchViewController.xib
Expand Up @@ -12,7 +12,6 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -38,7 +37,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -134,7 +133,6 @@
</object>
</object>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
Expand Down Expand Up @@ -428,11 +426,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>centerHeaderButton</string>
<string>directMessageButton</string>
<string>mentionsButton</string>
<string>searchButton</string>
<string>timelineButton</string>
<string>twitterCenterHeaderButton</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down
6 changes: 2 additions & 4 deletions Classes/KBTwitterUserListViewController.xib
Expand Up @@ -12,7 +12,6 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="8"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand All @@ -38,7 +37,7 @@
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="845122041">
<reference key="NSNextResponder"/>
<nil key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -66,7 +65,6 @@
</object>
</object>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
Expand Down Expand Up @@ -300,11 +298,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>centerHeaderButton</string>
<string>directMessageButton</string>
<string>mentionsButton</string>
<string>searchButton</string>
<string>timelineButton</string>
<string>twitterCenterHeaderButton</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down
6 changes: 3 additions & 3 deletions Classes/KBTwitterViewController.h
Expand Up @@ -7,17 +7,17 @@
//

#import <UIKit/UIKit.h>
#import "KBBaseViewController.h"
#import "KBFoursquareViewController.h"
#import "XAuthTwitterEngine.h"
#import "KBTwitterManager.h"


@interface KBTwitterViewController : KBBaseViewController {
@interface KBTwitterViewController : KBFoursquareViewController {
IBOutlet UIButton *timelineButton;
IBOutlet UIButton *mentionsButton;
IBOutlet UIButton *directMessageButton;
IBOutlet UIButton *searchButton;
IBOutlet UIButton *centerHeaderButton;
IBOutlet UIButton *twitterCenterHeaderButton;

XAuthTwitterEngine *twitterEngine;
}
Expand Down

0 comments on commit c43b2d5

Please sign in to comment.