Changeset 896 for apps/iphone/superbook/trunk/Classes/NaptrViewController.m
- Timestamp:
- 09/13/11 11:09:35 (20 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
apps/iphone/superbook/trunk/Classes/NaptrViewController.m
r886 r896 35 35 #import "WebUrlViewController.h" 36 36 #import "RecordNaptr+HAAdditions.h" 37 #import "SHK.h" 37 38 38 39 static UIFont *headerFont; … … 41 42 static CGFloat naptrCellRowLineHeight; 42 43 static CGSize maximumLabelSize; 44 45 enum ActionSheets_enum { 46 ActionSheet_Action, 47 ActionSheet_Call, 48 ActionSheet_Share 49 }; 43 50 44 51 @interface NaptrViewController (PrivateMethods) … … 58 65 @synthesize loadingAIButton; 59 66 @synthesize logoImage; 60 @synthesize storeContactButton;67 @synthesize actionContactButton; 61 68 @synthesize abId; 62 69 … … 98 105 self.loadingAIButton = [[[UIBarButtonItem alloc] initWithCustomView:self.loadingAIView] autorelease]; 99 106 100 self. storeContactButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave107 self.actionContactButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction 101 108 target:self 102 action:@selector( saveContact:)] autorelease];109 action:@selector(domainAction:)] autorelease]; 103 110 self.logoImage = nil; 104 111 … … 186 193 [self.loadingAIView stopAnimating]; 187 194 [self performSelector:@selector(stopLoading) withObject:nil afterDelay:0.1]; 188 self.navigationItem.rightBarButtonItem = self. storeContactButton;195 self.navigationItem.rightBarButtonItem = self.actionContactButton; 189 196 if (! self.theDomain.isCached) { 190 197 // Cache the domain data if it's new data … … 824 831 destructiveButtonTitle:nil 825 832 otherButtonTitles:nil]; 833 actionSheet.tag = ActionSheet_Call; 826 834 callButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Call this number", @"Call this number")]; 827 835 smsButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Send an SMS Message", @"Send an SMS Message")]; … … 846 854 return; 847 855 } 848 NSURL *naptrUrl; 849 NSString *uri = [actionSheet title]; 850 if (buttonIndex == callButtonIndex) { 851 naptrUrl = [NSURL URLWithString:[uri stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; 852 [[UIApplication sharedApplication] openURL:naptrUrl]; 853 } else if (buttonIndex == smsButtonIndex) { 854 NSRange telPrefixRange = [uri rangeOfString:@"tel:"]; 855 naptrUrl = [NSURL URLWithString:[uri stringByReplacingCharactersInRange:telPrefixRange withString:@"sms:"]]; 856 [[UIApplication sharedApplication] openURL:naptrUrl]; 856 if (actionSheet.tag == ActionSheet_Call) { 857 NSURL *naptrUrl; 858 NSString *uri = [actionSheet title]; 859 if (buttonIndex == callButtonIndex) { 860 naptrUrl = [NSURL URLWithString:[uri stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; 861 [[UIApplication sharedApplication] openURL:naptrUrl]; 862 } else if (buttonIndex == smsButtonIndex) { 863 NSRange telPrefixRange = [uri rangeOfString:@"tel:"]; 864 naptrUrl = [NSURL URLWithString:[uri stringByReplacingCharactersInRange:telPrefixRange withString:@"sms:"]]; 865 [[UIApplication sharedApplication] openURL:naptrUrl]; 866 } 867 } else if (actionSheet.tag == ActionSheet_Action) { 868 if (buttonIndex == 0) { // Save 869 [self saveContact:nil]; 870 } else if (buttonIndex == 1) { // Share 871 [self shareContact:nil]; 872 } 857 873 } 858 874 return; 859 875 } 860 876 861 #pragma mark ------ Methods to save a contact 877 #pragma mark ------ Action methods 878 879 - (IBAction)domainAction:(id)sender { 880 UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 881 delegate:self 882 cancelButtonTitle:nil 883 destructiveButtonTitle:nil 884 otherButtonTitles:nil]; 885 actionSheet.tag = ActionSheet_Action; 886 [actionSheet addButtonWithTitle:NSLocalizedString(@"Save to Address Book", @"Save")]; 887 [actionSheet addButtonWithTitle:NSLocalizedString(@"Share this", @"Share")]; 888 actionSheet.cancelButtonIndex = [actionSheet addButtonWithTitle:NSLocalizedString(@"Cancel", @"Cancel")]; 889 [actionSheet showInView:self.view]; 890 [actionSheet release]; 891 } 862 892 863 893 - (IBAction)saveContact:(id)sender { … … 874 904 [self showError:err]; 875 905 } 906 } 907 908 - (IBAction)shareContact:(id)sender { 909 // Create the item to share (in this example, a url) 910 NSURL *url = [NSURL URLWithString:[@"http://" stringByAppendingString:self.theDomain.telName]]; 911 NSString *urlString = [url.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 912 NSString *sharingString = [NSString stringWithFormat:NSLocalizedString(@"I just checked out %@ on Superbook", @"sharing string"), urlString]; 913 SHKItem *item = [SHKItem text:sharingString]; 914 915 // Get the ShareKit action sheet 916 SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; 917 // Display the action sheet 918 [actionSheet showInView:self.view]; 876 919 } 877 920








