Skip to content
Browse files

added api token to login and settings

  • Loading branch information...
1 parent 894e41a commit be6a9dbfea9dceea9771851e735a0e96e28f37c9 @sschroed committed Jan 25, 2009
View
2 Classes/LoginViewController.h
@@ -11,11 +11,13 @@
@interface LoginViewController : UIViewController <UITextFieldDelegate> {
IBOutlet UITextField *userName;
+ IBOutlet UITextField *apiToken;
IBOutlet UILabel *systemPrefs;
IBOutlet UILabel *copyRight;
}
@property(nonatomic, retain) UITextField *userName;
+@property(nonatomic, retain) UITextField *apiToken;
@property(nonatomic, retain) UILabel *systemPrefs;
@property(nonatomic, retain) UILabel *copyRight;
View
35 Classes/LoginViewController.m
@@ -11,6 +11,7 @@
@implementation LoginViewController
@synthesize userName;
+@synthesize apiToken;
@synthesize systemPrefs;
@synthesize copyRight;
@@ -19,31 +20,40 @@ - (void)viewDidLoad {
// Setup UITextFields
userName.font = [UIFont systemFontOfSize:16];
- systemPrefs.font = [UIFont systemFontOfSize:11];
+ apiToken.font = [UIFont systemFontOfSize:16];
+ systemPrefs.font = [UIFont systemFontOfSize:13];
copyRight.font = [UIFont systemFontOfSize:11];
}
- (void)viewDidAppear:(BOOL)flag {
- [userName becomeFirstResponder];
+ //[userName becomeFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
- if (nil != textField.text && [textField.text length] > 0){
- [[Config instance] setGitHubUserName:[textField text]];
+ if (textField == userName) {
[textField resignFirstResponder];
- [Repository loadAll];
+ [apiToken becomeFirstResponder];
return YES;
- } else {
- [self showAlert:@"Please enter your GitHub username" withTitle:@"Octocat FAIL"];
- return NO;
+ } else if (textField == apiToken) {
+ if (nil != textField.text && [textField.text length] > 0){
+ [textField resignFirstResponder];
+ return YES;
+ } else {
+ [self showAlert:@"Please enter your GitHub username & API Token" withTitle:@"Octocat FAIL"];
+ return NO;
+ }
}
-
-
+ return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField {
- [self dismissModalViewControllerAnimated:YES];
+ if (textField == apiToken) {
+ [[Config instance] setGitHubUserName:[userName text]];
+ [[Config instance] setGitHubToken:[apiToken text]];
+ [Repository loadAll];
+ [self dismissModalViewControllerAnimated:YES];
+ }
}
- (void)showAlert:(NSString *)message withTitle:(NSString *)title {
@@ -57,6 +67,9 @@ - (void)showAlert:(NSString *)message withTitle:(NSString *)title {
- (void)dealloc {
[userName release];
+ [apiToken release];
+ [systemPrefs release];
+ [copyRight release];
[super dealloc];
}
View
4 Classes/git_phoneAppDelegate.m
@@ -54,18 +54,20 @@ - (void) loadPreferences {
// read user prefs
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[[Config instance] setGitHubUserName:[defaults stringForKey:@"GitHubUserName"]];
+ [[Config instance] setGitHubToken:[defaults stringForKey:@"GitHubToken"]];
DevLog2(@"username: %@", [[Config instance] gitHubUserName]);
// Check if username is set
- if ([[Config instance] gitHubUserName] == NULL) {
+ if ([[Config instance] gitHubUserName] == NULL || [[Config instance] gitHubToken] == NULL) {
LoginViewController *loginViewController = [[[LoginViewController alloc] initWithNibName:@"Login" bundle:nil] autorelease];
[window addSubview:[loginViewController view]];
[navigationController presentModalViewController:loginViewController animated:YES];
} else {
//TODO: Autologin
DevLog(@"NOT NULL");
}
+ //LOAD MAIN APP
}
- (void)dealloc {
View
78 Login.xib
@@ -39,7 +39,7 @@
<object class="IBUITextField" id="125215618">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{119, 120}, {181, 31}}</string>
+ <string key="NSFrame">{{20, 20}, {280, 31}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
@@ -50,7 +50,7 @@
<object class="NSColor" key="IBUITextColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
+ <object class="NSColorSpace" key="NSCustomColorSpace" id="624450056">
<int key="NSID">2</int>
</object>
</object>
@@ -59,13 +59,13 @@
<float key="IBUIMinimumFontSize">1.700000e+01</float>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocorrectionType">1</int>
- <int key="IBUIReturnKeyType">9</int>
+ <int key="IBUIReturnKeyType">4</int>
</object>
</object>
<object class="IBUIImageView" id="880546554">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrameSize">{147, 205}</string>
+ <string key="NSFrame">{{5, 98}, {147, 205}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
@@ -79,7 +79,7 @@
<object class="IBUILabel" id="66803320">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{158, 20}, {142, 55}}</string>
+ <string key="NSFrame">{{158, 141}, {142, 55}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -99,19 +99,18 @@
<object class="IBUILabel" id="534270360">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{119, 153}, {181, 44}}</string>
+ <string key="NSFrame">{{20, 332}, {280, 44}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
- <string type="base64-UTF8" key="IBUIText">T2N0b2NhdCBoYXMgYWRkZWQgYSBzZXR0aW5nIGluIHlvdXIgc3lzdGVtIHByZWZlcmVuY2VzIGlmIHlv
-dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
+ <string type="base64-UTF8" key="IBUIText">T2N0b2NhdCBoYXMgYWRkZWQgc2V0dGluZ3MgaW4geW91ciBzeXN0ZW0gcHJlZmVyZW5jZXMgaWYgeW91
+J2QgbGlrZSB0byBhdXRvbWF0aWNhbGx5IGxvZ2luLg</string>
<reference key="IBUITextColor" ref="983173934"/>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">4.000000e+00</float>
<int key="IBUINumberOfLines">3</int>
- <int key="IBUITextAlignment">2</int>
<int key="IBUILineBreakMode">0</int>
</object>
<object class="IBUILabel" id="556151773">
@@ -127,7 +126,32 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<nil key="IBUIHighlightedColor"/>
<int key="IBUIBaselineAdjustment">1</int>
<float key="IBUIMinimumFontSize">1.000000e+01</float>
- <int key="IBUITextAlignment">1</int>
+ <int key="IBUITextAlignment">2</int>
+ </object>
+ <object class="IBUITextField" id="37565244">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{20, 59}, {280, 31}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClearsContextBeforeDrawing">NO</bool>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUIText"/>
+ <int key="IBUIBorderStyle">3</int>
+ <string key="IBUIPlaceholder">GitHub API Token</string>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ <reference key="NSCustomColorSpace" ref="624450056"/>
+ </object>
+ <bool key="IBUIClearsOnBeginEditing">YES</bool>
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+ <float key="IBUIMinimumFontSize">1.700000e+01</float>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <int key="IBUIAutocorrectionType">1</int>
+ <int key="IBUIReturnKeyType">9</int>
+ <bool key="IBUISecureTextEntry">YES</bool>
+ </object>
</object>
</object>
<string key="NSFrameSize">{320, 480}</string>
@@ -181,6 +205,22 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
</object>
<int key="connectionID">13</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">apiToken</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="37565244"/>
+ </object>
+ <int key="connectionID">15</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="37565244"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">16</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -198,11 +238,12 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="880546554"/>
- <reference ref="66803320"/>
+ <reference ref="556151773"/>
<reference ref="125215618"/>
+ <reference ref="37565244"/>
+ <reference ref="880546554"/>
<reference ref="534270360"/>
- <reference ref="556151773"/>
+ <reference ref="66803320"/>
</object>
<reference key="parent" ref="360949347"/>
</object>
@@ -242,6 +283,11 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<reference key="object" ref="556151773"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">14</int>
+ <reference key="object" ref="37565244"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -253,6 +299,7 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<string>1.IBEditorWindowLastContentRect</string>
<string>1.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
+ <string>14.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
@@ -269,6 +316,7 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -291,7 +339,7 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">13</int>
+ <int key="maxID">16</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -303,12 +351,14 @@ dSdkIGxpa2UgdG8gYXV0b21hdGljYWxseSBsb2dpbi4</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>apiToken</string>
<string>copyRight</string>
<string>systemPrefs</string>
<string>userName</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>UITextField</string>
<string>UILabel</string>
<string>UILabel</string>
<string>UITextField</string>
View
20 git-phone.xcodeproj/project.pbxproj
@@ -11,6 +11,8 @@
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
+ 229445A10F2CFD4200502D5C /* private.png in Resources */ = {isa = PBXBuildFile; fileRef = 2294459F0F2CFD4200502D5C /* private.png */; };
+ 229445A20F2CFD4200502D5C /* public.png in Resources */ = {isa = PBXBuildFile; fileRef = 229445A00F2CFD4200502D5C /* public.png */; };
22E17B660F22334300D2853B /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E17B650F22334300D2853B /* Reachability.m */; };
22E17B890F2233E400D2853B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22E17B880F2233E400D2853B /* SystemConfiguration.framework */; };
22E17B910F22361B00D2853B /* ConnectivityController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E17B900F22361B00D2853B /* ConnectivityController.m */; };
@@ -37,6 +39,8 @@
1D3623250D0F684500981E51 /* git_phoneAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = git_phoneAppDelegate.m; sourceTree = "<group>"; };
1D6058910D05DD3D006BFB54 /* git-phone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "git-phone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ 2294459F0F2CFD4200502D5C /* private.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = private.png; sourceTree = "<group>"; };
+ 229445A00F2CFD4200502D5C /* public.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = public.png; sourceTree = "<group>"; };
22E17B640F22334300D2853B /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = "<group>"; };
22E17B650F22334300D2853B /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = "<group>"; };
22E17B880F2233E400D2853B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = /System/Library/Frameworks/SystemConfiguration.framework; sourceTree = "<absolute>"; };
@@ -45,17 +49,17 @@
22E17B9B0F223AA600D2853B /* ApplicationErrorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationErrorViewController.h; sourceTree = "<group>"; };
22E17B9C0F223AA600D2853B /* ApplicationErrorViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationErrorViewController.m; sourceTree = "<group>"; };
22E17B9E0F223BC800D2853B /* ApplicationError.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ApplicationError.xib; sourceTree = "<group>"; };
- 22E17C070F223E9C00D2853B /* octocat_sad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = octocat_sad.png; path = images/octocat_sad.png; sourceTree = "<group>"; };
+ 22E17C070F223E9C00D2853B /* octocat_sad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = octocat_sad.png; sourceTree = "<group>"; };
22E17C1C0F22467200D2853B /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
22E17C1D0F22467200D2853B /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
22E17C3A0F22490800D2853B /* Login.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Login.xib; sourceTree = "<group>"; };
- 22E17C400F224A5700D2853B /* octocat_large.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = octocat_large.png; path = images/octocat_large.png; sourceTree = "<group>"; };
+ 22E17C400F224A5700D2853B /* octocat_large.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = octocat_large.png; sourceTree = "<group>"; };
22E17D0B0F24F08C00D2853B /* Connector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Connector.h; sourceTree = "<group>"; };
22E17D0C0F24F08C00D2853B /* Connector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Connector.m; sourceTree = "<group>"; };
22E17D560F25043800D2853B /* Repository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Repository.h; sourceTree = "<group>"; };
22E17D570F25043800D2853B /* Repository.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Repository.m; sourceTree = "<group>"; };
22FA50030F212ED300709123 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
- 22FA502D0F21374300709123 /* octocat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = octocat.png; path = images/octocat.png; sourceTree = "<group>"; };
+ 22FA502D0F21374300709123 /* octocat.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = octocat.png; sourceTree = "<group>"; };
22FA50CC0F21463D00709123 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = Classes/Config.h; sourceTree = "<group>"; };
22FA50CD0F21463D00709123 /* Config.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Config.m; path = Classes/Config.m; sourceTree = "<group>"; };
22FA50DB0F2147DC00709123 /* Models.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Models.h; path = Classes/Models.h; sourceTree = "<group>"; };
@@ -124,14 +128,16 @@
path = Classes;
sourceTree = "<group>";
};
- 22FA50100F21349300709123 /* Images */ = {
+ 22FA50100F21349300709123 /* images */ = {
isa = PBXGroup;
children = (
+ 2294459F0F2CFD4200502D5C /* private.png */,
+ 229445A00F2CFD4200502D5C /* public.png */,
22E17C400F224A5700D2853B /* octocat_large.png */,
22E17C070F223E9C00D2853B /* octocat_sad.png */,
22FA502D0F21374300709123 /* octocat.png */,
);
- name = Images;
+ path = images;
sourceTree = "<group>";
};
22FA50C60F2144DF00709123 /* Models */ = {
@@ -187,7 +193,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
- 22FA50100F21349300709123 /* Images */,
+ 22FA50100F21349300709123 /* images */,
22E17B9E0F223BC800D2853B /* ApplicationError.xib */,
22E17C3A0F22490800D2853B /* Login.xib */,
28AD735F0D9D9599002E5188 /* MainWindow.xib */,
@@ -265,6 +271,8 @@
22E17C080F223E9C00D2853B /* octocat_sad.png in Resources */,
22E17C3B0F22490800D2853B /* Login.xib in Resources */,
22E17C410F224A5700D2853B /* octocat_large.png in Resources */,
+ 229445A10F2CFD4200502D5C /* private.png in Resources */,
+ 229445A20F2CFD4200502D5C /* public.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
BIN images/private.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN images/public.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit be6a9db

Please sign in to comment.
Something went wrong with that request. Please try again.