Changeset 589
- Timestamp:
- 12/03/09 11:13:52 (3 months ago)
- Location:
- apps/iphone/my.tel/trunk
- Files:
-
- 29 added
- 20 removed
- 33 modified
-
APIAccount.plist (added)
-
APISubdomain.plist (modified) (1 diff)
-
Classes/AccountViewController.h (added)
-
Classes/AccountViewController.m (added)
-
Classes/AlertRenameView.m (modified) (3 diffs)
-
Classes/API Classes/Account.h (added)
-
Classes/API Classes/Account.m (added)
-
Classes/API Classes/Group.h (added)
-
Classes/API Classes/Group.m (added)
-
Classes/API Classes/JsonConnection.h (added)
-
Classes/API Classes/JsonConnection.m (added)
-
Classes/API Classes/Keyword.h (added)
-
Classes/API Classes/Keyword.m (added)
-
Classes/API Classes/Location.h (added)
-
Classes/API Classes/Location.m (added)
-
Classes/API Classes/Record.h (added)
-
Classes/API Classes/Record.m (added)
-
Classes/API Classes/Subdomain.h (added)
-
Classes/API Classes/Subdomain.m (added)
-
Classes/DomainViewController.h (added)
-
Classes/DomainViewController.m (added)
-
Classes/GroupFriendsController.h (modified) (3 diffs)
-
Classes/GroupFriendsController.m (modified) (8 diffs)
-
Classes/Group.h (deleted)
-
Classes/Group.m (deleted)
-
Classes/GroupsViewController.h (modified) (2 diffs)
-
Classes/GroupsViewController.m (modified) (6 diffs)
-
Classes/HATextViewEditController.h (added)
-
Classes/HATextViewEditController.m (added)
-
Classes/HeaderViewController.h (deleted)
-
Classes/HeaderViewController.m (deleted)
-
Classes/JsonConnection.h (deleted)
-
Classes/JsonConnection.m (deleted)
-
Classes/KeywordCell.m (modified) (1 diff)
-
Classes/KeywordEditController.h (modified) (3 diffs)
-
Classes/KeywordEditController.m (modified) (8 diffs)
-
Classes/Keyword.h (deleted)
-
Classes/Keyword.m (deleted)
-
Classes/KeywordViewController.h (modified) (2 diffs)
-
Classes/KeywordViewController.m (modified) (15 diffs)
-
Classes/Location.h (deleted)
-
Classes/Location.m (deleted)
-
Classes/LocationViewController.h (modified) (3 diffs)
-
Classes/LocationViewController.m (modified) (8 diffs)
-
Classes/LoginViewController.h (modified) (2 diffs)
-
Classes/LoginViewController.m (modified) (5 diffs)
-
Classes/MainTabBarController.h (deleted)
-
Classes/MainTabBarController.m (deleted)
-
Classes/ProfileRecordsViewController.h (added)
-
Classes/ProfileRecordsViewController.m (added)
-
Classes/ProfileViewController.h (modified) (2 diffs)
-
Classes/ProfileViewController.m (modified) (16 diffs)
-
Classes/RecordCell.h (modified) (2 diffs)
-
Classes/RecordCell.m (modified) (8 diffs)
-
Classes/RecordEditController.h (modified) (3 diffs)
-
Classes/RecordEditController.m (modified) (22 diffs)
-
Classes/RecordGroupsController.h (modified) (1 diff)
-
Classes/RecordGroupsController.m (modified) (2 diffs)
-
Classes/Record.h (deleted)
-
Classes/Record.m (deleted)
-
Classes/RecordViewController.h (modified) (5 diffs)
-
Classes/RecordViewController.m (modified) (18 diffs)
-
Classes/Subdomain.h (deleted)
-
Classes/Subdomain.m (deleted)
-
Classes/SubdomainViewController.h (deleted)
-
Classes/SubdomainViewController.m (deleted)
-
Classes/VIPConnect.h (modified) (1 diff)
-
Classes/VIPConnect.m (modified) (3 diffs)
-
English.lproj/MainWindow.xib (modified) (50 diffs)
-
English.lproj/ProfileRecords.xib (added)
-
English.lproj/Profiles.xib (deleted)
-
English.lproj/RecordEdit.xib (modified) (15 diffs)
-
English.lproj/TabGroups.xib (deleted)
-
English.lproj/TabLoc.xib (modified) (9 diffs)
-
English.lproj/TabNaptr.xib (modified) (15 diffs)
-
HATextFieldEditController.xib (added)
-
HATextViewEditController.xib (added)
-
icons/greybarbutton.png (added)
-
idna.h (added)
-
libidn.a (added)
-
offlineSampleData.plist (modified) (2 diffs)
-
VIP.tel.xcodeproj/project.pbxproj (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/my.tel/trunk/APISubdomain.plist
r218 r589 7 7 <key>storefolder</key> 8 8 <string>/domain/storefolder.action</string> 9 <key>renamefolder</key> 10 <string>/domain/renamefolder.action</string> 9 11 <key>deletefolder</key> 10 12 <string>/domain/deletefolder.action</string> 13 <key>getdisplaystring</key> 14 <string>/domain/getdisplaystring.action</string> 15 <key>setdisplaystring</key> 16 <string>/domain/setdisplaystring.action</string> 11 17 </dict> 12 18 </plist> -
apps/iphone/my.tel/trunk/Classes/AlertRenameView.m
r266 r589 12 12 // and the width of the text field inside 13 13 #define kARTextFieldDiff 50 14 // Height of text field 15 #define kARTextFieldHeight 32 14 16 15 17 @implementation AlertRenameView … … 45 47 [super drawRect:rect]; 46 48 CGRect boundsRect = self.bounds; 47 // Move the alert view upwards so the keyboard can be shown properly48 self.frame = CGRectOffset(self.frame, 0, -80);49 49 CGRect textRect = boundsRect; 50 textRect.size = CGSizeMake(rect.size.width - kARTextFieldDiff, 32);51 textRect = CGRectOffset(textRect, kARTextFieldDiff/2 , 50);50 textRect.size = CGSizeMake(rect.size.width - kARTextFieldDiff, kARTextFieldHeight); 51 textRect = CGRectOffset(textRect, kARTextFieldDiff/2 , kARTextFieldHeight+18); 52 52 uiStringField.frame = textRect; 53 53 } … … 65 65 return YES; 66 66 } 67 - (BOOL)textFieldShouldEndEditing:(UITextField *)textField { 68 if ([textField.text isEqual:@""]) { 69 return NO; 70 } 67 - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { 68 self.frame = CGRectOffset(self.frame, 0, -(48+kARTextFieldHeight)); 71 69 return YES; 72 70 } 73 71 - (void)textFieldDidEndEditing:(UITextField *)textField { 72 self.frame = CGRectOffset(self.frame, 0, 48+kARTextFieldHeight); 74 73 } 75 74 @end -
apps/iphone/my.tel/trunk/Classes/GroupFriendsController.h
r313 r589 12 12 #import "Group.h" 13 13 14 @protocol GroupDetailsDelegate <NSObject>15 @required16 - (void)didModifyGroup:(NSDictionary *)aGroup;17 @end18 19 14 @interface GroupFriendsController : UIViewController 20 15 <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, UIActionSheetDelegate> { … … 22 17 IBOutlet UIBarButtonItem *buttonEdit; 23 18 NSDictionary *theGroup; // Group for which friends are requested 24 id delegate;19 id <TelControllerDelegate>delegate; 25 20 @private 26 21 NSMutableArray *friendsArray; // retrieved raw JSON data of getgroupfriends … … 57 52 @property (nonatomic, retain) UIBarButtonItem *buttonEdit; 58 53 @property (nonatomic, retain) NSDictionary *theGroup; 59 @property (nonatomic,assign) id < GroupDetailsDelegate> delegate;54 @property (nonatomic,assign) id <TelControllerDelegate> delegate; 60 55 @end -
apps/iphone/my.tel/trunk/Classes/GroupFriendsController.m
r535 r589 61 61 62 62 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 63 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];63 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 64 64 [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 65 65 … … 68 68 [requestData release]; 69 69 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 70 [self.delegate d idModifyGroup:theGroup];70 [self.delegate dataDidLoadForController:self]; 71 71 [self.navigationController popViewControllerAnimated:YES]; 72 72 } else { … … 88 88 89 89 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 90 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];90 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 91 91 [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 92 92 [requestData setObject:newName forKey:@"groupName"]; … … 201 201 [theGroup setValue:newGroupName forKey:@"groupName"]; 202 202 self.navigationItem.title = newGroupName; 203 [self.delegate didModifyGroup:theGroup]; 203 // Tell the delegate something changed 204 //[self.delegate didModifyGroup:theGroup]; 205 [self.delegate dataDidLoadForController:self]; 204 206 } else { 205 207 [Group throwJsonErrorAlert:parsedJson]; … … 231 233 232 234 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 233 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];235 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 234 236 [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 235 237 … … 247 249 248 250 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 249 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];251 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 250 252 // allFriendsGroupId should already be set. 251 253 [requestData setObject:[VIPConnect sharedInstance].allFriendsGroupId forKey:@"groupId"]; … … 301 303 302 304 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 303 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];305 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 304 306 [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 305 307 [requestData setObject:friendsIdList forKey:@"readerIds"]; … … 332 334 333 335 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:50] retain]; 334 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];336 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 335 337 [requestData setObject:[theGroup objectForKey:@"id"] forKey:@"groupId"]; 336 338 [requestData setObject:friendsIdList forKey:@"readerIds"]; -
apps/iphone/my.tel/trunk/Classes/GroupsViewController.h
r249 r589 13 13 14 14 15 @interface GroupsViewController : UI ViewController <UITableViewDelegate, UITableViewDataSource,16 UIAlertViewDelegate, GroupDetailsDelegate> {15 @interface GroupsViewController : UITableViewController 16 <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, TelControllerDelegate> { 17 17 NSMutableArray *groupsArray; // retrieved raw JSON data (also used as the datasource array) 18 19 IBOutlet UITableView *theTable; 20 IBOutlet UIBarButtonItem *buttonAdd;18 id <TelControllerDelegate> delegate; 19 @private 20 BOOL didPreload; 21 21 } 22 22 23 + (GroupsViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 23 24 - (void)updateUITableWithJson:(NSDictionary *)parsedJson; 24 25 … … 26 27 - (void)createGroup:(NSString *)aGroupName; 27 28 28 @property (nonatomic, retain) NSMutableArray *groupsArray;29 29 30 30 - (IBAction)didClickAdd:(id)sender; 31 31 32 @property (nonatomic, retain) UITableView *theTable;33 @property ( nonatomic, retain) UIBarButtonItem *buttonAdd;32 @property (nonatomic, retain) NSMutableArray *groupsArray; 33 @property (retain) id delegate; 34 34 35 35 @end -
apps/iphone/my.tel/trunk/Classes/GroupsViewController.m
r535 r589 9 9 #import "GroupsViewController.h" 10 10 11 @interface GroupsViewController (PrivateMethods) 12 - (void)setDidPreload:(BOOL)preload; 13 @end; 14 11 15 12 16 @implementation GroupsViewController 13 17 14 18 @synthesize groupsArray; 15 @synthesize theTable; 16 @synthesize buttonAdd; 19 @synthesize delegate; 17 20 18 21 #define kAlertAddId 1 19 22 23 #pragma mark - 24 #pragma mark Designated initializer 25 26 + (GroupsViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 27 GroupsViewController *theC = [[[GroupsViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; 28 theC.delegate = aDelegate; 29 theC.groupsArray = [NSMutableArray arrayWithCapacity:10]; 30 if (preload) { 31 [theC listGroups]; 32 } 33 [theC setDidPreload:preload]; 34 return theC; 35 } 36 37 - (void)setDidPreload:(BOOL)preload { 38 didPreload = preload; 39 } 40 41 20 42 #pragma mark ------ Default Methods 21 /*22 // The designated initializer. Override to perform setup that is required before the view is loaded.23 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {24 if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {25 // Custom initialization26 }27 return self;28 }29 */30 31 /*32 // Implement loadView to create a view hierarchy programmatically, without using a nib.33 - (void)loadView {34 }35 */36 37 43 - (void)viewDidLoad { 38 44 [super viewDidLoad]; 39 [[VIPConnect sharedInstance] addObserver:self forKeyPath:@"selectedDomain" options:NSKeyValueObservingOptionNew context:NULL]; 40 self.groupsArray = [NSMutableArray arrayWithCapacity:10]; 41 self.navigationItem.rightBarButtonItem = buttonAdd; 42 [self listGroups]; 43 } 44 45 /* 46 // Override to allow orientations other than the default portrait orientation. 45 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 46 target:self 47 action:@selector(didClickAdd:)] 48 autorelease]; 49 self.title = @"Privacy Groups"; 50 } 51 52 53 - (void)viewWillAppear:(BOOL)animated { 54 [super viewWillAppear:animated]; 55 // Don't get the data if we preloaded 56 if (didPreload) { 57 didPreload = NO; 58 } else { 59 [self listGroups]; 60 } 61 } 62 47 63 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 48 64 // Return YES for supported orientations 49 65 return (interfaceOrientation == UIInterfaceOrientationPortrait); 50 66 } 51 */52 67 53 68 - (void)didReceiveMemoryWarning { … … 153 168 // no groups 154 169 } 155 } else { 170 [self.delegate dataDidLoadForController:self]; 171 [self.tableView reloadData]; 172 } else { 173 [self.tableView reloadData]; 156 174 [Group throwJsonErrorAlert:parsedJson]; 157 175 } 158 [theTable reloadData]; 159 } 160 161 #pragma mark ------ GroupDetailsDelegate methods 162 163 - (void)didModifyGroup:(NSDictionary *)aGroup { 164 [self listGroups]; 176 } 177 178 #pragma mark ------ TelControllerDelegate methods 179 180 - (void)dataDidLoadForController:(UIViewController *)controller { 181 if ([controller isMemberOfClass:[GroupFriendsController class]]) { 182 [self listGroups]; 183 } 184 } 185 186 - (NSString *)domain { 187 // request the domain from the calling controller 188 return [self.delegate domain]; 165 189 } 166 190 … … 205 229 206 230 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 207 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];231 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 208 232 209 233 [conn setPayload:requestData]; … … 235 259 // create empty group 236 260 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 237 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];261 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 238 262 [requestData setObject:@"0" forKey:@"groupId"]; 239 263 [requestData setObject:aGroupName forKey:@"groupName"]; … … 251 275 nil]; 252 276 [groupsArray addObject:newGroup]; 253 NSIndexPath *lastPath = [NSIndexPath indexPathForRow:[ theTablenumberOfRowsInSection:0] inSection:0];254 [ theTableinsertRowsAtIndexPaths:[NSArray arrayWithObject:lastPath] withRowAnimation:UITableViewRowAnimationFade];277 NSIndexPath *lastPath = [NSIndexPath indexPathForRow:[self.tableView numberOfRowsInSection:0] inSection:0]; 278 [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:lastPath] withRowAnimation:UITableViewRowAnimationFade]; 255 279 } 256 280 [aGroupName release]; … … 265 289 context:(void *)context { 266 290 267 if ([keyPath isEqual:@"selected ProfileName"]) {291 if ([keyPath isEqual:@"selectedDomain"]) { 268 292 [self listGroups]; 269 293 return; -
apps/iphone/my.tel/trunk/Classes/KeywordCell.m
r264 r589 17 17 @synthesize labelSecondaryText; 18 18 19 - (id)initWith Frame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {20 if (self = [super initWith Frame:frame reuseIdentifier:reuseIdentifier]) {19 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 20 if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 21 21 // Initialization code 22 22 -
apps/iphone/my.tel/trunk/Classes/KeywordEditController.h
r161 r589 19 19 #import "biKeywordView.h" 20 20 21 @protocol KeywordEditDelegate 21 @protocol KeywordEditDelegate <TelControllerDelegate> 22 22 23 23 - (void)didStoreKeyword:(NSDictionary *)aRec; … … 39 39 IBOutlet UIView *editSubview; // Subview with editing fields 40 40 41 id <KeywordEditDelegate> caller;41 id <KeywordEditDelegate> delegate; 42 42 @private 43 43 NSMutableArray *tArrKey; … … 66 66 @property (nonatomic, retain) IBOutlet UIView *editSubview; 67 67 @property (nonatomic, retain) IBOutlet UIActivityIndicatorView *saveIndicator; 68 @property (retain) id caller;68 @property (retain) id delegate; 69 69 70 70 @end -
apps/iphone/my.tel/trunk/Classes/KeywordEditController.m
r535 r589 30 30 @synthesize editSubview; 31 31 @synthesize saveIndicator; 32 @synthesize caller;32 @synthesize delegate; 33 33 34 34 #pragma mark ------ Transition methods … … 50 50 rValue.textColor = [UIColor blackColor]; 51 51 [theKeyword setObject:@"0" forKey:@"primaryKeywordId"]; 52 [theKeyword setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];52 [theKeyword setObject:[self.delegate domain] forKey:@"domain"]; 53 53 primaryKeywords.hidden = NO; 54 54 [self displaySecondaryViewAtIndex:primaryKeywords.selectedSegmentIndex]; … … 62 62 theKeyword = [[NSMutableDictionary dictionaryWithCapacity:[aRec count]] retain]; 63 63 [theKeyword setDictionary:aRec]; 64 editKeywordType.text = [[ callerdelegateKeywordTypes] objectForKey:[theKeyword objectForKey:@"field"]];64 editKeywordType.text = [[delegate delegateKeywordTypes] objectForKey:[theKeyword objectForKey:@"field"]]; 65 65 barHeader.title = @"View Keyword"; 66 66 barButtonSave.enabled = FALSE; 67 [theKeyword setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];67 [theKeyword setObject:[self.delegate domain] forKey:@"domain"]; 68 68 rValue.text = [theKeyword objectForKey:@"value"]; 69 69 rValue.textColor = [UIColor whiteColor]; … … 71 71 NSMutableString *secDesc = [NSMutableString stringWithCapacity:100]; 72 72 for (NSDictionary *sec in [theKeyword objectForKey:@"secondaryKeywords"]) { 73 [secDesc appendFormat:@"%@: %@\n", [[ callerdelegateKeywordTypes] objectForKey:[sec objectForKey:@"field"]],73 [secDesc appendFormat:@"%@: %@\n", [[delegate delegateKeywordTypes] objectForKey:[sec objectForKey:@"field"]], 74 74 [sec objectForKey:@"value"]]; 75 75 } … … 78 78 79 79 // TODO: Enable keyword editing 80 //NSDictionary *validKeywordTypes = [[ callerdelegateKeywordTypes] retain];80 //NSDictionary *validKeywordTypes = [[delegate delegateKeywordTypes] retain]; 81 81 } 82 82 83 83 [self viewWillAppear:YES]; 84 84 // Insert our view just at the top of the caller's subview stack 85 [[(UIViewController *) callerview] addSubview:self.view];85 [[(UIViewController *)delegate view] addSubview:self.view]; 86 86 // Set up the animation 87 87 CATransition *animation = [CATransition animation]; … … 95 95 [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 96 96 97 [[[(UIViewController *) callerview] layer] addAnimation:animation forKey:@"kEditAnimation"];97 [[[(UIViewController *)delegate view] layer] addAnimation:animation forKey:@"kEditAnimation"]; 98 98 99 99 } … … 164 164 // store all the keyword info 165 165 NSMutableDictionary *saveKeywordDict = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 166 [saveKeywordDict setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];166 [saveKeywordDict setObject:[self.delegate domain] forKey:@"domain"]; 167 167 NSMutableArray *saveSecKeywordArray = [[NSMutableArray arrayWithCapacity:8] retain]; 168 168 [saveSecKeywordArray addObject:[NSDictionary dictionaryWithObjectsAndKeys: … … 197 197 - (void)afterSaveAction:(NSDictionary *)parsedJson { 198 198 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 199 [ callerdidStoreKeyword:theKeyword];199 [delegate didStoreKeyword:theKeyword]; 200 200 [self.view removeFromSuperview]; 201 201 } else { -
apps/iphone/my.tel/trunk/Classes/KeywordViewController.h
r426 r589 27 27 IBOutlet UINavigationBar *navBar; 28 28 IBOutlet KeywordEditController *editController; 29 id <TelControllerDelegate> delegate; 29 30 @private 31 BOOL didPreload; 30 32 } 31 33 34 + (KeywordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 32 35 - (NSDictionary *)selectRecordInSetUsingId:(NSString *)anId; 33 36 - (void)updateUITableWithJson:(NSDictionary *)parsedJson; … … 54 57 @property (nonatomic, retain) IBOutlet UINavigationBar *navBar; 55 58 @property (nonatomic, retain) IBOutlet KeywordEditController *editController; 59 @property (retain) id delegate; 56 60 57 61 @end -
apps/iphone/my.tel/trunk/Classes/KeywordViewController.m
r535 r589 16 16 #define kKRowLineHeightIncrease 20.0 17 17 18 @interface KeywordViewController (PrivateMethods) 19 - (void)setDidPreload:(BOOL)preload; 20 @end; 21 18 22 @implementation KeywordViewController 19 23 … … 29 33 @synthesize navBar; 30 34 @synthesize editController; 35 @synthesize delegate; 36 37 #pragma mark - 38 #pragma mark Designated initializer 39 40 + (KeywordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 41 KeywordViewController *theC = [[[KeywordViewController alloc] initWithNibName:@"TabTxt" bundle:nil] autorelease]; 42 theC.delegate = aDelegate; 43 theC.keywordsArray = [NSMutableArray arrayWithCapacity:20]; 44 theC.uiArray = [NSMutableArray arrayWithCapacity:20]; 45 if (preload) { 46 [theC getValidKeywords:FALSE]; 47 [theC getKeywords]; 48 } 49 [theC setDidPreload:preload]; 50 return theC; 51 } 52 53 - (void)setDidPreload:(BOOL)preload { 54 didPreload = preload; 55 } 31 56 32 57 #pragma mark ------ Standard View Controller Methods … … 34 59 - (void)viewDidLoad { 35 60 [super viewDidLoad]; 36 self.keywordsArray = [NSMutableArray arrayWithCapacity:20];37 self.uiArray = [NSMutableArray arrayWithCapacity:20];38 61 keywordTableHeight = kKRowHeight; 39 [self getValidKeywords:FALSE];40 62 } 41 63 42 64 - (void)viewWillAppear:(BOOL)animated { 43 // This triggers when switching tabs 44 self.title = navBar.topItem.title = [VIPConnect sharedInstance].selectedDomain; 45 [self getKeywords]; 65 [super viewWillAppear:animated]; 66 // Don't get the data if we preloaded 67 if (didPreload) { 68 didPreload = NO; 69 } else { 70 [self getValidKeywords:FALSE]; 71 [self getKeywords]; 72 } 46 73 } 47 74 … … 59 86 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 60 87 return nil; 61 //return [NSString stringWithFormat:@"Profile: %@", [VIPConnect sharedInstance].selectedProfileName];62 88 } 63 89 … … 77 103 KeywordCell *cell = (KeywordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 78 104 if (cell == nil) { 79 cell = [[[KeywordCell alloc] initWithFrame:CGRectZeroreuseIdentifier:CellIdentifier] autorelease];105 cell = [[[KeywordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 80 106 } 81 107 NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; … … 124 150 editController = [[KeywordEditController alloc] 125 151 initWithNibName:@"KeywordEdit" bundle:[NSBundle mainBundle]]; 126 editController. caller= self;152 editController.delegate = self; 127 153 NSDictionary *theKeyword = [self selectRecordInSetUsingId:[[uiArray objectAtIndex:indexPath.row] 128 154 objectForKey:@"id"]]; … … 162 188 } 163 189 190 - (void)dataDidLoadForController:(UIViewController *)controller { 191 // TODO: fix this controller to conform to the new stuff 192 } 193 194 - (NSString *)domain { 195 return ([self.delegate domain]); 196 } 197 164 198 #pragma mark ------ UI Methods and Json Delegates 165 199 … … 170 204 editController = [[KeywordEditController alloc] 171 205 initWithNibName:@"KeywordEdit" bundle:[NSBundle mainBundle]]; 172 editController. caller= self;206 editController.delegate = self; 173 207 [editController presentViewForRecord:nil]; 174 208 } … … 183 217 navBar.topItem.rightBarButtonItem = buttonEdit; 184 218 [theTable setEditing:NO animated:YES]; 185 //keywordTableHeight = k RowHeight;219 //keywordTableHeight = kKRowHeight; 186 220 [theTable reloadData]; 187 221 } … … 210 244 [self.uiArray addObject:[self uiItemFromJsonItem:aRec]]; 211 245 } 246 [self.delegate dataDidLoadForController:self]; 212 247 [self.theTable reloadData]; 213 248 } else { … … 320 355 321 356 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 322 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];357 [requestData setObject:[self.delegate domain] forKey:@"domain"]; 323 358 [requestData setObject:[VIPConnect sharedInstance].selectedProfileId forKey:@"profileId"]; 324 359 … … 376 411 [newConn setConnectionUrl:[newConn urlFromAction:@"addkeyword"]]; 377 412 NSMutableDictionary *newRequestData = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 378 [ aRec objectForKey:@"domain"], @"domain",413 [self.delegate domain], @"domain", 379 414 [thePrimary objectForKey:@"key"], @"type", 380 415 [thePrimary objectForKey:@"value"], @"value", … … 397 432 398 433 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 399 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];434 [requestData setObject:[self.delegate domain] forKey:@"domain"]; 400 435 [requestData setObject:[aRec objectForKey:@"keywords"] forKey:@"keywords"]; 401 436 if (newId) { … … 437 472 438 473 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 439 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];474 [requestData setObject:[self.delegate domain] forKey:@"domain"]; 440 475 [requestData setObject:idsToDelete forKey:@"idList"]; 441 476 … … 470 505 471 506 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 472 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domain"];507 [requestData setObject:[self.delegate domain] forKey:@"domain"]; 473 508 474 509 [conn setPayload:requestData]; -
apps/iphone/my.tel/trunk/Classes/LocationViewController.h
r535 r589 27 27 IBOutlet MKMapView *theMap; 28 28 TelMapAnnotation *markerTel; 29 id <TelControllerDelegate> delegate; 29 30 @private 30 31 BOOL gpsLocIsAvailable; … … 32 33 NSInteger moveToGPSButtonIndex; 33 34 NSInteger moveToTelButtonIndex; 35 BOOL didPreload; 34 36 } 35 37 38 + (LocationViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 39 - (void)resetData; 36 40 - (void)recenterMap; 37 41 - (void)updateUILocationWithJson:(NSDictionary *)parsedJson; … … 56 60 @property (nonatomic, retain) IBOutlet MKMapView *theMap; 57 61 @property (nonatomic, retain) TelMapAnnotation *markerTel; 62 @property (retain) id delegate; 58 63 59 64 @end -
apps/iphone/my.tel/trunk/Classes/LocationViewController.m
r535 r589 9 9 #import "LocationViewController.h" 10 10 11 @interface LocationViewController (PrivateMethods) 12 - (void)setDidPreload:(BOOL)preload; 13 @end; 14 11 15 @implementation LocationViewController 12 16 … … 20 24 @synthesize theMap; 21 25 @synthesize markerTel; 26 @synthesize delegate; 27 28 #pragma mark - 29 #pragma mark Designated initializer 30 31 + (LocationViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 32 LocationViewController *theC = [[[LocationViewController alloc] initWithNibName:@"TabLoc" bundle:nil] autorelease]; 33 theC.delegate = aDelegate; 34 [theC resetData]; 35 if (preload) { 36 [theC.view setNeedsLayout]; 37 [theC getLocation]; 38 } 39 [theC setDidPreload:preload]; 40 theC.title = @"Map"; 41 return theC; 42 } 43 44 - (void)setDidPreload:(BOOL)preload { 45 didPreload = preload; 46 } 22 47 23 48 #pragma mark ------ Standard View Controller Methods … … 26 51 [super viewDidLoad]; 27 52 theMap.delegate = self; 53 [MyCLController sharedInstance].delegate = self; 54 } 55 56 - (void)viewWillAppear:(BOOL)animated { 57 [super viewWillAppear:animated]; 58 // Don't get the data if we preloaded 59 if (didPreload) { 60 didPreload = NO; 61 } else { 62 [self getLocation]; 63 } 64 } 65 66 - (void)viewDidAppear:(BOOL)animated { 67 [super viewDidAppear:animated]; 68 self.theMap.showsUserLocation = YES; 69 } 70 71 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 72 // Return YES for supported orientations 73 return (interfaceOrientation == UIInterfaceOrientationPortrait); 74 } 75 76 - (void)didReceiveMemoryWarning { 77 [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 78 // Release anything that's not essential, such as cached data 79 } 80 81 82 - (void)dealloc { 83 [super dealloc]; 84 } 85 86 - (void)resetData { 28 87 gpsLocIsAvailable = NO; 29 88 telLocIsAvailable = NO; 30 89 buttonDeleteLoc.enabled = telLocIsAvailable; 31 [MyCLController sharedInstance].delegate = self;32 [self getLocation];33 }34 35 - (void)viewWillAppear:(BOOL)animated {36 [super viewWillAppear:animated];37 [self getLocation];38 }39 40 - (void)viewDidAppear:(BOOL)animated {41 [super viewDidAppear:animated];42 self.theMap.showsUserLocation = YES;43 }44 45 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {46 // Return YES for supported orientations47 return (interfaceOrientation == UIInterfaceOrientationPortrait);48 }49 50 - (void)didReceiveMemoryWarning {51 [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview52 // Release anything that's not essential, such as cached data53 }54 55 56 - (void)dealloc {57 [super dealloc];58 90 } 59 91 … … 134 166 CLLocationCoordinate2D newCoords = {[jsonLat floatValue], [jsonLong floatValue]}; 135 167 self.markerTel = [TelMapAnnotation annotationWithCoordinate:newCoords]; 136 self.markerTel.title = [ VIPConnect sharedInstance].selectedDomain;168 self.markerTel.title = [self.delegate domain]; 137 169 [self.theMap addAnnotation:markerTel]; 138 170 [self.theMap selectAnnotation:markerTel animated:YES]; … … 151 183 } 152 184 buttonDeleteLoc.enabled = telLocIsAvailable; 185 [self.delegate dataDidLoadForController:self]; 153 186 } 154 187 … … 212 245 213 246 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 214 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];247 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 215 248 216 249 [conn setPayload:requestData]; … … 235 268 NSString *currLong = [NSString stringWithFormat:@"%f", centerPointCoord.longitude]; 236 269 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 237 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];270 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 238 271 [requestData setObject:self.apiId forKey:@"apiId"]; 239 272 [requestData setObject:currLat forKey:@"latitude"]; … … 259 292 260 293 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 261 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];294 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 262 295 [requestData setObject:self.apiId forKey:@"apiId"]; 263 296 -
apps/iphone/my.tel/trunk/Classes/LoginViewController.h
r299 r589 10 10 #import "VIPConnect.h" 11 11 #import "DnsResolver.h" 12 #import " MainTabBarController.h"12 #import "DomainViewController.h" 13 13 14 14 @interface LoginViewController : UIViewController <UITextFieldDelegate> { 15 IBOutlet MainTabBarController *tabBarController;16 15 IBOutlet UITextField *fieldUser; 17 16 IBOutlet UITextField *fieldPassword; … … 36 35 - (IBAction)didClickSignUpButton:(id)sender; 37 36 38 @property (nonatomic, retain) IBOutlet MainTabBarController *tabBarController;39 37 @property (nonatomic, retain) IBOutlet UITextField *fieldUser; 40 38 @property (nonatomic, retain) IBOutlet UITextField *fieldPassword; -
apps/iphone/my.tel/trunk/Classes/LoginViewController.m
r313 r589 11 11 @implementation LoginViewController 12 12 13 @synthesize tabBarController;14 13 @synthesize fieldUser; 15 14 @synthesize fieldPassword; … … 92 91 username = fieldUser.text; 93 92 password = fieldPassword.text; 94 if ([fieldDomain.text hasSuffix:@".vip.tel"]) { 95 domainName = [NSString stringWithString:fieldDomain.text]; 96 } else if ([fieldDomain.text hasSuffix:@".tel"]) { 93 if ([fieldDomain.text hasSuffix:@".tel"]) { 97 94 domainName = [NSString stringWithString:fieldDomain.text]; 98 95 } else { … … 137 134 - (void)postLoginSetup:(NSDictionary *)parsedJson { 138 135 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 139 // TODO: Put the VIPConnect stuff also in the TelPostLoginDelegate protocol140 if (! [VIPConnect sharedInstance].selectedDomain) {141 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];142 [VIPConnect sharedInstance].selectedDomain = [defaults stringForKey:@"domainName"];143 }144 if (! [VIPConnect sharedInstance].selectedProfileId) {145 [[VIPConnect sharedInstance] retrieveProfiles];146 [[VIPConnect sharedInstance] grabActiveProfile];147 }148 149 136 if ([[parsedJson valueForKey:@"usedTempPassword"] integerValue] == 1) { 150 137 // Don't support temp passwords, consider login ok 151 138 } 152 [[UIApplication sharedApplication].keyWindow addSubview:tabBarController.view]; 139 //[[UIApplication sharedApplication].keyWindow addSubview:tabBarController.view]; 140 DomainViewController *theDVC = [DomainViewController controllerForDomain:[self.delegate domain]]; 141 UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:theDVC]; 142 [[UIApplication sharedApplication].keyWindow addSubview:navC.view]; 153 143 [self.view removeFromSuperview]; 154 144 } else { … … 170 160 if (!aDomain) 171 161 return nil; 172 if ([aDomain hasSuffix:@".vip.tel"]) {173 return @"https://demo.vip.tel/g2/json";174 }175 162 // try to autoprovision apiRootUrl 176 163 NSMutableArray *naptrArray = [[NSMutableArray arrayWithCapacity:1] retain]; … … 218 205 [[NSNotificationCenter defaultCenter] removeObserver:self 219 206 name:UITextFieldTextDidEndEditingNotification object:nil]; 220 [tabBarController release];221 207 [super dealloc]; 222 208 } -
apps/iphone/my.tel/trunk/Classes/ProfileViewController.h
r254 r589 12 12 #import "Profile.h" 13 13 #import "TextHeader.h" 14 #import "ProfileRecordsViewController.h" 14 15 15 @protocol ProfileViewDelegate 16 17 - (void)didActivateProfile:(NSString *)profileId; 18 19 @end 20 21 @interface ProfileViewController : UIViewController 22 <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate> { 16 @interface ProfileViewController : UITableViewController 17 <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate, TelControllerDelegate> { 23 18 NSString *apiId; 24 19 NSMutableArray *profilesArray; // retrieved raw JSON data (also used as the datasource array) … … 28 23 UIImage *iconactiveselected; 29 24 30 IBOutlet UITableView *theTable; 31 IBOutlet UILabel *domainLabel; 32 IBOutlet UIBarButtonItem *buttonSelect; 33 IBOutlet UIBarButtonItem *buttonActivate; 34 IBOutlet UIBarButtonItem *buttonRename; 35 IBOutlet UIBarButtonItem *buttonNew; 36 IBOutlet UIBarButtonItem *buttonDelete; 37 id <ProfileViewDelegate> delegate; 25 id <TelControllerDelegate> delegate; 26 @private 27 BOOL didPreload; 38 28 } 39 29 30 + (ProfileViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 40 31 - (void)updateUITableWithJson:(NSDictionary *)parsedJson; 41 32 42 33 - (void)listProfiles; 43 - (void)activateProfile:(NSDictionary *)aProf;44 34 - (void)createProfile:(NSString *)aProfName; 45 - (NSDecimalNumber *)updateProfile:(NSString *)aProfName forId:(NSString *)anId ; 46 - (void)deleteProfile:(NSDictionary *)aProf; 35 - (NSDecimalNumber *)updateProfile:(NSString *)aProfName forId:(NSString *)anId; 36 - (void)deleteProfile:(NSDictionary *)aProf atIndex:(NSIndexPath *)indexPath; 37 38 - (IBAction)didClickAdd:(id)sender; 47 39 48 40 @property (nonatomic, retain) NSString *apiId; 49 41 @property (nonatomic, retain) NSMutableArray *profilesArray; 50 51 - (IBAction)didClickDone:(id)sender;52 - (IBAction)didClickSelect:(id)sender;53 - (IBAction)didClickActivate:(id)sender;54 - (IBAction)didClickRename:(id)sender;55 - (IBAction)didClickAdd:(id)sender;56 - (IBAction)didClickDelete:(id)sender;57 58 @property (nonatomic, retain) IBOutlet UITableView *theTable;59 @property (nonatomic, retain) IBOutlet UILabel *domainLabel;60 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonSelect;61 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonActivate;62 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonRename;63 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonNew;64 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonDelete;65 42 @property (retain) id delegate; 66 43 -
apps/iphone/my.tel/trunk/Classes/ProfileViewController.m
r535 r589 9 9 #import "ProfileViewController.h" 10 10 11 @interface ProfileViewController (PrivateMethods) 12 - (void)setDidPreload:(BOOL)preload; 13 @end; 11 14 12 15 @implementation ProfileViewController … … 15 18 @synthesize profilesArray; 16 19 17 @synthesize theTable;18 @synthesize domainLabel;19 @synthesize buttonSelect;20 @synthesize buttonActivate;21 @synthesize buttonRename;22 @synthesize buttonNew;23 @synthesize buttonDelete;24 20 @synthesize delegate; 25 21 26 #define kAlertAddId 1 27 #define kAlertRenameId 2 22 #pragma mark - 23 #pragma mark Designated initializer 24 25 + (ProfileViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 26 ProfileViewController *theC = [[[ProfileViewController alloc] initWithStyle:UITableViewStylePlain] autorelease]; 27 theC.delegate = aDelegate; 28 theC.profilesArray = [NSMutableArray arrayWithCapacity:10]; 29 if (preload) { 30 [theC listProfiles]; 31 } 32 [theC setDidPreload:preload]; 33 return theC; 34 } 35 36 - (void)setDidPreload:(BOOL)preload { 37 didPreload = preload; 38 } 28 39 29 40 #pragma mark ------ Standard View Controller Methods … … 31 42 - (void)viewDidLoad { 32 43 [super viewDidLoad]; 33 self.profilesArray = [NSMutableArray arrayWithCapacity:10]; 34 [self listProfiles]; 35 44 45 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 46 target:self 47 action:@selector(didClickAdd:)] 48 autorelease]; 49 self.title = @"Profiles"; 36 50 // Load the icons for the table view 37 51 NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"iconinactive" ofType:@"png"]; … … 46 60 47 61 - (void)viewWillAppear:(BOOL)animated { 48 [domainLabel setText:[VIPConnect sharedInstance].selectedDomain]; 62 [super viewWillAppear:animated]; 63 // Don't get the data if we preloaded 64 if (didPreload) { 65 didPreload = NO; 66 } else { 67 [self listProfiles]; 68 } 49 69 } 50 70 … … 75 95 76 96 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 77 return [[VIPConnect sharedInstance] topDomainFromDomain:[ VIPConnect sharedInstance].selectedDomain];97 return [[VIPConnect sharedInstance] topDomainFromDomain:[self.delegate domain]]; 78 98 } 79 99 … … 122 142 123 143 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 124 [buttonSelect setEnabled:YES]; 125 [buttonActivate setEnabled:YES]; 126 [buttonRename setEnabled:YES]; 127 [buttonDelete setEnabled:YES]; 128 } 129 130 /* 131 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 132 return 60; 133 } 134 */ 144 [tableView deselectRowAtIndexPath:indexPath animated:YES]; 145 NSDictionary *aProf = [[profilesArray objectAtIndex:indexPath.row] retain]; 146 ProfileRecordsViewController *prVC = [ProfileRecordsViewController controllerWithProfile:aProf delegate:self preload:YES]; 147 [aProf release]; 148 [self.navigationController pushViewController:prVC animated:YES]; 149 } 150 151 - (void)setEditing:(BOOL)editing animated:(BOOL)animated { 152 if (editing) { 153 self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 154 target:self 155 action:@selector(didClickAdd:)] 156 autorelease]; 157 } else { 158 self.navigationItem.leftBarButtonItem = nil; 159 } 160 } 161 162 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 163 forRowAtIndexPath:(NSIndexPath *)indexPath { 164 if (editingStyle == UITableViewCellEditingStyleDelete) { 165 NSDictionary *aProf = [profilesArray objectAtIndex:indexPath.row]; 166 [self deleteProfile:aProf atIndex:indexPath]; 167 } 168 } 169 170 #pragma mark - 171 #pragma mark TelControllerDelegate Methods 172 173 - (void)dataDidLoadForController:(UIViewController *)controller { 174 if ([controller isMemberOfClass:[ProfileRecordsViewController class]]) { 175 // Something changed with the selected profile, let's refresh our list 176 [self listProfiles]; 177 } 178 } 179 180 - (NSString *)domain { 181 // return the actual domain from its domain controller 182 return ([self.delegate domain]); 183 } 135 184 136 185 #pragma mark ------ UI Methods and Json Delegates 137 138 - (IBAction)didClickDone:(id)sender {139 [self.view removeFromSuperview];140 }141 142 - (IBAction)didClickSelect:(id)sender {143 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow];144 NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain];145 [VIPConnect sharedInstance].selectedProfileId = [aProf objectForKey:@"id"];146 [VIPConnect sharedInstance].selectedProfileName = [aProf objectForKey:@"name"];147 [theTable reloadData];148 [aProf release];149 }150 151 - (IBAction)didClickActivate:(id)sender {152 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow];153 if (selectedPath) {154 NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain];155 [self activateProfile:aProf];156 [aProf release];157 [self listProfiles];158 }159 }160 161 - (IBAction)didClickRename:(id)sender {162 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow];163 if (selectedPath) {164 NSDictionary *aProf = [[profilesArray objectAtIndex:selectedPath.row] retain];165 AlertRenameView *alert = [AlertRenameView alloc];166 [[alert initWithTitle:@"Edit Profile Name"167 message:@"\n\n"168 delegate:self169 cancelButtonTitle:@"Cancel"170 otherButtonTitles:@"OK", nil] autorelease];171 alert.alertId = [NSNumber numberWithInt:kAlertRenameId];172 alert.uiStringField.text = [aProf objectForKey:@"name"];173 [alert show];174 [aProf release];175 }176 }177 186 178 187 - (IBAction)didClickAdd:(id)sender { … … 183 192 cancelButtonTitle:@"Cancel" 184 193 otherButtonTitles:@"OK", nil] autorelease]; 185 alert.alertId = [NSNumber numberWithInt: kAlertAddId];194 alert.alertId = [NSNumber numberWithInt:0]; 186 195 alert.uiStringField.text = @""; 187 196 [alert show]; 188 }189 190 - (IBAction)didClickDelete:(id)sender {191 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow];192 if (selectedPath) {193 NSDictionary *aProf = [profilesArray objectAtIndex:selectedPath.row];194 [self deleteProfile:aProf];195 [self listProfiles];196 }197 197 } 198 198 … … 206 206 [self.profilesArray setArray:(NSArray *)[parsedJson valueForKey:@"profileList"]]; 207 207 [VIPConnect sharedInstance].profilesInDomain = self.profilesArray; 208 } else { 208 [self.delegate dataDidLoadForController:self]; 209 [self.tableView reloadData]; 210 } else { 211 [self.tableView reloadData]; 209 212 [Profile throwJsonErrorAlert:parsedJson]; 210 213 } 211 [self.theTable reloadData];212 213 214 } 214 215 … … 224 225 return; 225 226 } 226 if ([aV.alertId integerValue] == kAlertAddId) { 227 [self createProfile:aV.uiStringField.text]; 228 [self listProfiles]; 229 return; 230 } 231 if ([aV.alertId integerValue] == kAlertRenameId) { 232 NSIndexPath *selectedPath = [theTable indexPathForSelectedRow]; 233 if (selectedPath) { 234 NSDictionary *aProf = [profilesArray objectAtIndex:selectedPath.row]; 235 [self updateProfile:aV.uiStringField.text forId:[aProf objectForKey:@"id"]]; 236 [self listProfiles]; 237 } 238 return; 239 } 227 [self createProfile:aV.uiStringField.text]; 228 [self listProfiles]; 229 return; 240 230 } 241 231 … … 265 255 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; 266 256 VIPConnect *cVip = [VIPConnect sharedInstance]; 267 [requestData setObject:[cVip topDomainFromDomain: cVip.selectedDomain] forKey:@"domainName"];257 [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 268 258 269 259 [conn setPayload:requestData]; 270 260 [conn performLookup:TRUE]; 271 261 [requestData release]; 272 }273 274 - (void)activateProfile:(NSDictionary *)aProf {275 // inputProfile = {276 // domainName: "cartman.tel",277 // profileId: 23278 // };279 //280 // successResult = {281 // success: true,282 // actionMessages: ["profile activated",283 // "2nd message here",284 // "3rd message here"]285 // };286 287 if (!aProf) {288 return;289 }290 [aProf retain];291 Profile *conn = [[[Profile alloc] init] autorelease];292 [conn setTheDelegate:[VIPConnect sharedInstance]];293 [conn setActionSel:@selector(doNothing:)];294 [conn setConnectionUrl:[conn urlFromAction:@"activateprofile"]];295 296 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain];297 VIPConnect *cVip = [VIPConnect sharedInstance];298 [requestData setObject:[cVip topDomainFromDomain:cVip.selectedDomain] forKey:@"domainName"];299 [requestData setObject:[aProf objectForKey:@"id"] forKey:@"profileId"];300 301 [conn setPayload:requestData];302 NSDictionary *parsedJson = [conn performLookup:FALSE];303 [requestData release];304 if ([[parsedJson valueForKey:@"success"] integerValue] == 0) {305 [Profile throwJsonErrorAlert:parsedJson];306 } else {307 [delegate didActivateProfile:[aProf objectForKey:@"id"]];308 }309 [aProf release];310 262 } 311 263 … … 322 274 323 275 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:4] retain]; 324 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];276 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 325 277 [requestData setObject:newProfileId forKey:@"profileId"]; 326 278 [requestData setObject:@"0" forKey:@"apiId"]; … … 362 314 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:3] retain]; 363 315 VIPConnect *cVip = [VIPConnect sharedInstance]; 364 [requestData setObject:[cVip topDomainFromDomain: cVip.selectedDomain] forKey:@"domainName"];316 [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 365 317 if (anId) { // update name of existing profile 366 318 [requestData setObject:anId forKey:@"profileId"]; … … 376 328 [Profile throwJsonErrorAlert:parsedJson]; 377 329 } else { 378 // if it's the selected profile, update our cache379 if ([[VIPConnect sharedInstance].selectedProfileId isEqual:anId]) {380 [VIPConnect sharedInstance].selectedProfileName = aProfName;381 }382 330 newProfileId = [parsedJson valueForKey:@"profileId"]; 383 331 } … … 386 334 } 387 335 388 - (void)deleteProfile:(NSDictionary *)aProf {336 - (void)deleteProfile:(NSDictionary *)aProf atIndex:(NSIndexPath *)indexPath { 389 337 // inputProfile = { 390 338 // domainName: "cartman.tel", … … 412 360 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 413 361 VIPConnect *cVip = [VIPConnect sharedInstance]; 414 [requestData setObject:[cVip topDomainFromDomain: cVip.selectedDomain] forKey:@"domainName"];362 [requestData setObject:[cVip topDomainFromDomain:[self.delegate domain]] forKey:@"domainName"]; 415 363 [requestData setObject:[aProf objectForKey:@"id"] forKey:@"profileId"]; 416 364 … … 421 369 if ([[parsedJson valueForKey:@"success"] integerValue] == 0) { 422 370 [Profile throwJsonErrorAlert:parsedJson]; 371 } else { 372 [self.profilesArray removeObjectAtIndex:indexPath.row]; 373 [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 423 374 } 424 375 [aProf release]; -
apps/iphone/my.tel/trunk/Classes/RecordCell.h
r149 r589 17 17 IBOutlet UILabel *labelValue; 18 18 IBOutlet UIImageView *labelImage; 19 IBOutlet UISwitch *switchEnabled; 19 BOOL canBeDisabled; // if yes, put checkmark and allow disabling 20 BOOL enabledInProfile; 20 21 } 21 22 … … 25 26 @property (nonatomic, retain) UILabel *labelValue; 26 27 @property (nonatomic, retain) UIImageView *labelImage; 27 @property (nonatomic, retain) UISwitch *switchEnabled; 28 29 - (IBAction)setEnabledState:(id)sender; 28 @property (nonatomic) BOOL canBeDisabled; 29 @property (nonatomic) BOOL enabledInProfile; 30 30 31 31 @end -
apps/iphone/my.tel/trunk/Classes/RecordCell.m
r535 r589 10 10 11 11 #ifndef kRowHeight 12 #define kRowHeight 5 4.012 #define kRowHeight 52.0 13 13 #endif 14 14 15 #define kFontSize 14 15 #define kFontSize 12 16 #define kMarginSize 3 16 17 17 18 @implementation RecordCell … … 22 23 @synthesize labelValue; 23 24 @synthesize labelImage; 24 @synthesize switchEnabled; 25 @synthesize canBeDisabled; 26 @dynamic enabledInProfile; 25 27 26 28 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { … … 33 35 labelValue = nil; 34 36 labelImage = nil; 35 switchEnabled = nil;37 canBeDisabled = NO; 36 38 37 39 self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; … … 48 50 // label.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.7]; 49 51 label.backgroundColor = [UIColor clearColor]; 50 label.font = [UIFont systemFontOfSize:kFontSize -2];51 label.textColor = [UIColor blueColor];52 label.font = [UIFont systemFontOfSize:kFontSize]; 53 label.textColor = [UIColor darkGrayColor]; 52 54 self.labelLabel = label; 53 55 [self.contentView addSubview:label]; … … 57 59 label.backgroundColor = [UIColor clearColor]; 58 60 label.font = [UIFont systemFontOfSize:kFontSize]; 59 self.labelValue = label; 61 label.textColor = [UIColor blueColor]; 62 self.labelValue = label; 60 63 [self.contentView addSubview:label]; 61 64 [label release]; … … 67 70 [img release]; 68 71 69 UISwitch *sw = [[UISwitch alloc] initWithFrame:CGRectZero]; 70 self.switchEnabled = sw; 71 [self.contentView addSubview:sw]; 72 [sw release]; 73 // Make sure we update the underlying data source when the cell turned on/off 74 [switchEnabled addTarget:self.target 75 action:@selector(switchedEnabling:) 76 forControlEvents:UIControlEventValueChanged]; 77 // and also change the look 78 [switchEnabled addTarget:self 79 action:@selector(setEnabledState:) 80 forControlEvents:UIControlEventValueChanged]; 81 72 self.enabledInProfile = TRUE; 82 73 } 83 74 return self; … … 94 85 CGRect iconImageRect = self.contentView.bounds; 95 86 iconImageRect.size = CGSizeMake(30.0, 30.0); 96 iconImageRect = CGRectOffset(iconImageRect,3,(kRowHeight-iconImageRect.size.height)/2); 97 labelImage.frame = iconImageRect; 87 // Choose the below to vertically align the icon in the cell 88 // That won't work if the cell is dynamically resized 89 // iconImageRect = CGRectOffset(iconImageRect,kMarginSize,(kRowHeight-iconImageRect.size.height)/2); 90 iconImageRect = CGRectOffset(iconImageRect,kMarginSize,kMarginSize); 91 labelImage.frame = iconImageRect; 98 92 99 // position the text label in the content rect93 // position the text labels in the content rect 100 94 CGRect labelRect = contentRect; 101 labelRect.origin.x = contentRect.origin.x+ 36;102 labelRect.origin.y = contentRect.origin.y+ 3;95 labelRect.origin.x = contentRect.origin.x+kMarginSize+labelImage.frame.size.width+kMarginSize; 96 labelRect.origin.y = contentRect.origin.y+kMarginSize; 103 97 labelRect.size.height = labelService.font.pointSize+2; 104 98 labelRect.size.width = 250; 105 99 labelService.frame = labelRect; 106 labelRect.origin.y = labelRect.origin.y+labelRect.size.height+ 4;100 labelRect.origin.y = labelRect.origin.y+labelRect.size.height+2; 107 101 labelValue.frame = labelRect; 108 labelRect.origin.y = labelService.frame.origin.y;109 102 labelRect.size.height = labelLabel.font.pointSize+2; 110 labelRect.size.width = 120; 111 labelRect.origin.x = contentRect.origin.x + contentRect.size.width - labelRect.size.width; 103 labelRect.origin.y = labelRect.origin.y+labelRect.size.height+2; 104 // labelRect.size.width = 120; 105 // labelRect.origin.x = contentRect.origin.x + contentRect.size.width - labelRect.size.width; 112 106 labelLabel.frame = labelRect; 113 labelLabel.textAlignment = UITextAlignmentRight;114 115 //position the switch icon116 if (self.editing) {117 CGRect switchFrame = switchEnabled.frame;118 switchFrame.origin.x = contentRect.origin.x + contentRect.size.width/2 - switchEnabled.frame.size.width/2;119 switchFrame.origin.y = contentRect.origin.y + contentRect.size.height - switchEnabled.frame.size.height - 5;120 [switchEnabled setFrame:switchFrame];121 }122 switchEnabled.hidden = !self.editing;123 labelLabel.hidden = self.editing;124 107 } 125 108 … … 138 121 */ 139 122 140 - (IBAction)setEnabledState:(id)sender { 141 // User changed the enabled state 142 // Change look and feel if enabled or disabled 143 if ([switchEnabled isOn]) { 123 - (BOOL)enabledInProfile { 124 return enabledInProfile; 125 } 126 127 - (void)setEnabledInProfile:(BOOL)isEnabled { 128 if (canBeDisabled) { 129 enabledInProfile = isEnabled; 130 } else { 131 enabledInProfile = TRUE; 132 } 133 134 if (enabledInProfile) { 144 135 [labelImage setContentMode:UIViewContentModeTop]; 145 136 [labelService setTextColor:[UIColor blackColor]]; 146 [labelLabel setTextColor:[UIColor blueColor]];147 [labelValue setTextColor:[UIColor bl ackColor]];137 [labelLabel setTextColor:[UIColor darkGrayColor]]; 138 [labelValue setTextColor:[UIColor blueColor]]; 148 139 } else { 149 140 [labelImage setContentMode:UIViewContentModeBottom]; 150 141 [labelService setTextColor:[UIColor grayColor]]; 151 142 [labelLabel setTextColor:[UIColor grayColor]]; 152 [labelValue setTextColor:[UIColor grayColor]]; 143 [labelValue setTextColor:[UIColor grayColor]]; 153 144 } 154 145 } 155 156 146 @end -
apps/iphone/my.tel/trunk/Classes/RecordEditController.h
r263 r589 17 17 18 18 - (void)didStoreRecord:(NSDictionary *)aRec; 19 - (NSString *)domain; 19 20 20 21 @end … … 22 23 @interface RecordEditController : UIViewController 23 24 <RecordGroupsDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate> { 24 IBOutlet UIBarButtonItem *barHeader;25 IBOutlet UIBarButtonItem *barButtonSave;26 25 IBOutlet UIPickerView *rPicker; 27 26 IBOutlet UITextField *rValue; 28 27 IBOutlet UITextField *rLabel; 29 IBOutlet UISwitch *rVisibility;30 28 IBOutlet UIButton *buttonPrivacy; 31 29 id <RecordEditDelegate> delegate; 32 30 @private 31 NSMutableDictionary *_record; 33 32 NSMutableArray *sArrKey; 34 33 NSMutableArray *sArrVal; 35 34 NSMutableArray *liArrKey; 36 35 NSMutableArray *liArrVal; 37 NSMutableDictionary *theRecord;38 36 NSDictionary *naptrValuePlaceholders; 37 UIResponder *currentResponder; 39 38 } 40 39 41 - (void) setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData1; 42 - (void)presentViewForRecord:(NSDictionary *)aRec; 40 + (RecordEditController *)controllerWithServiceKeys:(NSDictionary *)skeysDict lihKeys:(NSDictionary *)liDict; 43 41 - (void)setStateForTerminal:(BOOL)isTerminal; 44 42 - (void)setStateForButtonPrivacy; … … 52 50 - (void)storeNTNaptrRecord; 53 51 54 @property (nonatomic, retain) IBOutlet UIBarButtonItem *barHeader; 55 @property (nonatomic, retain) IBOutlet UIBarButtonItem *barButtonSave; 52 @property (nonatomic, copy) NSDictionary *record; 56 53 @property (nonatomic, retain) IBOutlet UIPickerView *rPicker; 57 54 @property (nonatomic, retain) IBOutlet UITextField *rValue; 58 55 @property (nonatomic, retain) IBOutlet UITextField *rLabel; 59 @property (nonatomic, retain) IBOutlet UISwitch *rVisibility;60 56 @property (nonatomic, retain) IBOutlet UIButton *buttonPrivacy; 61 @property (retain) id delegate;57 @property (retain) id <RecordEditDelegate> delegate; 62 58 @end -
apps/iphone/my.tel/trunk/Classes/RecordEditController.m
r504 r589 11 11 #import "RecordEditController.h" 12 12 13 #define kRTransitionDuration 0.3 14 15 #define kNTNLabelLength 100 // NTN label length TODO: verify with engineers 16 #define kTLabelLength 20 // Terminal label length 13 #define kNTNLabelLength 255 // NTN label length 14 #define kTLabelLength 255 // Terminal label length 15 16 @interface RecordEditController (PrivateMethods) 17 18 - (void) setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData1; 19 20 @end 17 21 18 22 @implementation RecordEditController 19 23 20 @synthesize barHeader; 21 @synthesize barButtonSave; 24 @dynamic record; 22 25 @synthesize rPicker; 23 26 @synthesize rValue; 24 27 @synthesize rLabel; 25 @synthesize rVisibility;26 28 @synthesize buttonPrivacy; 27 29 @synthesize delegate; 28 30 29 #pragma mark ----- Calling methods 30 31 - (void)presentViewForRecord:(NSDictionary *)aRec { 32 [theRecord release]; 33 if (!aRec) { // new 34 barHeader.title = @"New Item"; 35 rValue.text = @""; 36 rLabel.text = @""; 37 rVisibility.on = TRUE; 38 theRecord = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 39 @"0", @"apiId", 40 [VIPConnect sharedInstance].selectedDomain, @"domainName", 41 [NSArray arrayWithObject:@"voice"], @"serviceKeys", 42 @"", @"label", 43 [NSArray array], @"locations", 44 [NSArray array], @"profiles", 45 [NSArray array], @"groups", 46 @"1", @"terminal", 47 nil] retain]; 48 } else { // edit 49 theRecord = [[NSMutableDictionary dictionaryWithDictionary:aRec] retain]; 50 barHeader.title = @"Edit Item"; 51 [theRecord setObject:[VIPConnect sharedInstance].selectedDomain forKey:@"domainName"]; 52 // An NTN may not have the below items 53 if ([[theRecord objectForKey:@"label"] isKindOfClass:[NSNull class]]) 54 [theRecord setObject:@"" forKey:@"label"]; 55 if ([[theRecord objectForKey:@"locations"] isKindOfClass:[NSNull class]]) 56 [theRecord setObject:[NSArray array] forKey:@"locations"]; 57 if ([[theRecord objectForKey:@"serviceKeys"] isKindOfClass:[NSNull class]]) { 58 if ([[theRecord objectForKey:@"terminal"] integerValue] == 0) { 59 [theRecord setObject:[NSArray arrayWithObject:@"ntn"] forKey:@"serviceKeys"]; 60 } else { 61 [theRecord setObject:[NSArray arrayWithObject:@"voice"] forKey:@"serviceKeys"]; 62 } 63 } 64 if ([[theRecord objectForKey:@"profiles"] isKindOfClass:[NSNull class]]) 65 [theRecord setObject:[NSArray array] forKey:@"profiles"]; 66 if ([[theRecord objectForKey:@"groups"] isKindOfClass:[NSNull class]]) 67 [theRecord setObject:[NSArray array] forKey:@"groups"]; 68 69 rValue.text = [theRecord objectForKey:@"value"]; 70 rLabel.text = [theRecord objectForKey:@"label"]; 71 if ([(NSArray *)[theRecord objectForKey:@"profiles"] containsObject:[VIPConnect sharedInstance].selectedProfileId]) { 72 rVisibility.on = TRUE; 73 } else { 74 rVisibility.on = FALSE; 75 } 76 } 77 // We only respect the first LIH and service types. 78 NSString *theService = [(NSArray *)[theRecord objectForKey:@"serviceKeys"] objectAtIndex:0]; 79 NSString *theLi; 80 if ([(NSArray *)[theRecord objectForKey:@"locations"] count] == 0) { 81 theLi = @""; 82 } else { 83 theLi = [(NSArray *)[theRecord objectForKey:@"locations"] objectAtIndex:0]; 84 } 85 86 [rPicker selectRow:[sArrKey indexOfObject:theService] inComponent:0 animated:NO]; 87 [rPicker selectRow:[liArrKey indexOfObject:theLi] inComponent:1 animated:NO]; 88 [self viewWillAppear:YES]; 89 [self setStateForTerminal:[[theRecord objectForKey:@"terminal"] boolValue]]; 90 // Insert our view at the absolute top 91 [[UIApplication sharedApplication].keyWindow addSubview:self.navigationController.view]; 92 // Set up the animation 93 CATransition *animation = [CATransition animation]; 94 [animation setDelegate:self]; 95 96 [animation setType:kCATransitionMoveIn]; 97 [animation setSubtype:kCATransitionFromRight]; 98 99 // Set the duration and timing function of the transtion -- duration is passed in as a parameter, use ease in/ease out as the timing function 100 [animation setDuration:kRTransitionDuration]; 101 [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 102 103 [[[UIApplication sharedApplication].keyWindow layer] addAnimation:animation forKey:@"kEditAnimation"]; 104 } 31 #pragma mark - 32 #pragma mark Designated Initializer 33 34 + (RecordEditController *)controllerWithServiceKeys:(NSDictionary *)skeysDict lihKeys:(NSDictionary *)liDict { 35 RecordEditController *theC = [[[RecordEditController alloc] initWithNibName:@"RecordEdit" bundle:nil] autorelease]; 36 [theC setPickerCol1:skeysDict col2:liDict]; 37 [theC setRecord:nil]; 38 return theC; 39 } 40 41 #pragma mark - 42 #pragma mark Record management 43 44 - (void)setRecord:(NSDictionary *)aRecord { 45 if (_record) [_record release]; 46 if (aRecord == nil) { 47 _record = nil; 48 } else { 49 _record = [NSMutableDictionary dictionaryWithDictionary:aRecord]; 50 [_record retain]; 51 } 52 } 53 54 - (NSDictionary *)record { 55 return (NSDictionary *)_record; 56 } 57 58 59 #pragma mark - 60 #pragma mark Set Pickers 105 61 106 62 - (void)setPickerCol1:(NSDictionary *)pickerData1 col2:(NSDictionary *)pickerData2 { … … 108 64 NSUInteger i, count; 109 65 66 [sArrKey release]; 67 [sArrVal release]; 68 [liArrKey release]; 69 [liArrVal release]; 70 71 sArrKey = [[NSMutableArray arrayWithCapacity:30] retain]; 72 sArrVal = [[NSMutableArray arrayWithCapacity:30] retain]; 73 liArrKey = [[NSMutableArray arrayWithCapacity:10] retain]; 74 liArrVal = [[NSMutableArray arrayWithCapacity:10] retain]; 75 110 76 // Do first column 111 77 // First set the keys and related strings 112 78 [sArrKey setArray:[pickerData1 allKeys]]; 113 [sArrVal removeAllObjects];114 79 for (NSString *aK in sArrKey) { 115 80 [sArrVal addObject:[pickerData1 objectForKey:aK]]; … … 130 95 // Same for second column, but also add a "None" entry 131 96 [liArrKey setArray:[pickerData2 allKeys]]; 132 [liArrVal removeAllObjects];133 97 for (NSString *aK in liArrKey) { 134 98 [liArrVal addObject:[pickerData2 objectForKey:aK]]; … … 153 117 - (void)viewDidLoad { 154 118 [super viewDidLoad]; 155 sArrKey = [[NSMutableArray arrayWithCapacity:30] retain]; 156 sArrVal = [[NSMutableArray arrayWithCapacity:30] retain]; 157 liArrKey = [[NSMutableArray arrayWithCapacity:10] retain]; 158 liArrVal = [[NSMutableArray arrayWithCapacity:10] retain]; 119 self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 120 target:self 121 action:@selector(didClickCancel:)] autorelease]; 122 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave 123 target:self 124 action:@selector(didClickSave:)] autorelease]; 159 125 [buttonPrivacy setTitle:@" This item is public" 160 126 forState:UIControlStateDisabled]; … … 166 132 167 133 - (void)viewWillAppear:(BOOL)animated { 168 [self setStateForButtonPrivacy]; 134 if (_record == nil) { // new 135 self.title = @"New Item"; 136 rValue.text = @""; 137 rLabel.text = @""; 138 _record = [[NSMutableDictionary dictionaryWithObjectsAndKeys: 139 @"0", @"apiId", 140 [self.delegate domain], @"domainName", 141 [NSArray arrayWithObject:@"voice"], @"serviceKeys", 142 @"", @"label", 143 [NSArray array], @"locations", 144 [NSArray array], @"profiles", 145 [NSArray array], @"groups", 146 @"1", @"terminal", 147 nil] retain]; 148 } else { // edit 149 self.title = @"Edit Item"; 150 [_record setObject:[self.delegate domain] forKey:@"domainName"]; 151 // An NTN may not have the below items 152 if ([[_record objectForKey:@"label"] isKindOfClass:[NSNull class]]) 153 [_record setObject:@"" forKey:@"label"]; 154 if ([[_record objectForKey:@"locations"] isKindOfClass:[NSNull class]]) 155 [_record setObject:[NSArray array] forKey:@"locations"]; 156 if ([[_record objectForKey:@"serviceKeys"] isKindOfClass:[NSNull class]]) { 157 if ([[_record objectForKey:@"terminal"] integerValue] == 0) { 158 [_record setObject:[NSArray arrayWithObject:@"ntn"] forKey:@"serviceKeys"]; 159 } else { 160 [_record setObject:[NSArray arrayWithObject:@"voice"] forKey:@"serviceKeys"]; 161 } 162 } 163 if ([[_record objectForKey:@"profiles"] isKindOfClass:[NSNull class]]) 164 [_record setObject:[NSArray array] forKey:@"profiles"]; 165 if ([[_record objectForKey:@"groups"] isKindOfClass:[NSNull class]]) 166 [_record setObject:[NSArray array] forKey:@"groups"]; 167 168 rValue.text = [_record objectForKey:@"value"]; 169 rLabel.text = [_record objectForKey:@"label"]; 170 } 171 // We only respect the first LIH and service types. 172 NSString *theService = [(NSArray *)[_record objectForKey:@"serviceKeys"] objectAtIndex:0]; 173 NSString *theLi; 174 if ([(NSArray *)[_record objectForKey:@"locations"] count] == 0) { 175 theLi = @""; 176 } else { 177 theLi = [(NSArray *)[_record objectForKey:@"locations"] objectAtIndex:0]; 178 } 179 180 [rPicker selectRow:[sArrKey indexOfObject:theService] inComponent:0 animated:NO]; 181 [rPicker selectRow:[liArrKey indexOfObject:theLi] inComponent:1 animated:NO]; 182 [self setStateForTerminal:[[_record objectForKey:@"terminal"] boolValue]]; 169 183 } 170 184 … … 182 196 183 197 - (void)dealloc { 198 if (_record) [_record release]; 184 199 [sArrKey release]; 185 200 [sArrVal release]; … … 194 209 - (IBAction)didClickCancel:(id)sender { 195 210 [self slideViewForEditing:NO]; 196 [self.navigationController .view removeFromSuperview];211 [self.navigationController popViewControllerAnimated:YES]; 197 212 } 198 213 … … 201 216 // servicekey and LI are set when the user selects the pickerViews 202 217 // apiId and domainName are set at the start in presentView 203 [theRecord setObject:rValue.text forKey:@"value"]; 204 [theRecord setObject:rLabel.text forKey:@"label"]; 205 206 VIPConnect *vipSI = [VIPConnect sharedInstance]; 207 NSMutableArray *newProfilesArray = [NSMutableArray arrayWithArray:[theRecord objectForKey:@"profiles"]]; 208 [newProfilesArray removeObjectIdenticalTo:vipSI.selectedProfileId]; 209 if (rVisibility.on) { 210 [newProfilesArray addObject:vipSI.selectedProfileId]; 211 } 212 [theRecord setObject:newProfilesArray forKey:@"profiles"]; 213 218 [_record setObject:rValue.text forKey:@"value"]; 219 [_record setObject:rLabel.text forKey:@"label"]; 220 214 221 // Store the record 215 222 if ([rPicker numberOfRowsInComponent:1] == 0) { // ntn … … 221 228 222 229 - (IBAction)didClickPrivacy:(id)sender { 223 RecordGroupsController *rGC = [RecordGroupsController controllerForRecord: theRecord groups:nil];230 RecordGroupsController *rGC = [RecordGroupsController controllerForRecord:_record groups:nil]; 224 231 rGC.delegate = self; 225 232 [self.navigationController pushViewController:rGC animated:YES]; … … 253 260 [conn setActionSel:@selector(doNothing:)]; 254 261 [conn setConnectionUrl:[conn urlFromAction:@"storerecord"]]; 255 [conn setPayload: theRecord];262 [conn setPayload:_record]; 256 263 NSDictionary *parsedJson = [conn performLookup:FALSE]; 257 264 258 265 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 259 [delegate didStoreRecord: theRecord];266 [delegate didStoreRecord:_record]; 260 267 [self slideViewForEditing:NO]; 261 [self.navigationController .view removeFromSuperview];268 [self.navigationController popViewControllerAnimated:YES]; 262 269 } else { 263 270 [JsonConnection throwJsonErrorAlert:parsedJson]; … … 285 292 */ 286 293 287 NSMutableDictionary *ntnRec = [NSMutableDictionary dictionaryWithDictionary: theRecord];294 NSMutableDictionary *ntnRec = [NSMutableDictionary dictionaryWithDictionary:_record]; 288 295 [ntnRec removeObjectForKey:@"locations"]; 289 296 //[ntnRec setObject:[NSArray array] forKey:@"groups"]; … … 305 312 306 313 if ([[parsedJson valueForKey:@"success"] integerValue] == 1) { 307 [delegate didStoreRecord: theRecord];314 [delegate didStoreRecord:_record]; 308 315 [self slideViewForEditing:NO]; 309 [self.navigationController .view removeFromSuperview];316 [self.navigationController popViewControllerAnimated:YES]; 310 317 } else { 311 318 [JsonConnection throwJsonErrorAlert:parsedJson]; … … 316 323 317 324 - (void)setStateForTerminal:(BOOL)isTerminal { 318 // Disable label for now on ntn. 319 // TODO: re-enable when labels allowed for ntn 320 if (isTerminal) { 321 rLabel.placeholder = @"Short description"; 322 rLabel.enabled = YES; 323 rVisibility.enabled = YES; 324 buttonPrivacy.enabled = YES; 325 [self setStateForButtonPrivacy]; 326 } else { 327 rLabel.text = @""; 328 rLabel.enabled = NO; 329 rLabel.placeholder = @" -- disabled --"; 330 rVisibility.on = YES; 331 rVisibility.enabled = NO; 332 buttonPrivacy.enabled = YES; // TODO: See if privacy works for NTN 333 [self setStateForButtonPrivacy]; 334 } 325 // NTNs now have all the features of terminal NAPTRs including labels 326 // if (isTerminal) { 327 // } else { 328 // } 329 rLabel.placeholder = @""; 330 rLabel.enabled = YES; 331 buttonPrivacy.enabled = YES; 332 [self setStateForButtonPrivacy]; 335 333 [self.view setNeedsLayout]; 336 334 [self.view setNeedsDisplay]; … … 338 336 339 337 - (void)setStateForButtonPrivacy { 340 NSUInteger numGroups = [(NSArray *)[ theRecord objectForKey:@"groups"] count];338 NSUInteger numGroups = [(NSArray *)[_record objectForKey:@"groups"] count]; 341 339 if (numGroups == 0) { 342 [buttonPrivacy setTitle:@" This item is public"340 [buttonPrivacy setTitle:@" Public item" 343 341 forState:(UIControlStateNormal & UIControlStateHighlighted)]; 344 342 } else { 345 343 if (numGroups == 1) 346 [buttonPrivacy setTitle:@" Member of 1 privacygroup"344 [buttonPrivacy setTitle:@" In 1 group" 347 345 forState:(UIControlStateNormal & UIControlStateHighlighted)]; 348 346 else 349 [buttonPrivacy setTitle:[NSString stringWithFormat:@" Member of %d privacygroups", numGroups]347 [buttonPrivacy setTitle:[NSString stringWithFormat:@" In %d groups", numGroups] 350 348 forState:(UIControlStateNormal & UIControlStateHighlighted)]; 351 349 } … … 353 351 354 352 - (void)slideViewForEditing:(BOOL)isEditing { 353 self.navigationItem.rightBarButtonItem.enabled = !isEditing; // disable the "Save" button until done editing 355 354 if (isEditing) { 356 355 if (self.view.frame.origin.y >=0) { … … 366 365 self.view.frame = newFrame; 367 366 } 367 // resign firstResponder status 368 [currentResponder resignFirstResponder]; 369 currentResponder = nil; 368 370 } 369 371 } … … 371 373 #pragma mark ------ RecordGroupsDelegate methods 372 374 - (void)replaceGroupsForRecord:(NSDictionary *)aRecord withGroups:(NSArray *)groupsIdList { 373 [theRecord setObject:groupsIdList forKey:@"groups"]; 375 [_record setObject:groupsIdList forKey:@"groups"]; 376 } 377 378 - (NSString *)domain { 379 // request the domain from the calling controller 380 return [self.delegate domain]; 374 381 } 375 382 376 383 #pragma mark ------ TextField delegate methods 377 384 - (void)textFieldDidBeginEditing:(UITextField *)textField { 385 currentResponder = textField; 378 386 [self slideViewForEditing:YES]; 379 387 return; … … 383 391 } 384 392 - (BOOL)textFieldShouldReturn:(UITextField *)textField { 385 [textField resignFirstResponder];386 393 [self slideViewForEditing:NO]; 387 394 return YES; … … 389 396 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range 390 397 replacementString:(NSString *)string { 391 // Check length of fields. Terminal labels should be very short392 398 if (textField == rLabel) { 399 NSUInteger labelLength; 393 400 if ([rPicker numberOfRowsInComponent:1] == 0) { // ntn 394 if ((range.location + range.length) >= kNTNLabelLength) 395 return NO; 401 labelLength = kNTNLabelLength; 396 402 } else { 397 if ((range.location + range.length) >= kTLabelLength) 398 return NO; 403 labelLength = kTLabelLength; 404 } 405 if (([textField.text length] - range.length + [string length]) > labelLength) { 406 return NO; 399 407 } 400 408 } … … 414 422 if (component == 1) { 415 423 if (!self.navigationController.view.superview) { // View hasn't been loaded yet, check for ntn directly from record 416 if ([[ theRecord objectForKey:@"terminal"] integerValue] == 0)424 if ([[_record objectForKey:@"terminal"] integerValue] == 0) 417 425 return 0; 418 426 } else { … … 429 437 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 430 438 if (component == 0) { 431 [ theRecord setObject:[NSArray arrayWithObject:[sArrKey objectAtIndex:row]]439 [_record setObject:[NSArray arrayWithObject:[sArrKey objectAtIndex:row]] 432 440 forKey:@"serviceKeys"]; 433 441 rValue.placeholder = [naptrValuePlaceholders objectForKey:[sArrKey objectAtIndex:row]]; … … 448 456 if (component == 1) { 449 457 if (row > -1) { // Not an ntn 450 [ theRecord setObject:[NSArray arrayWithObject:[liArrKey objectAtIndex:row]]458 [_record setObject:[NSArray arrayWithObject:[liArrKey objectAtIndex:row]] 451 459 forKey:@"locations"]; 452 460 } else { 453 461 // this shouldn't happen 454 [ theRecord removeObjectForKey:@"locations"];462 [_record removeObjectForKey:@"locations"]; 455 463 } 456 464 } -
apps/iphone/my.tel/trunk/Classes/RecordGroupsController.h
r263 r589 15 15 // if groupIdList is an empty array, record is public 16 16 - (void)replaceGroupsForRecord:(NSDictionary *)aRecord withGroups:(NSArray *)groupsIdList; 17 - (NSString *)domain; 17 18 18 19 @end -
apps/iphone/my.tel/trunk/Classes/RecordGroupsController.m
r535 r589 26 26 #pragma mark ------ Initializer 27 27 28 + (RecordGroupsController *)controllerForRecord:(NSDictionary *)aRec groups:(NSArray *)aGroupsArray {28 + (RecordGroupsController *)controllerForRecord:(NSDictionary *)aRec groups:(NSArray *)aGroupsArray { 29 29 if (!aRec) 30 30 return nil; … … 112 112 113 113 NSMutableDictionary *requestData = [[NSMutableDictionary dictionaryWithCapacity:2] retain]; 114 [requestData setObject:[ VIPConnect sharedInstance].selectedDomainforKey:@"domainName"];114 [requestData setObject:[self.delegate domain] forKey:@"domainName"]; 115 115 116 116 [conn setPayload:requestData]; -
apps/iphone/my.tel/trunk/Classes/RecordViewController.h
r535 r589 13 13 #import "RecordEditController.h" 14 14 15 @interface RecordViewController : UI ViewController <UITableViewDelegate, UITableViewDataSource, RecordEditDelegate> {15 @interface RecordViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource, RecordEditDelegate> { 16 16 NSMutableDictionary *skeysDict; // Localized Service Keys (voice -> Voice Call) 17 17 NSMutableDictionary *liDict; // Localized Location indicators (x-home -> Home) … … 21 21 NSMutableArray *uiArray; // the data to show in a UITable 22 22 23 CGFloat recordTableHeight; // Record table height: kRowHeight if not editing, add kRowHeightEditIncrease if editing23 CGFloat recordTableHeight; // Record table height: kRowHeight by default 24 24 25 IBOutlet UITableView *theTable; 26 IBOutlet UIBarButtonItem *buttonAdd; 27 IBOutlet UIBarButtonItem *buttonEdit; 28 IBOutlet UIBarButtonItem *buttonDone; 29 IBOutlet UINavigationBar *navBar; 30 IBOutlet RecordEditController *editController; 25 id <TelControllerDelegate> delegate; 31 26 @private 32 UINavigationController *editNavController; // Navigation controller for the editing27 RecordEditController *editController; 33 28 NSUInteger buttonEditCount; 29 BOOL didPreload; 34 30 } 31 32 + (RecordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload; 33 + (NSDictionary *)imageMappings; 34 35 - (void)displayEditingForRecord:(NSDictionary *)aRec; 35 36 36 37 - (NSDictionary *)selectRecordInSetUsingId:(NSString *)anId; … … 38 39 - (void)updateUITableWithJson:(NSDictionary *)parsedJson; 39 40 - (NSMutableDictionary *)uiItemFromJsonItem:(NSDictionary *)jsonItem; 40 - (void)fillServicesDict:(NSDictionary *)parsedJson;41 - (void)fillLocationsDict:(NSDictionary *)parsedJson;42 41 43 42 - (void)getRecords; … … 45 44 - (void)deleteRecords:(NSDictionary *)aRec; 46 45 - (void)orderRecords; 47 - (void)enableRecords; 48 - (void)disableRecords; 49 - (void)getServiceKeys:(BOOL)fromNetwork; 50 - (void)getLocations:(BOOL)fromNetwork; 51 - (void)displayEditingForRecord:(NSDictionary *)aRec; 46 47 - (IBAction)switchedEnabling:(id)sender; 52 48 53 49 @property (nonatomic, retain) NSMutableDictionary *skeysDict; … … 58 54 @property (nonatomic, retain) NSMutableArray *uiArray; 59 55 60 - (IBAction)switchedEnabling:(id)sender;61 - (IBAction)addRecord:(id)sender;62 - (IBAction)editTable:(id)sender;63 - (IBAction)doneEditingTable:(id)sender;64 65 @property (nonatomic, retain) IBOutlet UITableView *theTable;66 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonAdd;67 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonEdit;68 @property (nonatomic, retain) IBOutlet UIBarButtonItem *buttonDone;69 @property (nonatomic, retain) IBOutlet UINavigationBar *navBar;70 56 @property (nonatomic, retain) IBOutlet RecordEditController *editController; 57 @property (retain) id delegate; 71 58 72 59 @end -
apps/iphone/my.tel/trunk/Classes/RecordViewController.m
r536 r589 9 9 #import "RecordViewController.h" 10 10 11 #define kRowHeight 47.011 #define kRowHeight 52.0 12 12 #define kRowHeightEditIncrease 35.0 13 13 14 14 static NSDictionary *imageMappings; 15 16 @interface RecordViewController (PrivateMethods) 17 - (void)setDidPreload:(BOOL)preload; 18 @end; 15 19 16 20 @implementation RecordViewController … … 23 27 @synthesize uiArray; 24 28 25 @synthesize theTable;26 @synthesize buttonAdd;27 @synthesize buttonEdit;28 @synthesize buttonDone;29 @synthesize navBar;30 29 @synthesize editController; 30 @synthesize delegate; 31 32 #pragma mark - 33 #pragma mark Designated initializer 34 35 + (RecordViewController *)controllerWithDelegate:(id <TelControllerDelegate>)aDelegate preload:(BOOL)preload { 36 RecordViewController *theC = [[[RecordViewController alloc] initWithNibName:@"TabNaptr" bundle:nil] autorelease]; 37 theC.delegate = aDelegate; 38 theC.skeysDict = [NSMutableDictionary dictionaryWithContentsOfFile: 39 [[NSBundle mainBundle] pathForResource:@"ServiceTypes" ofType:@"plist"]]; 40 theC.liDict = [NSMutableDictionary dictionaryWithContentsOfFile: 41 [[NSBundle mainBundle] pathForResource:@"LocationIndicators" ofType:@"plist"]]; 42 theC.recordsArray = [NSMutableArray arrayWithCapacity:20]; 43 theC.uiArray = [NSMutableArray arrayWithCapacity:20]; 44 45 if (preload) { 46 [theC getRecords]; 47 } 48 [theC setDidPreload:preload]; 49 return theC; 50 } 51 52 - (void)setDidPreload:(BOOL)preload { 53 didPreload = preload; 54 } 31 55 32 56 #pragma mark ------ Class variables access … … 76 100 - (void)viewDidLoad { 77 101 [super viewDidLoad]; 78 [self getServiceKeys:NO]; 79 [self getLocations:NO]; 80 self.recordsArray = [NSMutableArray arrayWithCapacity:20]; 81 self.uiArray = [NSMutableArray arrayWithCapacity:20]; 102 self.title = @"Contact Items"; 103 self.navigationItem.rightBarButtonItem = self.editButtonItem; 104 self.tableView.allowsSelectionDuringEditing = YES; // so that the insert cell can be selected 82 105 recordTableHeight = kRowHeight; 83 106 [[self class] imageMappings]; 84 107 } 108 85 109 - (void)viewWillAppear:(BOOL)animated { 86 // This triggers when switching tabs 87 self.title = navBar.topItem.title = [VIPConnect sharedInstance].selectedDomain; 88 [self getRecords]; 110 [super viewWillAppear:animated]; 111 // Don't get the data if we preloaded 112 if (didPreload) { 113 didPreload = NO; 114 } else { 115 [self getRecords]; 116 } 89 117 } 90 118 91 119 - (void)dealloc { 92 [liDict release]; 93 [skeysDict release]; 120 self.liDict = nil; 121 self.skeysDict = nil; 122 self.apiId = nil; 123 self.recordsArray = nil; 124 self.uiArray = nil; 125 self.editController = nil; 94 126 [imageMappings release]; 95 127 [super dealloc]; … … 103 135 104 136 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 105 return [NSString stringWithFormat:@"Profile: %@", [VIPConnect sharedInstance].selectedProfileName];137 return @"All records"; 106 138 } 107 139 108 140 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 109 return [uiArray count]; 141 NSUInteger addRow = self.editing ? 1 : 0; // put in the insert row when editing 142 return ([uiArray count] + addRow); 110 143 } 111 144 … … 116 149 117 150 static NSString *CellIdentifier = @"RecordCellIdentifier"; 151 static NSString *AddCellIdentifier = @"RecordAddCellIdentifier"; 118 152 119 RecordCell *cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 120 if (cell == nil) { 121 cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 122 } 123 NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; 124 [cell.labelService setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"service"]]]; 125 [cell.labelLabel setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"label"]]]; 126 [cell.labelValue setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"value"]]]; 127 128 // Set the icon image 129 [cell.labelImage setImage:[UIImage imageNamed:(NSString *)[uiItem objectForKey:@"imageName"]]]; 130 //[cell.labelImage setBounds:CGRectMake(33.0, 5.0, 30.0, 30.0)]; 131 132 // Change look and feel if enabled or disabled 133 if ([[uiItem valueForKey:@"enabled"] integerValue] == 1) { 134 [cell.labelImage setContentMode:UIViewContentModeTop]; 135 [cell.labelService setTextColor:[UIColor blackColor]]; 136 [cell.labelLabel setTextColor:[UIColor blueColor]]; 137 [cell.labelValue setTextColor:[UIColor blackColor]]; 138 [cell.switchEnabled setOn:TRUE]; 139 } else { 140 [cell.labelImage setContentMode:UIViewContentModeBottom]; 141 [cell.labelService setTextColor:[UIColor grayColor]]; 142 [cell.labelLabel setTextColor:[UIColor grayColor]]; 143 [cell.labelValue setTextColor:[UIColor grayColor]]; 144 [cell.switchEnabled setOn:FALSE]; 145 } 146 if ([[uiItem valueForKey:@"terminal"] integerValue] == 1) { 147 [cell.switchEnabled setEnabled:TRUE]; 148 } else { 149 [cell.switchEnabled setEnabled:FALSE]; 150 } 151 // TODO: Overlay a small padlock image if the record is private 152 153 [uiItem release]; 153 RecordCell *cell; 154 155 if (self.editing && (indexPath.row == ([self tableView:tableView numberOfRowsInSection:indexPath.section]-1))) { 156 // we're in editing mode, show the last row as an insert row 157 cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:AddCellIdentifier]; 158 if (cell == nil) { 159 cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleDefault 160 reuseIdentifier:AddCellIdentifier] autorelease]; 161 cell.accessoryType = cell.editingAccessoryType = UITableViewCellAccessoryNone; 162 cell.textLabel.text = @"Add new contact item"; 163 cell.textLabel.textColor = [UIColor blueColor]; 164 cell.textLabel.font = [UIFont boldSystemFontOfSize:15]; 165 } 166 } else { 167 168 cell = (RecordCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 169 if (cell == nil) { 170 cell = [[[RecordCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease]; 171 cell.canBeDisabled = FALSE; // When not handling profiles, don't allow enable/disable 172 } 173 NSMutableDictionary *uiItem = [[uiArray objectAtIndex:indexPath.row] retain]; 174 [cell.labelService setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"service"]]]; 175 [cell.labelLabel setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"label"]]]; 176 [cell.labelValue setText:[NSString stringWithFormat:@"%@", [uiItem objectForKey:@"value"]]]; 177 178 // Set the icon image 179 [cell.labelImage setImage:[UIImage imageNamed:(NSString *)[uiItem objectForKey:@"imageName"]]]; 180 //[cell.labelImage setBounds:CGRectMake(33.0, 5.0, 30.0, 30.0)]; 181 182 // cell.enabledInProfile = [[uiItem valueForKey:@"enabled"] boolValue]; 183 // // Change look and feel if enabled or disabled 184 // if ([[uiItem valueForKey:@"terminal"] integerValue] == 1) { 185 // [cell.switchEnabled setEnabled:TRUE]; 186 // } else { 187 // [cell.switchEnabled setEnabled:FALSE]; 188 // } 189 // TODO: Overlay a small padlock image if the record is private 190 191 [uiItem release]; 192 } 154 193 155 194 return cell; 156 195 } 157 196 197 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { 198 if ([tableView cellForRowAtIndexPath:indexPath].editingStyle == UITableViewCellEditingStyleDelete) { 199 // Do not go into the record edit view when the table is in editing mode 200 return nil; 201 } 202 return indexPath; 203 } 204 158 205 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 159 if (tableView.editing) { 160 // Don't go to the details screen for a record if we're editing the table 161 [tableView deselectRowAtIndexPath:indexPath animated:NO]; 206 [tableView deselectRowAtIndexPath:indexPath animated:YES]; 207 if ([tableView cellForRowAtIndexPath:indexPath].editingStyle == UITableViewCellEditingStyleInsert) { 208 // we're inserting a row 209 [tableView.dataSource tableView:tableView 210 commitEditingStyle:UITableViewCellEditingStyleInsert forRowAtIndexPath:indexPath]; 162 211 } else { 163 [tableView deselectRowAtIndexPath:indexPath animated:YES];164 212 NSDictionary *theRecord = [self selectRecordInSetUsingId:[[uiArray objectAtIndex:indexPath.row] 165 213 objectForKey:@"apiId"]]; 166 214 [self displayEditingForRecord:theRecord]; 215 167 216 } 168 217 } 169 218 219 - (void)setEditing:(BOOL)editing animated:(BOOL)animated { 220 [super setEditing:editing animated:animated]; 221 UITableView *tv = self.tableView; 222 [tv beginUpdates]; 223 NSArray *insertIndexPaths = [NSArray arrayWithObjects: 224 [NSIndexPath indexPathForRow:([self.recordsArray count]) 225 inSection:0], 226 nil]; 227 if (editing) { 228 [tv insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationTop]; 229 } else { 230 [tv deleteRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationTop]; 231 buttonEditCount = 3; 232 UIActivityIndicatorView *aiV = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; 233 [aiV startAnimating]; 234 UIBarButtonItem *savingButton = [[UIBarButtonItem alloc] initWithCustomView:aiV]; 235 [aiV release]; 236 self.navigationItem.rightBarButtonItem = savingButton; 237 [self orderRecords]; 238 // [tableView reloadData]; 239 } 240 [tv endUpdates]; 241 } 242 243 - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 244 if (self.editing) { 245 if (indexPath.row == [tableView numberOfRowsInSection:indexPath.section]-1) { 246 // We're in the last row, which is the insert row 247 return UITableViewCellEditingStyleInsert; 248 } else { 249 return UITableViewCellEditingStyleDelete; 250 } 251 } else { 252 return UITableViewCellEditingStyleNone; 253 } 254 } 255 170 256 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 171 257 172 258 if (editingStyle == UITableViewCellEditingStyleDelete) { 173 if ( tableView.editing) {259 &nb
