diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e43b0f9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/Twitter+OAuth/Libraries & Headers/jQueryInjectLandscape.txt b/Twitter+OAuth/Libraries & Headers/jQueryInjectLandscape.txt
new file mode 100644
index 0000000..c4a81cb
--- /dev/null
+++ b/Twitter+OAuth/Libraries & Headers/jQueryInjectLandscape.txt
@@ -0,0 +1,40 @@
+$('html').css({'-webkit-background-size':'360px'});
+$('body').css({'font-size':'12px','background':'#9AE4E8'});
+$('#header').width(430);
+$('.signin-content').css({'padding' : '15px','width' : '430px'});
+$('#twitainer').width(430);
+$('#twitainer').css({'margin-left' : '8px'});
+$('#login_form').width(30);
+$('#content').width(430);
+$('#content').css({'margin':'0px','float':'left'});
+$('.tos').hide();
+$('.newtos').css({'text-align':'left', 'border':'1px solid red','color':'#555555','font-size':'12px','line-height':'1.3','margin':'20px 15px 5px'});
+$('.newtos p').css({'margin' : '8px'});
+$('h2').hide();
+$('.oauth-errors').after("
" + $('.tos').html() + "
");
+$("label:contains('Username or Email: ')").html("Username: ");
+$(".app-icon").attr({align : "right"});
+$(".app-icon").css({'margin': '20px 0px 0px 0px;', 'border': '0px solid black', 'padding' : '-20px 0 0 10px'});
+$('#signin_form .text').width(155);
+$('#signin_form .password').width(155);
+$('h4').after("
");
+$('#signin_form').css({'padding-top': '0'});
+$("h4").width(410);
+$("h4").css('font-size', '12px');
+$("h4").html($("h4").html().replace(/This application/, '
This application'));
+$('.buttons').css({'margin-left' : '-17px' , 'width':'300'});
+$('#deny').css({'-webkit-transform': 'scale(0.9)'});
+$('#allow').css({'-webkit-transform': 'scale(0.9)'});
+$('#oauth_pin').css({'-webkit-transform': 'scale(0.5)'});
+$('.newtos').css({'border':'1px solid #A9BF74', 'background-color':'#E8FECD'});
+$('.newtos p').css({'margin':'8px'});
+
+// This rearranges the allow and deny buttons so that
+// the allow button is the first of the two input[type=submit]
+// This allows the "Go" button on the UIWebView's keyboard
+// to trigger an allow, instead of a deny.
+var deny = $( '#deny' );
+var allow = $( '#allow' );
+$('div.buttons').empty();
+$('div.buttons').append( allow );
+$('div.buttons').append( deny );
diff --git a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.h b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.h
index 46be49c..52d9d34 100755
--- a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.h
+++ b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.h
@@ -30,6 +30,8 @@
id _delegate;
UIActivityIndicatorView *_activityIndicator;
+
+ UIInterfaceOrientation _orientation;
}
@@ -37,9 +39,12 @@
@property (nonatomic, readwrite, assign) id delegate;
@property (nonatomic, readonly) UINavigationBar *navigationBar;
+@property (nonatomic) UIInterfaceOrientation orientation;
+
++ (SA_OAuthTwitterController *) controllerToEnterCredentialsWithTwitterEngine: (SA_OAuthTwitterEngine *) engine delegate: (id ) delegate forOrientation:(UIInterfaceOrientation)theOrientation;
+ (SA_OAuthTwitterController *) controllerToEnterCredentialsWithTwitterEngine: (SA_OAuthTwitterEngine *) engine delegate: (id ) delegate;
+ (BOOL) credentialEntryRequiredWithTwitterEngine: (SA_OAuthTwitterEngine *) engine;
-- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine;
+- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation;
@end
diff --git a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m
index c3a50fc..f52e16f 100755
--- a/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m
+++ b/Twitter+OAuth/SAOAuthTwitterEngine/SA_OAuthTwitterController.m
@@ -24,7 +24,7 @@ - (void) setDetectsPhoneNumbers: (BOOL) detects;
@end
@implementation SA_OAuthTwitterController
-@synthesize engine = _engine, delegate = _delegate, navigationBar = _navBar;
+@synthesize engine = _engine, delegate = _delegate, navigationBar = _navBar, orientation = _orientation;
- (void) dealloc {
@@ -41,28 +41,37 @@ - (void) dealloc {
[super dealloc];
}
-+ (SA_OAuthTwitterController *) controllerToEnterCredentialsWithTwitterEngine: (SA_OAuthTwitterEngine *) engine delegate: (id ) delegate {
++ (SA_OAuthTwitterController *) controllerToEnterCredentialsWithTwitterEngine: (SA_OAuthTwitterEngine *) engine delegate: (id ) delegate forOrientation:(UIInterfaceOrientation)theOrientation {
if (![self credentialEntryRequiredWithTwitterEngine: engine]) return nil; //not needed
- SA_OAuthTwitterController *controller = [[[SA_OAuthTwitterController alloc] initWithEngine: engine] autorelease];
-
+ SA_OAuthTwitterController *controller = [[[SA_OAuthTwitterController alloc] initWithEngine:engine andOrientation:theOrientation] autorelease];
controller.delegate = delegate;
return controller;
}
++ (SA_OAuthTwitterController *) controllerToEnterCredentialsWithTwitterEngine: (SA_OAuthTwitterEngine *) engine delegate: (id ) delegate {
+ return [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:engine delegate:delegate forOrientation:UIInterfaceOrientationPortrait];
+}
+
+
+ (BOOL) credentialEntryRequiredWithTwitterEngine: (SA_OAuthTwitterEngine *) engine {
return ![engine isAuthorized];
}
-- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine {
+- (id) initWithEngine: (SA_OAuthTwitterEngine *) engine andOrientation:(UIInterfaceOrientation)theOrientation {
if (self = [super init]) {
self.engine = engine;
-
+ self.orientation = theOrientation;
+
_activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhite];
_activityIndicator.hidesWhenStopped = YES;
- _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 44, 320, 416)];
+ if ( UIInterfaceOrientationIsLandscape( self.orientation ) )
+ _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 32, 480, 288)];
+ else
+ _webView = [[UIWebView alloc] initWithFrame: CGRectMake(0, 44, 320, 416)];
+
_webView.delegate = self;
_webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
if ([_webView respondsToSelector: @selector(setDetectsPhoneNumbers:)]) [(id) _webView setDetectsPhoneNumbers: NO];
@@ -99,47 +108,68 @@ - (void) cancel: (id) sender {
#pragma mark View Controller Stuff
- (void) loadView {
[super loadView];
- self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 416)] autorelease];
- _backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kGGTwitterLoadingBackgroundImage]];
- _backgroundView.frame = CGRectMake(0, 44, 320, 416);
+
UIActivityIndicatorView* spinner = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
[spinner startAnimating];
- spinner.frame = CGRectMake((320 / 2) - (spinner.bounds.size.width / 2),
- (416 / 2) - (spinner.bounds.size.height / 2),
- spinner.bounds.size.width,
- spinner.bounds.size.height);
+ _backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:kGGTwitterLoadingBackgroundImage]];
+ if ( UIInterfaceOrientationIsLandscape( self.orientation ) ) {
+ self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 480, 288)] autorelease];
+ _backgroundView.frame = CGRectMake(0, 44, 480, 288);
+ spinner.frame = CGRectMake((480 / 2) - (spinner.bounds.size.width / 2),
+ (288 / 2) - (spinner.bounds.size.height / 2),
+ spinner.bounds.size.width,
+ spinner.bounds.size.height);
+
+ _navBar = [[[UINavigationBar alloc] initWithFrame: CGRectMake(0, 0, 480, 32)] autorelease];
+ }
+ else {
+ self.view = [[[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 416)] autorelease];
+ _backgroundView.frame = CGRectMake(0, 44, 320, 416);
+ spinner.frame = CGRectMake((320 / 2) - (spinner.bounds.size.width / 2),
+ (416 / 2) - (spinner.bounds.size.height / 2),
+ spinner.bounds.size.width,
+ spinner.bounds.size.height);
+
+ _navBar = [[[UINavigationBar alloc] initWithFrame: CGRectMake(0, 0, 320, 44)] autorelease];
+ }
[_backgroundView addSubview:spinner];
-
- [self.view addSubview:_backgroundView];
+
+ if ( !UIInterfaceOrientationIsLandscape( self.orientation ) )
+ [self.view addSubview:_backgroundView];
[self.view addSubview: _webView];
- _navBar = [[[UINavigationBar alloc] initWithFrame: CGRectMake(0, 0, 320, 44)] autorelease];
[self.view addSubview: _navBar];
UINavigationItem *navItem = [[[UINavigationItem alloc] initWithTitle: NSLocalizedString(@"Twitter Info", @"Twitter Info")] autorelease];
navItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemCancel target: self action: @selector(cancel:)] autorelease];
[_navBar pushNavigationItem: navItem animated: NO];
-
}
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ return (interfaceOrientation == self.orientation);
+}
//=============================================================================================================================
#pragma mark Webview Delegate stuff
- (void) webViewDidFinishLoad: (UIWebView *) webView {
NSError *error;
- NSString *path = [[NSBundle mainBundle] pathForResource: @"jQueryInject" ofType: @"txt"];
+ NSString *path = [[NSBundle mainBundle]
+ pathForResource:
+ UIInterfaceOrientationIsLandscape( self.orientation ) ? @"jQueryInjectLandscape" : @"jQueryInject"
+ ofType:@"txt"];
+
NSString *dataSource = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
-
+
if (dataSource == nil) {
NSLog(@"An error occured while processing the jQueryInject file");
}
-
+
[_webView stringByEvaluatingJavaScriptFromString:dataSource]; //This line injects the jQuery to make it look better
-
+
NSString *authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
-
+
if (authPin.length == 0) authPin = [[_webView stringByEvaluatingJavaScriptFromString: @"document.getElementById('oauth_pin').getElementsByTagName('a')[0].innerHTML"] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
[_activityIndicator stopAnimating];