aboutsummaryrefslogtreecommitdiffhomepage
path: root/example
diff options
context:
space:
mode:
authorGravatar Jonathan Willing <jwilling@me.com>2013-05-11 16:53:41 -0500
committerGravatar Jonathan Willing <jwilling@me.com>2013-05-11 16:53:41 -0500
commitce800f23933baa4fa0e86e3277aeb4a45e558532 (patch)
tree51c0408b1cb0936b07f5cab241103a59cfbf62a5 /example
parent177bf6b6ee038630d7a0e916f20377d0adb88025 (diff)
add the ability in the iOS demo to change the hostname
Diffstat (limited to 'example')
-rw-r--r--example/ios/iOS UI Test/iOS UI Test/MasterViewController.m21
-rw-r--r--example/ios/iOS UI Test/iOS UI Test/SettingsViewController.h2
-rw-r--r--example/ios/iOS UI Test/iOS UI Test/SettingsViewController.m24
-rw-r--r--example/ios/iOS UI Test/iOS UI Test/SettingsViewController.xib175
4 files changed, 192 insertions, 30 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
index 0e4c848b..493c8e5b 100644
--- a/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
+++ b/example/ios/iOS UI Test/iOS UI Test/MasterViewController.m
@@ -24,19 +24,23 @@
- (void)viewDidLoad {
[super viewDidLoad];
+ [[NSUserDefaults standardUserDefaults] registerDefaults:@{ HostnameKey: @"imap.gmail.com" }];
+
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:UsernameKey];
NSString *password = [[FXKeychain defaultKeychain] objectForKey:PasswordKey];
- [self loadAccountWithUsername:username password:password];
+ NSString *hostname = [[NSUserDefaults standardUserDefaults] objectForKey:HostnameKey];
+
+ [self loadAccountWithUsername:username password:password hostname:hostname];
}
-- (void)loadAccountWithUsername:(NSString *)username password:(NSString *)password {
+- (void)loadAccountWithUsername:(NSString *)username password:(NSString *)password hostname:(NSString *)hostname {
if (!username.length || !password.length) {
[self performSelector:@selector(showSettingsViewController:) withObject:nil afterDelay:0.5];
return;
}
self.imapSession = [[MCOIMAPSession alloc] init];
- self.imapSession.hostname = @"imap.gmail.com";
+ self.imapSession.hostname = hostname;
self.imapSession.port = 993;
self.imapSession.username = username;
self.imapSession.password = password;
@@ -74,7 +78,9 @@
[self.imapMessagesFetchOp start:^(NSError *error, NSArray *messages, MCOIndexSet *vanishedMessages) {
MasterViewController *strongSelf = weakSelf;
NSLog(@"fetched all messages.");
- strongSelf.messages = [NSArray arrayWithArray:messages];
+
+ NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"header.date" ascending:NO];
+ strongSelf.messages = [messages sortedArrayUsingDescriptors:@[sort]];//[NSArray arrayWithArray:messages];
[strongSelf.tableView reloadData];
}];
}
@@ -116,10 +122,13 @@
NSString *username = [[NSUserDefaults standardUserDefaults] stringForKey:UsernameKey];
NSString *password = [[FXKeychain defaultKeychain] objectForKey:PasswordKey];
+ NSString *hostname = [[NSUserDefaults standardUserDefaults] objectForKey:HostnameKey];
- if (![username isEqualToString:self.imapSession.username] || ![password isEqualToString:self.imapSession.password]) {
+ if (![username isEqualToString:self.imapSession.username] ||
+ ![password isEqualToString:self.imapSession.password] ||
+ ![hostname isEqualToString:self.imapSession.hostname]) {
self.imapSession = nil;
- [self loadAccountWithUsername:username password:password];
+ [self loadAccountWithUsername:username password:password hostname:hostname];
}
}
diff --git a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.h b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.h
index 2c6cd2ef..2172b4d4 100644
--- a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.h
+++ b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.h
@@ -10,6 +10,7 @@
extern NSString * const UsernameKey;
extern NSString * const PasswordKey;
+extern NSString * const HostnameKey;
@protocol SettingsViewControllerDelegate;
@@ -17,6 +18,7 @@ extern NSString * const PasswordKey;
@property (weak, nonatomic) IBOutlet UITextField *emailTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
+@property (weak, nonatomic) IBOutlet UITextField *hostnameTextField;
@property (nonatomic, weak) id<SettingsViewControllerDelegate> delegate;
- (IBAction)done:(id)sender;
diff --git a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.m b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.m
index f08eba77..6fbd6db2 100644
--- a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.m
+++ b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.m
@@ -11,25 +11,14 @@
NSString * const UsernameKey = @"username";
NSString * const PasswordKey = @"password";
-
-@interface SettingsViewController ()
-
-@end
+NSString * const HostnameKey = @"hostname";
@implementation SettingsViewController
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
-{
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
-}
-
- (void)done:(id)sender {
- [[NSUserDefaults standardUserDefaults] setObject:self.emailTextField.text forKey:UsernameKey];
+ [[NSUserDefaults standardUserDefaults] setObject:self.emailTextField.text ?: @"" forKey:UsernameKey];
[[FXKeychain defaultKeychain] setObject:self.passwordTextField.text ?: @"" forKey:PasswordKey];
+ [[NSUserDefaults standardUserDefaults] setObject:self.hostnameTextField.text ?: @"" forKey:HostnameKey];
[self.delegate settingsViewControllerFinished:self];
}
@@ -40,12 +29,7 @@ NSString * const PasswordKey = @"password";
self.view.backgroundColor = [UIColor underPageBackgroundColor];
self.emailTextField.text = [[NSUserDefaults standardUserDefaults] stringForKey:UsernameKey];
self.passwordTextField.text = [[FXKeychain defaultKeychain] objectForKey:PasswordKey];
-}
-
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
+ self.hostnameTextField.text = [[NSUserDefaults standardUserDefaults] stringForKey:HostnameKey];
}
@end
diff --git a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.xib b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.xib
index 6e788970..00041150 100644
--- a/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.xib
+++ b/example/ios/iOS UI Test/iOS UI Test/SettingsViewController.xib
@@ -44,10 +44,11 @@
<int key="NSvFlags">290</int>
<string key="NSFrameSize">{320, 44}</string>
<reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="339913914"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
- <array class="NSMutableArray" key="IBUIItems">
+ <array key="IBUIItems">
<object class="IBUINavigationItem" id="938505117">
<reference key="IBUINavigationBar" ref="703582545"/>
<string key="IBUITitle">Settings</string>
@@ -66,6 +67,7 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 66}, {280, 30}}</string>
<reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="923634912"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
@@ -103,7 +105,8 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{20, 104}, {280, 30}}</string>
<reference key="NSSuperview" ref="191373211"/>
- <reference key="NSNextKeyView"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="394260873"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -127,9 +130,39 @@
<reference key="IBUIFontDescription" ref="985700861"/>
<reference key="IBUIFont" ref="649714166"/>
</object>
+ <object class="IBUITextField" id="394260873">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">292</int>
+ <string key="NSFrame">{{20, 142}, {280, 30}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <string key="NSReuseIdentifierKey">_NS:9</string>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <int key="IBUIContentVerticalAlignment">0</int>
+ <string key="IBUIText"/>
+ <int key="IBUIBorderStyle">3</int>
+ <string key="IBUIPlaceholder">imap hostname (e.g. imap.gmail.com)</string>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ <reference key="NSCustomColorSpace" ref="327218161"/>
+ </object>
+ <bool key="IBUIAdjustsFontSizeToFit">YES</bool>
+ <float key="IBUIMinimumFontSize">17</float>
+ <object class="IBUITextInputTraits" key="IBUITextInputTraits">
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <int key="IBUIClearButtonMode">1</int>
+ <reference key="IBUIFontDescription" ref="985700861"/>
+ <reference key="IBUIFont" ref="649714166"/>
+ </object>
</array>
<string key="NSFrame">{{0, 20}, {320, 548}}</string>
<reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="703582545"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">1</int>
@@ -183,6 +216,14 @@
<int key="connectionID">50</int>
</object>
<object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">hostnameTextField</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="394260873"/>
+ </object>
+ <int key="connectionID">55</int>
+ </object>
+ <object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">done:</string>
<reference key="source" ref="38144743"/>
@@ -203,6 +244,54 @@
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<array class="NSMutableArray" key="children">
+ <object class="IBNSLayoutConstraint" id="1036238214">
+ <reference key="firstItem" ref="191373211"/>
+ <int key="firstAttribute">6</int>
+ <int key="relation">0</int>
+ <reference key="secondItem" ref="394260873"/>
+ <int key="secondAttribute">6</int>
+ <float key="multiplier">1</float>
+ <object class="IBNSLayoutSymbolicConstant" key="constant">
+ <double key="value">20</double>
+ </object>
+ <float key="priority">1000</float>
+ <reference key="containingView" ref="191373211"/>
+ <int key="scoringType">8</int>
+ <float key="scoringTypeFloat">29</float>
+ <int key="contentType">3</int>
+ </object>
+ <object class="IBNSLayoutConstraint" id="662191761">
+ <reference key="firstItem" ref="394260873"/>
+ <int key="firstAttribute">5</int>
+ <int key="relation">0</int>
+ <reference key="secondItem" ref="191373211"/>
+ <int key="secondAttribute">5</int>
+ <float key="multiplier">1</float>
+ <object class="IBNSLayoutSymbolicConstant" key="constant">
+ <double key="value">20</double>
+ </object>
+ <float key="priority">1000</float>
+ <reference key="containingView" ref="191373211"/>
+ <int key="scoringType">8</int>
+ <float key="scoringTypeFloat">29</float>
+ <int key="contentType">3</int>
+ </object>
+ <object class="IBNSLayoutConstraint" id="457196062">
+ <reference key="firstItem" ref="394260873"/>
+ <int key="firstAttribute">3</int>
+ <int key="relation">0</int>
+ <reference key="secondItem" ref="923634912"/>
+ <int key="secondAttribute">4</int>
+ <float key="multiplier">1</float>
+ <object class="IBNSLayoutSymbolicConstant" key="constant">
+ <double key="value">8</double>
+ </object>
+ <float key="priority">1000</float>
+ <reference key="containingView" ref="191373211"/>
+ <int key="scoringType">6</int>
+ <float key="scoringTypeFloat">24</float>
+ <int key="contentType">3</int>
+ </object>
<object class="IBNSLayoutConstraint" id="295413753">
<reference key="firstItem" ref="923634912"/>
<int key="firstAttribute">3</int>
@@ -350,6 +439,7 @@
<reference ref="703582545"/>
<reference ref="339913914"/>
<reference ref="923634912"/>
+ <reference ref="394260873"/>
</array>
<reference key="parent" ref="0"/>
</object>
@@ -441,6 +531,26 @@
<reference key="object" ref="295413753"/>
<reference key="parent" ref="191373211"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">51</int>
+ <reference key="object" ref="394260873"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">52</int>
+ <reference key="object" ref="457196062"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">53</int>
+ <reference key="object" ref="662191761"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">54</int>
+ <reference key="object" ref="1036238214"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -459,6 +569,9 @@
<reference ref="620844127"/>
<reference ref="144109937"/>
<reference ref="295413753"/>
+ <reference ref="457196062"/>
+ <reference ref="662191761"/>
+ <reference ref="1036238214"/>
</array>
<string key="10.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -476,15 +589,69 @@
<string key="47.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="48.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="51.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <boolean value="NO" key="51.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/>
+ <string key="52.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="53.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="54.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="9.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">50</int>
+ <int key="maxID">55</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">NSLayoutConstraint</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/NSLayoutConstraint.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">SettingsViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <string key="NS.key.0">done:</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <string key="NS.key.0">done:</string>
+ <object class="IBActionInfo" key="NS.object.0">
+ <string key="name">done:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
+ <dictionary class="NSMutableDictionary" key="outlets">
+ <string key="emailTextField">UITextField</string>
+ <string key="hostnameTextField">UITextField</string>
+ <string key="passwordTextField">UITextField</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <object class="IBToOneOutletInfo" key="emailTextField">
+ <string key="name">emailTextField</string>
+ <string key="candidateClassName">UITextField</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="hostnameTextField">
+ <string key="name">hostnameTextField</string>
+ <string key="candidateClassName">UITextField</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="passwordTextField">
+ <string key="name">passwordTextField</string>
+ <string key="candidateClassName">UITextField</string>
+ </object>
+ </dictionary>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/SettingsViewController.h</string>
+ </object>
+ </object>
+ </array>
</object>
- <object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>